diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s3/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l6-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l6-s3/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l6-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..16508ccb157f7542a5a8a45c6a5bbb9a0363f1da --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s3/environment/instance.json @@ -0,0 +1 @@ +{"N": 7370, "t": 2398, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s3/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l6-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..96fe0b1c681eb7c3da881227bd21f12fd2c065e9 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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' +{"factors": [28776, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2398, 2399, 2399, 2399, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2401, 2402, 2402, 2402, 2402, 2402, 2402, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2403, 2404, 2404, 2404, 2404, 2404, 2404, 2404, 2404, 2404, 2404, 2404, 2404, 2405, 2405, 2405, 2405, 2405, 2405, 2405, 2405, 2405, 2405, 2405, 2405, 2405, 2405, 2405, 2405, 2405, 2405, 2405, 2405, 2405, 2405, 2405, 2406, 2406, 2406, 2406, 2406, 2406, 2406, 2406, 2406, 2406, 2406, 2406, 2406, 2406, 2406, 2406, 2406, 2406, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2407, 2408, 2408, 2408, 2408, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2409, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2410, 2411, 2411, 2411, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2412, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2413, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2414, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2415, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2416, 2417, 2417, 2417, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2418, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2419, 2420, 2420, 2420, 2420, 2420, 2420, 2420, 2420, 2420, 2420, 2420, 2420, 2420, 2420, 2420, 2420, 2420, 2421, 2421, 2421, 2421, 2421, 2421, 2421, 2421, 2421, 2421, 2421, 2421, 2421, 2421, 2421, 2421, 2421, 2421, 2421, 2421, 2421, 2421, 2421, 2421, 2421, 2421, 2421, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2422, 2423, 2423, 2423, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2424, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2425, 2426, 2426, 2426, 2426, 2426, 2426, 2427, 2427, 2427, 2427, 2427, 2427, 2427, 2427, 2427, 2428, 2428, 2428, 2428, 2428, 2428, 2428, 2428, 2428, 2428, 2428, 2428, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2434, 2434, 2434, 2434, 2434, 2434, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2437, 2437, 2437, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2441, 2441, 2441, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2446, 2446, 2446, 2446, 2446, 2446, 2447, 2447, 2447, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2452, 2452, 2452, 2452, 2452, 2452, 2452, 2452, 2452, 2452, 2452, 2452, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2458, 2458, 2458, 2458, 2458, 2459, 2459, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2462, 2462, 2462, 2462, 2462, 2463, 2463, 2463, 2463, 2463, 2463, 2463, 2463, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2467, 2467, 2468, 2468, 2468, 2468, 2468, 2468, 2468, 2468, 2468, 2468, 2468, 2469, 2469, 2469, 2469, 2469, 2469, 2469, 2469, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2473, 2473, 2474, 2474, 2474, 2474, 2474, 2476, 2476, 2476, 2476, 2476, 2476, 2476, 2476, 2476, 2476, 2476, 2477, 2477, 2479, 2481, 2481, 2481, 2481, 2481, 2481, 2481, 2481, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2487, 2487, 2487, 2487, 2487, 2487, 2487, 2487, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2490, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2498, 2498, 2498, 2498, 2498, 2500, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2501, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2503, 2503, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2517, 2517, 2517, 2517, 2517, 2517, 2517, 2517, 2518, 2518, 2518, 2518, 2518, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2521, 2521, 2524, 2524, 2524, 2524, 2524, 2524, 2524, 2524, 2524, 2524, 2524, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2528, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2531, 2531, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2537, 2539, 2539, 2542, 2543, 2543, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2549, 2549, 2551, 2551, 2554, 2554, 2554, 2554, 2554, 2557, 2557, 2558, 2558, 2558, 2558, 2558, 2559, 2559, 2559, 2559, 2559, 2559, 2559, 2559, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2564, 2564, 2564, 2564, 2564, 2564, 2564, 2564, 2564, 2564, 2564, 2566, 2566, 2566, 2566, 2566, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2571, 2571, 2571, 2571, 2571, 2571, 2571, 2571, 2572, 2572, 2572, 2572, 2572, 2572, 2572, 2572, 2572, 2572, 2572, 2577, 2577, 2577, 2577, 2577, 2577, 2577, 2577, 2578, 2578, 2578, 2578, 2578, 2579, 2579, 2582, 2582, 2582, 2582, 2582, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2588, 2588, 2588, 2588, 2588, 2588, 2588, 2588, 2588, 2588, 2588, 2589, 2589, 2589, 2589, 2589, 2589, 2589, 2589, 2591, 2591, 2593, 2593, 2594, 2594, 2594, 2594, 2594, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2601, 2602, 2602, 2602, 2602, 2602, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2606, 2606, 2606, 2606, 2606, 2609, 2609, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2612, 2612, 2612, 2612, 2612, 2612, 2612, 2612, 2612, 2612, 2612, 2614, 2614, 2614, 2614, 2614, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2617, 2617, 2621, 2621, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2631, 2631, 2631, 2631, 2631, 2631, 2631, 2631, 2633, 2633, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2636, 2636, 2636, 2636, 2636, 2636, 2636, 2636, 2636, 2636, 2636, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2638, 2638, 2638, 2638, 2638, 2642, 2642, 2642, 2642, 2642, 2643, 2643, 2643, 2643, 2643, 2643, 2643, 2643, 2644, 2644, 2644, 2644, 2644, 2644, 2644, 2644, 2644, 2644, 2644, 2647, 2647, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2649, 2649, 2649, 2649, 2649, 2649, 2649, 2649, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2654, 2654, 2654, 2654, 2654, 2657, 2657, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2659, 2659, 2661, 2661, 2661, 2661, 2661, 2661, 2661, 2661, 2663, 2663, 2671, 2671, 2677, 2677, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2683, 2683, 2687, 2687, 2689, 2689, 2692, 2692, 2692, 2692, 2692, 2692, 2692, 2692, 2692, 2692, 2693, 2693, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2699, 2699, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2707, 2707, 2708, 2708, 2708, 2708, 2708, 2708, 2708, 2708, 2708, 2708, 2711, 2711, 2713, 2713, 2719, 2719, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2722, 2722, 2722, 2722, 2722, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2729, 2729, 2731, 2731, 2732, 2732, 2732, 2732, 2732, 2732, 2732, 2732, 2732, 2732, 2733, 2733, 2733, 2733, 2733, 2733, 2733, 2733, 2734, 2734, 2734, 2734, 2734, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2741, 2741, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2746, 2746, 2746, 2746, 2746, 2749, 2749, 2753, 2753, 2757, 2757, 2757, 2757, 2757, 2757, 2757, 2757, 2762, 2762, 2762, 2762, 2762, 2764, 2764, 2764, 2764, 2764, 2764, 2764, 2764, 2764, 2764, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2767, 2767, 2777, 2777, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2787, 2787, 2787, 2787, 2787, 2787, 2787, 2789, 2789, 2791, 2791, 2797, 2797, 2798, 2798, 2798, 2798, 2798, 2801, 2801, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2803, 2803, 2804, 2804, 2804, 2804, 2804, 2804, 2804, 2804, 2804, 2804, 2811, 2811, 2811, 2811, 2811, 2811, 2811, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2818, 2818, 2818, 2818, 2818, 2819, 2819, 2823, 2823, 2823, 2823, 2823, 2823, 2823, 2833, 2833, 2836, 2836, 2836, 2836, 2836, 2836, 2836, 2836, 2836, 2836, 2837, 2837, 2841, 2841, 2841, 2841, 2841, 2841, 2841, 2843, 2843, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2846, 2846, 2846, 2846, 2846, 2851, 2851, 2854, 2854, 2854, 2854, 2854, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2857, 2857, 2858, 2858, 2858, 2858, 2858, 2859, 2859, 2859, 2859, 2859, 2859, 2859, 2861, 2861, 2866, 2866, 2866, 2866, 2866, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2876, 2876, 2876, 2876, 2876, 2876, 2876, 2876, 2876, 2876, 2878, 2878, 2878, 2878, 2878, 2879, 2879, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2887, 2887, 2894, 2894, 2894, 2894, 2894, 2897, 2897, 2901, 2901, 2901, 2901, 2901, 2901, 2901, 2902, 2902, 2902, 2902, 2902, 2903, 2903, 2906, 2906, 2906, 2906, 2906, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2909, 2909, 2913, 2913, 2913, 2913, 2913, 2913, 2913, 2917, 2917, 2918, 2918, 2918, 2918, 2918, 2927, 2927, 2931, 2931, 2931, 2931, 2931, 2931, 2931, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2939, 2939, 2942, 2942, 2942, 2942, 2942, 2949, 2949, 2949, 2949, 2949, 2949, 2949, 2953, 2953, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2957, 2957, 2962, 2962, 2962, 2962, 2963, 2963, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2966, 2966, 2966, 2966, 2969, 2969, 2971, 2971, 2972, 2972, 2972, 2972, 2972, 2972, 2972, 2972, 2972, 2973, 2973, 2973, 2973, 2973, 2973, 2973, 2974, 2974, 2974, 2974, 2978, 2978, 2978, 2978, 2986, 2986, 2986, 2986, 2991, 2991, 2991, 2991, 2991, 2991, 2991, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2998, 2998, 2998, 2998, 2999, 2999, 3001, 3001, 3004, 3004, 3004, 3004, 3004, 3004, 3004, 3004, 3004, 3011, 3011, 3019, 3019, 3022, 3022, 3022, 3022, 3023, 3023, 3027, 3027, 3027, 3027, 3027, 3027, 3027, 3028, 3028, 3028, 3028, 3028, 3028, 3028, 3028, 3028, 3037, 3037, 3039, 3039, 3039, 3039, 3039, 3039, 3039, 3041, 3041, 3044, 3044, 3044, 3044, 3044, 3044, 3044, 3044, 3044, 3046, 3046, 3046, 3046, 3049, 3049, 3057, 3057, 3057, 3057, 3057, 3057, 3057, 3061, 3061, 3062, 3062, 3062, 3062, 3063, 3063, 3063, 3063, 3063, 3063, 3063, 3067, 3067, 3076, 3076, 3076, 3076, 3076, 3076, 3076, 3076, 3076, 3079, 3079, 3083, 3083, 3086, 3086, 3086, 3086, 3089, 3089, 3092, 3092, 3092, 3092, 3092, 3092, 3092, 3092, 3092, 3093, 3093, 3093, 3093, 3093, 3093, 3093, 3098, 3098, 3098, 3098, 3099, 3099, 3099, 3099, 3099, 3099, 3099, 3106, 3106, 3106, 3106, 3109, 3109, 3117, 3117, 3117, 3117, 3117, 3117, 3117, 3118, 3118, 3118, 3118, 3119, 3119, 3121, 3121, 3134, 3134, 3134, 3134, 3137, 3137, 3142, 3142, 3142, 3142, 3147, 3147, 3147, 3147, 3147, 3147, 3147, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3153, 3153, 3153, 3153, 3153, 3153, 3153, 3158, 3158, 3158, 3158, 3163, 3163, 3166, 3166, 3166, 3166, 3167, 3167, 3169, 3169, 3181, 3181, 3183, 3183, 3183, 3183, 3183, 3183, 3187, 3187, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3189, 3189, 3189, 3189, 3189, 3189, 3191, 3191, 3194, 3194, 3194, 3194, 3202, 3202, 3202, 3202, 3203, 3203, 3207, 3207, 3207, 3207, 3207, 3207, 3209, 3209, 3214, 3214, 3214, 3214, 3217, 3217, 3218, 3218, 3218, 3218, 3221, 3221, 3226, 3226, 3226, 3226, 3229, 3229, 3238, 3238, 3238, 3238, 3242, 3242, 3242, 3242, 3251, 3251, 3253, 3253, 3254, 3254, 3254, 3254, 3257, 3257, 3259, 3259, 3261, 3261, 3261, 3261, 3261, 3261, 3271, 3271, 3273, 3273, 3273, 3273, 3273, 3273, 3274, 3274, 3274, 3274, 3279, 3279, 3279, 3279, 3279, 3279, 3291, 3291, 3291, 3291, 3291, 3291, 3299, 3299, 3301, 3301, 3307, 3307, 3309, 3309, 3309, 3309, 3309, 3309, 3313, 3313, 3314, 3314, 3314, 3314, 3319, 3319, 3323, 3323, 3326, 3326, 3326, 3326, 3327, 3327, 3327, 3327, 3327, 3327, 3329, 3329, 3331, 3331, 3334, 3334, 3334, 3334, 3338, 3338, 3338, 3338, 3343, 3343, 3347, 3347, 3351, 3351, 3351, 3351, 3351, 3351, 3359, 3359, 3361, 3361, 3369, 3369, 3369, 3369, 3369, 3369, 3371, 3371, 3373, 3373, 3386, 3386, 3386, 3386, 3387, 3387, 3387, 3387, 3387, 3387, 3389, 3389, 3391, 3391, 3394, 3394, 3394, 3394, 3398, 3398, 3398, 3398, 3407, 3407, 3413, 3413, 3418, 3418, 3418, 3418, 3433, 3433, 3442, 3442, 3442, 3442, 3446, 3446, 3446, 3446, 3449, 3449, 3453, 3453, 3453, 3453, 3453, 3453, 3457, 3457, 3459, 3459, 3459, 3459, 3459, 3459, 3461, 3461, 3463, 3463, 3466, 3466, 3466, 3466, 3467, 3467, 3469, 3469, 3482, 3482, 3482, 3482, 3489, 3489, 3489, 3489, 3489, 3489, 3491, 3491, 3494, 3494, 3494, 3494, 3499, 3499, 3506, 3506, 3506, 3506, 3511, 3511, 3513, 3513, 3513, 3513, 3513, 3513, 3517, 3517, 3518, 3518, 3518, 3518, 3527, 3527, 3529, 3529, 3533, 3533, 3539, 3539, 3541, 3541, 3543, 3543, 3543, 3543, 3543, 3543, 3547, 3547, 3554, 3554, 3554, 3554, 3557, 3557, 3559, 3559, 3561, 3561, 3561, 3561, 3561, 3561, 3566, 3566, 3566, 3566, 3571, 3571, 3574, 3574, 3574, 3574, 3578, 3578, 3578, 3578, 3579, 3579, 3579, 3579, 3579, 3579, 3581, 3581, 3583, 3583, 3593, 3593, 3602, 3602, 3602, 3602, 3607, 3607, 3613, 3613, 3617, 3617, 3622, 3622, 3622, 3622, 3623, 3623, 3631, 3631, 3637, 3637, 3643, 3643, 3646, 3646, 3646, 3646, 3659, 3659, 3662, 3662, 3662, 3662, 3671, 3671, 3673, 3673, 3677, 3677, 3691, 3694, 3694, 3694, 3697, 3701, 3709, 3719, 3722, 3722, 3722, 3727, 3733, 3734, 3734, 3734, 3739, 3742, 3742, 3742, 3746, 3746, 3746, 3754, 3754, 3754, 3758, 3758, 3758, 3761, 3767, 3769, 3778, 3778, 3778, 3779, 3793, 3797, 3802, 3802, 3802, 3803, 3814, 3814, 3814, 3821, 3823, 3826, 3826, 3826, 3833, 3847, 3851, 3853, 3862, 3862, 3862, 3863, 3866, 3866, 3866, 3877, 3881, 3889, 3898, 3898, 3898, 3902, 3902, 3902, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3946, 3946, 3946, 3947, 3958, 3958, 3958, 3967, 3974, 3974, 3974, 3986, 3986, 3986, 3989, 3994, 3994, 3994, 3998, 3998, 3998, 4001, 4003, 4006, 4006, 4006, 4007, 4013, 4019, 4021, 4022, 4022, 4022, 4027, 4034, 4034, 4034, 4049, 4051, 4054, 4054, 4054, 4057, 4058, 4058, 4058, 4073, 4078, 4078, 4078, 4079, 4091, 4093, 4099, 4106, 4106, 4106, 4111, 4126, 4126, 4126, 4127, 4129, 4133, 4138, 4138, 4138, 4139, 4153, 4157, 4159, 4162, 4162, 4162, 4166, 4166, 4166, 4174, 4174, 4174, 4177, 4178, 4178, 4178, 4198, 4198, 4198, 4201, 4211, 4217, 4219, 4222, 4222, 4222, 4226, 4226, 4226, 4229, 4231, 4241, 4243, 4253, 4258, 4258, 4258, 4259, 4261, 4262, 4262, 4262, 4271, 4273, 4274, 4274, 4274, 4282, 4282, 4282, 4283, 4286, 4286, 4286, 4289, 4297, 4306, 4306, 4306, 4322, 4322, 4322, 4327, 4337, 4339, 4349, 4357, 4358, 4358, 4358, 4363, 4373, 4391, 4397, 4406, 4406, 4406, 4409, 4414, 4414, 4414, 4421, 4423, 4426, 4426, 4426, 4441, 4442, 4442, 4442, 4447, 4451, 4457, 4463, 4474, 4474, 4474, 4478, 4478, 4478, 4481, 4483, 4486, 4486, 4486, 4493, 4502, 4502, 4502, 4507, 4513, 4517, 4519, 4523, 4534, 4534, 4534, 4538, 4538, 4538, 4546, 4546, 4546, 4547, 4549, 4561, 4562, 4562, 4562, 4567, 4574, 4574, 4574, 4583, 4586, 4586, 4586, 4591, 4594, 4594, 4594, 4597, 4603, 4618, 4618, 4618, 4621, 4622, 4622, 4622, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4666, 4666, 4666, 4673, 4678, 4678, 4678, 4679, 4682, 4682, 4682, 4691, 4694, 4694, 4694, 4702, 4702, 4702, 4703, 4714, 4714, 4714, 4721, 4723, 4729, 4733, 4742, 4742, 4742, 4751, 4754, 4754, 4754, 4759, 4762, 4762, 4762, 4766, 4766, 4766, 4778, 4778, 4778, 4783, 4786, 4786, 4786, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s3/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l6-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s3/tests/check.py @@ -0,0 +1,12 @@ +"""Factor N! into N factors, each >= t (AlphaEvolve problem 38 / OEIS A034258). Exact big-integer check.""" +import math + +from run import Invalid, int_list + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + f = int_list(ans.get("factors"), n, t, None, "factors") + if math.prod(f) != math.factorial(n): + raise Invalid(f"the product of the factors is not {n}!") + return None, {"min_factor": min(f)} diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s3/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l6-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..16508ccb157f7542a5a8a45c6a5bbb9a0363f1da --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s3/tests/instance.json @@ -0,0 +1 @@ +{"N": 7370, "t": 2398, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s3/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l6-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l6-s3/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l6-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l6-s4/environment/Dockerfile b/tasks/construct-ae-p38-factorial-factors-l6-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l6-s4/environment/instance.json b/tasks/construct-ae-p38-factorial-factors-l6-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d452b8f946f175b5368a4c7832f6b53ef3d2e390 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s4/environment/instance.json @@ -0,0 +1 @@ +{"N": 7446, "t": 2426, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s4/solution/solve.sh b/tasks/construct-ae-p38-factorial-factors-l6-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..09d97f1bf52739c1855f276c4886db807aa11096 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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' +{"factors": [9704, 2426, 2426, 2426, 2426, 2426, 2427, 2427, 2427, 2427, 2427, 2427, 2427, 2427, 2427, 2428, 2428, 2428, 2428, 2428, 2428, 2428, 2428, 2428, 2428, 2428, 2428, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2429, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2430, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2431, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2432, 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433, 2434, 2434, 2434, 2434, 2434, 2434, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2435, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2436, 2437, 2437, 2437, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2438, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2439, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2440, 2441, 2441, 2441, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2442, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2443, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2444, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2445, 2446, 2446, 2446, 2446, 2446, 2446, 2447, 2447, 2447, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2449, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2450, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2451, 2452, 2452, 2452, 2452, 2452, 2452, 2452, 2452, 2452, 2452, 2452, 2452, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2453, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2454, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2455, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2456, 2458, 2458, 2458, 2458, 2458, 2458, 2459, 2459, 2459, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2460, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2461, 2462, 2462, 2462, 2462, 2462, 2462, 2463, 2463, 2463, 2463, 2463, 2463, 2463, 2463, 2463, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2464, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2465, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2466, 2467, 2467, 2467, 2468, 2468, 2468, 2468, 2468, 2468, 2468, 2468, 2468, 2468, 2468, 2468, 2469, 2469, 2469, 2469, 2469, 2469, 2469, 2469, 2469, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2471, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2472, 2473, 2473, 2473, 2474, 2474, 2474, 2474, 2474, 2474, 2475, 2475, 2475, 2475, 2475, 2475, 2475, 2475, 2475, 2475, 2475, 2475, 2476, 2476, 2476, 2476, 2476, 2476, 2476, 2476, 2476, 2476, 2476, 2476, 2477, 2477, 2477, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2478, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2479, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2480, 2481, 2481, 2481, 2481, 2481, 2481, 2481, 2481, 2481, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2482, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2483, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2485, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2486, 2487, 2487, 2487, 2487, 2487, 2487, 2487, 2487, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2488, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2489, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2490, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2492, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2493, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2495, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2497, 2498, 2498, 2498, 2498, 2498, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2502, 2503, 2503, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2504, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2505, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2506, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2507, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2509, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2510, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2511, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2512, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2513, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2514, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2515, 2517, 2517, 2517, 2517, 2517, 2517, 2517, 2517, 2518, 2518, 2518, 2518, 2518, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2519, 2521, 2521, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2522, 2524, 2524, 2524, 2524, 2524, 2524, 2524, 2524, 2524, 2524, 2524, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2525, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2526, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2529, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2530, 2531, 2531, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2532, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2533, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2534, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2536, 2539, 2539, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2540, 2543, 2543, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2545, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2547, 2549, 2549, 2551, 2551, 2554, 2554, 2554, 2554, 2554, 2557, 2557, 2558, 2558, 2558, 2558, 2558, 2559, 2559, 2559, 2559, 2559, 2559, 2559, 2559, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2561, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2563, 2564, 2564, 2564, 2564, 2564, 2564, 2564, 2564, 2564, 2564, 2564, 2566, 2566, 2566, 2566, 2566, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2567, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2569, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2570, 2571, 2571, 2571, 2571, 2571, 2571, 2571, 2571, 2572, 2572, 2572, 2572, 2572, 2572, 2572, 2572, 2572, 2572, 2572, 2575, 2575, 2577, 2577, 2577, 2577, 2577, 2577, 2577, 2577, 2578, 2578, 2578, 2578, 2578, 2579, 2579, 2582, 2582, 2582, 2582, 2582, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2586, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2587, 2588, 2588, 2588, 2588, 2588, 2588, 2588, 2588, 2588, 2588, 2588, 2589, 2589, 2589, 2589, 2589, 2589, 2589, 2589, 2591, 2591, 2592, 2593, 2593, 2594, 2594, 2594, 2594, 2594, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2595, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2598, 2602, 2602, 2602, 2602, 2602, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2605, 2606, 2606, 2606, 2606, 2606, 2609, 2609, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2611, 2612, 2612, 2612, 2612, 2612, 2612, 2612, 2612, 2612, 2612, 2612, 2614, 2614, 2614, 2614, 2614, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2615, 2617, 2617, 2621, 2621, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2629, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2630, 2631, 2631, 2631, 2631, 2631, 2631, 2631, 2631, 2633, 2633, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2634, 2636, 2636, 2636, 2636, 2636, 2636, 2636, 2636, 2636, 2636, 2636, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2637, 2638, 2638, 2638, 2638, 2638, 2642, 2642, 2642, 2642, 2642, 2643, 2643, 2643, 2643, 2643, 2643, 2643, 2643, 2644, 2644, 2644, 2644, 2644, 2644, 2644, 2644, 2644, 2644, 2644, 2647, 2647, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2648, 2649, 2649, 2649, 2649, 2649, 2649, 2649, 2649, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2651, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2653, 2654, 2654, 2654, 2654, 2654, 2657, 2657, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2658, 2659, 2659, 2661, 2661, 2661, 2661, 2661, 2661, 2661, 2661, 2663, 2663, 2671, 2671, 2677, 2677, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2681, 2683, 2683, 2687, 2687, 2689, 2689, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2690, 2692, 2692, 2692, 2692, 2692, 2692, 2692, 2692, 2692, 2692, 2692, 2693, 2693, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2694, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2696, 2699, 2699, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2705, 2707, 2707, 2708, 2708, 2708, 2708, 2708, 2708, 2708, 2708, 2708, 2708, 2711, 2711, 2713, 2713, 2719, 2719, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2721, 2722, 2722, 2722, 2722, 2722, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2723, 2729, 2729, 2731, 2731, 2732, 2732, 2732, 2732, 2732, 2732, 2732, 2732, 2732, 2732, 2733, 2733, 2733, 2733, 2733, 2733, 2733, 2733, 2734, 2734, 2734, 2734, 2734, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2735, 2741, 2741, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2742, 2746, 2746, 2746, 2746, 2746, 2749, 2749, 2753, 2753, 2757, 2757, 2757, 2757, 2757, 2757, 2757, 2757, 2762, 2762, 2762, 2762, 2762, 2764, 2764, 2764, 2764, 2764, 2764, 2764, 2764, 2764, 2764, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2766, 2767, 2767, 2777, 2777, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2778, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2779, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2785, 2787, 2787, 2787, 2787, 2787, 2787, 2787, 2787, 2789, 2789, 2791, 2791, 2797, 2797, 2798, 2798, 2798, 2798, 2798, 2801, 2801, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2802, 2803, 2803, 2804, 2804, 2804, 2804, 2804, 2804, 2804, 2804, 2804, 2804, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2807, 2811, 2811, 2811, 2811, 2811, 2811, 2811, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2815, 2818, 2818, 2818, 2818, 2818, 2819, 2819, 2823, 2823, 2823, 2823, 2823, 2823, 2823, 2833, 2833, 2836, 2836, 2836, 2836, 2836, 2836, 2836, 2836, 2836, 2836, 2837, 2837, 2841, 2841, 2841, 2841, 2841, 2841, 2841, 2843, 2843, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2845, 2846, 2846, 2846, 2846, 2846, 2851, 2851, 2854, 2854, 2854, 2854, 2854, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2855, 2857, 2857, 2858, 2858, 2858, 2858, 2858, 2859, 2859, 2859, 2859, 2859, 2859, 2859, 2861, 2861, 2866, 2866, 2866, 2866, 2866, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2874, 2876, 2876, 2876, 2876, 2876, 2876, 2876, 2876, 2876, 2876, 2878, 2878, 2878, 2878, 2878, 2879, 2879, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2885, 2887, 2887, 2894, 2894, 2894, 2894, 2894, 2897, 2897, 2901, 2901, 2901, 2901, 2901, 2901, 2901, 2902, 2902, 2902, 2902, 2902, 2903, 2903, 2906, 2906, 2906, 2906, 2906, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2908, 2909, 2909, 2913, 2913, 2913, 2913, 2913, 2913, 2913, 2917, 2917, 2918, 2918, 2918, 2918, 2918, 2927, 2927, 2931, 2931, 2931, 2931, 2931, 2931, 2931, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2932, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2935, 2939, 2939, 2942, 2942, 2942, 2942, 2942, 2949, 2949, 2949, 2949, 2949, 2949, 2949, 2953, 2953, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2956, 2957, 2957, 2962, 2962, 2962, 2962, 2962, 2963, 2963, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2965, 2966, 2966, 2966, 2966, 2966, 2969, 2969, 2971, 2971, 2972, 2972, 2972, 2972, 2972, 2972, 2972, 2972, 2972, 2972, 2973, 2973, 2973, 2973, 2973, 2973, 2973, 2974, 2974, 2974, 2974, 2974, 2978, 2978, 2978, 2978, 2978, 2986, 2986, 2986, 2986, 2991, 2991, 2991, 2991, 2991, 2991, 2991, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2995, 2998, 2998, 2998, 2998, 2999, 2999, 3001, 3001, 3004, 3004, 3004, 3004, 3004, 3004, 3004, 3004, 3004, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3005, 3011, 3011, 3019, 3019, 3022, 3022, 3022, 3022, 3023, 3023, 3027, 3027, 3027, 3027, 3027, 3027, 3027, 3028, 3028, 3028, 3028, 3028, 3028, 3028, 3028, 3028, 3037, 3037, 3039, 3039, 3039, 3039, 3039, 3039, 3039, 3041, 3041, 3044, 3044, 3044, 3044, 3044, 3044, 3044, 3044, 3044, 3046, 3046, 3046, 3046, 3049, 3049, 3057, 3057, 3057, 3057, 3057, 3057, 3057, 3061, 3061, 3062, 3062, 3062, 3062, 3063, 3063, 3063, 3063, 3063, 3063, 3063, 3067, 3067, 3076, 3076, 3076, 3076, 3076, 3076, 3076, 3076, 3076, 3079, 3079, 3083, 3083, 3086, 3086, 3086, 3086, 3089, 3089, 3092, 3092, 3092, 3092, 3092, 3092, 3092, 3092, 3092, 3093, 3093, 3093, 3093, 3093, 3093, 3093, 3098, 3098, 3098, 3098, 3099, 3099, 3099, 3099, 3099, 3099, 3099, 3106, 3106, 3106, 3106, 3109, 3109, 3117, 3117, 3117, 3117, 3117, 3117, 3117, 3118, 3118, 3118, 3118, 3119, 3119, 3121, 3121, 3134, 3134, 3134, 3134, 3137, 3137, 3142, 3142, 3142, 3142, 3147, 3147, 3147, 3147, 3147, 3147, 3147, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3148, 3153, 3153, 3153, 3153, 3153, 3153, 3153, 3158, 3158, 3158, 3158, 3163, 3163, 3166, 3166, 3166, 3166, 3167, 3167, 3169, 3169, 3181, 3181, 3183, 3183, 3183, 3183, 3183, 3183, 3183, 3187, 3187, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3188, 3189, 3189, 3189, 3189, 3189, 3189, 3189, 3191, 3191, 3194, 3194, 3194, 3194, 3202, 3202, 3202, 3202, 3203, 3203, 3207, 3207, 3207, 3207, 3207, 3207, 3209, 3209, 3214, 3214, 3214, 3214, 3217, 3217, 3218, 3218, 3218, 3218, 3221, 3221, 3226, 3226, 3226, 3226, 3229, 3229, 3238, 3238, 3238, 3238, 3242, 3242, 3242, 3242, 3251, 3251, 3253, 3253, 3254, 3254, 3254, 3254, 3257, 3257, 3259, 3259, 3261, 3261, 3261, 3261, 3261, 3261, 3271, 3271, 3273, 3273, 3273, 3273, 3273, 3273, 3274, 3274, 3274, 3274, 3279, 3279, 3279, 3279, 3279, 3279, 3291, 3291, 3291, 3291, 3291, 3291, 3299, 3299, 3301, 3301, 3307, 3307, 3309, 3309, 3309, 3309, 3309, 3309, 3313, 3313, 3314, 3314, 3314, 3314, 3319, 3319, 3323, 3323, 3326, 3326, 3326, 3326, 3327, 3327, 3327, 3327, 3327, 3327, 3329, 3329, 3331, 3331, 3334, 3334, 3334, 3334, 3338, 3338, 3338, 3338, 3343, 3343, 3347, 3347, 3351, 3351, 3351, 3351, 3351, 3351, 3359, 3359, 3361, 3361, 3369, 3369, 3369, 3369, 3369, 3369, 3371, 3371, 3373, 3373, 3386, 3386, 3386, 3386, 3387, 3387, 3387, 3387, 3387, 3387, 3389, 3389, 3391, 3391, 3394, 3394, 3394, 3394, 3398, 3398, 3398, 3398, 3407, 3407, 3413, 3413, 3418, 3418, 3418, 3418, 3433, 3433, 3442, 3442, 3442, 3442, 3446, 3446, 3446, 3446, 3449, 3449, 3453, 3453, 3453, 3453, 3453, 3453, 3457, 3457, 3459, 3459, 3459, 3459, 3459, 3459, 3461, 3461, 3463, 3463, 3466, 3466, 3466, 3466, 3467, 3467, 3469, 3469, 3482, 3482, 3482, 3482, 3489, 3489, 3489, 3489, 3489, 3489, 3491, 3491, 3494, 3494, 3494, 3494, 3499, 3499, 3506, 3506, 3506, 3506, 3511, 3511, 3513, 3513, 3513, 3513, 3513, 3513, 3517, 3517, 3518, 3518, 3518, 3518, 3527, 3527, 3529, 3529, 3533, 3533, 3539, 3539, 3541, 3541, 3543, 3543, 3543, 3543, 3543, 3543, 3547, 3547, 3554, 3554, 3554, 3554, 3557, 3557, 3559, 3559, 3561, 3561, 3561, 3561, 3561, 3561, 3566, 3566, 3566, 3566, 3571, 3571, 3574, 3574, 3574, 3574, 3578, 3578, 3578, 3578, 3579, 3579, 3579, 3579, 3579, 3579, 3581, 3581, 3583, 3583, 3593, 3593, 3602, 3602, 3602, 3602, 3603, 3603, 3603, 3603, 3603, 3603, 3607, 3607, 3613, 3613, 3617, 3617, 3622, 3622, 3622, 3622, 3623, 3623, 3631, 3631, 3637, 3637, 3643, 3643, 3646, 3646, 3646, 3646, 3659, 3659, 3662, 3662, 3662, 3662, 3671, 3671, 3673, 3673, 3677, 3677, 3691, 3691, 3694, 3694, 3694, 3694, 3697, 3697, 3701, 3701, 3709, 3709, 3719, 3719, 3722, 3722, 3722, 3722, 3727, 3733, 3734, 3734, 3734, 3739, 3742, 3742, 3742, 3746, 3746, 3746, 3754, 3754, 3754, 3758, 3758, 3758, 3761, 3767, 3769, 3778, 3778, 3778, 3779, 3793, 3797, 3802, 3802, 3802, 3803, 3814, 3814, 3814, 3821, 3823, 3826, 3826, 3826, 3833, 3847, 3851, 3853, 3862, 3862, 3862, 3863, 3866, 3866, 3866, 3877, 3881, 3889, 3898, 3898, 3898, 3902, 3902, 3902, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3946, 3946, 3946, 3947, 3958, 3958, 3958, 3967, 3974, 3974, 3974, 3986, 3986, 3986, 3989, 3994, 3994, 3994, 3998, 3998, 3998, 4001, 4003, 4006, 4006, 4006, 4007, 4013, 4019, 4021, 4022, 4022, 4022, 4027, 4034, 4034, 4034, 4049, 4051, 4054, 4054, 4054, 4057, 4058, 4058, 4058, 4073, 4078, 4078, 4078, 4079, 4091, 4093, 4099, 4106, 4106, 4106, 4111, 4126, 4126, 4126, 4127, 4129, 4133, 4138, 4138, 4138, 4139, 4153, 4157, 4159, 4162, 4162, 4162, 4166, 4166, 4166, 4174, 4174, 4174, 4177, 4178, 4178, 4178, 4198, 4198, 4198, 4201, 4211, 4217, 4219, 4222, 4222, 4222, 4226, 4226, 4226, 4229, 4231, 4241, 4243, 4253, 4258, 4258, 4258, 4259, 4261, 4262, 4262, 4262, 4271, 4273, 4274, 4274, 4274, 4282, 4282, 4282, 4283, 4286, 4286, 4286, 4289, 4297, 4306, 4306, 4306, 4322, 4322, 4322, 4327, 4337, 4339, 4349, 4357, 4358, 4358, 4358, 4363, 4373, 4391, 4397, 4406, 4406, 4406, 4409, 4414, 4414, 4414, 4421, 4423, 4426, 4426, 4426, 4441, 4442, 4442, 4442, 4447, 4451, 4457, 4463, 4474, 4474, 4474, 4478, 4478, 4478, 4481, 4483, 4486, 4486, 4486, 4493, 4502, 4502, 4502, 4507, 4513, 4517, 4519, 4523, 4534, 4534, 4534, 4538, 4538, 4538, 4546, 4546, 4546, 4547, 4549, 4561, 4562, 4562, 4562, 4567, 4574, 4574, 4574, 4583, 4586, 4586, 4586, 4591, 4594, 4594, 4594, 4597, 4603, 4618, 4618, 4618, 4621, 4622, 4622, 4622, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4666, 4666, 4666, 4673, 4678, 4678, 4678, 4679, 4682, 4682, 4682, 4691, 4694, 4694, 4694, 4702, 4702, 4702, 4703, 4714, 4714, 4714, 4721, 4723, 4729, 4733, 4742, 4742, 4742, 4751, 4754, 4754, 4754, 4759, 4762, 4762, 4762, 4766, 4766, 4766, 4778, 4778, 4778, 4783, 4786, 4786, 4786, 4787, 4789, 4793, 4798, 4798, 4798, 4799, 4801, 4813, 4817, 4822, 4822, 4822, 4831, 4834, 4834, 4834, 4846, 4846, 4846, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433]} +RLMATH_EOF diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s4/tests/check.py b/tasks/construct-ae-p38-factorial-factors-l6-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..93ec67a19039afa8b4ce6e39811691b802132562 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s4/tests/check.py @@ -0,0 +1,12 @@ +"""Factor N! into N factors, each >= t (AlphaEvolve problem 38 / OEIS A034258). Exact big-integer check.""" +import math + +from run import Invalid, int_list + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + f = int_list(ans.get("factors"), n, t, None, "factors") + if math.prod(f) != math.factorial(n): + raise Invalid(f"the product of the factors is not {n}!") + return None, {"min_factor": min(f)} diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s4/tests/instance.json b/tasks/construct-ae-p38-factorial-factors-l6-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d452b8f946f175b5368a4c7832f6b53ef3d2e390 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-l6-s4/tests/instance.json @@ -0,0 +1 @@ +{"N": 7446, "t": 2426, "family": "ae_p38_factorial_factors", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p38-factorial-factors-l6-s4/tests/run.py b/tasks/construct-ae-p38-factorial-factors-l6-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p38-factorial-factors-l6-s4/tests/test.sh b/tasks/construct-ae-p38-factorial-factors-l6-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p38-factorial-factors-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-ae-p52-erdos-squarefree-l2-s0/environment/Dockerfile b/tasks/construct-ae-p52-erdos-squarefree-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s0/environment/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0293fe7bdd595281d810e15590fd0ff1e57fcf66 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"N": 101, "t": 4, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s0/solution/solve.sh b/tasks/construct-ae-p52-erdos-squarefree-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b4fe921cb53c008dbabfbc68a8723cafd2892b5b --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"A": [7, 32, 57, 82]} +RLMATH_EOF diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s0/tests/check.py b/tasks/construct-ae-p52-erdos-squarefree-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..87e15b242f211059193ba122baecdee9add99130 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s0/tests/check.py @@ -0,0 +1,38 @@ +"""Erdos squarefree problem (AlphaEvolve problem 52): A in [1, N], |A| >= t, ab+1 NOT squarefree for all a, b in A +(a = b included). The repo's problem page says "square-free"; the notebook and the Erdos problem ask for +"never squarefree", which is what we check. Exact: for every pair we find a prime p with p^2 | ab+1.""" +import numpy as np + +from run import Invalid, int_list + + +def _primes(n): + s = np.ones(n + 1, dtype=bool) + s[:2] = False + for i in range(2, int(n ** .5) + 1): + if s[i]: + s[i * i::i] = False + return np.nonzero(s)[0] + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + a = ans.get("A") + if not isinstance(a, list) or not (t <= len(a) <= 2 * t + 20): + raise Invalid(f"A must be a list of {t}..{2 * t + 20} integers") + int_list(a, None, 1, n, "A") + if len(set(a)) != len(a): + raise Invalid("A must consist of distinct integers") + x = np.array(sorted(a), dtype=np.int64) + iu, ju = np.triu_indices(len(x)) + va, vb = x[iu], x[ju] + left = np.ones(len(iu), dtype=bool) # pairs without a square divisor found yet + for p in _primes(int((n * n + 1) ** .5) + 1): + q = int(p) * int(p) + idx = np.nonzero(left)[0] + hit = ((va[idx] % q) * (vb[idx] % q) + 1) % q == 0 + left[idx[hit]] = False + if not left.any(): + return None, {"size": len(a)} + k = int(np.nonzero(left)[0][0]) + raise Invalid(f"{int(va[k])}*{int(vb[k])}+1 = {int(va[k]) * int(vb[k]) + 1} is squarefree") diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s0/tests/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0293fe7bdd595281d810e15590fd0ff1e57fcf66 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"N": 101, "t": 4, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s0/tests/run.py b/tasks/construct-ae-p52-erdos-squarefree-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s0/tests/test.sh b/tasks/construct-ae-p52-erdos-squarefree-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s7/environment/Dockerfile b/tasks/construct-ae-p52-erdos-squarefree-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l2-s7/environment/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..095f8a956c21ee65d7e894d4d8bd3bdb9ceb431b --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"N": 102, "t": 4, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s7/solution/solve.sh b/tasks/construct-ae-p52-erdos-squarefree-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b4fe921cb53c008dbabfbc68a8723cafd2892b5b --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"A": [7, 32, 57, 82]} +RLMATH_EOF diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s7/tests/check.py b/tasks/construct-ae-p52-erdos-squarefree-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..87e15b242f211059193ba122baecdee9add99130 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s7/tests/check.py @@ -0,0 +1,38 @@ +"""Erdos squarefree problem (AlphaEvolve problem 52): A in [1, N], |A| >= t, ab+1 NOT squarefree for all a, b in A +(a = b included). The repo's problem page says "square-free"; the notebook and the Erdos problem ask for +"never squarefree", which is what we check. Exact: for every pair we find a prime p with p^2 | ab+1.""" +import numpy as np + +from run import Invalid, int_list + + +def _primes(n): + s = np.ones(n + 1, dtype=bool) + s[:2] = False + for i in range(2, int(n ** .5) + 1): + if s[i]: + s[i * i::i] = False + return np.nonzero(s)[0] + + +def check(inst, ans): + n, t = inst["N"], inst["t"] + a = ans.get("A") + if not isinstance(a, list) or not (t <= len(a) <= 2 * t + 20): + raise Invalid(f"A must be a list of {t}..{2 * t + 20} integers") + int_list(a, None, 1, n, "A") + if len(set(a)) != len(a): + raise Invalid("A must consist of distinct integers") + x = np.array(sorted(a), dtype=np.int64) + iu, ju = np.triu_indices(len(x)) + va, vb = x[iu], x[ju] + left = np.ones(len(iu), dtype=bool) # pairs without a square divisor found yet + for p in _primes(int((n * n + 1) ** .5) + 1): + q = int(p) * int(p) + idx = np.nonzero(left)[0] + hit = ((va[idx] % q) * (vb[idx] % q) + 1) % q == 0 + left[idx[hit]] = False + if not left.any(): + return None, {"size": len(a)} + k = int(np.nonzero(left)[0][0]) + raise Invalid(f"{int(va[k])}*{int(vb[k])}+1 = {int(va[k]) * int(vb[k]) + 1} is squarefree") diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s7/tests/instance.json b/tasks/construct-ae-p52-erdos-squarefree-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..095f8a956c21ee65d7e894d4d8bd3bdb9ceb431b --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"N": 102, "t": 4, "family": "ae_p52_erdos_squarefree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p52-erdos-squarefree-l2-s7/tests/run.py b/tasks/construct-ae-p52-erdos-squarefree-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p52-erdos-squarefree-l2-s7/tests/test.sh b/tasks/construct-ae-p52-erdos-squarefree-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p52-erdos-squarefree-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-ae-p65-imo2025-p6-tiling-l5-s0/environment/Dockerfile b/tasks/construct-ae-p65-imo2025-p6-tiling-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-ae-p65-imo2025-p6-tiling-l5-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-ae-p65-imo2025-p6-tiling-l5-s0/environment/instance.json b/tasks/construct-ae-p65-imo2025-p6-tiling-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..adf8c40c9c13bdd8ce57aae19b7b4a097addd30d --- /dev/null +++ b/tasks/construct-ae-p65-imo2025-p6-tiling-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 900, "max_tiles": 957, "family": "ae_p65_imo2025_p6_tiling", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p65-imo2025-p6-tiling-l5-s0/solution/solve.sh b/tasks/construct-ae-p65-imo2025-p6-tiling-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ff187f52c5bc82d9d8880a6a49adc5c92dda4a42 --- /dev/null +++ b/tasks/construct-ae-p65-imo2025-p6-tiling-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' +{"tiles": [[0, 0, 30, 29], [0, 30, 1, 870], [1, 29, 30, 30], [1, 60, 1, 840], [2, 59, 30, 30], [2, 90, 1, 810], [3, 89, 30, 30], [3, 120, 1, 780], [4, 119, 30, 30], [4, 150, 1, 750], [5, 149, 30, 30], [5, 180, 1, 720], [6, 179, 30, 30], [6, 210, 1, 690], [7, 209, 30, 30], [7, 240, 1, 660], [8, 239, 30, 30], [8, 270, 1, 630], [9, 269, 30, 30], [9, 300, 1, 600], [10, 299, 30, 30], [10, 330, 1, 570], [11, 329, 30, 30], [11, 360, 1, 540], [12, 359, 30, 30], [12, 390, 1, 510], [13, 389, 30, 30], [13, 420, 1, 480], [14, 419, 30, 30], [14, 450, 1, 450], [15, 449, 30, 30], [15, 480, 1, 420], [16, 479, 30, 30], [16, 510, 1, 390], [17, 509, 30, 30], [17, 540, 1, 360], [18, 539, 30, 30], [18, 570, 1, 330], [19, 569, 30, 30], [19, 600, 1, 300], [20, 599, 30, 30], [20, 630, 1, 270], [21, 629, 30, 30], [21, 660, 1, 240], [22, 659, 30, 30], [22, 690, 1, 210], [23, 689, 30, 30], [23, 720, 1, 180], [24, 719, 30, 30], [24, 750, 1, 150], [25, 749, 30, 30], [25, 780, 1, 120], [26, 779, 30, 30], [26, 810, 1, 90], [27, 809, 30, 30], [27, 840, 1, 60], [28, 839, 30, 30], [28, 870, 1, 30], [29, 869, 30, 30], [30, 0, 30, 28], [30, 899, 870, 1], [31, 28, 30, 30], [32, 58, 30, 30], [33, 88, 30, 30], [34, 118, 30, 30], [35, 148, 30, 30], [36, 178, 30, 30], [37, 208, 30, 30], [38, 238, 30, 30], [39, 268, 30, 30], [40, 298, 30, 30], [41, 328, 30, 30], [42, 358, 30, 30], [43, 388, 30, 30], [44, 418, 30, 30], [45, 448, 30, 30], [46, 478, 30, 30], [47, 508, 30, 30], [48, 538, 30, 30], [49, 568, 30, 30], [50, 598, 30, 30], [51, 628, 30, 30], [52, 658, 30, 30], [53, 688, 30, 30], [54, 718, 30, 30], [55, 748, 30, 30], [56, 778, 30, 30], [57, 808, 30, 30], [58, 838, 30, 30], [59, 868, 30, 30], [60, 0, 30, 27], [60, 898, 840, 1], [61, 27, 30, 30], [62, 57, 30, 30], [63, 87, 30, 30], [64, 117, 30, 30], [65, 147, 30, 30], [66, 177, 30, 30], [67, 207, 30, 30], [68, 237, 30, 30], [69, 267, 30, 30], [70, 297, 30, 30], [71, 327, 30, 30], [72, 357, 30, 30], [73, 387, 30, 30], [74, 417, 30, 30], [75, 447, 30, 30], [76, 477, 30, 30], [77, 507, 30, 30], [78, 537, 30, 30], [79, 567, 30, 30], [80, 597, 30, 30], [81, 627, 30, 30], [82, 657, 30, 30], [83, 687, 30, 30], [84, 717, 30, 30], [85, 747, 30, 30], [86, 777, 30, 30], [87, 807, 30, 30], [88, 837, 30, 30], [89, 867, 30, 30], [90, 0, 30, 26], [90, 897, 810, 1], [91, 26, 30, 30], [92, 56, 30, 30], [93, 86, 30, 30], [94, 116, 30, 30], [95, 146, 30, 30], [96, 176, 30, 30], [97, 206, 30, 30], [98, 236, 30, 30], [99, 266, 30, 30], [100, 296, 30, 30], [101, 326, 30, 30], [102, 356, 30, 30], [103, 386, 30, 30], [104, 416, 30, 30], [105, 446, 30, 30], [106, 476, 30, 30], [107, 506, 30, 30], [108, 536, 30, 30], [109, 566, 30, 30], [110, 596, 30, 30], [111, 626, 30, 30], [112, 656, 30, 30], [113, 686, 30, 30], [114, 716, 30, 30], [115, 746, 30, 30], [116, 776, 30, 30], [117, 806, 30, 30], [118, 836, 30, 30], [119, 866, 30, 30], [120, 0, 30, 25], [120, 896, 780, 1], [121, 25, 30, 30], [122, 55, 30, 30], [123, 85, 30, 30], [124, 115, 30, 30], [125, 145, 30, 30], [126, 175, 30, 30], [127, 205, 30, 30], [128, 235, 30, 30], [129, 265, 30, 30], [130, 295, 30, 30], [131, 325, 30, 30], [132, 355, 30, 30], [133, 385, 30, 30], [134, 415, 30, 30], [135, 445, 30, 30], [136, 475, 30, 30], [137, 505, 30, 30], [138, 535, 30, 30], [139, 565, 30, 30], [140, 595, 30, 30], [141, 625, 30, 30], [142, 655, 30, 30], [143, 685, 30, 30], [144, 715, 30, 30], [145, 745, 30, 30], [146, 775, 30, 30], [147, 805, 30, 30], [148, 835, 30, 30], [149, 865, 30, 30], [150, 0, 30, 24], [150, 895, 750, 1], [151, 24, 30, 30], [152, 54, 30, 30], [153, 84, 30, 30], [154, 114, 30, 30], [155, 144, 30, 30], [156, 174, 30, 30], [157, 204, 30, 30], [158, 234, 30, 30], [159, 264, 30, 30], [160, 294, 30, 30], [161, 324, 30, 30], [162, 354, 30, 30], [163, 384, 30, 30], [164, 414, 30, 30], [165, 444, 30, 30], [166, 474, 30, 30], [167, 504, 30, 30], [168, 534, 30, 30], [169, 564, 30, 30], [170, 594, 30, 30], [171, 624, 30, 30], [172, 654, 30, 30], [173, 684, 30, 30], [174, 714, 30, 30], [175, 744, 30, 30], [176, 774, 30, 30], [177, 804, 30, 30], [178, 834, 30, 30], [179, 864, 30, 30], [180, 0, 30, 23], [180, 894, 720, 1], [181, 23, 30, 30], [182, 53, 30, 30], [183, 83, 30, 30], [184, 113, 30, 30], [185, 143, 30, 30], [186, 173, 30, 30], [187, 203, 30, 30], [188, 233, 30, 30], [189, 263, 30, 30], [190, 293, 30, 30], [191, 323, 30, 30], [192, 353, 30, 30], [193, 383, 30, 30], [194, 413, 30, 30], [195, 443, 30, 30], [196, 473, 30, 30], [197, 503, 30, 30], [198, 533, 30, 30], [199, 563, 30, 30], [200, 593, 30, 30], [201, 623, 30, 30], [202, 653, 30, 30], [203, 683, 30, 30], [204, 713, 30, 30], [205, 743, 30, 30], [206, 773, 30, 30], [207, 803, 30, 30], [208, 833, 30, 30], [209, 863, 30, 30], [210, 0, 30, 22], [210, 893, 690, 1], [211, 22, 30, 30], [212, 52, 30, 30], [213, 82, 30, 30], [214, 112, 30, 30], [215, 142, 30, 30], [216, 172, 30, 30], [217, 202, 30, 30], [218, 232, 30, 30], [219, 262, 30, 30], [220, 292, 30, 30], [221, 322, 30, 30], [222, 352, 30, 30], [223, 382, 30, 30], [224, 412, 30, 30], [225, 442, 30, 30], [226, 472, 30, 30], [227, 502, 30, 30], [228, 532, 30, 30], [229, 562, 30, 30], [230, 592, 30, 30], [231, 622, 30, 30], [232, 652, 30, 30], [233, 682, 30, 30], [234, 712, 30, 30], [235, 742, 30, 30], [236, 772, 30, 30], [237, 802, 30, 30], [238, 832, 30, 30], [239, 862, 30, 30], [240, 0, 30, 21], [240, 892, 660, 1], [241, 21, 30, 30], [242, 51, 30, 30], [243, 81, 30, 30], [244, 111, 30, 30], [245, 141, 30, 30], [246, 171, 30, 30], [247, 201, 30, 30], [248, 231, 30, 30], [249, 261, 30, 30], [250, 291, 30, 30], [251, 321, 30, 30], [252, 351, 30, 30], [253, 381, 30, 30], [254, 411, 30, 30], [255, 441, 30, 30], [256, 471, 30, 30], [257, 501, 30, 30], [258, 531, 30, 30], [259, 561, 30, 30], [260, 591, 30, 30], [261, 621, 30, 30], [262, 651, 30, 30], [263, 681, 30, 30], [264, 711, 30, 30], [265, 741, 30, 30], [266, 771, 30, 30], [267, 801, 30, 30], [268, 831, 30, 30], [269, 861, 30, 30], [270, 0, 30, 20], [270, 891, 630, 1], [271, 20, 30, 30], [272, 50, 30, 30], [273, 80, 30, 30], [274, 110, 30, 30], [275, 140, 30, 30], [276, 170, 30, 30], [277, 200, 30, 30], [278, 230, 30, 30], [279, 260, 30, 30], [280, 290, 30, 30], [281, 320, 30, 30], [282, 350, 30, 30], [283, 380, 30, 30], [284, 410, 30, 30], [285, 440, 30, 30], [286, 470, 30, 30], [287, 500, 30, 30], [288, 530, 30, 30], [289, 560, 30, 30], [290, 590, 30, 30], [291, 620, 30, 30], [292, 650, 30, 30], [293, 680, 30, 30], [294, 710, 30, 30], [295, 740, 30, 30], [296, 770, 30, 30], [297, 800, 30, 30], [298, 830, 30, 30], [299, 860, 30, 30], [300, 0, 30, 19], [300, 890, 600, 1], [301, 19, 30, 30], [302, 49, 30, 30], [303, 79, 30, 30], [304, 109, 30, 30], [305, 139, 30, 30], [306, 169, 30, 30], [307, 199, 30, 30], [308, 229, 30, 30], [309, 259, 30, 30], [310, 289, 30, 30], [311, 319, 30, 30], [312, 349, 30, 30], [313, 379, 30, 30], [314, 409, 30, 30], [315, 439, 30, 30], [316, 469, 30, 30], [317, 499, 30, 30], [318, 529, 30, 30], [319, 559, 30, 30], [320, 589, 30, 30], [321, 619, 30, 30], [322, 649, 30, 30], [323, 679, 30, 30], [324, 709, 30, 30], [325, 739, 30, 30], [326, 769, 30, 30], [327, 799, 30, 30], [328, 829, 30, 30], [329, 859, 30, 30], [330, 0, 30, 18], [330, 889, 570, 1], [331, 18, 30, 30], [332, 48, 30, 30], [333, 78, 30, 30], [334, 108, 30, 30], [335, 138, 30, 30], [336, 168, 30, 30], [337, 198, 30, 30], [338, 228, 30, 30], [339, 258, 30, 30], [340, 288, 30, 30], [341, 318, 30, 30], [342, 348, 30, 30], [343, 378, 30, 30], [344, 408, 30, 30], [345, 438, 30, 30], [346, 468, 30, 30], [347, 498, 30, 30], [348, 528, 30, 30], [349, 558, 30, 30], [350, 588, 30, 30], [351, 618, 30, 30], [352, 648, 30, 30], [353, 678, 30, 30], [354, 708, 30, 30], [355, 738, 30, 30], [356, 768, 30, 30], [357, 798, 30, 30], [358, 828, 30, 30], [359, 858, 30, 30], [360, 0, 30, 17], [360, 888, 540, 1], [361, 17, 30, 30], [362, 47, 30, 30], [363, 77, 30, 30], [364, 107, 30, 30], [365, 137, 30, 30], [366, 167, 30, 30], [367, 197, 30, 30], [368, 227, 30, 30], [369, 257, 30, 30], [370, 287, 30, 30], [371, 317, 30, 30], [372, 347, 30, 30], [373, 377, 30, 30], [374, 407, 30, 30], [375, 437, 30, 30], [376, 467, 30, 30], [377, 497, 30, 30], [378, 527, 30, 30], [379, 557, 30, 30], [380, 587, 30, 30], [381, 617, 30, 30], [382, 647, 30, 30], [383, 677, 30, 30], [384, 707, 30, 30], [385, 737, 30, 30], [386, 767, 30, 30], [387, 797, 30, 30], [388, 827, 30, 30], [389, 857, 30, 30], [390, 0, 30, 16], [390, 887, 510, 1], [391, 16, 30, 30], [392, 46, 30, 30], [393, 76, 30, 30], [394, 106, 30, 30], [395, 136, 30, 30], [396, 166, 30, 30], [397, 196, 30, 30], [398, 226, 30, 30], [399, 256, 30, 30], [400, 286, 30, 30], [401, 316, 30, 30], [402, 346, 30, 30], [403, 376, 30, 30], [404, 406, 30, 30], [405, 436, 30, 30], [406, 466, 30, 30], [407, 496, 30, 30], [408, 526, 30, 30], [409, 556, 30, 30], [410, 586, 30, 30], [411, 616, 30, 30], [412, 646, 30, 30], [413, 676, 30, 30], [414, 706, 30, 30], [415, 736, 30, 30], [416, 766, 30, 30], [417, 796, 30, 30], [418, 826, 30, 30], [419, 856, 30, 30], [420, 0, 30, 15], [420, 886, 480, 1], [421, 15, 30, 30], [422, 45, 30, 30], [423, 75, 30, 30], [424, 105, 30, 30], [425, 135, 30, 30], [426, 165, 30, 30], [427, 195, 30, 30], [428, 225, 30, 30], [429, 255, 30, 30], [430, 285, 30, 30], [431, 315, 30, 30], [432, 345, 30, 30], [433, 375, 30, 30], [434, 405, 30, 30], [435, 435, 30, 30], [436, 465, 30, 30], [437, 495, 30, 30], [438, 525, 30, 30], [439, 555, 30, 30], [440, 585, 30, 30], [441, 615, 30, 30], [442, 645, 30, 30], [443, 675, 30, 30], [444, 705, 30, 30], [445, 735, 30, 30], [446, 765, 30, 30], [447, 795, 30, 30], [448, 825, 30, 30], [449, 855, 30, 30], [450, 0, 30, 14], [450, 885, 450, 1], [451, 14, 30, 30], [452, 44, 30, 30], [453, 74, 30, 30], [454, 104, 30, 30], [455, 134, 30, 30], [456, 164, 30, 30], [457, 194, 30, 30], [458, 224, 30, 30], [459, 254, 30, 30], [460, 284, 30, 30], [461, 314, 30, 30], [462, 344, 30, 30], [463, 374, 30, 30], [464, 404, 30, 30], [465, 434, 30, 30], [466, 464, 30, 30], [467, 494, 30, 30], [468, 524, 30, 30], [469, 554, 30, 30], [470, 584, 30, 30], [471, 614, 30, 30], [472, 644, 30, 30], [473, 674, 30, 30], [474, 704, 30, 30], [475, 734, 30, 30], [476, 764, 30, 30], [477, 794, 30, 30], [478, 824, 30, 30], [479, 854, 30, 30], [480, 0, 30, 13], [480, 884, 420, 1], [481, 13, 30, 30], [482, 43, 30, 30], [483, 73, 30, 30], [484, 103, 30, 30], [485, 133, 30, 30], [486, 163, 30, 30], [487, 193, 30, 30], [488, 223, 30, 30], [489, 253, 30, 30], [490, 283, 30, 30], [491, 313, 30, 30], [492, 343, 30, 30], [493, 373, 30, 30], [494, 403, 30, 30], [495, 433, 30, 30], [496, 463, 30, 30], [497, 493, 30, 30], [498, 523, 30, 30], [499, 553, 30, 30], [500, 583, 30, 30], [501, 613, 30, 30], [502, 643, 30, 30], [503, 673, 30, 30], [504, 703, 30, 30], [505, 733, 30, 30], [506, 763, 30, 30], [507, 793, 30, 30], [508, 823, 30, 30], [509, 853, 30, 30], [510, 0, 30, 12], [510, 883, 390, 1], [511, 12, 30, 30], [512, 42, 30, 30], [513, 72, 30, 30], [514, 102, 30, 30], [515, 132, 30, 30], [516, 162, 30, 30], [517, 192, 30, 30], [518, 222, 30, 30], [519, 252, 30, 30], [520, 282, 30, 30], [521, 312, 30, 30], [522, 342, 30, 30], [523, 372, 30, 30], [524, 402, 30, 30], [525, 432, 30, 30], [526, 462, 30, 30], [527, 492, 30, 30], [528, 522, 30, 30], [529, 552, 30, 30], [530, 582, 30, 30], [531, 612, 30, 30], [532, 642, 30, 30], [533, 672, 30, 30], [534, 702, 30, 30], [535, 732, 30, 30], [536, 762, 30, 30], [537, 792, 30, 30], [538, 822, 30, 30], [539, 852, 30, 30], [540, 0, 30, 11], [540, 882, 360, 1], [541, 11, 30, 30], [542, 41, 30, 30], [543, 71, 30, 30], [544, 101, 30, 30], [545, 131, 30, 30], [546, 161, 30, 30], [547, 191, 30, 30], [548, 221, 30, 30], [549, 251, 30, 30], [550, 281, 30, 30], [551, 311, 30, 30], [552, 341, 30, 30], [553, 371, 30, 30], [554, 401, 30, 30], [555, 431, 30, 30], [556, 461, 30, 30], [557, 491, 30, 30], [558, 521, 30, 30], [559, 551, 30, 30], [560, 581, 30, 30], [561, 611, 30, 30], [562, 641, 30, 30], [563, 671, 30, 30], [564, 701, 30, 30], [565, 731, 30, 30], [566, 761, 30, 30], [567, 791, 30, 30], [568, 821, 30, 30], [569, 851, 30, 30], [570, 0, 30, 10], [570, 881, 330, 1], [571, 10, 30, 30], [572, 40, 30, 30], [573, 70, 30, 30], [574, 100, 30, 30], [575, 130, 30, 30], [576, 160, 30, 30], [577, 190, 30, 30], [578, 220, 30, 30], [579, 250, 30, 30], [580, 280, 30, 30], [581, 310, 30, 30], [582, 340, 30, 30], [583, 370, 30, 30], [584, 400, 30, 30], [585, 430, 30, 30], [586, 460, 30, 30], [587, 490, 30, 30], [588, 520, 30, 30], [589, 550, 30, 30], [590, 580, 30, 30], [591, 610, 30, 30], [592, 640, 30, 30], [593, 670, 30, 30], [594, 700, 30, 30], [595, 730, 30, 30], [596, 760, 30, 30], [597, 790, 30, 30], [598, 820, 30, 30], [599, 850, 30, 30], [600, 0, 30, 9], [600, 880, 300, 1], [601, 9, 30, 30], [602, 39, 30, 30], [603, 69, 30, 30], [604, 99, 30, 30], [605, 129, 30, 30], [606, 159, 30, 30], [607, 189, 30, 30], [608, 219, 30, 30], [609, 249, 30, 30], [610, 279, 30, 30], [611, 309, 30, 30], [612, 339, 30, 30], [613, 369, 30, 30], [614, 399, 30, 30], [615, 429, 30, 30], [616, 459, 30, 30], [617, 489, 30, 30], [618, 519, 30, 30], [619, 549, 30, 30], [620, 579, 30, 30], [621, 609, 30, 30], [622, 639, 30, 30], [623, 669, 30, 30], [624, 699, 30, 30], [625, 729, 30, 30], [626, 759, 30, 30], [627, 789, 30, 30], [628, 819, 30, 30], [629, 849, 30, 30], [630, 0, 30, 8], [630, 879, 270, 1], [631, 8, 30, 30], [632, 38, 30, 30], [633, 68, 30, 30], [634, 98, 30, 30], [635, 128, 30, 30], [636, 158, 30, 30], [637, 188, 30, 30], [638, 218, 30, 30], [639, 248, 30, 30], [640, 278, 30, 30], [641, 308, 30, 30], [642, 338, 30, 30], [643, 368, 30, 30], [644, 398, 30, 30], [645, 428, 30, 30], [646, 458, 30, 30], [647, 488, 30, 30], [648, 518, 30, 30], [649, 548, 30, 30], [650, 578, 30, 30], [651, 608, 30, 30], [652, 638, 30, 30], [653, 668, 30, 30], [654, 698, 30, 30], [655, 728, 30, 30], [656, 758, 30, 30], [657, 788, 30, 30], [658, 818, 30, 30], [659, 848, 30, 30], [660, 0, 30, 7], [660, 878, 240, 1], [661, 7, 30, 30], [662, 37, 30, 30], [663, 67, 30, 30], [664, 97, 30, 30], [665, 127, 30, 30], [666, 157, 30, 30], [667, 187, 30, 30], [668, 217, 30, 30], [669, 247, 30, 30], [670, 277, 30, 30], [671, 307, 30, 30], [672, 337, 30, 30], [673, 367, 30, 30], [674, 397, 30, 30], [675, 427, 30, 30], [676, 457, 30, 30], [677, 487, 30, 30], [678, 517, 30, 30], [679, 547, 30, 30], [680, 577, 30, 30], [681, 607, 30, 30], [682, 637, 30, 30], [683, 667, 30, 30], [684, 697, 30, 30], [685, 727, 30, 30], [686, 757, 30, 30], [687, 787, 30, 30], [688, 817, 30, 30], [689, 847, 30, 30], [690, 0, 30, 6], [690, 877, 210, 1], [691, 6, 30, 30], [692, 36, 30, 30], [693, 66, 30, 30], [694, 96, 30, 30], [695, 126, 30, 30], [696, 156, 30, 30], [697, 186, 30, 30], [698, 216, 30, 30], [699, 246, 30, 30], [700, 276, 30, 30], [701, 306, 30, 30], [702, 336, 30, 30], [703, 366, 30, 30], [704, 396, 30, 30], [705, 426, 30, 30], [706, 456, 30, 30], [707, 486, 30, 30], [708, 516, 30, 30], [709, 546, 30, 30], [710, 576, 30, 30], [711, 606, 30, 30], [712, 636, 30, 30], [713, 666, 30, 30], [714, 696, 30, 30], [715, 726, 30, 30], [716, 756, 30, 30], [717, 786, 30, 30], [718, 816, 30, 30], [719, 846, 30, 30], [720, 0, 30, 5], [720, 876, 180, 1], [721, 5, 30, 30], [722, 35, 30, 30], [723, 65, 30, 30], [724, 95, 30, 30], [725, 125, 30, 30], [726, 155, 30, 30], [727, 185, 30, 30], [728, 215, 30, 30], [729, 245, 30, 30], [730, 275, 30, 30], [731, 305, 30, 30], [732, 335, 30, 30], [733, 365, 30, 30], [734, 395, 30, 30], [735, 425, 30, 30], [736, 455, 30, 30], [737, 485, 30, 30], [738, 515, 30, 30], [739, 545, 30, 30], [740, 575, 30, 30], [741, 605, 30, 30], [742, 635, 30, 30], [743, 665, 30, 30], [744, 695, 30, 30], [745, 725, 30, 30], [746, 755, 30, 30], [747, 785, 30, 30], [748, 815, 30, 30], [749, 845, 30, 30], [750, 0, 30, 4], [750, 875, 150, 1], [751, 4, 30, 30], [752, 34, 30, 30], [753, 64, 30, 30], [754, 94, 30, 30], [755, 124, 30, 30], [756, 154, 30, 30], [757, 184, 30, 30], [758, 214, 30, 30], [759, 244, 30, 30], [760, 274, 30, 30], [761, 304, 30, 30], [762, 334, 30, 30], [763, 364, 30, 30], [764, 394, 30, 30], [765, 424, 30, 30], [766, 454, 30, 30], [767, 484, 30, 30], [768, 514, 30, 30], [769, 544, 30, 30], [770, 574, 30, 30], [771, 604, 30, 30], [772, 634, 30, 30], [773, 664, 30, 30], [774, 694, 30, 30], [775, 724, 30, 30], [776, 754, 30, 30], [777, 784, 30, 30], [778, 814, 30, 30], [779, 844, 30, 30], [780, 0, 30, 3], [780, 874, 120, 1], [781, 3, 30, 30], [782, 33, 30, 30], [783, 63, 30, 30], [784, 93, 30, 30], [785, 123, 30, 30], [786, 153, 30, 30], [787, 183, 30, 30], [788, 213, 30, 30], [789, 243, 30, 30], [790, 273, 30, 30], [791, 303, 30, 30], [792, 333, 30, 30], [793, 363, 30, 30], [794, 393, 30, 30], [795, 423, 30, 30], [796, 453, 30, 30], [797, 483, 30, 30], [798, 513, 30, 30], [799, 543, 30, 30], [800, 573, 30, 30], [801, 603, 30, 30], [802, 633, 30, 30], [803, 663, 30, 30], [804, 693, 30, 30], [805, 723, 30, 30], [806, 753, 30, 30], [807, 783, 30, 30], [808, 813, 30, 30], [809, 843, 30, 30], [810, 0, 30, 2], [810, 873, 90, 1], [811, 2, 30, 30], [812, 32, 30, 30], [813, 62, 30, 30], [814, 92, 30, 30], [815, 122, 30, 30], [816, 152, 30, 30], [817, 182, 30, 30], [818, 212, 30, 30], [819, 242, 30, 30], [820, 272, 30, 30], [821, 302, 30, 30], [822, 332, 30, 30], [823, 362, 30, 30], [824, 392, 30, 30], [825, 422, 30, 30], [826, 452, 30, 30], [827, 482, 30, 30], [828, 512, 30, 30], [829, 542, 30, 30], [830, 572, 30, 30], [831, 602, 30, 30], [832, 632, 30, 30], [833, 662, 30, 30], [834, 692, 30, 30], [835, 722, 30, 30], [836, 752, 30, 30], [837, 782, 30, 30], [838, 812, 30, 30], [839, 842, 30, 30], [840, 0, 30, 1], [840, 872, 60, 1], [841, 1, 30, 30], [842, 31, 30, 30], [843, 61, 30, 30], [844, 91, 30, 30], [845, 121, 30, 30], [846, 151, 30, 30], [847, 181, 30, 30], [848, 211, 30, 30], [849, 241, 30, 30], [850, 271, 30, 30], [851, 301, 30, 30], [852, 331, 30, 30], [853, 361, 30, 30], [854, 391, 30, 30], [855, 421, 30, 30], [856, 451, 30, 30], [857, 481, 30, 30], [858, 511, 30, 30], [859, 541, 30, 30], [860, 571, 30, 30], [861, 601, 30, 30], [862, 631, 30, 30], [863, 661, 30, 30], [864, 691, 30, 30], [865, 721, 30, 30], [866, 751, 30, 30], [867, 781, 30, 30], [868, 811, 30, 30], [869, 841, 30, 30], [870, 871, 30, 1], [871, 0, 29, 30], [872, 30, 28, 30], [873, 60, 27, 30], [874, 90, 26, 30], [875, 120, 25, 30], [876, 150, 24, 30], [877, 180, 23, 30], [878, 210, 22, 30], [879, 240, 21, 30], [880, 270, 20, 30], [881, 300, 19, 30], [882, 330, 18, 30], [883, 360, 17, 30], [884, 390, 16, 30], [885, 420, 15, 30], [886, 450, 14, 30], [887, 480, 13, 30], [888, 510, 12, 30], [889, 540, 11, 30], [890, 570, 10, 30], [891, 600, 9, 30], [892, 630, 8, 30], [893, 660, 7, 30], [894, 690, 6, 30], [895, 720, 5, 30], [896, 750, 4, 30], [897, 780, 3, 30], [898, 810, 2, 30], [899, 840, 1, 30]]} +RLMATH_EOF diff --git a/tasks/construct-ae-p65-imo2025-p6-tiling-l5-s0/tests/check.py b/tasks/construct-ae-p65-imo2025-p6-tiling-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..401de49cfa895e6f1c47b996fa5e8bdc8fc609e4 --- /dev/null +++ b/tasks/construct-ae-p65-imo2025-p6-tiling-l5-s0/tests/check.py @@ -0,0 +1,24 @@ +"""IMO 2025 Problem 6 variant (AlphaEvolve problem 65): at most T rectangular tiles on an n x n grid, no overlaps, +every row and every column has exactly one uncovered unit square.""" +import numpy as np + +from run import Invalid, int_list + + +def check(inst, ans): + n, cap = inst["n"], inst["max_tiles"] + tiles = ans.get("tiles") + if not isinstance(tiles, list) or not (1 <= len(tiles) <= cap): + raise Invalid(f"tiles must be a list of 1..{cap} [row, col, height, width] entries") + cover = np.zeros((n, n), dtype=np.int32) + for t in tiles: + r, c, h, w = int_list(t, 4, 0, n, "tile") + if h < 1 or w < 1 or r + h > n or c + w > n: + raise Invalid(f"tile {t} is empty or leaves the grid") + cover[r:r + h, c:c + w] += 1 + if cover.max() > 1: + raise Invalid("tiles overlap") + free = cover == 0 + if not (free.sum(axis=1) == 1).all() or not (free.sum(axis=0) == 1).all(): + raise Invalid("some row or column does not have exactly one uncovered square") + return None, {"tiles": len(tiles)} diff --git a/tasks/construct-ae-p65-imo2025-p6-tiling-l5-s0/tests/instance.json b/tasks/construct-ae-p65-imo2025-p6-tiling-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..adf8c40c9c13bdd8ce57aae19b7b4a097addd30d --- /dev/null +++ b/tasks/construct-ae-p65-imo2025-p6-tiling-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 900, "max_tiles": 957, "family": "ae_p65_imo2025_p6_tiling", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-ae-p65-imo2025-p6-tiling-l5-s0/tests/run.py b/tasks/construct-ae-p65-imo2025-p6-tiling-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-ae-p65-imo2025-p6-tiling-l5-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-ae-p65-imo2025-p6-tiling-l5-s0/tests/test.sh b/tasks/construct-ae-p65-imo2025-p6-tiling-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-ae-p65-imo2025-p6-tiling-l5-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-all-interval-l2-s2/environment/Dockerfile b/tasks/construct-mc-all-interval-l2-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-all-interval-l2-s2/environment/instance.json b/tasks/construct-mc-all-interval-l2-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..443c0cdc35ba837d6b2bbb60d0e9f366a4bb11b2 --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 11, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l2-s2/solution/solve.sh b/tasks/construct-mc-all-interval-l2-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..19b713e93abe5aee5236c40f2bdd3bb3948287b8 --- /dev/null +++ b/tasks/construct-mc-all-interval-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' +{"x": [0, 10, 1, 9, 2, 8, 3, 7, 4, 6, 5]} +RLMATH_EOF diff --git a/tasks/construct-mc-all-interval-l2-s2/tests/check.py b/tasks/construct-mc-all-interval-l2-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2e39eec264b6422a47e35921b8cdbe1fa1748307 --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s2/tests/check.py @@ -0,0 +1,17 @@ +"""All-interval series of size n (MathConstraint all_interval, CC-BY-4.0). Accepts any valid series.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n - 1, "x") + if sorted(x) != list(range(n)): + raise Invalid("x is not a permutation of 0..n-1") + d = [abs(x[i + 1] - x[i]) for i in range(n - 1)] + if sorted(d) != list(range(1, n)): + raise Invalid("consecutive differences are not a permutation of 1..n-1") + seqs = {"x": x, "d": d} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-all-interval-l2-s2/tests/instance.json b/tasks/construct-mc-all-interval-l2-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..443c0cdc35ba837d6b2bbb60d0e9f366a4bb11b2 --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 11, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l2-s2/tests/run.py b/tasks/construct-mc-all-interval-l2-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-all-interval-l2-s2/tests/test.sh b/tasks/construct-mc-all-interval-l2-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-all-interval-l2-s5/environment/Dockerfile b/tasks/construct-mc-all-interval-l2-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-all-interval-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-mc-all-interval-l2-s5/environment/instance.json b/tasks/construct-mc-all-interval-l2-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2169471a5f6c5024baf21627c8ed6c0137b156d5 --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l2-s5/solution/solve.sh b/tasks/construct-mc-all-interval-l2-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5304b8a8355bf07f758713166fdf377215470dcd --- /dev/null +++ b/tasks/construct-mc-all-interval-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' +{"x": [0, 7, 1, 6, 2, 5, 3, 4]} +RLMATH_EOF diff --git a/tasks/construct-mc-all-interval-l2-s5/tests/check.py b/tasks/construct-mc-all-interval-l2-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2e39eec264b6422a47e35921b8cdbe1fa1748307 --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s5/tests/check.py @@ -0,0 +1,17 @@ +"""All-interval series of size n (MathConstraint all_interval, CC-BY-4.0). Accepts any valid series.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n - 1, "x") + if sorted(x) != list(range(n)): + raise Invalid("x is not a permutation of 0..n-1") + d = [abs(x[i + 1] - x[i]) for i in range(n - 1)] + if sorted(d) != list(range(1, n)): + raise Invalid("consecutive differences are not a permutation of 1..n-1") + seqs = {"x": x, "d": d} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-all-interval-l2-s5/tests/instance.json b/tasks/construct-mc-all-interval-l2-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2169471a5f6c5024baf21627c8ed6c0137b156d5 --- /dev/null +++ b/tasks/construct-mc-all-interval-l2-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "fixed": [], "family": "mc_all_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-all-interval-l2-s5/tests/run.py b/tasks/construct-mc-all-interval-l2-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-all-interval-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-mc-all-interval-l2-s5/tests/test.sh b/tasks/construct-mc-all-interval-l2-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-all-interval-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-mc-antimagic-square-l2-s0/environment/Dockerfile b/tasks/construct-mc-antimagic-square-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-antimagic-square-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-antimagic-square-l2-s0/environment/instance.json b/tasks/construct-mc-antimagic-square-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e675ded3c54d6ed09d22d6163cf3601eabdf13b9 --- /dev/null +++ b/tasks/construct-mc-antimagic-square-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 5, "family": "mc_antimagic_square", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-antimagic-square-l2-s0/solution/solve.sh b/tasks/construct-mc-antimagic-square-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c37723a3729c4be2ffc46580c0e7bb75f2e54db3 --- /dev/null +++ b/tasks/construct-mc-antimagic-square-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' +{"grid": [[9, 21, 6, 14, 19], [24, 3, 25, 7, 5], [17, 2, 23, 16, 12], [10, 15, 8, 11, 18], [1, 22, 4, 20, 13]]} +RLMATH_EOF diff --git a/tasks/construct-mc-antimagic-square-l2-s0/tests/check.py b/tasks/construct-mc-antimagic-square-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9c86a40bef203632c61a8ba237cae03eb53251a6 --- /dev/null +++ b/tasks/construct-mc-antimagic-square-l2-s0/tests/check.py @@ -0,0 +1,20 @@ +"""Antimagic square of order n (MathConstraint antimagic_square, CC-BY-4.0): the numbers 1..n^2 in an +n x n grid whose 2n+2 line sums (rows, columns, both main diagonals) are 2n+2 consecutive integers.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + g = ans.get("grid") + if not isinstance(g, list) or len(g) != n: + raise Invalid(f"grid must be a list of {n} rows") + g = [int_list(r, n, 1, n * n, "grid row") for r in g] + flat = [v for r in g for v in r] + if sorted(flat) != list(range(1, n * n + 1)): + raise Invalid(f"grid must contain each of 1..{n * n} exactly once") + sums = [sum(r) for r in g] + [sum(g[i][j] for i in range(n)) for j in range(n)] + sums += [sum(g[i][i] for i in range(n)), sum(g[i][n - 1 - i] for i in range(n))] + s = sorted(sums) + if any(s[i + 1] != s[i] + 1 for i in range(len(s) - 1)): + raise Invalid(f"line sums {sums} are not {2 * n + 2} consecutive integers") + return None, {} diff --git a/tasks/construct-mc-antimagic-square-l2-s0/tests/instance.json b/tasks/construct-mc-antimagic-square-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e675ded3c54d6ed09d22d6163cf3601eabdf13b9 --- /dev/null +++ b/tasks/construct-mc-antimagic-square-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 5, "family": "mc_antimagic_square", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-antimagic-square-l2-s0/tests/run.py b/tasks/construct-mc-antimagic-square-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-antimagic-square-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-antimagic-square-l2-s0/tests/test.sh b/tasks/construct-mc-antimagic-square-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-antimagic-square-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-bibd-l1-s1/environment/Dockerfile b/tasks/construct-mc-bibd-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-bibd-l1-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-bibd-l1-s1/environment/instance.json b/tasks/construct-mc-bibd-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e278d2a6a708c1cf284fa89b64be9dd46374025d --- /dev/null +++ b/tasks/construct-mc-bibd-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"v": 7, "k": 4, "lambda": 2, "b": 7, "family": "mc_bibd", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-bibd-l1-s1/solution/solve.sh b/tasks/construct-mc-bibd-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1231b16448e3456bc70eff5e6ced746c0f26aa00 --- /dev/null +++ b/tasks/construct-mc-bibd-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' +{"blocks": [[2, 4, 5, 6], [0, 3, 5, 6], [0, 1, 4, 6], [0, 1, 2, 5], [1, 2, 3, 6], [0, 2, 3, 4], [1, 3, 4, 5]]} +RLMATH_EOF diff --git a/tasks/construct-mc-bibd-l1-s1/tests/check.py b/tasks/construct-mc-bibd-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c4b5da62477026f27ff9869fe33602fcc41e2ea9 --- /dev/null +++ b/tasks/construct-mc-bibd-l1-s1/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-l1-s1/tests/instance.json b/tasks/construct-mc-bibd-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e278d2a6a708c1cf284fa89b64be9dd46374025d --- /dev/null +++ b/tasks/construct-mc-bibd-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"v": 7, "k": 4, "lambda": 2, "b": 7, "family": "mc_bibd", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-bibd-l1-s1/tests/run.py b/tasks/construct-mc-bibd-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-bibd-l1-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-bibd-l1-s1/tests/test.sh b/tasks/construct-mc-bibd-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-bibd-l1-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-bibd-l5-s0/environment/Dockerfile b/tasks/construct-mc-bibd-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-bibd-l5-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-bibd-l5-s0/environment/instance.json b/tasks/construct-mc-bibd-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d611e7d7bac85c1cd0330761d0a7775ba1a03530 --- /dev/null +++ b/tasks/construct-mc-bibd-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"v": 15, "k": 3, "lambda": 3, "b": 105, "family": "mc_bibd", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-bibd-l5-s0/solution/solve.sh b/tasks/construct-mc-bibd-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bfac58b41fa0b879a5183988a5264777453fcb94 --- /dev/null +++ b/tasks/construct-mc-bibd-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' +{"blocks": [[2, 6, 12], [3, 6, 11], [0, 6, 10], [3, 13, 14], [3, 6, 13], [3, 6, 11], [0, 13, 14], [1, 7, 12], [6, 12, 13], [8, 11, 13], [8, 10, 11], [2, 11, 14], [0, 7, 12], [0, 7, 8], [3, 7, 12], [3, 10, 12], [7, 11, 14], [2, 7, 11], [7, 10, 13], [9, 11, 12], [2, 4, 12], [5, 7, 13], [4, 5, 13], [2, 6, 14], [2, 6, 10], [5, 7, 11], [0, 5, 11], [5, 10, 12], [3, 9, 11], [4, 7, 10], [1, 2, 12], [1, 2, 11], [2, 5, 10], [5, 9, 11], [7, 9, 13], [5, 12, 13], [2, 13, 14], [1, 5, 6], [0, 5, 14], [10, 11, 12], [1, 4, 5], [5, 7, 10], [2, 5, 8], [0, 10, 14], [0, 5, 6], [5, 6, 14], [9, 10, 13], [0, 7, 8], [6, 8, 12], [4, 9, 10], [2, 4, 10], [8, 9, 13], [8, 10, 14], [8, 10, 14], [0, 2, 13], [1, 8, 13], [0, 2, 13], [1, 9, 14], [0, 10, 11], [4, 12, 14], [4, 11, 14], [1, 7, 14], [6, 8, 9], [1, 4, 8], [2, 3, 9], [7, 9, 14], [8, 11, 12], [1, 4, 8], [0, 2, 4], [2, 7, 9], [2, 3, 7], [3, 8, 14], [3, 5, 14], [5, 9, 12], [3, 12, 13], [3, 4, 7], [0, 3, 4], [6, 9, 14], [6, 9, 10], [4, 6, 13], [1, 6, 7], [0, 3, 9], [3, 5, 8], [1, 3, 10], [4, 6, 7], [0, 1, 6], [0, 1, 11], [1, 10, 13], [1, 3, 5], [0, 3, 4], [6, 7, 8], [4, 11, 13], [4, 5, 9], [4, 6, 11], [1, 2, 9], [0, 8, 12], [1, 3, 10], [4, 12, 14], [2, 3, 8], [4, 8, 9], [1, 11, 13], [0, 1, 9], [0, 9, 12], [2, 5, 8], [1, 12, 14]]} +RLMATH_EOF diff --git a/tasks/construct-mc-bibd-l5-s0/tests/check.py b/tasks/construct-mc-bibd-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c4b5da62477026f27ff9869fe33602fcc41e2ea9 --- /dev/null +++ b/tasks/construct-mc-bibd-l5-s0/tests/check.py @@ -0,0 +1,25 @@ +"""Balanced incomplete block design BIBD(v, k, lambda) (MathConstraint bibd, CC-BY-4.0). +Answer = list of b blocks; every block is a k-subset of {0..v-1}, every pair of points lies in exactly +lambda blocks (which forces every point to lie in r blocks). Repeated blocks are allowed, as upstream +(its 0/1 incidence-matrix model does not forbid equal columns).""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + v, k, lam, b = inst["v"], inst["k"], inst["lambda"], inst["b"] + blocks = ans.get("blocks") + if not isinstance(blocks, list) or len(blocks) != b: + raise Invalid(f"blocks must be a list of exactly {b} blocks") + pair = {} + for B in blocks: + B = int_list(B, k, 0, v - 1, "block") + if len(set(B)) != k: + raise Invalid("a block contains a repeated point") + for p in itertools.combinations(sorted(B), 2): + pair[p] = pair.get(p, 0) + 1 + for p in itertools.combinations(range(v), 2): + if pair.get(p, 0) != lam: + raise Invalid(f"points {p} lie together in {pair.get(p, 0)} blocks, need {lam}") + return None, {} diff --git a/tasks/construct-mc-bibd-l5-s0/tests/instance.json b/tasks/construct-mc-bibd-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d611e7d7bac85c1cd0330761d0a7775ba1a03530 --- /dev/null +++ b/tasks/construct-mc-bibd-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"v": 15, "k": 3, "lambda": 3, "b": 105, "family": "mc_bibd", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-bibd-l5-s0/tests/run.py b/tasks/construct-mc-bibd-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-bibd-l5-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-bibd-l5-s0/tests/test.sh b/tasks/construct-mc-bibd-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-bibd-l5-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-debruijn-l5-s1/environment/Dockerfile b/tasks/construct-mc-debruijn-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-debruijn-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-debruijn-l5-s1/environment/instance.json b/tasks/construct-mc-debruijn-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a344f7ae89e2669710ede99486fc97ca3348b985 --- /dev/null +++ b/tasks/construct-mc-debruijn-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"b": 2, "n": 11, "family": "mc_debruijn", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-debruijn-l5-s1/solution/solve.sh b/tasks/construct-mc-debruijn-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..46b27a3cfd8a670389aa86abd0505b68302e79a0 --- /dev/null +++ b/tasks/construct-mc-debruijn-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' +{"seq": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-debruijn-l5-s1/tests/check.py b/tasks/construct-mc-debruijn-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c9d6f0177d2b3bde8306d74939ee9704c1501a23 --- /dev/null +++ b/tasks/construct-mc-debruijn-l5-s1/tests/check.py @@ -0,0 +1,15 @@ +"""De Bruijn sequence B(b, n) (MathConstraint debruijn, CC-BY-4.0). Accepts any valid cyclic sequence.""" +from run import Invalid, int_list + + +def check(inst, ans): + b, n = inst["b"], inst["n"] + m = b ** n + x = int_list(ans.get("seq"), m, 0, b - 1, "seq") + seen = set() + for i in range(m): + w = tuple(x[(i + k) % m] for k in range(n)) + if w in seen: + raise Invalid(f"window {w} occurs twice") + seen.add(w) + return None, {} diff --git a/tasks/construct-mc-debruijn-l5-s1/tests/instance.json b/tasks/construct-mc-debruijn-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a344f7ae89e2669710ede99486fc97ca3348b985 --- /dev/null +++ b/tasks/construct-mc-debruijn-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"b": 2, "n": 11, "family": "mc_debruijn", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-debruijn-l5-s1/tests/run.py b/tasks/construct-mc-debruijn-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-debruijn-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-debruijn-l5-s1/tests/test.sh b/tasks/construct-mc-debruijn-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-debruijn-l5-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-graph-k-coloring-l1-s2/environment/Dockerfile b/tasks/construct-mc-graph-k-coloring-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-graph-k-coloring-l1-s2/environment/instance.json b/tasks/construct-mc-graph-k-coloring-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..df439095606d0d304f6deb2f3a9804a3475e6856 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 3, "edges": [[0, 4], [0, 15], [0, 16], [1, 8], [1, 14], [1, 15], [2, 5], [2, 10], [2, 16], [2, 18], [2, 19], [3, 9], [4, 7], [4, 13], [4, 15], [4, 18], [4, 19], [5, 6], [5, 13], [5, 18], [6, 19], [7, 9], [7, 18], [9, 15], [11, 13], [11, 17], [12, 19], [13, 15], [14, 19], [15, 17]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l1-s2/solution/solve.sh b/tasks/construct-mc-graph-k-coloring-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bb49fd87d88875a5a26535b7242d8806db32a45b --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coloring": [1, 1, 2, 0, 2, 0, 2, 0, 0, 2, 1, 2, 2, 1, 0, 0, 0, 1, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-graph-k-coloring-l1-s2/tests/check.py b/tasks/construct-mc-graph-k-coloring-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2b5f38cd0c22ac1b4ba37c0d3ff0a34635f08854 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s2/tests/check.py @@ -0,0 +1,11 @@ +"""Proper k-colouring of a given graph (MathConstraint graph_k_coloring, CC-BY-4.0). Any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-mc-graph-k-coloring-l1-s2/tests/instance.json b/tasks/construct-mc-graph-k-coloring-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..df439095606d0d304f6deb2f3a9804a3475e6856 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 3, "edges": [[0, 4], [0, 15], [0, 16], [1, 8], [1, 14], [1, 15], [2, 5], [2, 10], [2, 16], [2, 18], [2, 19], [3, 9], [4, 7], [4, 13], [4, 15], [4, 18], [4, 19], [5, 6], [5, 13], [5, 18], [6, 19], [7, 9], [7, 18], [9, 15], [11, 13], [11, 17], [12, 19], [13, 15], [14, 19], [15, 17]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l1-s2/tests/run.py b/tasks/construct-mc-graph-k-coloring-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-graph-k-coloring-l1-s2/tests/test.sh b/tasks/construct-mc-graph-k-coloring-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l1-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-graph-k-coloring-l5-s3/environment/Dockerfile b/tasks/construct-mc-graph-k-coloring-l5-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-graph-k-coloring-l5-s3/environment/instance.json b/tasks/construct-mc-graph-k-coloring-l5-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ae8f5de19fc1e189a95bd72606586a4ec2c60bb1 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 100, "k": 4, "edges": [[0, 14], [0, 23], [0, 59], [0, 60], [0, 72], [0, 89], [0, 92], [0, 95], [0, 97], [1, 13], [1, 16], [1, 36], [1, 49], [1, 93], [1, 98], [2, 4], [2, 30], [2, 32], [2, 34], [2, 45], [2, 48], [2, 56], [2, 66], [3, 57], [3, 66], [3, 73], [3, 93], [4, 14], [4, 18], [4, 33], [4, 51], [4, 84], [5, 12], [5, 20], [5, 25], [5, 40], [5, 65], [5, 73], [5, 78], [6, 32], [6, 54], [6, 69], [6, 73], [6, 74], [6, 75], [6, 83], [7, 28], [7, 30], [7, 42], [7, 53], [7, 68], [7, 70], [7, 78], [7, 79], [8, 33], [8, 50], [8, 70], [8, 90], [8, 95], [8, 96], [8, 97], [9, 22], [9, 27], [9, 33], [9, 42], [9, 93], [9, 97], [9, 99], [10, 19], [10, 20], [10, 22], [10, 42], [10, 68], [11, 18], [11, 20], [11, 38], [11, 56], [11, 66], [11, 92], [11, 99], [12, 56], [12, 58], [12, 60], [12, 71], [12, 98], [13, 29], [13, 91], [14, 26], [14, 28], [14, 42], [14, 48], [14, 69], [14, 89], [14, 99], [15, 46], [15, 57], [15, 70], [15, 88], [15, 96], [16, 19], [16, 43], [16, 72], [16, 96], [17, 19], [17, 30], [17, 37], [17, 45], [17, 52], [17, 68], [17, 75], [17, 84], [17, 90], [18, 23], [18, 47], [18, 70], [18, 96], [19, 24], [19, 51], [19, 52], [19, 66], [19, 81], [19, 85], [19, 93], [19, 97], [19, 98], [20, 24], [20, 34], [20, 37], [20, 54], [20, 61], [20, 83], [20, 87], [20, 94], [21, 25], [21, 51], [21, 59], [21, 75], [21, 93], [21, 97], [23, 30], [23, 59], [23, 63], [23, 77], [23, 95], [24, 25], [24, 40], [24, 52], [24, 56], [24, 93], [25, 34], [25, 51], [25, 85], [25, 89], [25, 90], [25, 95], [26, 32], [26, 42], [26, 58], [26, 63], [26, 70], [26, 76], [26, 79], [26, 98], [27, 48], [27, 57], [27, 75], [27, 94], [28, 44], [28, 53], [28, 61], [28, 63], [28, 65], [29, 39], [29, 40], [29, 49], [29, 55], [29, 88], [29, 98], [30, 53], [30, 57], [30, 60], [30, 61], [30, 70], [30, 83], [30, 94], [31, 34], [31, 46], [31, 51], [31, 57], [31, 68], [31, 72], [31, 77], [31, 79], [31, 81], [31, 82], [32, 38], [32, 51], [32, 53], [32, 54], [32, 75], [32, 87], [33, 34], [33, 55], [33, 61], [33, 64], [33, 75], [33, 78], [33, 82], [33, 92], [34, 40], [34, 44], [34, 60], [34, 67], [34, 81], [34, 97], [35, 39], [35, 52], [35, 53], [35, 75], [35, 81], [35, 85], [36, 40], [36, 47], [36, 60], [37, 38], [37, 48], [37, 49], [37, 58], [37, 70], [37, 88], [37, 99], [38, 55], [38, 57], [38, 69], [38, 85], [39, 43], [39, 44], [39, 45], [39, 49], [39, 65], [39, 68], [39, 89], [39, 95], [39, 96], [39, 98], [40, 47], [40, 52], [40, 57], [40, 77], [41, 56], [41, 62], [41, 64], [41, 72], [41, 80], [41, 98], [42, 46], [42, 58], [42, 66], [42, 84], [42, 97], [43, 48], [43, 56], [43, 82], [43, 88], [44, 57], [44, 68], [44, 76], [44, 77], [44, 78], [44, 83], [44, 94], [45, 62], [45, 68], [45, 79], [45, 80], [45, 88], [45, 90], [45, 92], [46, 77], [47, 61], [47, 83], [47, 94], [47, 96], [48, 63], [48, 64], [48, 69], [48, 98], [49, 52], [49, 76], [49, 78], [49, 83], [49, 87], [50, 62], [50, 74], [50, 80], [50, 92], [51, 67], [51, 96], [51, 99], [52, 64], [52, 78], [53, 57], [53, 73], [53, 74], [53, 98], [54, 60], [54, 69], [54, 70], [54, 71], [54, 74], [54, 77], [54, 99], [55, 64], [55, 82], [55, 84], [55, 88], [56, 67], [56, 87], [56, 95], [57, 78], [57, 84], [59, 89], [59, 91], [59, 93], [59, 98], [60, 62], [60, 64], [60, 74], [60, 75], [60, 86], [60, 88], [60, 92], [61, 63], [61, 72], [61, 74], [61, 86], [61, 95], [62, 69], [62, 81], [62, 86], [62, 95], [63, 90], [63, 99], [64, 85], [65, 77], [65, 80], [65, 82], [65, 88], [65, 98], [65, 99], [66, 70], [66, 71], [66, 82], [67, 85], [67, 87], [67, 89], [67, 91], [67, 92], [68, 97], [69, 77], [69, 90], [70, 74], [70, 87], [70, 88], [70, 92], [70, 96], [71, 79], [71, 82], [71, 92], [72, 78], [73, 79], [73, 95], [73, 96], [74, 80], [74, 94], [75, 99], [76, 87], [76, 88], [76, 90], [76, 92], [78, 93], [80, 87], [81, 99], [82, 92], [82, 94], [83, 89], [83, 99], [84, 89], [84, 93], [84, 94], [85, 97], [87, 88], [89, 92], [90, 92], [90, 93], [90, 96], [91, 99], [93, 99], [94, 99], [95, 97]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l5-s3/solution/solve.sh b/tasks/construct-mc-graph-k-coloring-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ef9b9bb35432e6288bc275104a90dc1b3c430d37 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coloring": [2, 2, 2, 1, 0, 2, 1, 2, 2, 2, 2, 2, 3, 3, 1, 3, 3, 0, 3, 1, 0, 3, 0, 0, 3, 0, 2, 0, 3, 1, 3, 1, 3, 1, 3, 3, 3, 2, 1, 2, 0, 1, 3, 1, 0, 1, 2, 1, 3, 0, 1, 2, 2, 1, 2, 2, 0, 2, 1, 1, 1, 2, 2, 1, 0, 1, 0, 1, 3, 0, 1, 1, 0, 3, 3, 2, 1, 3, 3, 0, 0, 0, 3, 2, 1, 2, 3, 2, 0, 3, 3, 0, 0, 0, 2, 1, 0, 0, 0, 3]} +RLMATH_EOF diff --git a/tasks/construct-mc-graph-k-coloring-l5-s3/tests/check.py b/tasks/construct-mc-graph-k-coloring-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2b5f38cd0c22ac1b4ba37c0d3ff0a34635f08854 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s3/tests/check.py @@ -0,0 +1,11 @@ +"""Proper k-colouring of a given graph (MathConstraint graph_k_coloring, CC-BY-4.0). Any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-mc-graph-k-coloring-l5-s3/tests/instance.json b/tasks/construct-mc-graph-k-coloring-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ae8f5de19fc1e189a95bd72606586a4ec2c60bb1 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 100, "k": 4, "edges": [[0, 14], [0, 23], [0, 59], [0, 60], [0, 72], [0, 89], [0, 92], [0, 95], [0, 97], [1, 13], [1, 16], [1, 36], [1, 49], [1, 93], [1, 98], [2, 4], [2, 30], [2, 32], [2, 34], [2, 45], [2, 48], [2, 56], [2, 66], [3, 57], [3, 66], [3, 73], [3, 93], [4, 14], [4, 18], [4, 33], [4, 51], [4, 84], [5, 12], [5, 20], [5, 25], [5, 40], [5, 65], [5, 73], [5, 78], [6, 32], [6, 54], [6, 69], [6, 73], [6, 74], [6, 75], [6, 83], [7, 28], [7, 30], [7, 42], [7, 53], [7, 68], [7, 70], [7, 78], [7, 79], [8, 33], [8, 50], [8, 70], [8, 90], [8, 95], [8, 96], [8, 97], [9, 22], [9, 27], [9, 33], [9, 42], [9, 93], [9, 97], [9, 99], [10, 19], [10, 20], [10, 22], [10, 42], [10, 68], [11, 18], [11, 20], [11, 38], [11, 56], [11, 66], [11, 92], [11, 99], [12, 56], [12, 58], [12, 60], [12, 71], [12, 98], [13, 29], [13, 91], [14, 26], [14, 28], [14, 42], [14, 48], [14, 69], [14, 89], [14, 99], [15, 46], [15, 57], [15, 70], [15, 88], [15, 96], [16, 19], [16, 43], [16, 72], [16, 96], [17, 19], [17, 30], [17, 37], [17, 45], [17, 52], [17, 68], [17, 75], [17, 84], [17, 90], [18, 23], [18, 47], [18, 70], [18, 96], [19, 24], [19, 51], [19, 52], [19, 66], [19, 81], [19, 85], [19, 93], [19, 97], [19, 98], [20, 24], [20, 34], [20, 37], [20, 54], [20, 61], [20, 83], [20, 87], [20, 94], [21, 25], [21, 51], [21, 59], [21, 75], [21, 93], [21, 97], [23, 30], [23, 59], [23, 63], [23, 77], [23, 95], [24, 25], [24, 40], [24, 52], [24, 56], [24, 93], [25, 34], [25, 51], [25, 85], [25, 89], [25, 90], [25, 95], [26, 32], [26, 42], [26, 58], [26, 63], [26, 70], [26, 76], [26, 79], [26, 98], [27, 48], [27, 57], [27, 75], [27, 94], [28, 44], [28, 53], [28, 61], [28, 63], [28, 65], [29, 39], [29, 40], [29, 49], [29, 55], [29, 88], [29, 98], [30, 53], [30, 57], [30, 60], [30, 61], [30, 70], [30, 83], [30, 94], [31, 34], [31, 46], [31, 51], [31, 57], [31, 68], [31, 72], [31, 77], [31, 79], [31, 81], [31, 82], [32, 38], [32, 51], [32, 53], [32, 54], [32, 75], [32, 87], [33, 34], [33, 55], [33, 61], [33, 64], [33, 75], [33, 78], [33, 82], [33, 92], [34, 40], [34, 44], [34, 60], [34, 67], [34, 81], [34, 97], [35, 39], [35, 52], [35, 53], [35, 75], [35, 81], [35, 85], [36, 40], [36, 47], [36, 60], [37, 38], [37, 48], [37, 49], [37, 58], [37, 70], [37, 88], [37, 99], [38, 55], [38, 57], [38, 69], [38, 85], [39, 43], [39, 44], [39, 45], [39, 49], [39, 65], [39, 68], [39, 89], [39, 95], [39, 96], [39, 98], [40, 47], [40, 52], [40, 57], [40, 77], [41, 56], [41, 62], [41, 64], [41, 72], [41, 80], [41, 98], [42, 46], [42, 58], [42, 66], [42, 84], [42, 97], [43, 48], [43, 56], [43, 82], [43, 88], [44, 57], [44, 68], [44, 76], [44, 77], [44, 78], [44, 83], [44, 94], [45, 62], [45, 68], [45, 79], [45, 80], [45, 88], [45, 90], [45, 92], [46, 77], [47, 61], [47, 83], [47, 94], [47, 96], [48, 63], [48, 64], [48, 69], [48, 98], [49, 52], [49, 76], [49, 78], [49, 83], [49, 87], [50, 62], [50, 74], [50, 80], [50, 92], [51, 67], [51, 96], [51, 99], [52, 64], [52, 78], [53, 57], [53, 73], [53, 74], [53, 98], [54, 60], [54, 69], [54, 70], [54, 71], [54, 74], [54, 77], [54, 99], [55, 64], [55, 82], [55, 84], [55, 88], [56, 67], [56, 87], [56, 95], [57, 78], [57, 84], [59, 89], [59, 91], [59, 93], [59, 98], [60, 62], [60, 64], [60, 74], [60, 75], [60, 86], [60, 88], [60, 92], [61, 63], [61, 72], [61, 74], [61, 86], [61, 95], [62, 69], [62, 81], [62, 86], [62, 95], [63, 90], [63, 99], [64, 85], [65, 77], [65, 80], [65, 82], [65, 88], [65, 98], [65, 99], [66, 70], [66, 71], [66, 82], [67, 85], [67, 87], [67, 89], [67, 91], [67, 92], [68, 97], [69, 77], [69, 90], [70, 74], [70, 87], [70, 88], [70, 92], [70, 96], [71, 79], [71, 82], [71, 92], [72, 78], [73, 79], [73, 95], [73, 96], [74, 80], [74, 94], [75, 99], [76, 87], [76, 88], [76, 90], [76, 92], [78, 93], [80, 87], [81, 99], [82, 92], [82, 94], [83, 89], [83, 99], [84, 89], [84, 93], [84, 94], [85, 97], [87, 88], [89, 92], [90, 92], [90, 93], [90, 96], [91, 99], [93, 99], [94, 99], [95, 97]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l5-s3/tests/run.py b/tasks/construct-mc-graph-k-coloring-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-graph-k-coloring-l5-s3/tests/test.sh b/tasks/construct-mc-graph-k-coloring-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-graph-k-coloring-l5-s4/environment/Dockerfile b/tasks/construct-mc-graph-k-coloring-l5-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-graph-k-coloring-l5-s4/environment/instance.json b/tasks/construct-mc-graph-k-coloring-l5-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f923677c485a9fb4a2504dd1717fb46f5b1e4844 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 100, "k": 4, "edges": [[0, 13], [0, 21], [0, 25], [0, 29], [0, 40], [0, 53], [0, 57], [0, 66], [0, 77], [1, 8], [1, 9], [1, 14], [1, 49], [1, 57], [1, 67], [1, 75], [1, 89], [1, 97], [2, 11], [2, 36], [2, 52], [2, 55], [2, 64], [2, 79], [3, 17], [3, 39], [3, 43], [3, 65], [3, 75], [3, 76], [3, 77], [3, 92], [4, 28], [4, 48], [4, 54], [4, 68], [4, 73], [5, 36], [5, 55], [5, 91], [6, 11], [6, 19], [6, 28], [6, 29], [6, 35], [6, 41], [6, 54], [6, 58], [6, 59], [6, 88], [7, 20], [7, 44], [7, 47], [7, 56], [7, 65], [7, 74], [7, 75], [8, 10], [8, 11], [8, 16], [8, 20], [8, 28], [8, 50], [8, 54], [8, 68], [8, 69], [8, 96], [8, 99], [9, 30], [9, 55], [9, 63], [9, 71], [9, 80], [10, 16], [10, 25], [10, 33], [10, 34], [10, 36], [10, 38], [10, 41], [10, 43], [10, 46], [10, 47], [10, 62], [10, 72], [10, 76], [10, 81], [10, 90], [10, 95], [10, 96], [11, 12], [11, 53], [11, 59], [11, 65], [11, 70], [11, 76], [11, 91], [12, 16], [12, 33], [12, 46], [12, 89], [12, 90], [13, 19], [13, 28], [13, 37], [13, 38], [13, 39], [13, 54], [13, 78], [13, 80], [13, 85], [13, 91], [13, 92], [13, 96], [14, 33], [14, 41], [14, 44], [14, 62], [14, 82], [15, 18], [15, 30], [15, 39], [15, 56], [15, 71], [15, 99], [16, 45], [16, 50], [16, 52], [16, 63], [16, 77], [16, 83], [16, 86], [16, 91], [16, 97], [17, 25], [17, 37], [17, 41], [17, 49], [17, 56], [17, 66], [17, 73], [17, 85], [17, 88], [17, 93], [17, 98], [17, 99], [18, 21], [18, 32], [18, 40], [18, 81], [18, 82], [18, 88], [18, 91], [19, 22], [19, 25], [19, 31], [20, 22], [20, 45], [20, 53], [20, 54], [20, 82], [21, 44], [21, 45], [21, 53], [21, 71], [21, 72], [21, 85], [21, 86], [21, 92], [21, 93], [22, 26], [22, 35], [22, 48], [22, 83], [22, 94], [22, 99], [23, 33], [23, 40], [23, 42], [23, 53], [23, 59], [23, 60], [23, 64], [23, 66], [24, 29], [24, 45], [24, 52], [24, 72], [24, 84], [24, 93], [25, 44], [25, 55], [25, 69], [25, 82], [25, 98], [26, 30], [26, 37], [26, 39], [26, 72], [26, 76], [26, 79], [27, 78], [27, 79], [27, 89], [28, 85], [28, 92], [28, 94], [29, 35], [29, 42], [29, 61], [29, 64], [29, 67], [29, 74], [30, 31], [30, 42], [30, 73], [30, 74], [30, 75], [30, 81], [30, 86], [30, 96], [31, 53], [31, 62], [31, 72], [31, 87], [32, 34], [32, 43], [32, 65], [32, 95], [33, 48], [33, 52], [33, 68], [33, 74], [33, 92], [34, 48], [34, 58], [34, 63], [34, 64], [34, 78], [34, 88], [35, 47], [35, 52], [35, 66], [36, 43], [36, 53], [36, 58], [36, 90], [37, 44], [37, 48], [37, 70], [37, 82], [37, 84], [37, 86], [38, 42], [38, 61], [38, 92], [38, 96], [39, 40], [39, 62], [39, 64], [39, 65], [39, 92], [40, 50], [40, 56], [40, 60], [40, 67], [40, 77], [40, 91], [41, 52], [41, 60], [41, 96], [42, 63], [42, 74], [42, 76], [42, 82], [42, 84], [42, 89], [42, 95], [43, 63], [43, 71], [43, 73], [43, 83], [43, 84], [44, 48], [44, 59], [44, 62], [44, 73], [45, 64], [45, 81], [46, 67], [46, 73], [46, 87], [48, 84], [48, 96], [48, 99], [49, 62], [49, 74], [50, 70], [50, 82], [50, 99], [51, 54], [51, 59], [51, 61], [51, 68], [51, 69], [51, 77], [51, 85], [51, 88], [51, 93], [51, 96], [51, 99], [52, 59], [52, 66], [52, 92], [53, 63], [53, 81], [53, 87], [53, 95], [54, 71], [55, 62], [55, 76], [55, 82], [55, 87], [55, 98], [56, 59], [56, 75], [57, 71], [57, 72], [57, 80], [57, 82], [57, 91], [58, 83], [58, 92], [58, 93], [58, 96], [59, 65], [59, 81], [59, 99], [60, 67], [60, 74], [60, 75], [60, 83], [61, 71], [61, 74], [61, 76], [61, 86], [61, 87], [62, 95], [62, 97], [63, 69], [63, 79], [63, 86], [63, 89], [64, 86], [64, 98], [65, 76], [65, 87], [66, 68], [66, 88], [67, 77], [68, 83], [68, 94], [69, 75], [69, 81], [69, 84], [70, 90], [70, 96], [71, 92], [72, 78], [72, 86], [72, 89], [73, 80], [73, 85], [73, 97], [74, 76], [74, 88], [74, 93], [74, 96], [75, 85], [77, 79], [78, 82], [78, 84], [81, 85], [82, 85], [82, 92], [84, 85], [84, 89], [84, 92], [86, 91], [87, 91], [87, 95], [90, 93], [90, 95], [93, 95], [93, 99], [94, 96], [94, 97], [94, 99], [95, 97], [95, 99]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l5-s4/solution/solve.sh b/tasks/construct-mc-graph-k-coloring-l5-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..aa2842f7a07a15319187128ad93fb182041e20eb --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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' +{"coloring": [0, 3, 0, 1, 3, 3, 2, 3, 2, 1, 0, 1, 0, 1, 2, 3, 1, 2, 2, 0, 1, 1, 3, 2, 1, 1, 1, 1, 0, 3, 0, 2, 1, 1, 3, 1, 2, 3, 2, 0, 1, 1, 1, 3, 0, 3, 3, 2, 2, 0, 3, 1, 2, 3, 0, 2, 0, 1, 0, 3, 0, 0, 1, 0, 1, 2, 3, 2, 0, 3, 0, 2, 3, 1, 2, 2, 3, 3, 2, 2, 3, 1, 0, 2, 0, 3, 2, 1, 0, 2, 1, 0, 3, 3, 2, 2, 3, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-graph-k-coloring-l5-s4/tests/check.py b/tasks/construct-mc-graph-k-coloring-l5-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2b5f38cd0c22ac1b4ba37c0d3ff0a34635f08854 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s4/tests/check.py @@ -0,0 +1,11 @@ +"""Proper k-colouring of a given graph (MathConstraint graph_k_coloring, CC-BY-4.0). Any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-mc-graph-k-coloring-l5-s4/tests/instance.json b/tasks/construct-mc-graph-k-coloring-l5-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f923677c485a9fb4a2504dd1717fb46f5b1e4844 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-l5-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 100, "k": 4, "edges": [[0, 13], [0, 21], [0, 25], [0, 29], [0, 40], [0, 53], [0, 57], [0, 66], [0, 77], [1, 8], [1, 9], [1, 14], [1, 49], [1, 57], [1, 67], [1, 75], [1, 89], [1, 97], [2, 11], [2, 36], [2, 52], [2, 55], [2, 64], [2, 79], [3, 17], [3, 39], [3, 43], [3, 65], [3, 75], [3, 76], [3, 77], [3, 92], [4, 28], [4, 48], [4, 54], [4, 68], [4, 73], [5, 36], [5, 55], [5, 91], [6, 11], [6, 19], [6, 28], [6, 29], [6, 35], [6, 41], [6, 54], [6, 58], [6, 59], [6, 88], [7, 20], [7, 44], [7, 47], [7, 56], [7, 65], [7, 74], [7, 75], [8, 10], [8, 11], [8, 16], [8, 20], [8, 28], [8, 50], [8, 54], [8, 68], [8, 69], [8, 96], [8, 99], [9, 30], [9, 55], [9, 63], [9, 71], [9, 80], [10, 16], [10, 25], [10, 33], [10, 34], [10, 36], [10, 38], [10, 41], [10, 43], [10, 46], [10, 47], [10, 62], [10, 72], [10, 76], [10, 81], [10, 90], [10, 95], [10, 96], [11, 12], [11, 53], [11, 59], [11, 65], [11, 70], [11, 76], [11, 91], [12, 16], [12, 33], [12, 46], [12, 89], [12, 90], [13, 19], [13, 28], [13, 37], [13, 38], [13, 39], [13, 54], [13, 78], [13, 80], [13, 85], [13, 91], [13, 92], [13, 96], [14, 33], [14, 41], [14, 44], [14, 62], [14, 82], [15, 18], [15, 30], [15, 39], [15, 56], [15, 71], [15, 99], [16, 45], [16, 50], [16, 52], [16, 63], [16, 77], [16, 83], [16, 86], [16, 91], [16, 97], [17, 25], [17, 37], [17, 41], [17, 49], [17, 56], [17, 66], [17, 73], [17, 85], [17, 88], [17, 93], [17, 98], [17, 99], [18, 21], [18, 32], [18, 40], [18, 81], [18, 82], [18, 88], [18, 91], [19, 22], [19, 25], [19, 31], [20, 22], [20, 45], [20, 53], [20, 54], [20, 82], [21, 44], [21, 45], [21, 53], [21, 71], [21, 72], [21, 85], [21, 86], [21, 92], [21, 93], [22, 26], [22, 35], [22, 48], [22, 83], [22, 94], [22, 99], [23, 33], [23, 40], [23, 42], [23, 53], [23, 59], [23, 60], [23, 64], [23, 66], [24, 29], [24, 45], [24, 52], [24, 72], [24, 84], [24, 93], [25, 44], [25, 55], [25, 69], [25, 82], [25, 98], [26, 30], [26, 37], [26, 39], [26, 72], [26, 76], [26, 79], [27, 78], [27, 79], [27, 89], [28, 85], [28, 92], [28, 94], [29, 35], [29, 42], [29, 61], [29, 64], [29, 67], [29, 74], [30, 31], [30, 42], [30, 73], [30, 74], [30, 75], [30, 81], [30, 86], [30, 96], [31, 53], [31, 62], [31, 72], [31, 87], [32, 34], [32, 43], [32, 65], [32, 95], [33, 48], [33, 52], [33, 68], [33, 74], [33, 92], [34, 48], [34, 58], [34, 63], [34, 64], [34, 78], [34, 88], [35, 47], [35, 52], [35, 66], [36, 43], [36, 53], [36, 58], [36, 90], [37, 44], [37, 48], [37, 70], [37, 82], [37, 84], [37, 86], [38, 42], [38, 61], [38, 92], [38, 96], [39, 40], [39, 62], [39, 64], [39, 65], [39, 92], [40, 50], [40, 56], [40, 60], [40, 67], [40, 77], [40, 91], [41, 52], [41, 60], [41, 96], [42, 63], [42, 74], [42, 76], [42, 82], [42, 84], [42, 89], [42, 95], [43, 63], [43, 71], [43, 73], [43, 83], [43, 84], [44, 48], [44, 59], [44, 62], [44, 73], [45, 64], [45, 81], [46, 67], [46, 73], [46, 87], [48, 84], [48, 96], [48, 99], [49, 62], [49, 74], [50, 70], [50, 82], [50, 99], [51, 54], [51, 59], [51, 61], [51, 68], [51, 69], [51, 77], [51, 85], [51, 88], [51, 93], [51, 96], [51, 99], [52, 59], [52, 66], [52, 92], [53, 63], [53, 81], [53, 87], [53, 95], [54, 71], [55, 62], [55, 76], [55, 82], [55, 87], [55, 98], [56, 59], [56, 75], [57, 71], [57, 72], [57, 80], [57, 82], [57, 91], [58, 83], [58, 92], [58, 93], [58, 96], [59, 65], [59, 81], [59, 99], [60, 67], [60, 74], [60, 75], [60, 83], [61, 71], [61, 74], [61, 76], [61, 86], [61, 87], [62, 95], [62, 97], [63, 69], [63, 79], [63, 86], [63, 89], [64, 86], [64, 98], [65, 76], [65, 87], [66, 68], [66, 88], [67, 77], [68, 83], [68, 94], [69, 75], [69, 81], [69, 84], [70, 90], [70, 96], [71, 92], [72, 78], [72, 86], [72, 89], [73, 80], [73, 85], [73, 97], [74, 76], [74, 88], [74, 93], [74, 96], [75, 85], [77, 79], [78, 82], [78, 84], [81, 85], [82, 85], [82, 92], [84, 85], [84, 89], [84, 92], [86, 91], [87, 91], [87, 95], [90, 93], [90, 95], [93, 95], [93, 99], [94, 96], [94, 97], [94, 99], [95, 97], [95, 99]], "family": "mc_graph_k_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-graph-k-coloring-l5-s4/tests/run.py b/tasks/construct-mc-graph-k-coloring-l5-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-graph-k-coloring-l5-s4/tests/test.sh b/tasks/construct-mc-graph-k-coloring-l5-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-graph-k-coloring-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-langford-l5-s3/environment/Dockerfile b/tasks/construct-mc-langford-l5-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-langford-l5-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-langford-l5-s3/environment/instance.json b/tasks/construct-mc-langford-l5-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d1f26e506e21df5a5a87ec0d7c7168ee7ba1915e --- /dev/null +++ b/tasks/construct-mc-langford-l5-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 35, "fixed": [], "family": "mc_langford", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-langford-l5-s3/solution/solve.sh b/tasks/construct-mc-langford-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..eede1ced661a16c6fed72d710717bbd87eb13ad3 --- /dev/null +++ b/tasks/construct-mc-langford-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' +{"seq": [26, 30, 31, 29, 24, 34, 3, 20, 9, 15, 3, 2, 7, 8, 2, 10, 28, 35, 9, 18, 7, 33, 8, 25, 32, 15, 10, 26, 20, 24, 27, 22, 30, 29, 31, 23, 11, 1, 18, 1, 34, 14, 19, 6, 21, 28, 13, 16, 11, 25, 6, 17, 12, 35, 22, 33, 14, 32, 27, 23, 13, 5, 19, 4, 16, 12, 21, 5, 4, 17]} +RLMATH_EOF diff --git a/tasks/construct-mc-langford-l5-s3/tests/check.py b/tasks/construct-mc-langford-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4672d7eacf321991933cb280d6c940f1c4a67935 --- /dev/null +++ b/tasks/construct-mc-langford-l5-s3/tests/check.py @@ -0,0 +1,17 @@ +"""Langford sequence L(2, n) (MathConstraint langford, CC-BY-4.0). Accepts any valid sequence.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + seq = int_list(ans.get("seq"), 2 * n, 1, n, "seq") + for v in range(1, n + 1): + pos = [i for i, s in enumerate(seq) if s == v] + if len(pos) != 2: + raise Invalid(f"value {v} occurs {len(pos)} times (need exactly 2)") + if pos[1] - pos[0] != v + 1: + raise Invalid(f"the two copies of {v} are {pos[1] - pos[0]} positions apart (need {v + 1})") + for name, i, v in inst.get("fixed", []): + if seq[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-langford-l5-s3/tests/instance.json b/tasks/construct-mc-langford-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d1f26e506e21df5a5a87ec0d7c7168ee7ba1915e --- /dev/null +++ b/tasks/construct-mc-langford-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 35, "fixed": [], "family": "mc_langford", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-langford-l5-s3/tests/run.py b/tasks/construct-mc-langford-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-langford-l5-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-langford-l5-s3/tests/test.sh b/tasks/construct-mc-langford-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-langford-l5-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-low-autocorrelation-l3-s7/environment/Dockerfile b/tasks/construct-mc-low-autocorrelation-l3-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-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-mc-low-autocorrelation-l3-s7/environment/instance.json b/tasks/construct-mc-low-autocorrelation-l3-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7b848f55ebd7e356e5c160f59ee2ba94a41e0bf1 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 29, "bound": 84, "fixed": [], "family": "mc_low_autocorrelation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-low-autocorrelation-l3-s7/solution/solve.sh b/tasks/construct-mc-low-autocorrelation-l3-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6a2c5a02cb259f7a4ed72d28e88131ce5130c075 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-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' +{"seq": [1, 1, 1, 1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, -1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-low-autocorrelation-l3-s7/tests/check.py b/tasks/construct-mc-low-autocorrelation-l3-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8456f7b1c0ff0c9fb4bc9ae5a49074c8afa7d1aa --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s7/tests/check.py @@ -0,0 +1,20 @@ +"""+-1 sequence of length n with aperiodic autocorrelation energy sum_k C_k^2 <= bound +(MathConstraint low_autocorrelation, CC-BY-4.0). Exact integer arithmetic.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, bound = inst["n"], inst["bound"] + s = int_list(ans.get("seq"), n, -1, 1, "seq") + if any(v == 0 for v in s): + raise Invalid("entries must be -1 or +1") + c = [sum(s[i] * s[i + k] for i in range(n - k)) for k in range(1, n)] + e = sum(v * v for v in c) + # fixed values: seq[i] or c[k] (c[k] is the autocorrelation at shift k+1, as upstream) + seqs = {"seq": s, "c": c} + for name, i, v in inst.get("fixed", []): + if seqs[name][i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + if e > bound: + raise Invalid(f"energy {e} exceeds the bound {bound}") + return None, {"energy": e} diff --git a/tasks/construct-mc-low-autocorrelation-l3-s7/tests/instance.json b/tasks/construct-mc-low-autocorrelation-l3-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7b848f55ebd7e356e5c160f59ee2ba94a41e0bf1 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-l3-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 29, "bound": 84, "fixed": [], "family": "mc_low_autocorrelation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-low-autocorrelation-l3-s7/tests/run.py b/tasks/construct-mc-low-autocorrelation-l3-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-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-mc-low-autocorrelation-l3-s7/tests/test.sh b/tasks/construct-mc-low-autocorrelation-l3-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-low-autocorrelation-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-mc-magic-sequence-l4-s1/environment/Dockerfile b/tasks/construct-mc-magic-sequence-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-magic-sequence-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-magic-sequence-l4-s1/environment/instance.json b/tasks/construct-mc-magic-sequence-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bdf5db80f9902ad320a4da44499b632feaba8acd --- /dev/null +++ b/tasks/construct-mc-magic-sequence-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 24, "fixed": [], "family": "mc_magic_sequence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-magic-sequence-l4-s1/solution/solve.sh b/tasks/construct-mc-magic-sequence-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..09f3341c080c3534652e11ac4a6976f03c4d4165 --- /dev/null +++ b/tasks/construct-mc-magic-sequence-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": [20, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-magic-sequence-l4-s1/tests/check.py b/tasks/construct-mc-magic-sequence-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..27f636ddd6cfe523924ae01c6b9f37ee392f0332 --- /dev/null +++ b/tasks/construct-mc-magic-sequence-l4-s1/tests/check.py @@ -0,0 +1,18 @@ +"""Magic sequence of length n: x[i] = number of occurrences of i in x (MathConstraint magic_sequence, +CC-BY-4.0). The property itself is checked (no stored answer).""" +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("x"), n, 0, n, "x") + cnt = Counter(x) + for i in range(n): + if x[i] != cnt.get(i, 0): + raise Invalid(f"x[{i}] = {x[i]} but {i} occurs {cnt.get(i, 0)} times") + for name, i, v in inst.get("fixed", []): + if x[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + return None, {} diff --git a/tasks/construct-mc-magic-sequence-l4-s1/tests/instance.json b/tasks/construct-mc-magic-sequence-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bdf5db80f9902ad320a4da44499b632feaba8acd --- /dev/null +++ b/tasks/construct-mc-magic-sequence-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 24, "fixed": [], "family": "mc_magic_sequence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-magic-sequence-l4-s1/tests/run.py b/tasks/construct-mc-magic-sequence-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-magic-sequence-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-magic-sequence-l4-s1/tests/test.sh b/tasks/construct-mc-magic-sequence-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-magic-sequence-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-number-partitioning-l4-s7/environment/Dockerfile b/tasks/construct-mc-number-partitioning-l4-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-number-partitioning-l4-s7/environment/instance.json b/tasks/construct-mc-number-partitioning-l4-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ee81bd9764faa8bc2cfaf708b18a48234f6ad4dd --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 31, "k": 4, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l4-s7/solution/solve.sh b/tasks/construct-mc-number-partitioning-l4-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e6d441b3301577009033c9d0491e3fd3bb067c8e --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [1, 2, 3, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-number-partitioning-l4-s7/tests/check.py b/tasks/construct-mc-number-partitioning-l4-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..67793721db8ba7d3c3979ea0e1e07091491ffa7e --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s7/tests/check.py @@ -0,0 +1,14 @@ +"""Partition {1..n} into k subsets of equal sum (MathConstraint number_partitioning, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + x = int_list(ans.get("x"), n, 0, k - 1, "x") + target = n * (n + 1) // 2 // k + sums = [0] * k + for i, s in enumerate(x): + sums[s] += i + 1 + if any(t != target for t in sums): + raise Invalid(f"subset sums {sums} are not all {target}") + return None, {} diff --git a/tasks/construct-mc-number-partitioning-l4-s7/tests/instance.json b/tasks/construct-mc-number-partitioning-l4-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ee81bd9764faa8bc2cfaf708b18a48234f6ad4dd --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 31, "k": 4, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l4-s7/tests/run.py b/tasks/construct-mc-number-partitioning-l4-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-number-partitioning-l4-s7/tests/test.sh b/tasks/construct-mc-number-partitioning-l4-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-number-partitioning-l4-s9/environment/Dockerfile b/tasks/construct-mc-number-partitioning-l4-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-number-partitioning-l4-s9/environment/instance.json b/tasks/construct-mc-number-partitioning-l4-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..04e9082b378ca99fb3c8a3d31c24fcddc5945616 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 34, "k": 7, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l4-s9/solution/solve.sh b/tasks/construct-mc-number-partitioning-l4-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8d92b4454dceb6d7ac56721c530759960f2f6096 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x": [6, 6, 5, 2, 4, 3, 3, 2, 4, 0, 1, 5, 6, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-number-partitioning-l4-s9/tests/check.py b/tasks/construct-mc-number-partitioning-l4-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..67793721db8ba7d3c3979ea0e1e07091491ffa7e --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s9/tests/check.py @@ -0,0 +1,14 @@ +"""Partition {1..n} into k subsets of equal sum (MathConstraint number_partitioning, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + x = int_list(ans.get("x"), n, 0, k - 1, "x") + target = n * (n + 1) // 2 // k + sums = [0] * k + for i, s in enumerate(x): + sums[s] += i + 1 + if any(t != target for t in sums): + raise Invalid(f"subset sums {sums} are not all {target}") + return None, {} diff --git a/tasks/construct-mc-number-partitioning-l4-s9/tests/instance.json b/tasks/construct-mc-number-partitioning-l4-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..04e9082b378ca99fb3c8a3d31c24fcddc5945616 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 34, "k": 7, "family": "mc_number_partitioning", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-number-partitioning-l4-s9/tests/run.py b/tasks/construct-mc-number-partitioning-l4-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-number-partitioning-l4-s9/tests/test.sh b/tasks/construct-mc-number-partitioning-l4-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-number-partitioning-l4-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-ortholatin-l2-s1/environment/Dockerfile b/tasks/construct-mc-ortholatin-l2-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ortholatin-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-ortholatin-l2-s1/environment/instance.json b/tasks/construct-mc-ortholatin-l2-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..31306724fed77ec5a4871e83fd97ff53e9c91d3e --- /dev/null +++ b/tasks/construct-mc-ortholatin-l2-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 9, "family": "mc_ortholatin", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ortholatin-l2-s1/solution/solve.sh b/tasks/construct-mc-ortholatin-l2-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b7c0409f6d58f847f0d1a5b7f106f8d084ad1a26 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l2-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"X": [[0, 1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 8, 0], [2, 3, 4, 5, 6, 7, 8, 0, 1], [3, 4, 5, 6, 7, 8, 0, 1, 2], [4, 5, 6, 7, 8, 0, 1, 2, 3], [5, 6, 7, 8, 0, 1, 2, 3, 4], [6, 7, 8, 0, 1, 2, 3, 4, 5], [7, 8, 0, 1, 2, 3, 4, 5, 6], [8, 0, 1, 2, 3, 4, 5, 6, 7]], "Y": [[0, 2, 4, 6, 8, 1, 3, 5, 7], [1, 3, 5, 7, 0, 2, 4, 6, 8], [2, 4, 6, 8, 1, 3, 5, 7, 0], [3, 5, 7, 0, 2, 4, 6, 8, 1], [4, 6, 8, 1, 3, 5, 7, 0, 2], [5, 7, 0, 2, 4, 6, 8, 1, 3], [6, 8, 1, 3, 5, 7, 0, 2, 4], [7, 0, 2, 4, 6, 8, 1, 3, 5], [8, 1, 3, 5, 7, 0, 2, 4, 6]]} +RLMATH_EOF diff --git a/tasks/construct-mc-ortholatin-l2-s1/tests/check.py b/tasks/construct-mc-ortholatin-l2-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a5418a59fae1c86318eee903e90d75b36d8a3306 --- /dev/null +++ b/tasks/construct-mc-ortholatin-l2-s1/tests/check.py @@ -0,0 +1,25 @@ +"""Pair of orthogonal Latin squares of order n (MathConstraint ortholatin, CC-BY-4.0).""" +from run import Invalid, int_list + + +def _square(v, n, name): + if not isinstance(v, list) or len(v) != n: + raise Invalid(f"{name} must be a list of {n} rows") + S = [int_list(r, n, 0, n - 1, f"{name} row") for r in v] + full = list(range(n)) + for i in range(n): + if sorted(S[i]) != full: + raise Invalid(f"{name}: row {i} is not a permutation of 0..{n - 1}") + if sorted(S[r][i] for r in range(n)) != full: + raise Invalid(f"{name}: column {i} is not a permutation of 0..{n - 1}") + return S + + +def check(inst, ans): + n = inst["n"] + X = _square(ans.get("X"), n, "X") + Y = _square(ans.get("Y"), n, "Y") + pairs = {(X[i][j], Y[i][j]) for i in range(n) for j in range(n)} + if len(pairs) != n * n: + raise Invalid("X and Y are not orthogonal (some ordered pair repeats)") + return None, {} diff --git a/tasks/construct-mc-ortholatin-l2-s1/tests/instance.json b/tasks/construct-mc-ortholatin-l2-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..31306724fed77ec5a4871e83fd97ff53e9c91d3e --- /dev/null +++ b/tasks/construct-mc-ortholatin-l2-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 9, "family": "mc_ortholatin", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ortholatin-l2-s1/tests/run.py b/tasks/construct-mc-ortholatin-l2-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ortholatin-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-ortholatin-l2-s1/tests/test.sh b/tasks/construct-mc-ortholatin-l2-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ortholatin-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-chromatic-girth-l6-s0/environment/Dockerfile b/tasks/construct-mc-pysms-chromatic-girth-l6-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-chromatic-girth-l6-s0/environment/instance.json b/tasks/construct-mc-pysms-chromatic-girth-l6-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..750838c6ec0291f8b82f6192edc970ebbac5ce28 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s0/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 21, "required_edges": [], "max_chromatic_number": 4, "min_edges": 27, "min_girth": 8, "family": "mc_pysms_chromatic_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-chromatic-girth-l6-s0/solution/solve.sh b/tasks/construct-mc-pysms-chromatic-girth-l6-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..803563f59964fa3619f7041b600e09db88430709 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 19], [0, 20], [1, 18], [1, 20], [2, 17], [2, 19], [3, 16], [3, 18], [4, 15], [4, 17], [5, 14], [5, 17], [5, 18], [6, 13], [6, 16], [7, 13], [7, 15], [7, 20], [8, 13], [8, 14], [9, 12], [9, 16], [9, 19], [10, 12], [10, 15], [11, 12], [11, 14]], "coloring": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-chromatic-girth-l6-s0/tests/check.py b/tasks/construct-mc-pysms-chromatic-girth-l6-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s0/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-chromatic-girth-l6-s0/tests/instance.json b/tasks/construct-mc-pysms-chromatic-girth-l6-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..750838c6ec0291f8b82f6192edc970ebbac5ce28 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s0/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 21, "required_edges": [], "max_chromatic_number": 4, "min_edges": 27, "min_girth": 8, "family": "mc_pysms_chromatic_girth", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-chromatic-girth-l6-s0/tests/run.py b/tasks/construct-mc-pysms-chromatic-girth-l6-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-chromatic-girth-l6-s0/tests/test.sh b/tasks/construct-mc-pysms-chromatic-girth-l6-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-chromatic-girth-l6-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-clique-coloring-l5-s2/environment/Dockerfile b/tasks/construct-mc-pysms-clique-coloring-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l5-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-clique-coloring-l5-s2/environment/instance.json b/tasks/construct-mc-pysms-clique-coloring-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..890a982534e91603e8aa6c1a8e6053e5aa3cd3ba --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 20, "required_edges": [], "max_chromatic_number": 3, "max_clique": 3, "min_degree": 5, "family": "mc_pysms_clique_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-clique-coloring-l5-s2/solution/solve.sh b/tasks/construct-mc-pysms-clique-coloring-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..306ae25ec30ed2fa5ef769b52e1fe7dd80471c02 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l5-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[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], [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], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [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]], "coloring": [1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-clique-coloring-l5-s2/tests/check.py b/tasks/construct-mc-pysms-clique-coloring-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l5-s2/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-clique-coloring-l5-s2/tests/instance.json b/tasks/construct-mc-pysms-clique-coloring-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..890a982534e91603e8aa6c1a8e6053e5aa3cd3ba --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 20, "required_edges": [], "max_chromatic_number": 3, "max_clique": 3, "min_degree": 5, "family": "mc_pysms_clique_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-clique-coloring-l5-s2/tests/run.py b/tasks/construct-mc-pysms-clique-coloring-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l5-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-clique-coloring-l5-s2/tests/test.sh b/tasks/construct-mc-pysms-clique-coloring-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-clique-coloring-l5-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-girth-degree-l5-s2/environment/Dockerfile b/tasks/construct-mc-pysms-girth-degree-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l5-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-girth-degree-l5-s2/environment/instance.json b/tasks/construct-mc-pysms-girth-degree-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fa82ed56f291fe0cf5701c9fecd8ab7c5bbe838e --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 28, "required_edges": [], "max_degree": 7, "min_degree": 4, "min_girth": 6, "family": "mc_pysms_girth_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-girth-degree-l5-s2/solution/solve.sh b/tasks/construct-mc-pysms-girth-degree-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ef36a5feaa990f6498f68005414fa140682dd823 --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l5-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 24], [0, 25], [0, 26], [0, 27], [1, 21], [1, 22], [1, 23], [1, 27], [2, 19], [2, 20], [2, 23], [2, 26], [3, 18], [3, 20], [3, 22], [3, 25], [4, 17], [4, 20], [4, 21], [4, 24], [5, 16], [5, 19], [5, 22], [5, 24], [6, 16], [6, 17], [6, 18], [6, 27], [7, 15], [7, 18], [7, 23], [7, 24], [8, 15], [8, 17], [8, 19], [8, 25], [9, 15], [9, 16], [9, 21], [9, 26], [10, 14], [10, 18], [10, 19], [10, 21], [11, 14], [11, 17], [11, 22], [11, 26], [12, 14], [12, 16], [12, 23], [12, 25], [13, 14], [13, 15], [13, 20], [13, 27]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-girth-degree-l5-s2/tests/check.py b/tasks/construct-mc-pysms-girth-degree-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l5-s2/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-girth-degree-l5-s2/tests/instance.json b/tasks/construct-mc-pysms-girth-degree-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fa82ed56f291fe0cf5701c9fecd8ab7c5bbe838e --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 28, "required_edges": [], "max_degree": 7, "min_degree": 4, "min_girth": 6, "family": "mc_pysms_girth_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-girth-degree-l5-s2/tests/run.py b/tasks/construct-mc-pysms-girth-degree-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l5-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-girth-degree-l5-s2/tests/test.sh b/tasks/construct-mc-pysms-girth-degree-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-girth-degree-l5-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-independent-connectivity-l4-s2/environment/Dockerfile b/tasks/construct-mc-pysms-independent-connectivity-l4-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-l4-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-independent-connectivity-l4-s2/environment/instance.json b/tasks/construct-mc-pysms-independent-connectivity-l4-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a5bcc13865e1ed7d2a9e352362bfbb2311279962 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-l4-s2/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 11, "required_edges": [[5, 9], [2, 7], [1, 4], [0, 8], [1, 5], [1, 9], [6, 8], [5, 6], [4, 8], [7, 8], [3, 8]], "max_independent_set": 4, "min_connectivity": 4, "family": "mc_pysms_independent_connectivity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-independent-connectivity-l4-s2/solution/solve.sh b/tasks/construct-mc-pysms-independent-connectivity-l4-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..24220ce9a34ebb047de09ce7f88464235e6a9a4b --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-l4-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 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-independent-connectivity-l4-s2/tests/check.py b/tasks/construct-mc-pysms-independent-connectivity-l4-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-l4-s2/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-independent-connectivity-l4-s2/tests/instance.json b/tasks/construct-mc-pysms-independent-connectivity-l4-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a5bcc13865e1ed7d2a9e352362bfbb2311279962 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-l4-s2/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 11, "required_edges": [[5, 9], [2, 7], [1, 4], [0, 8], [1, 5], [1, 9], [6, 8], [5, 6], [4, 8], [7, 8], [3, 8]], "max_independent_set": 4, "min_connectivity": 4, "family": "mc_pysms_independent_connectivity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-independent-connectivity-l4-s2/tests/run.py b/tasks/construct-mc-pysms-independent-connectivity-l4-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-l4-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-independent-connectivity-l4-s2/tests/test.sh b/tasks/construct-mc-pysms-independent-connectivity-l4-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-independent-connectivity-l4-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-min-degree-l1-s0/environment/Dockerfile b/tasks/construct-mc-pysms-min-degree-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l1-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-pysms-min-degree-l1-s0/environment/instance.json b/tasks/construct-mc-pysms-min-degree-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5b5cd1b5a71e759ad97f774a53ed1bd2fb3b1b4d --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 9, "required_edges": [[1, 5], [0, 1], [1, 3], [3, 6], [2, 8], [4, 5], [4, 6]], "min_degree": 4, "family": "mc_pysms_min_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-degree-l1-s0/solution/solve.sh b/tasks/construct-mc-pysms-min-degree-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..266b10696d549d81ec1db10a95e1067a0f575ccd --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l1-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 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-degree-l1-s0/tests/check.py b/tasks/construct-mc-pysms-min-degree-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l1-s0/tests/check.py @@ -0,0 +1,151 @@ +"""Graph-existence constraints (MathConstraint pysms_* problem types, CC-BY-4.0). The answer is a graph on +the stated vertex set, plus a proper colouring when a chromatic-number upper bound is asked for. Every +constraint present in the instance is checked exactly (no stored answer is compared). + +Upstream note: upstream verifies by fixing the edge variables in the pysms CNF and calling CaDiCaL; the +min-chromatic-number bound of pysms_graph_builder is only a raw smsg solver parameter, not a clause, so the +upstream verifier ignored it. It is enforced here. Edge endpoints are also type-checked (upstream accepted +floats/bools that compare in range).""" +import itertools + +from run import Invalid, int_list + + +def _has_clique(adj, n, k): + def rec(cand, size): + if size == k: + return True + while cand: + if size + bin(cand).count("1") < k: + return False + v = cand.bit_length() - 1 + cand &= ~(1 << v) + if rec(cand & adj[v], size + 1): + return True + return False + return rec((1 << n) - 1, 0) + + +def _connected(adj, n, removed): + alive = [v for v in range(n) if not removed >> v & 1] + if len(alive) <= 1: + return True + mask = sum(1 << v for v in alive) + seen = 1 << alive[0] + stack = [alive[0]] + while stack: + v = stack.pop() + new = adj[v] & mask & ~seen + seen |= new + while new: + u = new.bit_length() - 1 + new &= ~(1 << u) + stack.append(u) + return seen == mask + + +def _girth(adj, n): + best = None + for r in range(n): + dist, par, q = {r: 0}, {r: -1}, [r] + for v in q: + nb = adj[v] + while nb: + u = nb.bit_length() - 1 + nb &= ~(1 << u) + if u not in dist: + dist[u], par[u] = dist[v] + 1, v + q.append(u) + elif par[v] != u: + c = dist[u] + dist[v] + 1 + best = c if best is None else min(best, c) + return best # None = acyclic + + +def _colourable(adj, n, k): + col = [-1] * n + order = sorted(range(n), key=lambda v: -bin(adj[v]).count("1")) + + def rec(i): + if i == n: + return True + v = order[i] + used = {col[u] for u in range(n) if adj[v] >> u & 1 and col[u] >= 0} + for c in range(k): + if c not in used: + col[v] = c + if rec(i + 1): + return True + col[v] = -1 + return False + return rec(0) + + +def check(inst, ans): + n = inst["vertices"] + E = ans.get("edges") + if not isinstance(E, list): + raise Invalid("edges must be a list of [u, v] pairs") + edges = set() + for e in E: + u, v = int_list(e, 2, 0, n - 1, "edge") + if u == v: + raise Invalid(f"self-loop at {u}") + e2 = (min(u, v), max(u, v)) + if e2 in edges: + raise Invalid(f"duplicate edge {e2}") + edges.add(e2) + adj = [0] * n + for u, v in edges: + adj[u] |= 1 << v + adj[v] |= 1 << u + deg = [bin(a).count("1") for a in adj] + for u, v in inst.get("required_edges", []): + if (min(u, v), max(u, v)) not in edges: + raise Invalid(f"required edge ({u},{v}) is missing") + c = inst.get + if c("min_degree") is not None and min(deg) < c("min_degree"): + raise Invalid(f"minimum degree {min(deg)} < {c('min_degree')}") + if c("max_degree") is not None and max(deg) > c("max_degree"): + raise Invalid(f"maximum degree {max(deg)} > {c('max_degree')}") + if c("min_edges") is not None and len(edges) < c("min_edges"): + raise Invalid(f"{len(edges)} edges < {c('min_edges')}") + if c("max_edges") is not None and len(edges) > c("max_edges"): + raise Invalid(f"{len(edges)} edges > {c('max_edges')}") + if c("max_clique") is not None and _has_clique(adj, n, c("max_clique") + 1): + raise Invalid(f"graph contains a clique of size {c('max_clique') + 1}") + if c("max_independent_set") is not None: + full = (1 << n) - 1 + comp = [full & ~adj[v] & ~(1 << v) for v in range(n)] + if _has_clique(comp, n, c("max_independent_set") + 1): + raise Invalid(f"graph contains an independent set of size {c('max_independent_set') + 1}") + if c("min_girth") is not None: + g = _girth(adj, n) + if g is not None and g < c("min_girth"): + raise Invalid(f"graph has a cycle of length {g} < {c('min_girth')}") + if c("min_connectivity") is not None: + k = c("min_connectivity") + if n <= k: + raise Invalid("too few vertices for this connectivity") + for s in range(k): + for I in itertools.combinations(range(n), s): + if not _connected(adj, n, sum(1 << v for v in I)): + raise Invalid(f"deleting vertices {list(I)} disconnects the graph") + if c("mtf"): + for u, v in itertools.combinations(range(n), 2): + if adj[u] >> v & 1: + if adj[u] & adj[v]: + raise Invalid(f"triangle on edge ({u},{v})") + elif not adj[u] & adj[v]: + raise Invalid(f"non-adjacent {u}, {v} have no common neighbour (edge could be added)") + if c("max_chromatic_number") is not None: + k = c("max_chromatic_number") + col = int_list(ans.get("coloring"), n, 0, k - 1, "coloring") + for u, v in edges: + if col[u] == col[v]: + raise Invalid(f"coloring: edge ({u},{v}) is monochromatic") + if c("min_chromatic_number") is not None and c("min_chromatic_number") >= 2: + m = c("min_chromatic_number") + if not edges or _colourable(adj, n, m - 1): + raise Invalid(f"graph is {m - 1}-colourable, chromatic number must be at least {m}") + return None, {"num_edges": len(edges)} diff --git a/tasks/construct-mc-pysms-min-degree-l1-s0/tests/instance.json b/tasks/construct-mc-pysms-min-degree-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5b5cd1b5a71e759ad97f774a53ed1bd2fb3b1b4d --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 9, "required_edges": [[1, 5], [0, 1], [1, 3], [3, 6], [2, 8], [4, 5], [4, 6]], "min_degree": 4, "family": "mc_pysms_min_degree", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-min-degree-l1-s0/tests/run.py b/tasks/construct-mc-pysms-min-degree-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l1-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-pysms-min-degree-l1-s0/tests/test.sh b/tasks/construct-mc-pysms-min-degree-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-min-degree-l1-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-pysms-mtf-l2-s0/environment/Dockerfile b/tasks/construct-mc-pysms-mtf-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-pysms-mtf-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-mtf-l2-s0/environment/instance.json b/tasks/construct-mc-pysms-mtf-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5ab5607d4da3d46e0e5e4654ec096278e5d568ba --- /dev/null +++ b/tasks/construct-mc-pysms-mtf-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"vertices": 8, "required_edges": [[0, 6], [2, 6]], "mtf": true, "family": "mc_pysms_mtf", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-mtf-l2-s0/solution/solve.sh b/tasks/construct-mc-pysms-mtf-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..13213bd9952bfd2d251fa176f5f3849646a6e73d --- /dev/null +++ b/tasks/construct-mc-pysms-mtf-l2-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"edges": [[0, 6], [0, 7], [1, 6], [1, 7], [2, 6], [2, 7], [3, 6], [3, 7], [4, 6], [4, 7], [5, 6], [5, 7]]} +RLMATH_EOF diff --git a/tasks/construct-mc-pysms-mtf-l2-s0/tests/check.py b/tasks/construct-mc-pysms-mtf-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4ab0b12508cf59b733f007a9d1f50831aec9efdf --- /dev/null +++ b/tasks/construct-mc-pysms-mtf-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-mtf-l2-s0/tests/instance.json b/tasks/construct-mc-pysms-mtf-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5ab5607d4da3d46e0e5e4654ec096278e5d568ba --- /dev/null +++ b/tasks/construct-mc-pysms-mtf-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"vertices": 8, "required_edges": [[0, 6], [2, 6]], "mtf": true, "family": "mc_pysms_mtf", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-pysms-mtf-l2-s0/tests/run.py b/tasks/construct-mc-pysms-mtf-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-pysms-mtf-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-mtf-l2-s0/tests/test.sh b/tasks/construct-mc-pysms-mtf-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-pysms-mtf-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-quasigroup-idempotent-l5-s0/environment/Dockerfile b/tasks/construct-mc-quasigroup-idempotent-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-l5-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-quasigroup-idempotent-l5-s0/environment/instance.json b/tasks/construct-mc-quasigroup-idempotent-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0993b914897e0e7256c62da994882c8caf447964 --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 32, "family": "mc_quasigroup_idempotent", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-quasigroup-idempotent-l5-s0/solution/solve.sh b/tasks/construct-mc-quasigroup-idempotent-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..972687e88ab4de8e9a0025ff07baebc1fece982c --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-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' +{"table": [[0, 3, 6, 5, 12, 15, 10, 9, 24, 27, 30, 29, 20, 23, 18, 17, 21, 22, 19, 16, 25, 26, 31, 28, 13, 14, 11, 8, 1, 2, 7, 4], [2, 1, 4, 7, 14, 13, 8, 11, 26, 25, 28, 31, 22, 21, 16, 19, 23, 20, 17, 18, 27, 24, 29, 30, 15, 12, 9, 10, 3, 0, 5, 6], [4, 7, 2, 1, 8, 11, 14, 13, 28, 31, 26, 25, 16, 19, 22, 21, 17, 18, 23, 20, 29, 30, 27, 24, 9, 10, 15, 12, 5, 6, 3, 0], [6, 5, 0, 3, 10, 9, 12, 15, 30, 29, 24, 27, 18, 17, 20, 23, 19, 16, 21, 22, 31, 28, 25, 26, 11, 8, 13, 14, 7, 4, 1, 2], [8, 11, 14, 13, 4, 7, 2, 1, 16, 19, 22, 21, 28, 31, 26, 25, 29, 30, 27, 24, 17, 18, 23, 20, 5, 6, 3, 0, 9, 10, 15, 12], [10, 9, 12, 15, 6, 5, 0, 3, 18, 17, 20, 23, 30, 29, 24, 27, 31, 28, 25, 26, 19, 16, 21, 22, 7, 4, 1, 2, 11, 8, 13, 14], [12, 15, 10, 9, 0, 3, 6, 5, 20, 23, 18, 17, 24, 27, 30, 29, 25, 26, 31, 28, 21, 22, 19, 16, 1, 2, 7, 4, 13, 14, 11, 8], [14, 13, 8, 11, 2, 1, 4, 7, 22, 21, 16, 19, 26, 25, 28, 31, 27, 24, 29, 30, 23, 20, 17, 18, 3, 0, 5, 6, 15, 12, 9, 10], [16, 19, 22, 21, 28, 31, 26, 25, 8, 11, 14, 13, 4, 7, 2, 1, 5, 6, 3, 0, 9, 10, 15, 12, 29, 30, 27, 24, 17, 18, 23, 20], [18, 17, 20, 23, 30, 29, 24, 27, 10, 9, 12, 15, 6, 5, 0, 3, 7, 4, 1, 2, 11, 8, 13, 14, 31, 28, 25, 26, 19, 16, 21, 22], [20, 23, 18, 17, 24, 27, 30, 29, 12, 15, 10, 9, 0, 3, 6, 5, 1, 2, 7, 4, 13, 14, 11, 8, 25, 26, 31, 28, 21, 22, 19, 16], [22, 21, 16, 19, 26, 25, 28, 31, 14, 13, 8, 11, 2, 1, 4, 7, 3, 0, 5, 6, 15, 12, 9, 10, 27, 24, 29, 30, 23, 20, 17, 18], [24, 27, 30, 29, 20, 23, 18, 17, 0, 3, 6, 5, 12, 15, 10, 9, 13, 14, 11, 8, 1, 2, 7, 4, 21, 22, 19, 16, 25, 26, 31, 28], [26, 25, 28, 31, 22, 21, 16, 19, 2, 1, 4, 7, 14, 13, 8, 11, 15, 12, 9, 10, 3, 0, 5, 6, 23, 20, 17, 18, 27, 24, 29, 30], [28, 31, 26, 25, 16, 19, 22, 21, 4, 7, 2, 1, 8, 11, 14, 13, 9, 10, 15, 12, 5, 6, 3, 0, 17, 18, 23, 20, 29, 30, 27, 24], [30, 29, 24, 27, 18, 17, 20, 23, 6, 5, 0, 3, 10, 9, 12, 15, 11, 8, 13, 14, 7, 4, 1, 2, 19, 16, 21, 22, 31, 28, 25, 26], [5, 6, 3, 0, 9, 10, 15, 12, 29, 30, 27, 24, 17, 18, 23, 20, 16, 19, 22, 21, 28, 31, 26, 25, 8, 11, 14, 13, 4, 7, 2, 1], [7, 4, 1, 2, 11, 8, 13, 14, 31, 28, 25, 26, 19, 16, 21, 22, 18, 17, 20, 23, 30, 29, 24, 27, 10, 9, 12, 15, 6, 5, 0, 3], [1, 2, 7, 4, 13, 14, 11, 8, 25, 26, 31, 28, 21, 22, 19, 16, 20, 23, 18, 17, 24, 27, 30, 29, 12, 15, 10, 9, 0, 3, 6, 5], [3, 0, 5, 6, 15, 12, 9, 10, 27, 24, 29, 30, 23, 20, 17, 18, 22, 21, 16, 19, 26, 25, 28, 31, 14, 13, 8, 11, 2, 1, 4, 7], [13, 14, 11, 8, 1, 2, 7, 4, 21, 22, 19, 16, 25, 26, 31, 28, 24, 27, 30, 29, 20, 23, 18, 17, 0, 3, 6, 5, 12, 15, 10, 9], [15, 12, 9, 10, 3, 0, 5, 6, 23, 20, 17, 18, 27, 24, 29, 30, 26, 25, 28, 31, 22, 21, 16, 19, 2, 1, 4, 7, 14, 13, 8, 11], [9, 10, 15, 12, 5, 6, 3, 0, 17, 18, 23, 20, 29, 30, 27, 24, 28, 31, 26, 25, 16, 19, 22, 21, 4, 7, 2, 1, 8, 11, 14, 13], [11, 8, 13, 14, 7, 4, 1, 2, 19, 16, 21, 22, 31, 28, 25, 26, 30, 29, 24, 27, 18, 17, 20, 23, 6, 5, 0, 3, 10, 9, 12, 15], [21, 22, 19, 16, 25, 26, 31, 28, 13, 14, 11, 8, 1, 2, 7, 4, 0, 3, 6, 5, 12, 15, 10, 9, 24, 27, 30, 29, 20, 23, 18, 17], [23, 20, 17, 18, 27, 24, 29, 30, 15, 12, 9, 10, 3, 0, 5, 6, 2, 1, 4, 7, 14, 13, 8, 11, 26, 25, 28, 31, 22, 21, 16, 19], [17, 18, 23, 20, 29, 30, 27, 24, 9, 10, 15, 12, 5, 6, 3, 0, 4, 7, 2, 1, 8, 11, 14, 13, 28, 31, 26, 25, 16, 19, 22, 21], [19, 16, 21, 22, 31, 28, 25, 26, 11, 8, 13, 14, 7, 4, 1, 2, 6, 5, 0, 3, 10, 9, 12, 15, 30, 29, 24, 27, 18, 17, 20, 23], [29, 30, 27, 24, 17, 18, 23, 20, 5, 6, 3, 0, 9, 10, 15, 12, 8, 11, 14, 13, 4, 7, 2, 1, 16, 19, 22, 21, 28, 31, 26, 25], [31, 28, 25, 26, 19, 16, 21, 22, 7, 4, 1, 2, 11, 8, 13, 14, 10, 9, 12, 15, 6, 5, 0, 3, 18, 17, 20, 23, 30, 29, 24, 27], [25, 26, 31, 28, 21, 22, 19, 16, 1, 2, 7, 4, 13, 14, 11, 8, 12, 15, 10, 9, 0, 3, 6, 5, 20, 23, 18, 17, 24, 27, 30, 29], [27, 24, 29, 30, 23, 20, 17, 18, 3, 0, 5, 6, 15, 12, 9, 10, 14, 13, 8, 11, 2, 1, 4, 7, 22, 21, 16, 19, 26, 25, 28, 31]]} +RLMATH_EOF diff --git a/tasks/construct-mc-quasigroup-idempotent-l5-s0/tests/check.py b/tasks/construct-mc-quasigroup-idempotent-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..4563f2e9a90050cdd7c56dfc33831acde74c9ef2 --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-l5-s0/tests/check.py @@ -0,0 +1,21 @@ +"""Idempotent quasigroup satisfying QG3, (x*y)*(y*x) = x (MathConstraint quasigroup_idempotent, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + T = ans.get("table") + if not isinstance(T, list) or len(T) != n: + raise Invalid(f"table must be a list of {n} rows") + T = [int_list(r, n, 0, n - 1, "table row") for r in T] + full = list(range(n)) + for i in range(n): + if sorted(T[i]) != full or sorted(T[r][i] for r in range(n)) != full: + raise Invalid(f"row/column {i} is not a permutation (not a Latin square)") + if T[i][i] != i: + raise Invalid(f"not idempotent: {i}*{i} = {T[i][i]}") + for i in range(n): + for j in range(n): + if T[T[i][j]][T[j][i]] != i: + raise Invalid(f"QG3 fails for (x, y) = ({i}, {j})") + return None, {} diff --git a/tasks/construct-mc-quasigroup-idempotent-l5-s0/tests/instance.json b/tasks/construct-mc-quasigroup-idempotent-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0993b914897e0e7256c62da994882c8caf447964 --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 32, "family": "mc_quasigroup_idempotent", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-quasigroup-idempotent-l5-s0/tests/run.py b/tasks/construct-mc-quasigroup-idempotent-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-l5-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-quasigroup-idempotent-l5-s0/tests/test.sh b/tasks/construct-mc-quasigroup-idempotent-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-quasigroup-idempotent-l5-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-ramsey-l4-s3/environment/Dockerfile b/tasks/construct-mc-ramsey-l4-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-ramsey-l4-s3/environment/instance.json b/tasks/construct-mc-ramsey-l4-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..65ce1f980dd4f6a7b3516e9e0e582824527ac6e9 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 22, "r": 4, "s": 5, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l4-s3/solution/solve.sh b/tasks/construct-mc-ramsey-l4-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5ac1d5e9c8328f7b3a6ee8f9eab5fc7cb11b54ce --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-ramsey-l4-s3/tests/check.py b/tasks/construct-mc-ramsey-l4-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..53526c0bc87af6298219d3e1eac5f95f01b57541 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s3/tests/check.py @@ -0,0 +1,31 @@ +"""Two-colouring of the edges of K_n with no colour-0 K_r and no colour-1 K_s (MathConstraint ramsey, +CC-BY-4.0). Adapted from pilot/grader.py check_ramsey; adds the optional fixed edge colours.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, r, s = inst["n"], inst["r"], inst["s"] + edges = list(itertools.combinations(range(n), 2)) + col = int_list(ans.get("colors"), len(edges), 0, 1, "colors") + for name, i, v in inst.get("fixed", []): + if col[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + c = {e: col[i] for i, e in enumerate(edges)} + for k, colour in ((r, 0), (s, 1)): + adj = {v: {u for u in range(n) if u != v and c[(min(u, v), max(u, v))] == colour} for v in range(n)} + + def grow(size, cand): + if size == k: + return True + if size + len(cand) < k: + return False + for v in sorted(cand): + if grow(size + 1, {u for u in cand if u > v} & adj[v]): + return True + return False + + if grow(0, set(range(n))): + raise Invalid(f"monochromatic K_{k} in colour {colour}") + return None, {} diff --git a/tasks/construct-mc-ramsey-l4-s3/tests/instance.json b/tasks/construct-mc-ramsey-l4-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..65ce1f980dd4f6a7b3516e9e0e582824527ac6e9 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 22, "r": 4, "s": 5, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l4-s3/tests/run.py b/tasks/construct-mc-ramsey-l4-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-ramsey-l4-s3/tests/test.sh b/tasks/construct-mc-ramsey-l4-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-ramsey-l4-s4/environment/Dockerfile b/tasks/construct-mc-ramsey-l4-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-ramsey-l4-s4/environment/instance.json b/tasks/construct-mc-ramsey-l4-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..391349a1161174a3310d4bdf28d3b5b11d2d3c9d --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 18, "r": 7, "s": 3, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l4-s4/solution/solve.sh b/tasks/construct-mc-ramsey-l4-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..64ec5f945e62fbcea56ad301cde09e953b49868c --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-mc-ramsey-l4-s4/tests/check.py b/tasks/construct-mc-ramsey-l4-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..53526c0bc87af6298219d3e1eac5f95f01b57541 --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s4/tests/check.py @@ -0,0 +1,31 @@ +"""Two-colouring of the edges of K_n with no colour-0 K_r and no colour-1 K_s (MathConstraint ramsey, +CC-BY-4.0). Adapted from pilot/grader.py check_ramsey; adds the optional fixed edge colours.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, r, s = inst["n"], inst["r"], inst["s"] + edges = list(itertools.combinations(range(n), 2)) + col = int_list(ans.get("colors"), len(edges), 0, 1, "colors") + for name, i, v in inst.get("fixed", []): + if col[i] != v: + raise Invalid(f"fixed value {name}[{i}] = {v} not respected") + c = {e: col[i] for i, e in enumerate(edges)} + for k, colour in ((r, 0), (s, 1)): + adj = {v: {u for u in range(n) if u != v and c[(min(u, v), max(u, v))] == colour} for v in range(n)} + + def grow(size, cand): + if size == k: + return True + if size + len(cand) < k: + return False + for v in sorted(cand): + if grow(size + 1, {u for u in cand if u > v} & adj[v]): + return True + return False + + if grow(0, set(range(n))): + raise Invalid(f"monochromatic K_{k} in colour {colour}") + return None, {} diff --git a/tasks/construct-mc-ramsey-l4-s4/tests/instance.json b/tasks/construct-mc-ramsey-l4-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..391349a1161174a3310d4bdf28d3b5b11d2d3c9d --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 18, "r": 7, "s": 3, "fixed": [], "family": "mc_ramsey", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-ramsey-l4-s4/tests/run.py b/tasks/construct-mc-ramsey-l4-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-ramsey-l4-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-ramsey-l4-s4/tests/test.sh b/tasks/construct-mc-ramsey-l4-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-ramsey-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-social-golfers-l1-s1/environment/Dockerfile b/tasks/construct-mc-social-golfers-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l1-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-social-golfers-l1-s1/environment/instance.json b/tasks/construct-mc-social-golfers-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e3c89fffb01e94544ef097887c3702576fe02de6 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"n_groups": 5, "group_size": 5, "n_weeks": 3, "family": "mc_social_golfers", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-social-golfers-l1-s1/solution/solve.sh b/tasks/construct-mc-social-golfers-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1920f0bf82785a574480868e29dfd7f773d56d80 --- /dev/null +++ b/tasks/construct-mc-social-golfers-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' +{"schedule": [[0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 4, 0, 1, 2, 3, 3, 4, 0, 1, 2, 2, 3, 4, 0, 1, 1, 2, 3, 4, 0], [0, 1, 2, 3, 4, 3, 4, 0, 1, 2, 1, 2, 3, 4, 0, 4, 0, 1, 2, 3, 2, 3, 4, 0, 1]]} +RLMATH_EOF diff --git a/tasks/construct-mc-social-golfers-l1-s1/tests/check.py b/tasks/construct-mc-social-golfers-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..73977815b7b6094a8491075b6dc2ae1293e44930 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l1-s1/tests/check.py @@ -0,0 +1,25 @@ +"""Social golfer problem (MathConstraint social_golfers, CSPLib prob010, CC-BY-4.0): each week partition +the g*s players into g groups of size s; no two players share a group in more than one week.""" +from run import Invalid, int_list + + +def check(inst, ans): + g, s, w = inst["n_groups"], inst["group_size"], inst["n_weeks"] + P = g * s + sched = ans.get("schedule") + if not isinstance(sched, list) or len(sched) != w: + raise Invalid(f"schedule must be a list of {w} weeks") + met = set() + for wk, row in enumerate(sched): + row = int_list(row, P, 0, g - 1, f"week {wk}") + groups = [[p for p in range(P) if row[p] == grp] for grp in range(g)] + for grp, mem in enumerate(groups): + if len(mem) != s: + raise Invalid(f"week {wk}: group {grp} has {len(mem)} players, need {s}") + for i in range(s): + for j in range(i + 1, s): + pr = (mem[i], mem[j]) + if pr in met: + raise Invalid(f"players {pr} play together in more than one week") + met.add(pr) + return None, {} diff --git a/tasks/construct-mc-social-golfers-l1-s1/tests/instance.json b/tasks/construct-mc-social-golfers-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e3c89fffb01e94544ef097887c3702576fe02de6 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"n_groups": 5, "group_size": 5, "n_weeks": 3, "family": "mc_social_golfers", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-social-golfers-l1-s1/tests/run.py b/tasks/construct-mc-social-golfers-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-social-golfers-l1-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-social-golfers-l1-s1/tests/test.sh b/tasks/construct-mc-social-golfers-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-social-golfers-l1-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-van-der-waerden-l4-s1/environment/Dockerfile b/tasks/construct-mc-van-der-waerden-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-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-van-der-waerden-l4-s1/environment/instance.json b/tasks/construct-mc-van-der-waerden-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..eb6d5cbaf598f796b2ccdae775267e44fd807eb8 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"k": 4, "L": 3, "n": 45, "family": "mc_van_der_waerden", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-van-der-waerden-l4-s1/solution/solve.sh b/tasks/construct-mc-van-der-waerden-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9286e88b7f759e41fb2788b2837b7fb18123243c --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s1/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 2, 0, 2, 1, 1, 0, 2, 0, 3, 3, 0, 3, 3, 1, 2, 1, 2, 3, 3, 2, 3, 3, 0, 0, 1, 1, 0, 2, 0, 1, 1, 0, 0, 2, 2, 3, 3, 2, 3, 3, 1, 1, 2, 2]} +RLMATH_EOF diff --git a/tasks/construct-mc-van-der-waerden-l4-s1/tests/check.py b/tasks/construct-mc-van-der-waerden-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9853b089b6ac1773d80eac8e9e02ceb4019ad41f --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s1/tests/check.py @@ -0,0 +1,15 @@ +"""k-colouring of {1..n} with no monochromatic L-term arithmetic progression (MathConstraint +van_der_waerden, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k, L = inst["n"], inst["k"], inst["L"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + for a in range(n): + for d in range(1, n): + if a + (L - 1) * d >= n: + break + if all(c[a + j * d] == c[a] for j in range(1, L)): + raise Invalid(f"monochromatic progression {[a + 1 + j * d for j in range(L)]}") + return None, {} diff --git a/tasks/construct-mc-van-der-waerden-l4-s1/tests/instance.json b/tasks/construct-mc-van-der-waerden-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..eb6d5cbaf598f796b2ccdae775267e44fd807eb8 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"k": 4, "L": 3, "n": 45, "family": "mc_van_der_waerden", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-van-der-waerden-l4-s1/tests/run.py b/tasks/construct-mc-van-der-waerden-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-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-van-der-waerden-l4-s1/tests/test.sh b/tasks/construct-mc-van-der-waerden-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-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-van-der-waerden-l4-s6/environment/Dockerfile b/tasks/construct-mc-van-der-waerden-l4-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-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-van-der-waerden-l4-s6/environment/instance.json b/tasks/construct-mc-van-der-waerden-l4-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ac9dbe49ee8c4fe48cd3b4007600b7c7bc1216b6 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s6/environment/instance.json @@ -0,0 +1 @@ +{"k": 2, "L": 5, "n": 80, "family": "mc_van_der_waerden", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-van-der-waerden-l4-s6/solution/solve.sh b/tasks/construct-mc-van-der-waerden-l4-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bb81242648bd0e8e5ed5b1b06991e1fad4746f4d --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-mc-van-der-waerden-l4-s6/tests/check.py b/tasks/construct-mc-van-der-waerden-l4-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9853b089b6ac1773d80eac8e9e02ceb4019ad41f --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s6/tests/check.py @@ -0,0 +1,15 @@ +"""k-colouring of {1..n} with no monochromatic L-term arithmetic progression (MathConstraint +van_der_waerden, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k, L = inst["n"], inst["k"], inst["L"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + for a in range(n): + for d in range(1, n): + if a + (L - 1) * d >= n: + break + if all(c[a + j * d] == c[a] for j in range(1, L)): + raise Invalid(f"monochromatic progression {[a + 1 + j * d for j in range(L)]}") + return None, {} diff --git a/tasks/construct-mc-van-der-waerden-l4-s6/tests/instance.json b/tasks/construct-mc-van-der-waerden-l4-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ac9dbe49ee8c4fe48cd3b4007600b7c7bc1216b6 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-l4-s6/tests/instance.json @@ -0,0 +1 @@ +{"k": 2, "L": 5, "n": 80, "family": "mc_van_der_waerden", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-van-der-waerden-l4-s6/tests/run.py b/tasks/construct-mc-van-der-waerden-l4-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-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-van-der-waerden-l4-s6/tests/test.sh b/tasks/construct-mc-van-der-waerden-l4-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-van-der-waerden-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-vertex-cover-l1-s9/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l1-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-vertex-cover-l1-s9/environment/instance.json b/tasks/construct-mc-vertex-cover-l1-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0e959c989ed135ab93553d6aee446acbc4458f80 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 11, "edges": [[0, 7], [1, 4], [1, 8], [2, 12], [2, 18], [3, 8], [3, 13], [4, 6], [4, 7], [4, 11], [4, 19], [5, 8], [5, 12], [5, 14], [5, 15], [5, 16], [5, 19], [6, 16], [7, 9], [7, 11], [7, 18], [8, 16], [8, 19], [9, 13], [10, 14], [11, 12], [12, 17], [12, 19], [14, 16], [14, 19]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l1-s9/solution/solve.sh b/tasks/construct-mc-vertex-cover-l1-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c48c06c675e265b0fa4dd8f14ae44cf1af771bc5 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"cover": [2, 4, 5, 7, 8, 12, 13, 14, 16, 18, 19]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l1-s9/tests/check.py b/tasks/construct-mc-vertex-cover-l1-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s9/tests/check.py @@ -0,0 +1,16 @@ +"""Vertex cover of size <= k in a given graph (MathConstraint vertex_cover, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) > k: + raise Invalid(f"cover has {len(S)} vertices, at most {k} allowed") + C = set(S) + for u, v in inst["edges"]: + if u not in C and v not in C: + raise Invalid(f"edge ({u},{v}) is not covered") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-vertex-cover-l1-s9/tests/instance.json b/tasks/construct-mc-vertex-cover-l1-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0e959c989ed135ab93553d6aee446acbc4458f80 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 20, "k": 11, "edges": [[0, 7], [1, 4], [1, 8], [2, 12], [2, 18], [3, 8], [3, 13], [4, 6], [4, 7], [4, 11], [4, 19], [5, 8], [5, 12], [5, 14], [5, 15], [5, 16], [5, 19], [6, 16], [7, 9], [7, 11], [7, 18], [8, 16], [8, 19], [9, 13], [10, 14], [11, 12], [12, 17], [12, 19], [14, 16], [14, 19]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l1-s9/tests/run.py b/tasks/construct-mc-vertex-cover-l1-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-vertex-cover-l1-s9/tests/test.sh b/tasks/construct-mc-vertex-cover-l1-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l1-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-mc-vertex-cover-l5-s1/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-vertex-cover-l5-s1/environment/instance.json b/tasks/construct-mc-vertex-cover-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ddb6d9e9d62223f90d8cfa1d6abfffd5cea18ba8 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 63, "edges": [[0, 1], [0, 2], [0, 18], [0, 28], [0, 35], [0, 37], [0, 66], [0, 74], [0, 83], [1, 2], [1, 9], [1, 12], [1, 18], [1, 33], [1, 40], [1, 41], [1, 46], [1, 69], [1, 72], [1, 77], [1, 86], [1, 88], [2, 15], [2, 20], [2, 23], [2, 29], [2, 33], [2, 52], [2, 57], [2, 58], [2, 65], [2, 84], [2, 88], [3, 7], [3, 21], [3, 22], [3, 39], [3, 41], [3, 54], [3, 65], [3, 74], [3, 78], [3, 81], [3, 82], [3, 86], [3, 87], [3, 89], [4, 5], [4, 6], [4, 7], [4, 13], [4, 20], [4, 24], [4, 32], [4, 36], [4, 40], [4, 43], [4, 46], [4, 47], [4, 59], [4, 60], [4, 63], [4, 73], [4, 75], [4, 84], [4, 88], [5, 13], [5, 19], [5, 24], [5, 30], [5, 36], [5, 37], [5, 39], [5, 42], [5, 50], [5, 52], [5, 67], [5, 70], [5, 71], [5, 76], [6, 12], [6, 16], [6, 30], [6, 33], [6, 35], [6, 36], [6, 37], [6, 42], [6, 47], [6, 57], [6, 60], [6, 63], [6, 66], [6, 79], [7, 22], [7, 39], [7, 55], [7, 56], [7, 74], [7, 75], [7, 89], [8, 10], [8, 12], [8, 33], [8, 39], [8, 42], [8, 45], [8, 48], [8, 50], [8, 51], [8, 54], [8, 57], [8, 67], [8, 81], [8, 87], [8, 88], [8, 89], [9, 14], [9, 29], [9, 34], [9, 37], [9, 61], [9, 77], [9, 80], [9, 81], [10, 15], [10, 16], [10, 17], [10, 24], [10, 27], [10, 28], [10, 31], [10, 46], [10, 64], [10, 69], [10, 70], [10, 73], [11, 23], [11, 37], [11, 55], [11, 56], [11, 59], [11, 63], [11, 67], [11, 85], [12, 13], [12, 19], [12, 27], [12, 46], [12, 50], [12, 64], [12, 66], [12, 68], [12, 79], [12, 80], [13, 14], [13, 16], [13, 23], [13, 27], [13, 28], [13, 31], [13, 34], [13, 44], [13, 48], [13, 56], [13, 57], [13, 59], [13, 62], [13, 64], [13, 67], [13, 74], [13, 77], [13, 78], [14, 22], [14, 25], [14, 26], [14, 31], [14, 32], [14, 35], [14, 50], [14, 51], [14, 54], [14, 58], [14, 61], [14, 65], [14, 72], [14, 75], [14, 78], [15, 18], [15, 20], [15, 26], [15, 35], [15, 42], [15, 54], [15, 55], [15, 68], [15, 76], [15, 85], [16, 21], [16, 24], [16, 29], [16, 43], [16, 53], [16, 55], [16, 56], [16, 58], [16, 59], [16, 69], [16, 74], [16, 77], [16, 85], [17, 28], [17, 39], [17, 44], [17, 47], [17, 48], [17, 58], [17, 59], [18, 39], [18, 45], [18, 55], [18, 59], [18, 60], [18, 63], [18, 73], [18, 85], [19, 36], [19, 44], [19, 50], [19, 55], [19, 56], [19, 62], [19, 64], [19, 65], [19, 71], [19, 77], [19, 82], [19, 88], [20, 40], [20, 47], [20, 51], [20, 56], [20, 61], [20, 69], [20, 85], [21, 29], [21, 44], [21, 45], [21, 48], [21, 49], [21, 61], [21, 67], [21, 77], [21, 82], [21, 88], [21, 89], [22, 30], [22, 31], [22, 37], [22, 40], [22, 43], [22, 45], [22, 65], [22, 72], [22, 78], [22, 84], [22, 87], [23, 24], [23, 29], [23, 35], [23, 65], [23, 81], [24, 25], [24, 29], [24, 32], [24, 41], [24, 45], [24, 49], [24, 60], [24, 64], [24, 68], [24, 71], [24, 73], [25, 28], [25, 34], [25, 44], [26, 50], [26, 59], [26, 73], [26, 84], [27, 29], [27, 35], [27, 36], [27, 38], [27, 45], [27, 47], [27, 58], [27, 63], [27, 69], [28, 33], [28, 38], [28, 50], [28, 55], [28, 66], [28, 77], [28, 86], [29, 30], [29, 36], [29, 63], [29, 65], [29, 66], [29, 67], [29, 70], [29, 88], [30, 32], [30, 45], [30, 52], [30, 85], [31, 34], [31, 38], [31, 44], [31, 61], [31, 71], [31, 72], [31, 73], [31, 76], [31, 83], [32, 39], [32, 43], [32, 62], [32, 72], [32, 76], [33, 34], [33, 38], [33, 53], [33, 59], [33, 62], [33, 64], [33, 71], [33, 73], [34, 36], [34, 39], [34, 44], [34, 53], [34, 55], [34, 58], [34, 62], [34, 69], [34, 72], [34, 76], [34, 79], [34, 88], [35, 45], [35, 50], [35, 54], [35, 58], [35, 62], [35, 66], [35, 70], [35, 72], [35, 84], [36, 47], [36, 51], [36, 53], [36, 72], [37, 50], [37, 51], [37, 54], [37, 57], [37, 73], [37, 77], [37, 78], [37, 80], [37, 81], [38, 56], [38, 58], [38, 68], [38, 70], [38, 80], [38, 84], [39, 42], [39, 45], [39, 46], [39, 56], [39, 57], [39, 72], [39, 76], [39, 77], [39, 83], [40, 42], [40, 43], [40, 46], [40, 56], [40, 59], [40, 60], [40, 61], [40, 62], [40, 63], [40, 69], [40, 76], [40, 82], [40, 89], [41, 63], [41, 72], [42, 56], [42, 66], [42, 85], [43, 50], [43, 54], [43, 55], [43, 57], [43, 59], [43, 60], [43, 66], [43, 69], [43, 86], [44, 45], [44, 51], [44, 53], [44, 63], [44, 65], [44, 67], [44, 68], [44, 69], [44, 71], [44, 72], [44, 73], [44, 77], [44, 83], [45, 71], [45, 78], [45, 81], [45, 82], [46, 53], [46, 59], [46, 61], [46, 75], [46, 77], [46, 78], [46, 81], [47, 62], [47, 64], [47, 80], [47, 82], [48, 69], [48, 78], [48, 83], [48, 85], [49, 52], [49, 68], [49, 82], [49, 84], [49, 87], [50, 52], [50, 58], [50, 60], [50, 66], [50, 75], [50, 85], [50, 86], [51, 52], [51, 55], [51, 57], [51, 67], [51, 73], [51, 85], [51, 86], [52, 53], [52, 61], [52, 81], [52, 85], [53, 56], [53, 57], [53, 68], [53, 69], [53, 74], [53, 75], [53, 77], [53, 82], [54, 61], [54, 81], [54, 84], [55, 56], [55, 57], [55, 65], [55, 73], [55, 75], [55, 78], [55, 84], [56, 59], [56, 64], [56, 67], [56, 70], [56, 74], [56, 79], [56, 80], [56, 82], [56, 85], [56, 86], [57, 69], [57, 76], [58, 59], [58, 80], [58, 85], [58, 88], [59, 65], [59, 70], [59, 72], [59, 80], [59, 87], [60, 62], [60, 63], [60, 76], [61, 72], [61, 73], [61, 75], [61, 89], [62, 68], [62, 74], [62, 80], [63, 78], [63, 85], [63, 86], [64, 67], [64, 74], [64, 79], [64, 82], [64, 84], [65, 67], [65, 78], [65, 80], [66, 78], [67, 72], [67, 76], [67, 89], [68, 74], [68, 77], [68, 80], [68, 85], [69, 70], [69, 77], [69, 87], [70, 72], [70, 80], [70, 82], [71, 76], [71, 79], [71, 80], [71, 88], [72, 84], [73, 80], [73, 81], [73, 85], [73, 87], [74, 80], [74, 86], [75, 76], [75, 78], [75, 86], [75, 88], [76, 78], [77, 84], [79, 81], [79, 85], [79, 89], [80, 87], [81, 87], [82, 86], [82, 87], [82, 89], [83, 86], [83, 89], [84, 88], [84, 89], [85, 87]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l5-s1/solution/solve.sh b/tasks/construct-mc-vertex-cover-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..57ddf2847808e9923c86567ee36632ba8067ef05 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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' +{"cover": [1, 2, 3, 4, 5, 6, 8, 10, 12, 13, 14, 15, 18, 19, 21, 22, 23, 24, 27, 28, 29, 30, 34, 35, 36, 37, 38, 39, 40, 43, 44, 47, 48, 49, 50, 51, 53, 55, 56, 58, 59, 61, 62, 63, 64, 66, 67, 69, 71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 89]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l5-s1/tests/check.py b/tasks/construct-mc-vertex-cover-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s1/tests/check.py @@ -0,0 +1,16 @@ +"""Vertex cover of size <= k in a given graph (MathConstraint vertex_cover, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) > k: + raise Invalid(f"cover has {len(S)} vertices, at most {k} allowed") + C = set(S) + for u, v in inst["edges"]: + if u not in C and v not in C: + raise Invalid(f"edge ({u},{v}) is not covered") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-vertex-cover-l5-s1/tests/instance.json b/tasks/construct-mc-vertex-cover-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ddb6d9e9d62223f90d8cfa1d6abfffd5cea18ba8 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 63, "edges": [[0, 1], [0, 2], [0, 18], [0, 28], [0, 35], [0, 37], [0, 66], [0, 74], [0, 83], [1, 2], [1, 9], [1, 12], [1, 18], [1, 33], [1, 40], [1, 41], [1, 46], [1, 69], [1, 72], [1, 77], [1, 86], [1, 88], [2, 15], [2, 20], [2, 23], [2, 29], [2, 33], [2, 52], [2, 57], [2, 58], [2, 65], [2, 84], [2, 88], [3, 7], [3, 21], [3, 22], [3, 39], [3, 41], [3, 54], [3, 65], [3, 74], [3, 78], [3, 81], [3, 82], [3, 86], [3, 87], [3, 89], [4, 5], [4, 6], [4, 7], [4, 13], [4, 20], [4, 24], [4, 32], [4, 36], [4, 40], [4, 43], [4, 46], [4, 47], [4, 59], [4, 60], [4, 63], [4, 73], [4, 75], [4, 84], [4, 88], [5, 13], [5, 19], [5, 24], [5, 30], [5, 36], [5, 37], [5, 39], [5, 42], [5, 50], [5, 52], [5, 67], [5, 70], [5, 71], [5, 76], [6, 12], [6, 16], [6, 30], [6, 33], [6, 35], [6, 36], [6, 37], [6, 42], [6, 47], [6, 57], [6, 60], [6, 63], [6, 66], [6, 79], [7, 22], [7, 39], [7, 55], [7, 56], [7, 74], [7, 75], [7, 89], [8, 10], [8, 12], [8, 33], [8, 39], [8, 42], [8, 45], [8, 48], [8, 50], [8, 51], [8, 54], [8, 57], [8, 67], [8, 81], [8, 87], [8, 88], [8, 89], [9, 14], [9, 29], [9, 34], [9, 37], [9, 61], [9, 77], [9, 80], [9, 81], [10, 15], [10, 16], [10, 17], [10, 24], [10, 27], [10, 28], [10, 31], [10, 46], [10, 64], [10, 69], [10, 70], [10, 73], [11, 23], [11, 37], [11, 55], [11, 56], [11, 59], [11, 63], [11, 67], [11, 85], [12, 13], [12, 19], [12, 27], [12, 46], [12, 50], [12, 64], [12, 66], [12, 68], [12, 79], [12, 80], [13, 14], [13, 16], [13, 23], [13, 27], [13, 28], [13, 31], [13, 34], [13, 44], [13, 48], [13, 56], [13, 57], [13, 59], [13, 62], [13, 64], [13, 67], [13, 74], [13, 77], [13, 78], [14, 22], [14, 25], [14, 26], [14, 31], [14, 32], [14, 35], [14, 50], [14, 51], [14, 54], [14, 58], [14, 61], [14, 65], [14, 72], [14, 75], [14, 78], [15, 18], [15, 20], [15, 26], [15, 35], [15, 42], [15, 54], [15, 55], [15, 68], [15, 76], [15, 85], [16, 21], [16, 24], [16, 29], [16, 43], [16, 53], [16, 55], [16, 56], [16, 58], [16, 59], [16, 69], [16, 74], [16, 77], [16, 85], [17, 28], [17, 39], [17, 44], [17, 47], [17, 48], [17, 58], [17, 59], [18, 39], [18, 45], [18, 55], [18, 59], [18, 60], [18, 63], [18, 73], [18, 85], [19, 36], [19, 44], [19, 50], [19, 55], [19, 56], [19, 62], [19, 64], [19, 65], [19, 71], [19, 77], [19, 82], [19, 88], [20, 40], [20, 47], [20, 51], [20, 56], [20, 61], [20, 69], [20, 85], [21, 29], [21, 44], [21, 45], [21, 48], [21, 49], [21, 61], [21, 67], [21, 77], [21, 82], [21, 88], [21, 89], [22, 30], [22, 31], [22, 37], [22, 40], [22, 43], [22, 45], [22, 65], [22, 72], [22, 78], [22, 84], [22, 87], [23, 24], [23, 29], [23, 35], [23, 65], [23, 81], [24, 25], [24, 29], [24, 32], [24, 41], [24, 45], [24, 49], [24, 60], [24, 64], [24, 68], [24, 71], [24, 73], [25, 28], [25, 34], [25, 44], [26, 50], [26, 59], [26, 73], [26, 84], [27, 29], [27, 35], [27, 36], [27, 38], [27, 45], [27, 47], [27, 58], [27, 63], [27, 69], [28, 33], [28, 38], [28, 50], [28, 55], [28, 66], [28, 77], [28, 86], [29, 30], [29, 36], [29, 63], [29, 65], [29, 66], [29, 67], [29, 70], [29, 88], [30, 32], [30, 45], [30, 52], [30, 85], [31, 34], [31, 38], [31, 44], [31, 61], [31, 71], [31, 72], [31, 73], [31, 76], [31, 83], [32, 39], [32, 43], [32, 62], [32, 72], [32, 76], [33, 34], [33, 38], [33, 53], [33, 59], [33, 62], [33, 64], [33, 71], [33, 73], [34, 36], [34, 39], [34, 44], [34, 53], [34, 55], [34, 58], [34, 62], [34, 69], [34, 72], [34, 76], [34, 79], [34, 88], [35, 45], [35, 50], [35, 54], [35, 58], [35, 62], [35, 66], [35, 70], [35, 72], [35, 84], [36, 47], [36, 51], [36, 53], [36, 72], [37, 50], [37, 51], [37, 54], [37, 57], [37, 73], [37, 77], [37, 78], [37, 80], [37, 81], [38, 56], [38, 58], [38, 68], [38, 70], [38, 80], [38, 84], [39, 42], [39, 45], [39, 46], [39, 56], [39, 57], [39, 72], [39, 76], [39, 77], [39, 83], [40, 42], [40, 43], [40, 46], [40, 56], [40, 59], [40, 60], [40, 61], [40, 62], [40, 63], [40, 69], [40, 76], [40, 82], [40, 89], [41, 63], [41, 72], [42, 56], [42, 66], [42, 85], [43, 50], [43, 54], [43, 55], [43, 57], [43, 59], [43, 60], [43, 66], [43, 69], [43, 86], [44, 45], [44, 51], [44, 53], [44, 63], [44, 65], [44, 67], [44, 68], [44, 69], [44, 71], [44, 72], [44, 73], [44, 77], [44, 83], [45, 71], [45, 78], [45, 81], [45, 82], [46, 53], [46, 59], [46, 61], [46, 75], [46, 77], [46, 78], [46, 81], [47, 62], [47, 64], [47, 80], [47, 82], [48, 69], [48, 78], [48, 83], [48, 85], [49, 52], [49, 68], [49, 82], [49, 84], [49, 87], [50, 52], [50, 58], [50, 60], [50, 66], [50, 75], [50, 85], [50, 86], [51, 52], [51, 55], [51, 57], [51, 67], [51, 73], [51, 85], [51, 86], [52, 53], [52, 61], [52, 81], [52, 85], [53, 56], [53, 57], [53, 68], [53, 69], [53, 74], [53, 75], [53, 77], [53, 82], [54, 61], [54, 81], [54, 84], [55, 56], [55, 57], [55, 65], [55, 73], [55, 75], [55, 78], [55, 84], [56, 59], [56, 64], [56, 67], [56, 70], [56, 74], [56, 79], [56, 80], [56, 82], [56, 85], [56, 86], [57, 69], [57, 76], [58, 59], [58, 80], [58, 85], [58, 88], [59, 65], [59, 70], [59, 72], [59, 80], [59, 87], [60, 62], [60, 63], [60, 76], [61, 72], [61, 73], [61, 75], [61, 89], [62, 68], [62, 74], [62, 80], [63, 78], [63, 85], [63, 86], [64, 67], [64, 74], [64, 79], [64, 82], [64, 84], [65, 67], [65, 78], [65, 80], [66, 78], [67, 72], [67, 76], [67, 89], [68, 74], [68, 77], [68, 80], [68, 85], [69, 70], [69, 77], [69, 87], [70, 72], [70, 80], [70, 82], [71, 76], [71, 79], [71, 80], [71, 88], [72, 84], [73, 80], [73, 81], [73, 85], [73, 87], [74, 80], [74, 86], [75, 76], [75, 78], [75, 86], [75, 88], [76, 78], [77, 84], [79, 81], [79, 85], [79, 89], [80, 87], [81, 87], [82, 86], [82, 87], [82, 89], [83, 86], [83, 89], [84, 88], [84, 89], [85, 87]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l5-s1/tests/run.py b/tasks/construct-mc-vertex-cover-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-vertex-cover-l5-s1/tests/test.sh b/tasks/construct-mc-vertex-cover-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-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-vertex-cover-l5-s6/environment/Dockerfile b/tasks/construct-mc-vertex-cover-l5-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-mc-vertex-cover-l5-s6/environment/instance.json b/tasks/construct-mc-vertex-cover-l5-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6e05df4a8fce5e4e72b6fab6d77d4e05d8550ccc --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 63, "edges": [[0, 6], [0, 7], [0, 8], [0, 18], [0, 27], [0, 28], [0, 46], [0, 51], [0, 64], [0, 67], [0, 69], [0, 75], [0, 77], [0, 87], [0, 89], [1, 7], [1, 12], [1, 14], [1, 18], [1, 22], [1, 45], [1, 51], [1, 58], [1, 59], [1, 60], [1, 63], [1, 65], [1, 66], [1, 68], [1, 87], [1, 88], [2, 19], [2, 23], [2, 57], [2, 63], [2, 65], [2, 67], [2, 78], [2, 83], [3, 9], [3, 26], [3, 30], [3, 36], [3, 37], [3, 40], [3, 42], [3, 51], [3, 57], [3, 71], [3, 76], [3, 79], [3, 80], [3, 82], [3, 83], [3, 84], [3, 85], [4, 5], [4, 12], [4, 38], [4, 54], [4, 64], [4, 66], [4, 67], [4, 70], [4, 81], [4, 85], [4, 88], [5, 13], [5, 19], [5, 22], [5, 23], [5, 28], [5, 34], [5, 36], [5, 46], [5, 48], [5, 52], [5, 54], [5, 63], [5, 64], [5, 73], [5, 75], [5, 77], [5, 86], [5, 88], [6, 12], [6, 16], [6, 17], [6, 18], [6, 28], [6, 42], [6, 47], [6, 48], [6, 57], [6, 58], [6, 60], [6, 63], [6, 71], [6, 74], [6, 89], [7, 12], [7, 14], [7, 22], [7, 27], [7, 36], [7, 39], [7, 54], [7, 67], [7, 78], [7, 82], [7, 83], [7, 84], [7, 85], [8, 19], [8, 21], [8, 24], [8, 34], [8, 51], [8, 53], [8, 54], [8, 68], [8, 72], [8, 80], [8, 83], [8, 86], [9, 11], [9, 14], [9, 18], [9, 24], [9, 25], [9, 26], [9, 29], [9, 37], [9, 47], [9, 67], [9, 72], [10, 19], [10, 22], [10, 24], [10, 35], [10, 39], [10, 44], [10, 57], [10, 58], [10, 65], [10, 71], [10, 82], [10, 88], [11, 15], [11, 17], [11, 19], [11, 20], [11, 30], [11, 32], [11, 35], [11, 41], [11, 44], [11, 46], [11, 56], [11, 63], [11, 66], [11, 68], [11, 81], [12, 30], [12, 46], [12, 52], [12, 77], [12, 82], [12, 83], [12, 85], [12, 89], [13, 14], [13, 47], [13, 54], [13, 58], [13, 70], [14, 22], [14, 33], [14, 36], [14, 39], [14, 46], [14, 51], [14, 52], [14, 55], [14, 56], [14, 58], [14, 65], [14, 68], [14, 73], [14, 80], [14, 87], [15, 21], [15, 26], [15, 40], [15, 51], [15, 54], [15, 55], [15, 57], [15, 62], [15, 63], [15, 65], [15, 83], [15, 85], [16, 36], [16, 38], [16, 43], [16, 50], [16, 51], [16, 52], [16, 53], [16, 60], [16, 61], [16, 77], [16, 81], [16, 82], [17, 25], [17, 28], [17, 29], [17, 33], [17, 37], [17, 44], [17, 46], [17, 62], [17, 70], [17, 76], [17, 82], [18, 20], [18, 21], [18, 29], [18, 58], [18, 69], [18, 78], [18, 81], [18, 82], [19, 25], [19, 36], [19, 41], [19, 45], [19, 46], [19, 53], [19, 55], [19, 59], [19, 60], [19, 64], [19, 65], [19, 68], [19, 82], [19, 84], [19, 88], [20, 21], [20, 31], [20, 38], [20, 48], [20, 55], [20, 65], [21, 24], [21, 29], [21, 35], [21, 41], [21, 44], [21, 46], [21, 51], [21, 73], [21, 84], [22, 23], [22, 25], [22, 27], [22, 41], [22, 42], [22, 45], [22, 65], [22, 66], [22, 70], [22, 75], [22, 83], [22, 84], [22, 88], [23, 29], [23, 31], [23, 35], [23, 56], [23, 64], [23, 74], [23, 76], [23, 89], [24, 30], [24, 58], [24, 61], [24, 66], [24, 72], [24, 82], [24, 83], [25, 48], [25, 51], [25, 58], [25, 65], [26, 41], [26, 53], [26, 66], [26, 71], [26, 76], [26, 77], [27, 30], [27, 49], [27, 55], [27, 76], [27, 78], [27, 82], [28, 29], [28, 32], [28, 43], [28, 46], [28, 51], [28, 52], [28, 54], [28, 77], [28, 78], [28, 83], [29, 32], [29, 34], [29, 49], [29, 53], [29, 62], [29, 74], [29, 77], [29, 85], [30, 41], [30, 49], [30, 58], [30, 63], [30, 65], [30, 77], [30, 80], [31, 37], [31, 38], [31, 41], [31, 46], [31, 50], [31, 53], [31, 56], [31, 64], [31, 75], [31, 81], [31, 84], [32, 36], [32, 43], [32, 59], [32, 65], [32, 72], [32, 78], [32, 85], [32, 87], [33, 35], [33, 39], [33, 47], [33, 63], [34, 40], [34, 62], [34, 73], [34, 83], [34, 85], [35, 40], [35, 46], [35, 47], [35, 49], [35, 58], [35, 86], [36, 62], [36, 65], [36, 75], [36, 78], [37, 42], [37, 51], [37, 57], [37, 58], [37, 75], [38, 39], [38, 48], [38, 49], [38, 62], [38, 74], [38, 78], [38, 83], [38, 84], [38, 87], [39, 40], [39, 46], [39, 60], [39, 70], [39, 80], [39, 81], [39, 82], [40, 45], [40, 48], [40, 51], [40, 57], [40, 68], [40, 72], [40, 75], [40, 76], [40, 77], [40, 81], [40, 83], [40, 84], [40, 85], [40, 87], [41, 44], [41, 49], [41, 51], [41, 58], [41, 64], [41, 65], [41, 66], [41, 70], [42, 43], [42, 46], [42, 58], [42, 66], [42, 76], [42, 81], [42, 82], [43, 55], [43, 58], [43, 63], [43, 64], [43, 66], [43, 67], [43, 69], [43, 81], [43, 83], [43, 89], [44, 50], [44, 53], [44, 54], [44, 55], [44, 56], [44, 57], [44, 60], [44, 63], [44, 68], [44, 70], [44, 74], [44, 75], [44, 79], [44, 81], [44, 85], [45, 62], [45, 69], [45, 75], [45, 81], [45, 83], [45, 88], [46, 56], [46, 63], [46, 75], [46, 81], [47, 61], [47, 73], [47, 81], [48, 53], [48, 58], [48, 61], [48, 72], [48, 76], [48, 83], [48, 89], [49, 53], [49, 55], [49, 56], [49, 58], [49, 62], [49, 70], [50, 54], [50, 56], [50, 58], [50, 76], [51, 60], [51, 67], [51, 68], [51, 72], [51, 73], [52, 55], [52, 69], [52, 76], [52, 83], [53, 63], [53, 85], [54, 56], [54, 60], [54, 64], [54, 67], [54, 70], [54, 82], [54, 84], [55, 56], [55, 66], [55, 69], [55, 73], [55, 77], [55, 81], [55, 84], [56, 57], [56, 61], [56, 62], [56, 67], [56, 79], [56, 82], [57, 60], [57, 67], [57, 71], [57, 85], [57, 88], [58, 67], [58, 78], [58, 80], [59, 62], [59, 85], [60, 64], [60, 66], [60, 71], [60, 88], [61, 63], [61, 67], [61, 85], [61, 88], [62, 63], [62, 64], [62, 65], [62, 66], [62, 67], [62, 68], [62, 74], [63, 64], [63, 67], [63, 71], [63, 82], [63, 84], [63, 87], [64, 67], [64, 74], [64, 79], [64, 80], [64, 86], [64, 89], [65, 69], [65, 73], [65, 76], [65, 79], [65, 83], [65, 89], [66, 68], [66, 71], [66, 72], [66, 77], [66, 79], [66, 87], [67, 69], [67, 72], [67, 78], [67, 82], [67, 86], [67, 88], [68, 81], [68, 86], [69, 77], [69, 79], [69, 84], [69, 87], [69, 88], [70, 75], [71, 74], [73, 74], [73, 78], [73, 79], [73, 81], [74, 75], [74, 79], [74, 83], [75, 81], [75, 89], [76, 80], [76, 86], [81, 86], [82, 89], [83, 84], [83, 85], [84, 89], [86, 88], [87, 88]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l5-s6/solution/solve.sh b/tasks/construct-mc-vertex-cover-l5-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5e834d97e316ff2cd30377440a5ce199b4160605 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"cover": [0, 1, 2, 3, 5, 7, 8, 9, 11, 12, 14, 16, 17, 18, 19, 21, 22, 24, 26, 27, 28, 29, 30, 31, 32, 35, 38, 39, 40, 42, 44, 47, 48, 49, 51, 54, 55, 56, 57, 58, 60, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 78, 81, 82, 83, 84, 85, 88, 89]} +RLMATH_EOF diff --git a/tasks/construct-mc-vertex-cover-l5-s6/tests/check.py b/tasks/construct-mc-vertex-cover-l5-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e3accb3da1c773fd2126b8b5b0a97b099e29c83b --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s6/tests/check.py @@ -0,0 +1,16 @@ +"""Vertex cover of size <= k in a given graph (MathConstraint vertex_cover, CC-BY-4.0).""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + S = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(S)) != len(S): + raise Invalid("repeated vertex") + if len(S) > k: + raise Invalid(f"cover has {len(S)} vertices, at most {k} allowed") + C = set(S) + for u, v in inst["edges"]: + if u not in C and v not in C: + raise Invalid(f"edge ({u},{v}) is not covered") + return None, {"size": len(S)} diff --git a/tasks/construct-mc-vertex-cover-l5-s6/tests/instance.json b/tasks/construct-mc-vertex-cover-l5-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6e05df4a8fce5e4e72b6fab6d77d4e05d8550ccc --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 90, "k": 63, "edges": [[0, 6], [0, 7], [0, 8], [0, 18], [0, 27], [0, 28], [0, 46], [0, 51], [0, 64], [0, 67], [0, 69], [0, 75], [0, 77], [0, 87], [0, 89], [1, 7], [1, 12], [1, 14], [1, 18], [1, 22], [1, 45], [1, 51], [1, 58], [1, 59], [1, 60], [1, 63], [1, 65], [1, 66], [1, 68], [1, 87], [1, 88], [2, 19], [2, 23], [2, 57], [2, 63], [2, 65], [2, 67], [2, 78], [2, 83], [3, 9], [3, 26], [3, 30], [3, 36], [3, 37], [3, 40], [3, 42], [3, 51], [3, 57], [3, 71], [3, 76], [3, 79], [3, 80], [3, 82], [3, 83], [3, 84], [3, 85], [4, 5], [4, 12], [4, 38], [4, 54], [4, 64], [4, 66], [4, 67], [4, 70], [4, 81], [4, 85], [4, 88], [5, 13], [5, 19], [5, 22], [5, 23], [5, 28], [5, 34], [5, 36], [5, 46], [5, 48], [5, 52], [5, 54], [5, 63], [5, 64], [5, 73], [5, 75], [5, 77], [5, 86], [5, 88], [6, 12], [6, 16], [6, 17], [6, 18], [6, 28], [6, 42], [6, 47], [6, 48], [6, 57], [6, 58], [6, 60], [6, 63], [6, 71], [6, 74], [6, 89], [7, 12], [7, 14], [7, 22], [7, 27], [7, 36], [7, 39], [7, 54], [7, 67], [7, 78], [7, 82], [7, 83], [7, 84], [7, 85], [8, 19], [8, 21], [8, 24], [8, 34], [8, 51], [8, 53], [8, 54], [8, 68], [8, 72], [8, 80], [8, 83], [8, 86], [9, 11], [9, 14], [9, 18], [9, 24], [9, 25], [9, 26], [9, 29], [9, 37], [9, 47], [9, 67], [9, 72], [10, 19], [10, 22], [10, 24], [10, 35], [10, 39], [10, 44], [10, 57], [10, 58], [10, 65], [10, 71], [10, 82], [10, 88], [11, 15], [11, 17], [11, 19], [11, 20], [11, 30], [11, 32], [11, 35], [11, 41], [11, 44], [11, 46], [11, 56], [11, 63], [11, 66], [11, 68], [11, 81], [12, 30], [12, 46], [12, 52], [12, 77], [12, 82], [12, 83], [12, 85], [12, 89], [13, 14], [13, 47], [13, 54], [13, 58], [13, 70], [14, 22], [14, 33], [14, 36], [14, 39], [14, 46], [14, 51], [14, 52], [14, 55], [14, 56], [14, 58], [14, 65], [14, 68], [14, 73], [14, 80], [14, 87], [15, 21], [15, 26], [15, 40], [15, 51], [15, 54], [15, 55], [15, 57], [15, 62], [15, 63], [15, 65], [15, 83], [15, 85], [16, 36], [16, 38], [16, 43], [16, 50], [16, 51], [16, 52], [16, 53], [16, 60], [16, 61], [16, 77], [16, 81], [16, 82], [17, 25], [17, 28], [17, 29], [17, 33], [17, 37], [17, 44], [17, 46], [17, 62], [17, 70], [17, 76], [17, 82], [18, 20], [18, 21], [18, 29], [18, 58], [18, 69], [18, 78], [18, 81], [18, 82], [19, 25], [19, 36], [19, 41], [19, 45], [19, 46], [19, 53], [19, 55], [19, 59], [19, 60], [19, 64], [19, 65], [19, 68], [19, 82], [19, 84], [19, 88], [20, 21], [20, 31], [20, 38], [20, 48], [20, 55], [20, 65], [21, 24], [21, 29], [21, 35], [21, 41], [21, 44], [21, 46], [21, 51], [21, 73], [21, 84], [22, 23], [22, 25], [22, 27], [22, 41], [22, 42], [22, 45], [22, 65], [22, 66], [22, 70], [22, 75], [22, 83], [22, 84], [22, 88], [23, 29], [23, 31], [23, 35], [23, 56], [23, 64], [23, 74], [23, 76], [23, 89], [24, 30], [24, 58], [24, 61], [24, 66], [24, 72], [24, 82], [24, 83], [25, 48], [25, 51], [25, 58], [25, 65], [26, 41], [26, 53], [26, 66], [26, 71], [26, 76], [26, 77], [27, 30], [27, 49], [27, 55], [27, 76], [27, 78], [27, 82], [28, 29], [28, 32], [28, 43], [28, 46], [28, 51], [28, 52], [28, 54], [28, 77], [28, 78], [28, 83], [29, 32], [29, 34], [29, 49], [29, 53], [29, 62], [29, 74], [29, 77], [29, 85], [30, 41], [30, 49], [30, 58], [30, 63], [30, 65], [30, 77], [30, 80], [31, 37], [31, 38], [31, 41], [31, 46], [31, 50], [31, 53], [31, 56], [31, 64], [31, 75], [31, 81], [31, 84], [32, 36], [32, 43], [32, 59], [32, 65], [32, 72], [32, 78], [32, 85], [32, 87], [33, 35], [33, 39], [33, 47], [33, 63], [34, 40], [34, 62], [34, 73], [34, 83], [34, 85], [35, 40], [35, 46], [35, 47], [35, 49], [35, 58], [35, 86], [36, 62], [36, 65], [36, 75], [36, 78], [37, 42], [37, 51], [37, 57], [37, 58], [37, 75], [38, 39], [38, 48], [38, 49], [38, 62], [38, 74], [38, 78], [38, 83], [38, 84], [38, 87], [39, 40], [39, 46], [39, 60], [39, 70], [39, 80], [39, 81], [39, 82], [40, 45], [40, 48], [40, 51], [40, 57], [40, 68], [40, 72], [40, 75], [40, 76], [40, 77], [40, 81], [40, 83], [40, 84], [40, 85], [40, 87], [41, 44], [41, 49], [41, 51], [41, 58], [41, 64], [41, 65], [41, 66], [41, 70], [42, 43], [42, 46], [42, 58], [42, 66], [42, 76], [42, 81], [42, 82], [43, 55], [43, 58], [43, 63], [43, 64], [43, 66], [43, 67], [43, 69], [43, 81], [43, 83], [43, 89], [44, 50], [44, 53], [44, 54], [44, 55], [44, 56], [44, 57], [44, 60], [44, 63], [44, 68], [44, 70], [44, 74], [44, 75], [44, 79], [44, 81], [44, 85], [45, 62], [45, 69], [45, 75], [45, 81], [45, 83], [45, 88], [46, 56], [46, 63], [46, 75], [46, 81], [47, 61], [47, 73], [47, 81], [48, 53], [48, 58], [48, 61], [48, 72], [48, 76], [48, 83], [48, 89], [49, 53], [49, 55], [49, 56], [49, 58], [49, 62], [49, 70], [50, 54], [50, 56], [50, 58], [50, 76], [51, 60], [51, 67], [51, 68], [51, 72], [51, 73], [52, 55], [52, 69], [52, 76], [52, 83], [53, 63], [53, 85], [54, 56], [54, 60], [54, 64], [54, 67], [54, 70], [54, 82], [54, 84], [55, 56], [55, 66], [55, 69], [55, 73], [55, 77], [55, 81], [55, 84], [56, 57], [56, 61], [56, 62], [56, 67], [56, 79], [56, 82], [57, 60], [57, 67], [57, 71], [57, 85], [57, 88], [58, 67], [58, 78], [58, 80], [59, 62], [59, 85], [60, 64], [60, 66], [60, 71], [60, 88], [61, 63], [61, 67], [61, 85], [61, 88], [62, 63], [62, 64], [62, 65], [62, 66], [62, 67], [62, 68], [62, 74], [63, 64], [63, 67], [63, 71], [63, 82], [63, 84], [63, 87], [64, 67], [64, 74], [64, 79], [64, 80], [64, 86], [64, 89], [65, 69], [65, 73], [65, 76], [65, 79], [65, 83], [65, 89], [66, 68], [66, 71], [66, 72], [66, 77], [66, 79], [66, 87], [67, 69], [67, 72], [67, 78], [67, 82], [67, 86], [67, 88], [68, 81], [68, 86], [69, 77], [69, 79], [69, 84], [69, 87], [69, 88], [70, 75], [71, 74], [73, 74], [73, 78], [73, 79], [73, 81], [74, 75], [74, 79], [74, 83], [75, 81], [75, 89], [76, 80], [76, 86], [81, 86], [82, 89], [83, 84], [83, 85], [84, 89], [86, 88], [87, 88]], "family": "mc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-mc-vertex-cover-l5-s6/tests/run.py b/tasks/construct-mc-vertex-cover-l5-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-mc-vertex-cover-l5-s6/tests/test.sh b/tasks/construct-mc-vertex-cover-l5-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-mc-vertex-cover-l5-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-3col-l1-s0/environment/Dockerfile b/tasks/construct-nppc-3col-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-3col-l1-s0/environment/instance.json b/tasks/construct-nppc-3col-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b4ea7bc087ca1bea10e3521ab010d24701c333a8 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 10, "edges": [[0, 1], [0, 6], [0, 9], [1, 4], [1, 5], [1, 6], [1, 7], [2, 5], [2, 6], [3, 5], [3, 6], [3, 7], [3, 9], [4, 5], [4, 6], [4, 7], [4, 8], [5, 8], [5, 9], [7, 8]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l1-s0/solution/solve.sh b/tasks/construct-nppc-3col-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8b94290205f5c0be71fd048a1be621eb59ccd6f8 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coloring": [0, 1, 0, 0, 0, 2, 2, 2, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-nppc-3col-l1-s0/tests/check.py b/tasks/construct-nppc-3col-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..72362ed9180250b6c53ce0c71867ca476ac2af20 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s0/tests/check.py @@ -0,0 +1,12 @@ +"""Proper 3-colouring of a given graph. Accepts any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["num_nodes"] + # upstream NPPC verifier skips the range/length check, so an all-distinct colouring passed it + c = int_list(ans.get("coloring"), n, 0, 2, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-nppc-3col-l1-s0/tests/instance.json b/tasks/construct-nppc-3col-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b4ea7bc087ca1bea10e3521ab010d24701c333a8 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 10, "edges": [[0, 1], [0, 6], [0, 9], [1, 4], [1, 5], [1, 6], [1, 7], [2, 5], [2, 6], [3, 5], [3, 6], [3, 7], [3, 9], [4, 5], [4, 6], [4, 7], [4, 8], [5, 8], [5, 9], [7, 8]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l1-s0/tests/run.py b/tasks/construct-nppc-3col-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-3col-l1-s0/tests/test.sh b/tasks/construct-nppc-3col-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-3col-l1-s7/environment/Dockerfile b/tasks/construct-nppc-3col-l1-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-3col-l1-s7/environment/instance.json b/tasks/construct-nppc-3col-l1-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1a36d16500fa73a279a41402a4f77c7df51fff7f --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s7/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 10, "edges": [[0, 1], [0, 2], [0, 4], [0, 8], [1, 3], [1, 4], [1, 9], [2, 6], [2, 7], [2, 9], [3, 6], [3, 7], [3, 8], [4, 5], [4, 7], [4, 8], [6, 8], [7, 8], [7, 9], [8, 9]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l1-s7/solution/solve.sh b/tasks/construct-nppc-3col-l1-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7baa2172504ad61441f791f883de97cf92eeefd5 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coloring": [2, 0, 0, 1, 1, 0, 2, 2, 0, 1]} +RLMATH_EOF diff --git a/tasks/construct-nppc-3col-l1-s7/tests/check.py b/tasks/construct-nppc-3col-l1-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..72362ed9180250b6c53ce0c71867ca476ac2af20 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s7/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-l1-s7/tests/instance.json b/tasks/construct-nppc-3col-l1-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..1a36d16500fa73a279a41402a4f77c7df51fff7f --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s7/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 10, "edges": [[0, 1], [0, 2], [0, 4], [0, 8], [1, 3], [1, 4], [1, 9], [2, 6], [2, 7], [2, 9], [3, 6], [3, 7], [3, 8], [4, 5], [4, 7], [4, 8], [6, 8], [7, 8], [7, 9], [8, 9]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l1-s7/tests/run.py b/tasks/construct-nppc-3col-l1-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-3col-l1-s7/tests/test.sh b/tasks/construct-nppc-3col-l1-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-3col-l1-s9/environment/Dockerfile b/tasks/construct-nppc-3col-l1-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-3col-l1-s9/environment/instance.json b/tasks/construct-nppc-3col-l1-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e963862c556b6e34a45fbedcd16956d325a51de9 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s9/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 10, "edges": [[0, 1], [0, 4], [0, 5], [0, 6], [0, 8], [1, 2], [1, 5], [1, 6], [1, 9], [2, 3], [2, 5], [2, 6], [2, 8], [2, 9], [3, 5], [3, 9], [4, 8], [4, 9], [5, 7], [6, 7]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l1-s9/solution/solve.sh b/tasks/construct-nppc-3col-l1-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c67091c6ea28df60a8848c131791c0efad648755 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coloring": [1, 2, 1, 2, 2, 0, 0, 1, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-nppc-3col-l1-s9/tests/check.py b/tasks/construct-nppc-3col-l1-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..72362ed9180250b6c53ce0c71867ca476ac2af20 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s9/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-l1-s9/tests/instance.json b/tasks/construct-nppc-3col-l1-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..e963862c556b6e34a45fbedcd16956d325a51de9 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s9/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 10, "edges": [[0, 1], [0, 4], [0, 5], [0, 6], [0, 8], [1, 2], [1, 5], [1, 6], [1, 9], [2, 3], [2, 5], [2, 6], [2, 8], [2, 9], [3, 5], [3, 9], [4, 8], [4, 9], [5, 7], [6, 7]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l1-s9/tests/run.py b/tasks/construct-nppc-3col-l1-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-3col-l1-s9/tests/test.sh b/tasks/construct-nppc-3col-l1-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-3col-l1-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-3col-l5-s1/environment/Dockerfile b/tasks/construct-nppc-3col-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-3col-l5-s1/environment/instance.json b/tasks/construct-nppc-3col-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..336cc3987e6738b5e294e2184c994ac9a56047b2 --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 60, "edges": [[0, 23], [0, 29], [0, 33], [0, 54], [0, 56], [1, 2], [1, 25], [1, 32], [1, 46], [1, 54], [1, 55], [1, 58], [2, 8], [2, 10], [2, 12], [2, 21], [2, 40], [2, 46], [2, 59], [3, 7], [3, 10], [3, 19], [3, 20], [3, 23], [3, 52], [4, 6], [4, 19], [4, 26], [4, 47], [5, 7], [5, 11], [5, 20], [5, 21], [5, 29], [5, 36], [5, 46], [6, 7], [6, 16], [6, 24], [6, 25], [6, 54], [7, 31], [7, 46], [7, 49], [7, 57], [7, 58], [7, 59], [8, 22], [8, 42], [8, 43], [9, 12], [9, 20], [9, 23], [9, 26], [9, 30], [9, 34], [9, 36], [9, 40], [9, 46], [10, 24], [10, 41], [11, 40], [12, 24], [12, 25], [12, 32], [12, 37], [12, 44], [12, 50], [12, 59], [13, 20], [13, 30], [13, 33], [13, 34], [13, 36], [13, 48], [14, 16], [14, 18], [14, 43], [14, 52], [15, 16], [15, 18], [15, 19], [15, 28], [15, 33], [15, 38], [15, 44], [15, 53], [16, 21], [16, 25], [16, 29], [16, 45], [16, 50], [17, 31], [17, 44], [17, 45], [17, 53], [18, 20], [19, 28], [19, 29], [19, 34], [19, 50], [19, 54], [20, 21], [20, 25], [20, 32], [20, 41], [20, 42], [20, 45], [20, 46], [20, 51], [20, 58], [21, 45], [22, 45], [22, 46], [22, 49], [22, 57], [23, 40], [23, 44], [23, 55], [24, 32], [24, 57], [25, 27], [25, 44], [25, 55], [25, 57], [26, 32], [26, 39], [26, 42], [26, 54], [26, 55], [26, 58], [26, 59], [27, 30], [27, 35], [27, 46], [27, 56], [28, 47], [28, 48], [29, 31], [29, 32], [29, 36], [29, 44], [29, 45], [30, 32], [30, 34], [30, 55], [31, 46], [31, 47], [31, 54], [32, 39], [33, 39], [33, 40], [33, 58], [33, 59], [34, 44], [35, 49], [35, 50], [35, 51], [36, 42], [36, 46], [36, 53], [36, 57], [36, 58], [37, 43], [37, 47], [37, 52], [38, 43], [38, 51], [40, 57], [41, 47], [41, 49], [42, 46], [42, 47], [42, 52], [43, 48], [43, 50], [44, 49], [44, 56], [45, 46], [45, 47], [45, 50], [46, 47], [46, 53], [46, 55], [46, 58], [47, 49], [47, 54], [47, 57], [47, 58], [48, 56], [48, 57], [49, 53], [49, 56], [51, 56], [51, 58], [52, 57], [53, 54], [53, 59], [54, 57], [54, 58]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l5-s6/environment/Dockerfile b/tasks/construct-nppc-3col-l5-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-3col-l5-s6/environment/instance.json b/tasks/construct-nppc-3col-l5-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..37533ff91c3363147879628a441a68bb789abc1a --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s6/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 60, "edges": [[0, 1], [0, 22], [0, 37], [0, 43], [0, 45], [0, 59], [1, 3], [1, 17], [1, 27], [1, 33], [1, 54], [2, 6], [2, 23], [2, 30], [2, 34], [2, 54], [3, 12], [3, 16], [3, 20], [3, 31], [3, 35], [3, 40], [4, 5], [4, 14], [4, 20], [4, 31], [4, 34], [4, 42], [4, 55], [4, 56], [5, 8], [5, 21], [5, 27], [5, 29], [5, 35], [6, 10], [6, 12], [6, 15], [6, 16], [6, 23], [6, 25], [6, 42], [6, 50], [7, 11], [7, 22], [7, 25], [7, 26], [7, 40], [7, 41], [7, 45], [7, 48], [7, 58], [8, 9], [8, 10], [8, 14], [8, 26], [8, 30], [8, 31], [8, 49], [9, 35], [9, 36], [9, 38], [9, 45], [9, 47], [9, 48], [9, 59], [10, 25], [10, 29], [10, 37], [10, 39], [10, 47], [11, 14], [11, 20], [11, 24], [11, 38], [12, 18], [12, 33], [12, 37], [12, 38], [12, 41], [12, 48], [13, 20], [13, 28], [14, 18], [14, 21], [14, 26], [14, 33], [14, 36], [15, 18], [15, 37], [15, 54], [16, 21], [16, 25], [16, 26], [16, 29], [16, 32], [16, 37], [16, 38], [16, 41], [16, 46], [16, 48], [17, 28], [17, 51], [17, 52], [18, 36], [18, 42], [18, 53], [18, 55], [19, 33], [19, 50], [19, 53], [19, 54], [20, 21], [20, 24], [20, 25], [20, 37], [20, 40], [20, 46], [20, 48], [21, 42], [21, 43], [21, 53], [22, 23], [22, 39], [22, 46], [22, 50], [23, 37], [23, 45], [23, 59], [24, 55], [24, 56], [25, 46], [26, 29], [26, 35], [26, 40], [26, 49], [27, 28], [27, 44], [27, 50], [28, 49], [28, 50], [28, 54], [28, 57], [29, 43], [29, 50], [29, 53], [29, 56], [30, 34], [30, 35], [30, 38], [30, 43], [30, 46], [30, 48], [30, 57], [31, 36], [31, 37], [32, 35], [32, 49], [32, 53], [32, 58], [32, 59], [33, 40], [33, 55], [33, 58], [33, 59], [34, 35], [34, 42], [34, 51], [35, 49], [35, 53], [35, 55], [36, 41], [36, 49], [36, 54], [36, 56], [37, 41], [37, 51], [38, 47], [38, 51], [39, 53], [40, 55], [41, 44], [41, 49], [42, 44], [42, 56], [42, 58], [43, 58], [44, 49], [44, 50], [45, 47], [45, 51], [45, 55], [46, 52], [47, 49], [47, 51], [47, 55], [49, 57], [49, 59], [54, 55], [57, 59]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l5-s6/solution/solve.sh b/tasks/construct-nppc-3col-l5-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2972a0755ae14710c2b906e7cb3801cd0c469072 --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coloring": [1, 2, 2, 0, 2, 1, 0, 1, 2, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 2, 1, 2, 2, 1, 2, 2, 0, 0, 2, 2, 1, 1, 0, 0, 0, 2, 2, 2, 2, 0, 2, 0, 1, 0, 2, 2, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 2, 2]} +RLMATH_EOF diff --git a/tasks/construct-nppc-3col-l5-s6/tests/check.py b/tasks/construct-nppc-3col-l5-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..72362ed9180250b6c53ce0c71867ca476ac2af20 --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s6/tests/check.py @@ -0,0 +1,12 @@ +"""Proper 3-colouring of a given graph. Accepts any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["num_nodes"] + # upstream NPPC verifier skips the range/length check, so an all-distinct colouring passed it + c = int_list(ans.get("coloring"), n, 0, 2, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-nppc-3col-l5-s6/tests/instance.json b/tasks/construct-nppc-3col-l5-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..37533ff91c3363147879628a441a68bb789abc1a --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s6/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 60, "edges": [[0, 1], [0, 22], [0, 37], [0, 43], [0, 45], [0, 59], [1, 3], [1, 17], [1, 27], [1, 33], [1, 54], [2, 6], [2, 23], [2, 30], [2, 34], [2, 54], [3, 12], [3, 16], [3, 20], [3, 31], [3, 35], [3, 40], [4, 5], [4, 14], [4, 20], [4, 31], [4, 34], [4, 42], [4, 55], [4, 56], [5, 8], [5, 21], [5, 27], [5, 29], [5, 35], [6, 10], [6, 12], [6, 15], [6, 16], [6, 23], [6, 25], [6, 42], [6, 50], [7, 11], [7, 22], [7, 25], [7, 26], [7, 40], [7, 41], [7, 45], [7, 48], [7, 58], [8, 9], [8, 10], [8, 14], [8, 26], [8, 30], [8, 31], [8, 49], [9, 35], [9, 36], [9, 38], [9, 45], [9, 47], [9, 48], [9, 59], [10, 25], [10, 29], [10, 37], [10, 39], [10, 47], [11, 14], [11, 20], [11, 24], [11, 38], [12, 18], [12, 33], [12, 37], [12, 38], [12, 41], [12, 48], [13, 20], [13, 28], [14, 18], [14, 21], [14, 26], [14, 33], [14, 36], [15, 18], [15, 37], [15, 54], [16, 21], [16, 25], [16, 26], [16, 29], [16, 32], [16, 37], [16, 38], [16, 41], [16, 46], [16, 48], [17, 28], [17, 51], [17, 52], [18, 36], [18, 42], [18, 53], [18, 55], [19, 33], [19, 50], [19, 53], [19, 54], [20, 21], [20, 24], [20, 25], [20, 37], [20, 40], [20, 46], [20, 48], [21, 42], [21, 43], [21, 53], [22, 23], [22, 39], [22, 46], [22, 50], [23, 37], [23, 45], [23, 59], [24, 55], [24, 56], [25, 46], [26, 29], [26, 35], [26, 40], [26, 49], [27, 28], [27, 44], [27, 50], [28, 49], [28, 50], [28, 54], [28, 57], [29, 43], [29, 50], [29, 53], [29, 56], [30, 34], [30, 35], [30, 38], [30, 43], [30, 46], [30, 48], [30, 57], [31, 36], [31, 37], [32, 35], [32, 49], [32, 53], [32, 58], [32, 59], [33, 40], [33, 55], [33, 58], [33, 59], [34, 35], [34, 42], [34, 51], [35, 49], [35, 53], [35, 55], [36, 41], [36, 49], [36, 54], [36, 56], [37, 41], [37, 51], [38, 47], [38, 51], [39, 53], [40, 55], [41, 44], [41, 49], [42, 44], [42, 56], [42, 58], [43, 58], [44, 49], [44, 50], [45, 47], [45, 51], [45, 55], [46, 52], [47, 49], [47, 51], [47, 55], [49, 57], [49, 59], [54, 55], [57, 59]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l5-s6/tests/run.py b/tasks/construct-nppc-3col-l5-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-3col-l5-s6/tests/test.sh b/tasks/construct-nppc-3col-l5-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-3col-l5-s8/environment/Dockerfile b/tasks/construct-nppc-3col-l5-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-3col-l5-s8/environment/instance.json b/tasks/construct-nppc-3col-l5-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7a52c686158f8d374e92d1ee304a8ce5a84ccc5d --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s8/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 60, "edges": [[0, 5], [0, 10], [0, 18], [0, 37], [0, 43], [0, 53], [1, 13], [1, 28], [1, 36], [1, 38], [1, 39], [1, 45], [2, 5], [2, 6], [2, 8], [2, 13], [2, 14], [2, 17], [2, 22], [2, 53], [2, 59], [3, 11], [3, 13], [3, 23], [3, 29], [3, 30], [3, 31], [3, 32], [3, 40], [3, 47], [3, 48], [4, 7], [4, 15], [4, 17], [4, 23], [4, 28], [4, 29], [4, 31], [4, 47], [4, 55], [5, 20], [5, 25], [6, 17], [6, 18], [6, 23], [6, 27], [6, 40], [6, 43], [6, 44], [7, 9], [7, 10], [7, 14], [7, 23], [7, 35], [7, 43], [7, 49], [7, 57], [7, 58], [8, 17], [8, 21], [8, 24], [8, 31], [8, 33], [8, 43], [8, 45], [8, 47], [8, 51], [8, 56], [9, 17], [9, 19], [9, 27], [9, 28], [9, 48], [9, 49], [10, 13], [10, 18], [10, 40], [11, 14], [11, 29], [11, 35], [11, 48], [11, 52], [12, 13], [12, 15], [12, 55], [13, 19], [13, 20], [13, 30], [13, 34], [13, 37], [13, 43], [13, 44], [13, 54], [14, 40], [14, 48], [15, 16], [15, 19], [15, 31], [15, 49], [16, 35], [16, 45], [17, 29], [17, 34], [18, 19], [18, 30], [18, 36], [18, 44], [18, 51], [18, 52], [18, 57], [18, 59], [19, 20], [19, 45], [19, 50], [19, 59], [20, 30], [20, 31], [20, 38], [20, 43], [21, 22], [21, 37], [21, 52], [21, 57], [22, 27], [22, 29], [22, 40], [22, 42], [22, 43], [22, 49], [22, 58], [23, 41], [23, 53], [24, 30], [24, 33], [24, 34], [24, 43], [24, 44], [24, 52], [25, 50], [25, 53], [25, 54], [26, 29], [26, 42], [26, 53], [27, 54], [27, 57], [28, 31], [28, 34], [28, 35], [28, 36], [28, 48], [28, 51], [28, 57], [28, 58], [29, 38], [29, 41], [29, 45], [30, 32], [30, 47], [31, 39], [32, 41], [32, 44], [32, 49], [33, 56], [33, 59], [34, 42], [34, 45], [34, 47], [34, 55], [35, 37], [35, 38], [35, 40], [36, 38], [36, 53], [37, 39], [37, 54], [37, 55], [37, 57], [37, 59], [38, 48], [39, 40], [40, 44], [40, 46], [40, 51], [41, 45], [42, 46], [43, 50], [43, 56], [43, 57], [46, 51], [47, 54], [48, 50], [48, 56], [49, 53], [49, 57], [53, 57], [53, 58], [55, 58], [56, 58], [58, 59]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l5-s8/solution/solve.sh b/tasks/construct-nppc-3col-l5-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e7c441855b75e52c46508367f8f391e8318030cc --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"coloring": [1, 0, 0, 1, 1, 2, 1, 2, 1, 1, 0, 2, 0, 2, 1, 2, 0, 2, 2, 0, 1, 2, 1, 0, 2, 0, 1, 2, 2, 0, 0, 0, 2, 0, 0, 1, 1, 0, 2, 1, 2, 1, 2, 0, 0, 2, 1, 2, 0, 0, 1, 0, 1, 2, 1, 2, 2, 1, 0, 1]} +RLMATH_EOF diff --git a/tasks/construct-nppc-3col-l5-s8/tests/check.py b/tasks/construct-nppc-3col-l5-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..72362ed9180250b6c53ce0c71867ca476ac2af20 --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s8/tests/check.py @@ -0,0 +1,12 @@ +"""Proper 3-colouring of a given graph. Accepts any valid colouring.""" +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["num_nodes"] + # upstream NPPC verifier skips the range/length check, so an all-distinct colouring passed it + c = int_list(ans.get("coloring"), n, 0, 2, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-nppc-3col-l5-s8/tests/instance.json b/tasks/construct-nppc-3col-l5-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7a52c686158f8d374e92d1ee304a8ce5a84ccc5d --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s8/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 60, "edges": [[0, 5], [0, 10], [0, 18], [0, 37], [0, 43], [0, 53], [1, 13], [1, 28], [1, 36], [1, 38], [1, 39], [1, 45], [2, 5], [2, 6], [2, 8], [2, 13], [2, 14], [2, 17], [2, 22], [2, 53], [2, 59], [3, 11], [3, 13], [3, 23], [3, 29], [3, 30], [3, 31], [3, 32], [3, 40], [3, 47], [3, 48], [4, 7], [4, 15], [4, 17], [4, 23], [4, 28], [4, 29], [4, 31], [4, 47], [4, 55], [5, 20], [5, 25], [6, 17], [6, 18], [6, 23], [6, 27], [6, 40], [6, 43], [6, 44], [7, 9], [7, 10], [7, 14], [7, 23], [7, 35], [7, 43], [7, 49], [7, 57], [7, 58], [8, 17], [8, 21], [8, 24], [8, 31], [8, 33], [8, 43], [8, 45], [8, 47], [8, 51], [8, 56], [9, 17], [9, 19], [9, 27], [9, 28], [9, 48], [9, 49], [10, 13], [10, 18], [10, 40], [11, 14], [11, 29], [11, 35], [11, 48], [11, 52], [12, 13], [12, 15], [12, 55], [13, 19], [13, 20], [13, 30], [13, 34], [13, 37], [13, 43], [13, 44], [13, 54], [14, 40], [14, 48], [15, 16], [15, 19], [15, 31], [15, 49], [16, 35], [16, 45], [17, 29], [17, 34], [18, 19], [18, 30], [18, 36], [18, 44], [18, 51], [18, 52], [18, 57], [18, 59], [19, 20], [19, 45], [19, 50], [19, 59], [20, 30], [20, 31], [20, 38], [20, 43], [21, 22], [21, 37], [21, 52], [21, 57], [22, 27], [22, 29], [22, 40], [22, 42], [22, 43], [22, 49], [22, 58], [23, 41], [23, 53], [24, 30], [24, 33], [24, 34], [24, 43], [24, 44], [24, 52], [25, 50], [25, 53], [25, 54], [26, 29], [26, 42], [26, 53], [27, 54], [27, 57], [28, 31], [28, 34], [28, 35], [28, 36], [28, 48], [28, 51], [28, 57], [28, 58], [29, 38], [29, 41], [29, 45], [30, 32], [30, 47], [31, 39], [32, 41], [32, 44], [32, 49], [33, 56], [33, 59], [34, 42], [34, 45], [34, 47], [34, 55], [35, 37], [35, 38], [35, 40], [36, 38], [36, 53], [37, 39], [37, 54], [37, 55], [37, 57], [37, 59], [38, 48], [39, 40], [40, 44], [40, 46], [40, 51], [41, 45], [42, 46], [43, 50], [43, 56], [43, 57], [46, 51], [47, 54], [48, 50], [48, 56], [49, 53], [49, 57], [53, 57], [53, 58], [55, 58], [56, 58], [58, 59]], "family": "nppc_three_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-3col-l5-s8/tests/run.py b/tasks/construct-nppc-3col-l5-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-3col-l5-s8/tests/test.sh b/tasks/construct-nppc-3col-l5-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-3col-l5-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-clique-l2-s3/environment/Dockerfile b/tasks/construct-nppc-clique-l2-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-clique-l2-s3/environment/instance.json b/tasks/construct-nppc-clique-l2-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c186bcdc4554505da95d8a347a31dffebc3b6e03 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s3/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 14, "k": 7, "edges": [[0, 3], [0, 4], [0, 6], [0, 7], [0, 8], [0, 9], [0, 12], [1, 2], [1, 3], [1, 6], [1, 7], [1, 8], [1, 10], [1, 11], [1, 12], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [3, 4], [3, 5], [3, 6], [3, 7], [4, 7], [4, 10], [4, 11], [4, 12], [4, 13], [5, 6], [5, 8], [5, 9], [5, 10], [5, 12], [6, 8], [6, 11], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [8, 10], [8, 11], [8, 12], [8, 13], [9, 10], [9, 12], [10, 11], [10, 12], [11, 12]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l2-s3/solution/solve.sh b/tasks/construct-nppc-clique-l2-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..63538f354a11ca1c4edf74b5d1de0a2d46c50426 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [1, 2, 7, 8, 10, 11, 12]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l2-s3/tests/check.py b/tasks/construct-nppc-clique-l2-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s3/tests/check.py @@ -0,0 +1,19 @@ +"""Clique of size >= k. Accepts any valid clique.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + # upstream NPPC verifier checks len(list) >= k but only tests pairs u < v, so [v, v, ..., v] passed + if len(set(c)) != len(c): + raise Invalid("clique contains duplicates") + if len(c) < k: + raise Invalid(f"clique has {len(c)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(c), 2): + if (u, v) not in es: + raise Invalid(f"no edge between {u} and {v}") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-clique-l2-s3/tests/instance.json b/tasks/construct-nppc-clique-l2-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c186bcdc4554505da95d8a347a31dffebc3b6e03 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s3/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 14, "k": 7, "edges": [[0, 3], [0, 4], [0, 6], [0, 7], [0, 8], [0, 9], [0, 12], [1, 2], [1, 3], [1, 6], [1, 7], [1, 8], [1, 10], [1, 11], [1, 12], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [3, 4], [3, 5], [3, 6], [3, 7], [4, 7], [4, 10], [4, 11], [4, 12], [4, 13], [5, 6], [5, 8], [5, 9], [5, 10], [5, 12], [6, 8], [6, 11], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [8, 10], [8, 11], [8, 12], [8, 13], [9, 10], [9, 12], [10, 11], [10, 12], [11, 12]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l2-s3/tests/run.py b/tasks/construct-nppc-clique-l2-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-clique-l2-s3/tests/test.sh b/tasks/construct-nppc-clique-l2-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-clique-l2-s4/environment/Dockerfile b/tasks/construct-nppc-clique-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-clique-l2-s4/environment/instance.json b/tasks/construct-nppc-clique-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..192be396caf1b5c75895c17613635385579dec8b --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 14, "k": 7, "edges": [[0, 1], [0, 2], [0, 3], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 13], [1, 2], [1, 4], [1, 5], [1, 7], [1, 8], [1, 11], [1, 13], [2, 3], [2, 5], [2, 6], [2, 7], [2, 8], [2, 12], [2, 13], [3, 4], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 13], [4, 5], [4, 9], [4, 11], [4, 12], [4, 13], [5, 6], [5, 7], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [6, 7], [6, 8], [6, 10], [6, 11], [6, 13], [7, 8], [7, 9], [7, 10], [7, 12], [7, 13], [8, 9], [8, 10], [8, 12], [8, 13], [9, 10], [9, 12], [9, 13], [10, 11], [10, 13], [11, 12], [11, 13]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l2-s4/solution/solve.sh b/tasks/construct-nppc-clique-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9a591e0fe83cd7dcb3ec1ac12ced4826dd399a8e --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [0, 2, 3, 6, 7, 8, 13]} +RLMATH_EOF diff --git a/tasks/construct-nppc-clique-l2-s4/tests/check.py b/tasks/construct-nppc-clique-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..98eb4fc9097fcfa31988cf0a8b79280cec2b7980 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s4/tests/check.py @@ -0,0 +1,19 @@ +"""Clique of size >= k. Accepts any valid clique.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + # upstream NPPC verifier checks len(list) >= k but only tests pairs u < v, so [v, v, ..., v] passed + if len(set(c)) != len(c): + raise Invalid("clique contains duplicates") + if len(c) < k: + raise Invalid(f"clique has {len(c)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(c), 2): + if (u, v) not in es: + raise Invalid(f"no edge between {u} and {v}") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-clique-l2-s4/tests/instance.json b/tasks/construct-nppc-clique-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..192be396caf1b5c75895c17613635385579dec8b --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 14, "k": 7, "edges": [[0, 1], [0, 2], [0, 3], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 13], [1, 2], [1, 4], [1, 5], [1, 7], [1, 8], [1, 11], [1, 13], [2, 3], [2, 5], [2, 6], [2, 7], [2, 8], [2, 12], [2, 13], [3, 4], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 13], [4, 5], [4, 9], [4, 11], [4, 12], [4, 13], [5, 6], [5, 7], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [6, 7], [6, 8], [6, 10], [6, 11], [6, 13], [7, 8], [7, 9], [7, 10], [7, 12], [7, 13], [8, 9], [8, 10], [8, 12], [8, 13], [9, 10], [9, 12], [9, 13], [10, 11], [10, 13], [11, 12], [11, 13]], "family": "nppc_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-clique-l2-s4/tests/run.py b/tasks/construct-nppc-clique-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-clique-l2-s4/tests/test.sh b/tasks/construct-nppc-clique-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-clique-l2-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-dominating-set-l2-s3/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l2-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-dominating-set-l2-s3/environment/instance.json b/tasks/construct-nppc-dominating-set-l2-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..122c44ef7d962264bcd6bbad8b423fe8d6bd72b3 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s3/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "k": 15, "edges": [[0, 3], [0, 4], [0, 5], [0, 8], [0, 13], [0, 14], [0, 19], [0, 21], [0, 23], [0, 24], [0, 25], [0, 28], [0, 29], [1, 5], [1, 8], [1, 16], [1, 17], [1, 22], [1, 26], [1, 28], [2, 3], [2, 6], [2, 9], [2, 10], [2, 11], [2, 14], [2, 18], [2, 19], [2, 21], [2, 22], [2, 24], [2, 28], [3, 4], [3, 8], [3, 10], [3, 11], [3, 12], [3, 14], [3, 16], [3, 18], [3, 22], [3, 23], [3, 24], [3, 26], [4, 5], [4, 6], [4, 12], [4, 14], [4, 19], [4, 20], [4, 23], [5, 9], [5, 12], [5, 20], [5, 22], [6, 10], [6, 13], [6, 21], [6, 29], [7, 18], [7, 20], [7, 26], [7, 29], [8, 9], [8, 10], [8, 14], [8, 16], [8, 22], [8, 25], [9, 14], [9, 17], [9, 20], [9, 22], [9, 25], [9, 26], [9, 27], [10, 11], [10, 21], [10, 24], [10, 26], [10, 29], [11, 12], [11, 21], [11, 28], [12, 27], [12, 29], [13, 15], [13, 17], [13, 18], [13, 22], [13, 23], [13, 24], [13, 28], [14, 15], [14, 16], [14, 23], [14, 26], [14, 28], [14, 29], [15, 16], [15, 17], [15, 18], [15, 19], [15, 21], [15, 26], [15, 28], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [16, 24], [16, 25], [16, 27], [16, 29], [17, 18], [17, 23], [17, 27], [18, 19], [18, 20], [18, 23], [18, 24], [18, 26], [18, 28], [18, 29], [19, 20], [19, 21], [19, 24], [19, 26], [19, 27], [19, 28], [20, 21], [20, 22], [20, 24], [20, 25], [20, 26], [20, 27], [21, 23], [21, 29], [22, 23], [22, 25], [24, 26], [24, 29], [25, 26], [26, 28], [26, 29]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l2-s3/solution/solve.sh b/tasks/construct-nppc-dominating-set-l2-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..22b3960ae12838d23fc48d6afcbf42a0fc5aab7b --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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' +{"dominating_set": [0, 2, 3, 4, 6, 7, 8, 11, 12, 14, 17, 23, 24, 25, 28]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l2-s3/tests/check.py b/tasks/construct-nppc-dominating-set-l2-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s3/tests/check.py @@ -0,0 +1,23 @@ +"""Dominating set of size <= k. Accepts any valid dominating set.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier has no type/range checks (out-of-range labels and floats are silently used) + d = int_list(ans.get("dominating_set"), None, 0, n - 1, "dominating_set") + if len(set(d)) != len(d): + raise Invalid("dominating_set contains duplicates") + if not d or len(d) > k: + raise Invalid(f"dominating_set must have 1..{k} vertices, got {len(d)}") + dom = set(d) + s = set(d) + for u, v in inst["edges"]: + if u in s: + dom.add(v) + if v in s: + dom.add(u) + if len(dom) != n: + miss = min(set(range(n)) - dom) + raise Invalid(f"vertex {miss} is not dominated") + return None, {"size": len(d)} diff --git a/tasks/construct-nppc-dominating-set-l2-s3/tests/instance.json b/tasks/construct-nppc-dominating-set-l2-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..122c44ef7d962264bcd6bbad8b423fe8d6bd72b3 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s3/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "k": 15, "edges": [[0, 3], [0, 4], [0, 5], [0, 8], [0, 13], [0, 14], [0, 19], [0, 21], [0, 23], [0, 24], [0, 25], [0, 28], [0, 29], [1, 5], [1, 8], [1, 16], [1, 17], [1, 22], [1, 26], [1, 28], [2, 3], [2, 6], [2, 9], [2, 10], [2, 11], [2, 14], [2, 18], [2, 19], [2, 21], [2, 22], [2, 24], [2, 28], [3, 4], [3, 8], [3, 10], [3, 11], [3, 12], [3, 14], [3, 16], [3, 18], [3, 22], [3, 23], [3, 24], [3, 26], [4, 5], [4, 6], [4, 12], [4, 14], [4, 19], [4, 20], [4, 23], [5, 9], [5, 12], [5, 20], [5, 22], [6, 10], [6, 13], [6, 21], [6, 29], [7, 18], [7, 20], [7, 26], [7, 29], [8, 9], [8, 10], [8, 14], [8, 16], [8, 22], [8, 25], [9, 14], [9, 17], [9, 20], [9, 22], [9, 25], [9, 26], [9, 27], [10, 11], [10, 21], [10, 24], [10, 26], [10, 29], [11, 12], [11, 21], [11, 28], [12, 27], [12, 29], [13, 15], [13, 17], [13, 18], [13, 22], [13, 23], [13, 24], [13, 28], [14, 15], [14, 16], [14, 23], [14, 26], [14, 28], [14, 29], [15, 16], [15, 17], [15, 18], [15, 19], [15, 21], [15, 26], [15, 28], [16, 18], [16, 19], [16, 20], [16, 21], [16, 22], [16, 24], [16, 25], [16, 27], [16, 29], [17, 18], [17, 23], [17, 27], [18, 19], [18, 20], [18, 23], [18, 24], [18, 26], [18, 28], [18, 29], [19, 20], [19, 21], [19, 24], [19, 26], [19, 27], [19, 28], [20, 21], [20, 22], [20, 24], [20, 25], [20, 26], [20, 27], [21, 23], [21, 29], [22, 23], [22, 25], [24, 26], [24, 29], [25, 26], [26, 28], [26, 29]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l2-s3/tests/run.py b/tasks/construct-nppc-dominating-set-l2-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-dominating-set-l2-s3/tests/test.sh b/tasks/construct-nppc-dominating-set-l2-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-dominating-set-l2-s4/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-dominating-set-l2-s4/environment/instance.json b/tasks/construct-nppc-dominating-set-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..97ec6adaaebc029b4fb63b22c2df432c2e616083 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "k": 15, "edges": [[0, 3], [0, 4], [0, 7], [0, 8], [0, 12], [0, 16], [0, 17], [0, 18], [0, 21], [0, 22], [0, 25], [0, 28], [1, 4], [1, 5], [1, 7], [1, 9], [1, 14], [1, 15], [1, 26], [1, 27], [1, 28], [1, 29], [2, 3], [2, 6], [2, 10], [2, 13], [2, 18], [2, 19], [2, 21], [2, 23], [2, 24], [2, 28], [2, 29], [3, 6], [3, 8], [3, 9], [3, 11], [3, 12], [3, 14], [3, 22], [3, 24], [3, 26], [3, 28], [3, 29], [4, 11], [4, 12], [4, 20], [4, 22], [4, 24], [4, 26], [4, 28], [4, 29], [5, 10], [5, 13], [5, 14], [5, 19], [5, 22], [5, 26], [6, 8], [6, 10], [6, 13], [6, 14], [6, 17], [6, 19], [6, 23], [6, 28], [6, 29], [7, 12], [7, 17], [7, 21], [7, 25], [7, 26], [7, 27], [8, 9], [8, 10], [8, 11], [8, 17], [8, 18], [8, 20], [8, 21], [8, 24], [8, 25], [8, 27], [9, 11], [9, 15], [9, 18], [9, 19], [9, 21], [9, 22], [9, 23], [9, 25], [9, 26], [9, 28], [10, 11], [10, 15], [10, 17], [10, 21], [10, 22], [10, 26], [10, 28], [11, 13], [11, 14], [11, 22], [11, 27], [12, 16], [12, 17], [12, 18], [12, 20], [12, 23], [12, 24], [12, 25], [12, 28], [12, 29], [13, 14], [13, 15], [13, 18], [13, 21], [13, 22], [13, 23], [13, 27], [13, 29], [14, 15], [14, 19], [14, 21], [14, 24], [15, 18], [15, 21], [15, 23], [15, 24], [15, 27], [15, 28], [16, 22], [16, 24], [16, 27], [16, 29], [17, 20], [17, 23], [17, 25], [17, 29], [18, 24], [18, 28], [19, 24], [19, 25], [19, 26], [19, 27], [20, 26], [20, 28], [20, 29], [21, 24], [21, 26], [21, 28], [21, 29], [23, 29], [24, 26], [24, 28], [25, 26], [25, 28], [26, 28], [26, 29]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l2-s4/solution/solve.sh b/tasks/construct-nppc-dominating-set-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..545bbe3fc2860a7f8ac2696069732a488d511695 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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' +{"dominating_set": [1, 5, 6, 7, 8, 9, 11, 13, 20, 22, 23, 24, 27, 28, 29]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l2-s4/tests/check.py b/tasks/construct-nppc-dominating-set-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s4/tests/check.py @@ -0,0 +1,23 @@ +"""Dominating set of size <= k. Accepts any valid dominating set.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier has no type/range checks (out-of-range labels and floats are silently used) + d = int_list(ans.get("dominating_set"), None, 0, n - 1, "dominating_set") + if len(set(d)) != len(d): + raise Invalid("dominating_set contains duplicates") + if not d or len(d) > k: + raise Invalid(f"dominating_set must have 1..{k} vertices, got {len(d)}") + dom = set(d) + s = set(d) + for u, v in inst["edges"]: + if u in s: + dom.add(v) + if v in s: + dom.add(u) + if len(dom) != n: + miss = min(set(range(n)) - dom) + raise Invalid(f"vertex {miss} is not dominated") + return None, {"size": len(d)} diff --git a/tasks/construct-nppc-dominating-set-l2-s4/tests/instance.json b/tasks/construct-nppc-dominating-set-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..97ec6adaaebc029b4fb63b22c2df432c2e616083 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 30, "k": 15, "edges": [[0, 3], [0, 4], [0, 7], [0, 8], [0, 12], [0, 16], [0, 17], [0, 18], [0, 21], [0, 22], [0, 25], [0, 28], [1, 4], [1, 5], [1, 7], [1, 9], [1, 14], [1, 15], [1, 26], [1, 27], [1, 28], [1, 29], [2, 3], [2, 6], [2, 10], [2, 13], [2, 18], [2, 19], [2, 21], [2, 23], [2, 24], [2, 28], [2, 29], [3, 6], [3, 8], [3, 9], [3, 11], [3, 12], [3, 14], [3, 22], [3, 24], [3, 26], [3, 28], [3, 29], [4, 11], [4, 12], [4, 20], [4, 22], [4, 24], [4, 26], [4, 28], [4, 29], [5, 10], [5, 13], [5, 14], [5, 19], [5, 22], [5, 26], [6, 8], [6, 10], [6, 13], [6, 14], [6, 17], [6, 19], [6, 23], [6, 28], [6, 29], [7, 12], [7, 17], [7, 21], [7, 25], [7, 26], [7, 27], [8, 9], [8, 10], [8, 11], [8, 17], [8, 18], [8, 20], [8, 21], [8, 24], [8, 25], [8, 27], [9, 11], [9, 15], [9, 18], [9, 19], [9, 21], [9, 22], [9, 23], [9, 25], [9, 26], [9, 28], [10, 11], [10, 15], [10, 17], [10, 21], [10, 22], [10, 26], [10, 28], [11, 13], [11, 14], [11, 22], [11, 27], [12, 16], [12, 17], [12, 18], [12, 20], [12, 23], [12, 24], [12, 25], [12, 28], [12, 29], [13, 14], [13, 15], [13, 18], [13, 21], [13, 22], [13, 23], [13, 27], [13, 29], [14, 15], [14, 19], [14, 21], [14, 24], [15, 18], [15, 21], [15, 23], [15, 24], [15, 27], [15, 28], [16, 22], [16, 24], [16, 27], [16, 29], [17, 20], [17, 23], [17, 25], [17, 29], [18, 24], [18, 28], [19, 24], [19, 25], [19, 26], [19, 27], [20, 26], [20, 28], [20, 29], [21, 24], [21, 26], [21, 28], [21, 29], [23, 29], [24, 26], [24, 28], [25, 26], [25, 28], [26, 28], [26, 29]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l2-s4/tests/run.py b/tasks/construct-nppc-dominating-set-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-dominating-set-l2-s4/tests/test.sh b/tasks/construct-nppc-dominating-set-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l2-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-dominating-set-l6-s2/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-dominating-set-l6-s2/environment/instance.json b/tasks/construct-nppc-dominating-set-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..09fd3ea0fb1962bc8a749dd4be8ed894565ddbbe --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 300, "k": 20, "edges": [[0, 8], [0, 12], [0, 40], [0, 44], [0, 79], [0, 80], [0, 86], [0, 141], [0, 145], [0, 148], [0, 176], [0, 205], [0, 212], [0, 244], [0, 282], [0, 287], [1, 12], [1, 17], [1, 21], [1, 25], [1, 34], [1, 91], [1, 98], [1, 104], [1, 108], [1, 137], [1, 159], [1, 168], [1, 179], [1, 183], [1, 212], [1, 213], [1, 229], [1, 233], [1, 264], [1, 277], [1, 280], [1, 284], [1, 286], [1, 287], [1, 297], [2, 5], [2, 9], [2, 10], [2, 38], [2, 52], [2, 53], [2, 58], [2, 101], [2, 132], [2, 133], [2, 151], [2, 152], [2, 160], [2, 253], [2, 271], [2, 282], [3, 7], [3, 49], [3, 55], [3, 65], [3, 69], [3, 89], [3, 93], [3, 134], [3, 195], [3, 208], [3, 216], [3, 290], [4, 21], [4, 23], [4, 47], [4, 92], [4, 101], [4, 118], [4, 144], [4, 154], [4, 164], [4, 172], [4, 176], [4, 181], [4, 192], [4, 195], [4, 196], [4, 203], [4, 214], [4, 215], [4, 225], [4, 247], [4, 249], [4, 265], [4, 275], [4, 298], [5, 8], [5, 28], [5, 60], [5, 64], [5, 73], [5, 102], [5, 108], [5, 132], [5, 156], [5, 157], [5, 172], [5, 175], [5, 199], [5, 200], [5, 201], [5, 202], [5, 234], [5, 244], [5, 259], [5, 272], [5, 298], [6, 21], [6, 37], [6, 38], [6, 52], [6, 56], [6, 57], [6, 71], [6, 82], [6, 89], [6, 126], [6, 142], [6, 147], [6, 154], [6, 161], [6, 164], [6, 188], [6, 230], [6, 245], [6, 275], [6, 290], [7, 34], [7, 50], [7, 54], [7, 81], [7, 194], [7, 234], [7, 237], [7, 240], [7, 242], [7, 244], [7, 253], [7, 255], [7, 274], [7, 285], [7, 291], [7, 296], [8, 17], [8, 29], [8, 35], [8, 54], [8, 57], [8, 87], [8, 103], [8, 117], [8, 142], [8, 145], [8, 180], [8, 194], [8, 221], [8, 229], [8, 237], [8, 255], [8, 268], [8, 284], [9, 42], [9, 47], [9, 59], [9, 69], [9, 123], [9, 133], [9, 165], [9, 167], [9, 210], [9, 225], [9, 241], [10, 12], [10, 16], [10, 37], [10, 58], [10, 130], [10, 148], [10, 152], [10, 153], [10, 158], [10, 169], [10, 201], [10, 223], [10, 227], [10, 244], [10, 269], [11, 15], [11, 33], [11, 46], [11, 67], [11, 71], [11, 104], [11, 132], [11, 151], [11, 154], [11, 189], [11, 191], [11, 230], [11, 261], [11, 278], [11, 284], [11, 285], [12, 19], [12, 28], [12, 48], [12, 50], [12, 59], [12, 81], [12, 91], [12, 97], [12, 124], [12, 153], [12, 163], [12, 167], [12, 196], [12, 205], [12, 207], [12, 214], [12, 215], [12, 229], [12, 234], [12, 243], [12, 262], [12, 267], [13, 41], [13, 84], [13, 88], [13, 89], [13, 94], [13, 126], [13, 137], [13, 154], [13, 155], [13, 184], [13, 274], [13, 278], [13, 289], [14, 19], [14, 36], [14, 42], [14, 56], [14, 60], [14, 78], [14, 119], [14, 126], [14, 140], [14, 240], [14, 290], [14, 293], [15, 60], [15, 77], [15, 113], [15, 137], [15, 148], [15, 151], [15, 164], [15, 168], [15, 176], [15, 194], [15, 195], [15, 241], [15, 266], [15, 268], [15, 291], [15, 292], [16, 70], [16, 74], [16, 82], [16, 88], [16, 112], [16, 118], [16, 133], [16, 190], [16, 195], [16, 199], [16, 233], [16, 234], [16, 238], [16, 259], [16, 273], [16, 299], [17, 35], [17, 66], [17, 77], [17, 79], [17, 84], [17, 97], [17, 116], [17, 127], [17, 148], [17, 156], [17, 159], [17, 168], [17, 172], [17, 199], [17, 216], [17, 238], [17, 260], [17, 265], [18, 64], [18, 76], [18, 84], [18, 112], [18, 118], [18, 122], [18, 128], [18, 134], [18, 152], [18, 188], [18, 197], [18, 216], [18, 220], [18, 225], [18, 241], [18, 256], [18, 285], [18, 289], [18, 294], [19, 57], [19, 59], [19, 60], [19, 61], [19, 65], [19, 122], [19, 128], [19, 200], [19, 203], [19, 225], [19, 266], [19, 274], [19, 280], [20, 75], [20, 86], [20, 116], [20, 129], [20, 146], [20, 174], [20, 206], [20, 218], [20, 228], [20, 236], [20, 237], [20, 255], [20, 277], [20, 280], [20, 290], [21, 23], [21, 31], [21, 32], [21, 43], [21, 54], [21, 59], [21, 78], [21, 87], [21, 90], [21, 115], [21, 138], [21, 141], [21, 142], [21, 173], [21, 179], [21, 196], [21, 199], [21, 210], [21, 217], [21, 238], [21, 243], [21, 250], [21, 263], [21, 283], [21, 284], [22, 55], [22, 61], [22, 70], [22, 81], [22, 97], [22, 111], [22, 112], [22, 114], [22, 115], [22, 126], [22, 182], [22, 191], [22, 225], [22, 230], [22, 296], [23, 37], [23, 40], [23, 62], [23, 66], [23, 93], [23, 119], [23, 126], [23, 159], [23, 167], [23, 176], [23, 179], [23, 199], [23, 212], [23, 224], [23, 231], [23, 233], [23, 237], [23, 254], [23, 255], [23, 269], [23, 270], [23, 272], [23, 285], [24, 26], [24, 51], [24, 55], [24, 59], [24, 67], [24, 87], [24, 97], [24, 117], [24, 174], [24, 191], [24, 195], [24, 221], [24, 234], [24, 238], [24, 246], [24, 249], [24, 252], [24, 272], [24, 290], [25, 40], [25, 94], [25, 108], [25, 136], [25, 152], [25, 165], [25, 167], [25, 181], [25, 205], [25, 207], [25, 214], [25, 218], [25, 220], [25, 254], [25, 255], [25, 267], [25, 272], [25, 274], [25, 282], [26, 53], [26, 54], [26, 60], [26, 78], [26, 94], [26, 104], [26, 108], [26, 123], [26, 125], [26, 131], [26, 137], [26, 138], [26, 142], [26, 153], [26, 158], [26, 179], [26, 181], [26, 195], [26, 203], [26, 210], [26, 211], [26, 216], [26, 219], [26, 225], [26, 240], [26, 244], [27, 115], [27, 129], [27, 132], [27, 151], [27, 185], [27, 195], [27, 208], [27, 228], [27, 243], [27, 287], [27, 288], [28, 33], [28, 48], [28, 59], [28, 68], [28, 92], [28, 100], [28, 106], [28, 137], [28, 157], [28, 183], [28, 186], [28, 198], [28, 228], [28, 244], [28, 259], [28, 281], [28, 294], [28, 295], [28, 299], [29, 34], [29, 40], [29, 44], [29, 52], [29, 69], [29, 88], [29, 105], [29, 136], [29, 137], [29, 141], [29, 146], [29, 154], [29, 162], [29, 193], [29, 208], [29, 245], [29, 297], [29, 298], [30, 47], [30, 76], [30, 82], [30, 84], [30, 85], [30, 97], [30, 114], [30, 115], [30, 168], [30, 171], [30, 200], [30, 217], [30, 221], [30, 223], [30, 236], [30, 242], [30, 251], [30, 255], [31, 33], [31, 41], [31, 55], [31, 84], [31, 132], [31, 157], [31, 182], [31, 202], [31, 224], [31, 225], [31, 281], [31, 297], [32, 35], [32, 57], [32, 64], [32, 124], [32, 138], [32, 158], [32, 176], [32, 181], [32, 190], [32, 218], [32, 245], [32, 262], [33, 35], [33, 38], [33, 69], [33, 77], [33, 82], [33, 85], [33, 121], [33, 144], [33, 167], [33, 173], [33, 196], [33, 211], [33, 212], [33, 218], [33, 224], [33, 254], [33, 257], [33, 262], [33, 276], [33, 278], [33, 287], [34, 49], [34, 51], [34, 60], [34, 73], [34, 109], [34, 148], [34, 171], [34, 192], [34, 196], [34, 204], [34, 210], [34, 240], [34, 244], [35, 49], [35, 53], [35, 70], [35, 111], [35, 113], [35, 140], [35, 156], [35, 219], [35, 243], [35, 245], [35, 267], [35, 294], [36, 61], [36, 67], [36, 127], [36, 148], [36, 170], [36, 176], [36, 178], [36, 202], [36, 211], [36, 227], [36, 238], [36, 248], [36, 259], [36, 270], [36, 285], [37, 39], [37, 62], [37, 64], [37, 124], [37, 127], [37, 136], [37, 179], [37, 181], [37, 189], [37, 200], [37, 220], [37, 226], [37, 252], [37, 268], [38, 58], [38, 59], [38, 65], [38, 70], [38, 72], [38, 79], [38, 90], [38, 112], [38, 119], [38, 156], [38, 157], [38, 166], [38, 171], [38, 175], [38, 181], [38, 193], [38, 205], [38, 211], [38, 228], [38, 229], [38, 264], [38, 265], [38, 281], [38, 283], [38, 287], [39, 45], [39, 81], [39, 86], [39, 90], [39, 149], [39, 152], [39, 196], [39, 270], [40, 64], [40, 71], [40, 77], [40, 114], [40, 150], [40, 152], [40, 164], [40, 175], [40, 235], [40, 238], [40, 282], [41, 43], [41, 86], [41, 91], [41, 95], [41, 109], [41, 133], [41, 142], [41, 143], [41, 150], [41, 168], [41, 176], [41, 182], [41, 197], [41, 207], [41, 226], [41, 262], [41, 270], [41, 281], [41, 286], [41, 289], [42, 43], [42, 86], [42, 118], [42, 148], [42, 169], [42, 199], [42, 232], [42, 258], [42, 266], [42, 276], [43, 47], [43, 48], [43, 49], [43, 86], [43, 95], [43, 99], [43, 125], [43, 145], [43, 147], [43, 154], [43, 175], [43, 201], [43, 219], [43, 226], [43, 239], [44, 48], [44, 52], [44, 58], [44, 70], [44, 81], [44, 93], [44, 101], [44, 102], [44, 104], [44, 105], [44, 122], [44, 144], [44, 173], [44, 177], [44, 179], [44, 185], [44, 189], [44, 193], [44, 194], [44, 195], [44, 196], [44, 236], [44, 244], [45, 53], [45, 55], [45, 81], [45, 140], [45, 168], [45, 208], [45, 244], [45, 279], [45, 280], [45, 298], [46, 60], [46, 66], [46, 85], [46, 99], [46, 143], [46, 154], [46, 164], [46, 169], [46, 172], [46, 188], [46, 204], [46, 240], [46, 248], [46, 259], [46, 260], [46, 295], [46, 299], [47, 94], [47, 102], [47, 133], [47, 159], [47, 170], [47, 188], [47, 207], [47, 217], [47, 218], [47, 231], [47, 235], [47, 238], [47, 260], [47, 293], [47, 294], [48, 54], [48, 67], [48, 84], [48, 117], [48, 118], [48, 152], [48, 164], [48, 165], [48, 177], [48, 183], [48, 189], [48, 238], [48, 244], [48, 255], [48, 286], [49, 59], [49, 64], [49, 80], [49, 88], [49, 91], [49, 137], [49, 158], [49, 166], [49, 172], [49, 191], [49, 219], [49, 226], [49, 252], [49, 276], [49, 279], [49, 289], [49, 294], [49, 295], [49, 297], [50, 51], [50, 53], [50, 71], [50, 72], [50, 73], [50, 86], [50, 96], [50, 121], [50, 154], [50, 195], [50, 216], [50, 228], [50, 269], [50, 273], [50, 299], [51, 86], [51, 116], [51, 126], [51, 131], [51, 137], [51, 148], [51, 196], [51, 200], [51, 212], [51, 229], [51, 231], [51, 264], [52, 54], [52, 63], [52, 64], [52, 66], [52, 74], [52, 78], [52, 94], [52, 95], [52, 96], [52, 106], [52, 108], [52, 123], [52, 128], [52, 140], [52, 145], [52, 155], [52, 156], [52, 161], [52, 176], [52, 179], [52, 185], [52, 218], [52, 223], [52, 244], [52, 253], [52, 266], [52, 275], [52, 278], [52, 282], [53, 63], [53, 73], [53, 83], [53, 125], [53, 133], [53, 164], [53, 177], [53, 201], [53, 208], [53, 210], [53, 211], [53, 213], [53, 242], [53, 253], [53, 257], [53, 268], [53, 286], [53, 291], [54, 59], [54, 101], [54, 114], [54, 134], [54, 158], [54, 167], [54, 190], [54, 193], [54, 199], [54, 231], [54, 233], [54, 278], [54, 292], [55, 75], [55, 77], [55, 94], [55, 102], [55, 118], [55, 137], [55, 144], [55, 146], [55, 152], [55, 188], [55, 214], [55, 215], [55, 216], [55, 232], [55, 246], [55, 277], [55, 285], [56, 58], [56, 63], [56, 68], [56, 73], [56, 85], [56, 91], [56, 97], [56, 102], [56, 137], [56, 148], [56, 175], [56, 269], [57, 60], [57, 71], [57, 72], [57, 120], [57, 121], [57, 127], [57, 143], [57, 152], [57, 168], [57, 195], [57, 219], [57, 220], [57, 222], [57, 228], [57, 235], [57, 252], [57, 268], [58, 77], [58, 83], [58, 89], [58, 111], [58, 126], [58, 134], [58, 148], [58, 160], [58, 164], [58, 263], [58, 277], [59, 65], [59, 106], [59, 152], [59, 170], [59, 186], [59, 209], [59, 248], [59, 264], [59, 266], [59, 267], [59, 271], [60, 61], [60, 72], [60, 77], [60, 79], [60, 86], [60, 88], [60, 94], [60, 99], [60, 113], [60, 115], [60, 116], [60, 122], [60, 150], [60, 155], [60, 167], [60, 177], [60, 210], [60, 214], [60, 227], [60, 229], [60, 231], [60, 235], [60, 239], [60, 244], [60, 265], [60, 269], [60, 274], [60, 280], [60, 281], [60, 286], [60, 287], [61, 104], [61, 114], [61, 136], [61, 142], [61, 144], [61, 189], [61, 196], [61, 205], [61, 242], [61, 243], [61, 273], [61, 277], [61, 289], [62, 69], [62, 77], [62, 81], [62, 86], [62, 99], [62, 102], [62, 110], [62, 113], [62, 114], [62, 121], [62, 130], [62, 135], [62, 164], [62, 187], [62, 226], [62, 235], [62, 255], [62, 274], [63, 74], [63, 79], [63, 110], [63, 115], [63, 147], [63, 149], [63, 189], [63, 202], [63, 210], [63, 221], [63, 228], [63, 232], [63, 238], [63, 256], [63, 270], [63, 293], [64, 94], [64, 105], [64, 112], [64, 130], [64, 137], [64, 153], [64, 168], [64, 188], [64, 192], [64, 197], [64, 199], [64, 201], [64, 234], [64, 240], [64, 241], [64, 268], [64, 277], [65, 66], [65, 70], [65, 98], [65, 99], [65, 112], [65, 114], [65, 115], [65, 140], [65, 149], [65, 171], [65, 180], [65, 197], [65, 210], [65, 222], [65, 246], [65, 256], [66, 72], [66, 75], [66, 80], [66, 109], [66, 110], [66, 134], [66, 141], [66, 149], [66, 170], [66, 213], [66, 228], [66, 239], [66, 242], [66, 246], [66, 256], [66, 257], [66, 265], [66, 281], [67, 110], [67, 121], [67, 124], [67, 127], [67, 134], [67, 145], [67, 146], [67, 152], [67, 154], [67, 156], [67, 161], [67, 169], [67, 184], [67, 200], [67, 209], [67, 210], [67, 234], [67, 264], [67, 282], [67, 298], [68, 70], [68, 72], [68, 95], [68, 104], [68, 111], [68, 164], [68, 168], [68, 184], [68, 197], [68, 199], [68, 222], [68, 272], [68, 295], [68, 299], [69, 79], [69, 95], [69, 118], [69, 141], [69, 195], [69, 210], [69, 226], [69, 240], [69, 242], [69, 253], [69, 267], [69, 269], [69, 282], [70, 89], [70, 96], [70, 100], [70, 124], [70, 132], [70, 133], [70, 140], [70, 160], [70, 175], [70, 176], [70, 178], [70, 182], [70, 190], [70, 198], [70, 201], [70, 202], [70, 209], [70, 213], [70, 217], [70, 225], [70, 234], [70, 237], [70, 262], [70, 269], [70, 293], [71, 74], [71, 80], [71, 91], [71, 122], [71, 149], [71, 150], [71, 152], [71, 188], [71, 205], [71, 208], [71, 216], [71, 217], [71, 240], [71, 243], [71, 286], [71, 288], [71, 296], [72, 92], [72, 97], [72, 99], [72, 127], [72, 179], [72, 183], [72, 184], [72, 190], [72, 203], [72, 222], [72, 249], [72, 294], [73, 95], [73, 107], [73, 109], [73, 130], [73, 140], [73, 147], [73, 149], [73, 153], [73, 156], [73, 170], [73, 182], [73, 185], [73, 202], [73, 248], [73, 250], [73, 252], [73, 254], [73, 256], [73, 271], [74, 80], [74, 100], [74, 104], [74, 112], [74, 163], [74, 167], [74, 199], [74, 218], [74, 221], [74, 235], [74, 246], [74, 247], [74, 261], [74, 277], [74, 283], [74, 285], [75, 104], [75, 118], [75, 131], [75, 132], [75, 136], [75, 138], [75, 166], [75, 167], [75, 186], [75, 214], [75, 219], [75, 231], [75, 248], [75, 255], [75, 268], [75, 270], [75, 272], [75, 285], [76, 91], [76, 100], [76, 109], [76, 131], [76, 148], [76, 180], [76, 182], [76, 216], [76, 244], [76, 255], [76, 265], [76, 275], [76, 277], [77, 85], [77, 87], [77, 103], [77, 129], [77, 148], [77, 152], [77, 154], [77, 171], [77, 182], [77, 215], [77, 253], [77, 288], [78, 91], [78, 106], [78, 119], [78, 133], [78, 138], [78, 140], [78, 182], [78, 191], [78, 195], [78, 219], [78, 227], [78, 228], [78, 239], [78, 254], [78, 274], [78, 283], [79, 122], [79, 138], [79, 158], [79, 166], [79, 173], [79, 199], [79, 209], [79, 219], [79, 222], [79, 242], [79, 255], [79, 264], [79, 268], [80, 81], [80, 93], [80, 96], [80, 107], [80, 110], [80, 137], [80, 147], [80, 171], [80, 193], [80, 195], [80, 204], [80, 206], [80, 225], [80, 235], [80, 264], [80, 296], [80, 298], [81, 114], [81, 129], [81, 147], [81, 175], [81, 184], [81, 215], [81, 217], [81, 236], [81, 238], [81, 241], [81, 242], [81, 251], [81, 255], [81, 265], [81, 268], [81, 291], [81, 292], [81, 293], [82, 95], [82, 106], [82, 117], [82, 124], [82, 146], [82, 156], [82, 165], [82, 174], [82, 190], [82, 194], [82, 228], [82, 245], [82, 252], [82, 261], [82, 262], [82, 266], [82, 273], [82, 275], [82, 295], [83, 100], [83, 108], [83, 114], [83, 121], [83, 137], [83, 148], [83, 156], [83, 169], [83, 184], [83, 186], [83, 196], [83, 226], [83, 234], [83, 250], [83, 273], [84, 134], [84, 148], [84, 151], [84, 197], [84, 198], [84, 201], [84, 202], [84, 273], [84, 280], [85, 98], [85, 99], [85, 109], [85, 116], [85, 120], [85, 148], [85, 201], [85, 223], [85, 224], [85, 238], [85, 252], [85, 253], [85, 288], [85, 294], [86, 125], [86, 140], [86, 194], [86, 195], [86, 208], [86, 211], [86, 256], [86, 267], [86, 280], [86, 282], [86, 287], [86, 297], [86, 299], [87, 94], [87, 103], [87, 117], [87, 125], [87, 157], [87, 159], [87, 162], [87, 172], [87, 173], [87, 205], [87, 208], [87, 210], [87, 225], [87, 230], [87, 235], [87, 236], [87, 238], [87, 251], [87, 277], [88, 122], [88, 124], [88, 133], [88, 173], [88, 200], [88, 201], [88, 218], [88, 245], [88, 269], [88, 284], [88, 291], [89, 103], [89, 115], [89, 133], [89, 154], [89, 195], [89, 218], [89, 276], [89, 285], [89, 295], [90, 129], [90, 131], [90, 192], [90, 198], [90, 199], [90, 224], [90, 226], [90, 238], [90, 253], [90, 258], [90, 283], [90, 287], [90, 292], [91, 93], [91, 98], [91, 106], [91, 112], [91, 125], [91, 126], [91, 131], [91, 140], [91, 149], [91, 151], [91, 153], [91, 182], [91, 200], [91, 221], [91, 222], [91, 243], [91, 245], [91, 254], [91, 275], [91, 285], [91, 292], [91, 297], [92, 113], [92, 128], [92, 135], [92, 140], [92, 161], [92, 162], [92, 163], [92, 164], [92, 216], [92, 219], [92, 233], [92, 240], [92, 267], [92, 278], [92, 281], [92, 295], [93, 111], [93, 124], [93, 137], [93, 157], [93, 186], [93, 189], [93, 196], [93, 260], [93, 263], [93, 268], [93, 275], [94, 155], [94, 163], [94, 168], [94, 174], [94, 195], [94, 207], [94, 258], [94, 273], [94, 276], [94, 289], [94, 296], [95, 103], [95, 124], [95, 140], [95, 145], [95, 151], [95, 153], [95, 170], [95, 183], [95, 197], [95, 205], [95, 215], [95, 222], [95, 244], [95, 246], [95, 273], [95, 289], [95, 291], [96, 104], [96, 139], [96, 146], [96, 152], [96, 173], [96, 189], [96, 208], [96, 211], [96, 222], [96, 235], [96, 241], [96, 270], [96, 274], [96, 297], [97, 118], [97, 144], [97, 147], [97, 148], [97, 166], [97, 187], [97, 189], [97, 196], [97, 201], [97, 212], [97, 213], [97, 217], [97, 219], [97, 259], [97, 272], [97, 279], [98, 123], [98, 136], [98, 143], [98, 146], [98, 148], [98, 167], [98, 181], [98, 184], [98, 214], [98, 231], [98, 245], [98, 261], [98, 273], [98, 277], [98, 295], [99, 125], [99, 154], [99, 171], [99, 199], [99, 207], [99, 231], [99, 280], [100, 101], [100, 104], [100, 117], [100, 125], [100, 133], [100, 140], [100, 142], [100, 154], [100, 159], [100, 163], [100, 167], [100, 197], [100, 198], [100, 199], [100, 208], [100, 230], [100, 237], [100, 238], [100, 251], [100, 270], [100, 291], [101, 104], [101, 129], [101, 134], [101, 149], [101, 169], [101, 201], [101, 209], [101, 220], [101, 232], [101, 234], [101, 246], [101, 271], [101, 275], [102, 106], [102, 137], [102, 148], [102, 158], [102, 164], [102, 184], [102, 189], [102, 193], [102, 197], [102, 205], [102, 241], [102, 259], [102, 264], [102, 267], [103, 104], [103, 122], [103, 178], [103, 189], [103, 221], [103, 223], [103, 251], [103, 254], [103, 269], [103, 273], [103, 274], [104, 106], [104, 120], [104, 125], [104, 159], [104, 236], [104, 248], [104, 268], [104, 277], [104, 293], [105, 128], [105, 129], [105, 163], [105, 164], [105, 173], [105, 176], [105, 178], [105, 184], [105, 188], [105, 229], [105, 244], [105, 256], [105, 275], [105, 293], [106, 107], [106, 116], [106, 117], [106, 124], [106, 165], [106, 167], [106, 182], [106, 184], [106, 191], [106, 216], [106, 224], [106, 251], [106, 254], [106, 261], [106, 285], [106, 290], [106, 296], [107, 114], [107, 128], [107, 131], [107, 139], [107, 143], [107, 149], [107, 152], [107, 167], [107, 177], [107, 181], [107, 191], [107, 194], [107, 217], [107, 224], [107, 237], [107, 247], [107, 261], [107, 263], [107, 267], [107, 278], [107, 283], [108, 111], [108, 150], [108, 176], [108, 183], [108, 186], [108, 219], [108, 234], [109, 111], [109, 129], [109, 152], [109, 154], [109, 170], [109, 218], [109, 232], [109, 255], [109, 259], [109, 262], [109, 272], [109, 295], [110, 112], [110, 123], [110, 124], [110, 125], [110, 137], [110, 147], [110, 153], [110, 163], [110, 177], [110, 200], [110, 220], [110, 245], [110, 258], [110, 272], [110, 285], [110, 293], [111, 114], [111, 125], [111, 134], [111, 152], [111, 173], [111, 174], [111, 190], [111, 192], [111, 194], [111, 204], [111, 206], [111, 220], [111, 229], [111, 230], [111, 232], [111, 233], [111, 254], [111, 257], [111, 258], [111, 279], [111, 284], [111, 293], [111, 294], [112, 121], [112, 147], [112, 151], [112, 155], [112, 161], [112, 171], [112, 177], [112, 179], [112, 191], [112, 197], [112, 200], [112, 242], [112, 279], [112, 282], [112, 292], [112, 294], [113, 117], [113, 118], [113, 202], [113, 248], [113, 281], [114, 122], [114, 133], [114, 153], [114, 157], [114, 161], [114, 171], [114, 177], [114, 228], [114, 229], [114, 232], [114, 246], [114, 251], [114, 266], [114, 275], [114, 290], [114, 291], [115, 144], [115, 181], [115, 190], [115, 196], [115, 202], [115, 203], [115, 219], [115, 222], [115, 236], [116, 132], [116, 138], [116, 151], [116, 152], [116, 158], [116, 165], [116, 168], [116, 176], [116, 234], [116, 235], [116, 258], [116, 274], [116, 283], [117, 125], [117, 135], [117, 137], [117, 139], [117, 158], [117, 175], [117, 183], [117, 194], [117, 200], [117, 211], [117, 238], [117, 251], [117, 280], [117, 292], [118, 162], [118, 167], [118, 168], [118, 187], [118, 191], [118, 192], [118, 193], [118, 237], [118, 283], [118, 288], [119, 191], [119, 202], [119, 254], [119, 277], [120, 123], [120, 133], [120, 147], [120, 163], [120, 172], [120, 178], [120, 191], [120, 213], [120, 229], [120, 231], [120, 236], [120, 244], [120, 265], [121, 153], [121, 164], [121, 195], [121, 212], [121, 226], [121, 249], [121, 257], [121, 260], [122, 127], [122, 141], [122, 142], [122, 146], [122, 156], [122, 157], [122, 161], [122, 162], [122, 172], [122, 182], [122, 217], [122, 241], [122, 254], [122, 257], [122, 277], [122, 283], [122, 296], [123, 128], [123, 175], [123, 179], [123, 183], [123, 187], [123, 188], [123, 193], [123, 196], [123, 215], [123, 225], [123, 247], [123, 248], [123, 284], [124, 127], [124, 143], [124, 145], [124, 151], [124, 156], [124, 159], [124, 161], [124, 163], [124, 183], [124, 187], [124, 197], [124, 228], [124, 236], [124, 241], [124, 249], [124, 251], [124, 260], [124, 262], [124, 263], [124, 266], [124, 269], [124, 284], [124, 288], [124, 299], [125, 166], [125, 174], [125, 188], [125, 231], [125, 289], [126, 137], [126, 148], [126, 153], [126, 161], [126, 171], [126, 176], [126, 198], [126, 213], [126, 215], [126, 220], [126, 222], [126, 232], [126, 241], [126, 248], [126, 253], [126, 256], [126, 260], [126, 263], [127, 139], [127, 151], [127, 180], [127, 216], [127, 231], [127, 232], [127, 242], [127, 244], [127, 267], [127, 275], [127, 289], [128, 136], [128, 137], [128, 172], [128, 191], [128, 194], [128, 218], [128, 229], [128, 233], [128, 242], [128, 244], [128, 290], [129, 133], [129, 155], [129, 157], [129, 184], [129, 191], [129, 239], [129, 262], [129, 294], [129, 297], [129, 298], [130, 148], [130, 151], [130, 166], [130, 185], [130, 222], [130, 223], [130, 262], [130, 296], [131, 137], [131, 146], [131, 154], [131, 164], [131, 175], [131, 178], [131, 180], [131, 213], [131, 237], [131, 257], [131, 261], [131, 269], [131, 289], [132, 165], [132, 184], [132, 189], [132, 219], [132, 229], [132, 243], [132, 261], [132, 293], [133, 157], [133, 175], [133, 178], [133, 181], [133, 184], [133, 191], [133, 204], [133, 207], [133, 212], [133, 216], [133, 219], [133, 247], [133, 258], [133, 267], [133, 272], [133, 277], [133, 278], [134, 151], [134, 191], [134, 193], [134, 195], [134, 207], [134, 216], [134, 219], [134, 288], [134, 291], [135, 156], [135, 163], [135, 164], [135, 168], [135, 229], [135, 264], [135, 273], [135, 280], [136, 144], [136, 148], [136, 171], [136, 184], [136, 222], [136, 236], [136, 268], [136, 277], [136, 293], [137, 157], [137, 191], [137, 209], [137, 221], [137, 225], [137, 226], [137, 232], [137, 238], [137, 276], [137, 281], [137, 295], [137, 297], [138, 142], [138, 148], [138, 177], [138, 180], [138, 216], [138, 224], [138, 233], [138, 242], [138, 261], [138, 262], [138, 265], [138, 277], [138, 287], [139, 146], [139, 149], [139, 158], [139, 171], [139, 183], [139, 189], [139, 208], [139, 216], [139, 227], [139, 238], [139, 264], [139, 285], [140, 152], [140, 184], [140, 199], [140, 208], [140, 222], [140, 278], [140, 291], [141, 160], [141, 163], [141, 179], [141, 185], [141, 201], [141, 204], [141, 208], [141, 213], [141, 216], [141, 220], [141, 239], [141, 272], [141, 294], [142, 157], [142, 171], [142, 180], [142, 187], [142, 199], [142, 204], [142, 213], [142, 229], [142, 238], [142, 274], [143, 152], [143, 161], [143, 196], [143, 236], [143, 238], [143, 245], [143, 247], [143, 264], [143, 276], [143, 279], [143, 284], [144, 147], [144, 148], [144, 181], [144, 195], [144, 197], [144, 242], [144, 245], [144, 260], [144, 269], [144, 286], [144, 294], [145, 149], [145, 151], [145, 156], [145, 164], [145, 173], [145, 198], [145, 210], [145, 227], [145, 248], [145, 272], [145, 274], [145, 275], [145, 295], [146, 150], [146, 153], [146, 170], [146, 172], [146, 177], [146, 187], [146, 190], [146, 213], [146, 222], [146, 228], [146, 234], [146, 248], [146, 250], [146, 252], [146, 263], [146, 286], [146, 288], [146, 298], [147, 148], [147, 155], [147, 195], [147, 216], [147, 226], [147, 278], [147, 279], [147, 298], [148, 150], [148, 198], [148, 207], [148, 214], [148, 234], [148, 245], [148, 246], [148, 248], [148, 256], [148, 260], [148, 267], [148, 278], [149, 162], [149, 167], [149, 169], [149, 170], [149, 171], [149, 183], [149, 184], [149, 194], [149, 203], [149, 212], [149, 224], [149, 253], [149, 269], [149, 272], [150, 159], [150, 172], [150, 184], [150, 201], [150, 203], [150, 235], [150, 259], [150, 266], [150, 279], [150, 284], [150, 285], [151, 184], [151, 194], [151, 196], [151, 202], [151, 221], [151, 232], [151, 237], [151, 238], [151, 246], [151, 269], [151, 277], [152, 163], [152, 171], [152, 181], [152, 193], [152, 194], [152, 206], [152, 215], [152, 227], [152, 230], [152, 235], [152, 241], [152, 259], [152, 267], [152, 268], [152, 274], [152, 279], [153, 162], [153, 247], [153, 250], [153, 260], [153, 265], [153, 268], [153, 275], [153, 276], [153, 285], [153, 290], [154, 158], [154, 160], [154, 164], [154, 167], [154, 179], [154, 202], [154, 240], [154, 248], [154, 282], [154, 298], [155, 157], [155, 184], [155, 194], [155, 197], [155, 209], [155, 211], [155, 267], [155, 275], [155, 278], [155, 297], [156, 157], [156, 169], [156, 194], [156, 197], [156, 249], [156, 256], [156, 290], [157, 163], [157, 164], [157, 200], [157, 207], [157, 233], [157, 234], [157, 235], [157, 292], [157, 293], [158, 168], [158, 184], [158, 225], [158, 226], [158, 228], [158, 263], [158, 274], [158, 284], [158, 286], [158, 290], [159, 170], [159, 191], [159, 194], [159, 199], [159, 217], [159, 230], [159, 244], [159, 257], [159, 277], [159, 294], [160, 187], [160, 234], [160, 238], [160, 255], [160, 269], [160, 292], [160, 294], [160, 297], [161, 183], [161, 197], [161, 210], [161, 281], [162, 168], [162, 194], [162, 195], [162, 212], [162, 226], [162, 229], [162, 232], [162, 234], [162, 275], [162, 284], [163, 175], [163, 252], [163, 257], [163, 282], [163, 286], [163, 298], [164, 172], [164, 180], [164, 184], [164, 198], [164, 239], [164, 257], [164, 261], [164, 275], [164, 277], [164, 282], [165, 169], [165, 181], [165, 187], [165, 191], [165, 195], [165, 197], [165, 269], [165, 271], [165, 272], [165, 275], [165, 294], [166, 189], [166, 197], [166, 208], [166, 229], [166, 293], [167, 170], [167, 176], [167, 183], [167, 204], [167, 220], [167, 236], [167, 258], [167, 261], [167, 277], [167, 285], [167, 289], [168, 189], [168, 240], [168, 241], [168, 242], [168, 247], [168, 254], [168, 271], [168, 277], [168, 285], [168, 292], [168, 295], [168, 296], [169, 170], [169, 175], [169, 263], [169, 271], [169, 298], [169, 299], [170, 173], [170, 183], [170, 231], [170, 263], [170, 275], [170, 277], [170, 280], [170, 285], [171, 180], [171, 185], [171, 197], [171, 221], [171, 235], [171, 236], [171, 237], [171, 242], [171, 259], [171, 263], [172, 206], [172, 211], [172, 227], [172, 250], [172, 279], [172, 289], [173, 190], [173, 220], [173, 248], [173, 265], [173, 274], [173, 277], [173, 278], [174, 208], [174, 215], [174, 223], [174, 237], [174, 273], [174, 278], [175, 176], [175, 184], [175, 185], [175, 206], [175, 238], [175, 247], [175, 291], [176, 213], [176, 241], [176, 264], [176, 266], [176, 280], [176, 291], [177, 184], [177, 188], [177, 190], [177, 193], [177, 197], [177, 206], [177, 216], [177, 218], [177, 229], [177, 240], [177, 247], [177, 264], [177, 269], [178, 188], [178, 190], [178, 204], [178, 273], [179, 189], [179, 196], [179, 200], [179, 212], [179, 235], [179, 237], [179, 266], [180, 195], [180, 198], [180, 199], [180, 255], [180, 257], [180, 264], [180, 274], [180, 279], [180, 288], [180, 289], [180, 294], [181, 184], [181, 196], [181, 218], [181, 263], [182, 232], [182, 236], [182, 243], [182, 246], [182, 283], [182, 289], [183, 193], [183, 194], [183, 195], [183, 200], [183, 201], [183, 208], [183, 228], [183, 229], [183, 250], [183, 263], [183, 265], [183, 274], [184, 196], [184, 216], [184, 228], [184, 258], [184, 266], [184, 267], [184, 273], [185, 195], [185, 199], [185, 208], [185, 217], [185, 219], [185, 221], [185, 247], [185, 259], [185, 277], [185, 285], [185, 294], [186, 188], [186, 204], [186, 218], [186, 225], [186, 226], [186, 227], [186, 244], [186, 267], [186, 277], [186, 284], [186, 291], [186, 299], [187, 209], [187, 216], [187, 225], [187, 233], [187, 247], [187, 258], [187, 273], [187, 294], [187, 299], [188, 208], [188, 220], [188, 247], [188, 267], [188, 294], [189, 220], [189, 231], [189, 236], [190, 207], [190, 217], [190, 233], [190, 252], [190, 277], [190, 291], [190, 295], [191, 192], [191, 255], [192, 204], [192, 241], [192, 242], [192, 254], [192, 258], [192, 285], [192, 298], [193, 203], [193, 206], [193, 221], [193, 242], [193, 244], [193, 246], [193, 274], [193, 276], [194, 202], [194, 206], [194, 249], [194, 277], [194, 281], [194, 291], [195, 202], [195, 207], [195, 216], [195, 217], [195, 218], [195, 241], [195, 267], [195, 270], [195, 290], [195, 297], [196, 206], [196, 242], [196, 250], [196, 262], [196, 298], [197, 199], [197, 230], [197, 252], [197, 256], [197, 260], [197, 277], [197, 289], [198, 199], [198, 201], [198, 229], [199, 226], [199, 240], [199, 245], [199, 252], [199, 266], [199, 268], [199, 277], [199, 285], [200, 210], [200, 221], [200, 253], [200, 255], [200, 283], [201, 240], [201, 242], [201, 254], [201, 258], [201, 259], [201, 261], [202, 228], [202, 237], [202, 261], [202, 262], [202, 272], [202, 277], [202, 287], [203, 224], [203, 227], [203, 230], [203, 256], [203, 297], [203, 299], [204, 216], [204, 226], [204, 240], [204, 279], [205, 210], [205, 234], [205, 236], [205, 269], [205, 276], [205, 285], [205, 289], [206, 208], [206, 233], [206, 239], [206, 250], [206, 259], [206, 262], [206, 269], [206, 282], [206, 287], [207, 208], [207, 209], [207, 240], [207, 246], [207, 265], [207, 288], [208, 212], [208, 215], [208, 217], [208, 241], [208, 251], [208, 284], [208, 290], [208, 298], [209, 210], [209, 234], [209, 243], [209, 257], [209, 263], [209, 268], [209, 269], [209, 285], [210, 226], [210, 243], [210, 245], [210, 249], [210, 256], [210, 278], [211, 217], [211, 248], [211, 288], [211, 289], [211, 296], [212, 250], [212, 297], [213, 226], [213, 239], [213, 286], [214, 250], [214, 257], [214, 274], [215, 216], [215, 219], [215, 249], [215, 257], [215, 272], [215, 296], [216, 241], [216, 253], [217, 238], [217, 242], [217, 257], [217, 263], [217, 269], [217, 285], [217, 299], [218, 222], [218, 237], [218, 255], [219, 222], [219, 230], [219, 242], [219, 264], [219, 269], [219, 296], [220, 244], [220, 255], [220, 297], [221, 253], [221, 256], [221, 259], [221, 272], [221, 280], [221, 283], [221, 284], [221, 286], [222, 224], [222, 248], [222, 260], [222, 277], [222, 280], [222, 281], [223, 227], [223, 232], [223, 233], [223, 240], [223, 243], [223, 249], [223, 278], [223, 294], [224, 248], [224, 251], [224, 264], [224, 276], [224, 278], [224, 291], [225, 235], [225, 240], [225, 268], [225, 272], [225, 283], [226, 227], [226, 233], [226, 263], [226, 265], [226, 291], [226, 299], [227, 230], [227, 232], [227, 233], [227, 239], [227, 271], [227, 278], [227, 292], [228, 234], [228, 235], [228, 258], [228, 262], [229, 230], [229, 268], [229, 295], [229, 296], [230, 248], [230, 271], [231, 246], [231, 256], [231, 262], [231, 267], [231, 275], [232, 234], [232, 269], [232, 270], [233, 241], [233, 255], [233, 269], [234, 249], [234, 279], [235, 240], [235, 250], [235, 257], [235, 272], [236, 237], [236, 244], [236, 255], [236, 274], [236, 277], [236, 279], [236, 299], [237, 244], [237, 275], [237, 287], [238, 260], [238, 283], [239, 249], [239, 287], [239, 292], [240, 244], [240, 249], [240, 254], [240, 263], [240, 283], [240, 295], [240, 299], [241, 261], [241, 262], [241, 275], [241, 279], [241, 298], [242, 257], [242, 263], [242, 279], [243, 298], [244, 263], [244, 299], [245, 252], [245, 263], [245, 265], [246, 259], [246, 264], [246, 279], [246, 292], [247, 252], [247, 267], [247, 268], [247, 279], [247, 287], [247, 297], [248, 252], [248, 255], [249, 255], [249, 274], [250, 294], [251, 263], [251, 288], [251, 289], [252, 254], [252, 255], [252, 256], [252, 265], [252, 268], [252, 273], [252, 286], [253, 260], [253, 269], [254, 258], [254, 265], [254, 279], [254, 295], [255, 268], [255, 275], [256, 261], [256, 278], [257, 283], [257, 286], [257, 292], [257, 296], [258, 271], [258, 296], [258, 298], [259, 273], [259, 275], [260, 277], [260, 291], [261, 263], [261, 273], [261, 280], [261, 282], [261, 297], [262, 280], [262, 288], [263, 264], [263, 284], [263, 287], [264, 279], [264, 284], [265, 266], [265, 280], [266, 276], [267, 299], [268, 289], [269, 288], [270, 288], [271, 279], [271, 284], [272, 276], [272, 287], [273, 290], [274, 278], [274, 283], [276, 279], [276, 286], [276, 289], [276, 293], [276, 295], [277, 279], [277, 290], [277, 297], [278, 284], [278, 291], [279, 290], [280, 295], [280, 296], [281, 289], [281, 290], [281, 298], [283, 287], [287, 291], [288, 293], [288, 296], [289, 290], [290, 291], [290, 299], [291, 297], [295, 298], [296, 299], [297, 299]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l6-s2/solution/solve.sh b/tasks/construct-nppc-dominating-set-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..676be812ad5d9c38a84395eeeaf40d4d7527122c --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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' +{"dominating_set": [21, 38, 52, 60, 67, 70, 95, 111, 124, 133, 137, 148, 149, 152, 164, 168, 195, 208, 255, 277]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l6-s2/tests/check.py b/tasks/construct-nppc-dominating-set-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s2/tests/check.py @@ -0,0 +1,23 @@ +"""Dominating set of size <= k. Accepts any valid dominating set.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier has no type/range checks (out-of-range labels and floats are silently used) + d = int_list(ans.get("dominating_set"), None, 0, n - 1, "dominating_set") + if len(set(d)) != len(d): + raise Invalid("dominating_set contains duplicates") + if not d or len(d) > k: + raise Invalid(f"dominating_set must have 1..{k} vertices, got {len(d)}") + dom = set(d) + s = set(d) + for u, v in inst["edges"]: + if u in s: + dom.add(v) + if v in s: + dom.add(u) + if len(dom) != n: + miss = min(set(range(n)) - dom) + raise Invalid(f"vertex {miss} is not dominated") + return None, {"size": len(d)} diff --git a/tasks/construct-nppc-dominating-set-l6-s2/tests/instance.json b/tasks/construct-nppc-dominating-set-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..09fd3ea0fb1962bc8a749dd4be8ed894565ddbbe --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 300, "k": 20, "edges": [[0, 8], [0, 12], [0, 40], [0, 44], [0, 79], [0, 80], [0, 86], [0, 141], [0, 145], [0, 148], [0, 176], [0, 205], [0, 212], [0, 244], [0, 282], [0, 287], [1, 12], [1, 17], [1, 21], [1, 25], [1, 34], [1, 91], [1, 98], [1, 104], [1, 108], [1, 137], [1, 159], [1, 168], [1, 179], [1, 183], [1, 212], [1, 213], [1, 229], [1, 233], [1, 264], [1, 277], [1, 280], [1, 284], [1, 286], [1, 287], [1, 297], [2, 5], [2, 9], [2, 10], [2, 38], [2, 52], [2, 53], [2, 58], [2, 101], [2, 132], [2, 133], [2, 151], [2, 152], [2, 160], [2, 253], [2, 271], [2, 282], [3, 7], [3, 49], [3, 55], [3, 65], [3, 69], [3, 89], [3, 93], [3, 134], [3, 195], [3, 208], [3, 216], [3, 290], [4, 21], [4, 23], [4, 47], [4, 92], [4, 101], [4, 118], [4, 144], [4, 154], [4, 164], [4, 172], [4, 176], [4, 181], [4, 192], [4, 195], [4, 196], [4, 203], [4, 214], [4, 215], [4, 225], [4, 247], [4, 249], [4, 265], [4, 275], [4, 298], [5, 8], [5, 28], [5, 60], [5, 64], [5, 73], [5, 102], [5, 108], [5, 132], [5, 156], [5, 157], [5, 172], [5, 175], [5, 199], [5, 200], [5, 201], [5, 202], [5, 234], [5, 244], [5, 259], [5, 272], [5, 298], [6, 21], [6, 37], [6, 38], [6, 52], [6, 56], [6, 57], [6, 71], [6, 82], [6, 89], [6, 126], [6, 142], [6, 147], [6, 154], [6, 161], [6, 164], [6, 188], [6, 230], [6, 245], [6, 275], [6, 290], [7, 34], [7, 50], [7, 54], [7, 81], [7, 194], [7, 234], [7, 237], [7, 240], [7, 242], [7, 244], [7, 253], [7, 255], [7, 274], [7, 285], [7, 291], [7, 296], [8, 17], [8, 29], [8, 35], [8, 54], [8, 57], [8, 87], [8, 103], [8, 117], [8, 142], [8, 145], [8, 180], [8, 194], [8, 221], [8, 229], [8, 237], [8, 255], [8, 268], [8, 284], [9, 42], [9, 47], [9, 59], [9, 69], [9, 123], [9, 133], [9, 165], [9, 167], [9, 210], [9, 225], [9, 241], [10, 12], [10, 16], [10, 37], [10, 58], [10, 130], [10, 148], [10, 152], [10, 153], [10, 158], [10, 169], [10, 201], [10, 223], [10, 227], [10, 244], [10, 269], [11, 15], [11, 33], [11, 46], [11, 67], [11, 71], [11, 104], [11, 132], [11, 151], [11, 154], [11, 189], [11, 191], [11, 230], [11, 261], [11, 278], [11, 284], [11, 285], [12, 19], [12, 28], [12, 48], [12, 50], [12, 59], [12, 81], [12, 91], [12, 97], [12, 124], [12, 153], [12, 163], [12, 167], [12, 196], [12, 205], [12, 207], [12, 214], [12, 215], [12, 229], [12, 234], [12, 243], [12, 262], [12, 267], [13, 41], [13, 84], [13, 88], [13, 89], [13, 94], [13, 126], [13, 137], [13, 154], [13, 155], [13, 184], [13, 274], [13, 278], [13, 289], [14, 19], [14, 36], [14, 42], [14, 56], [14, 60], [14, 78], [14, 119], [14, 126], [14, 140], [14, 240], [14, 290], [14, 293], [15, 60], [15, 77], [15, 113], [15, 137], [15, 148], [15, 151], [15, 164], [15, 168], [15, 176], [15, 194], [15, 195], [15, 241], [15, 266], [15, 268], [15, 291], [15, 292], [16, 70], [16, 74], [16, 82], [16, 88], [16, 112], [16, 118], [16, 133], [16, 190], [16, 195], [16, 199], [16, 233], [16, 234], [16, 238], [16, 259], [16, 273], [16, 299], [17, 35], [17, 66], [17, 77], [17, 79], [17, 84], [17, 97], [17, 116], [17, 127], [17, 148], [17, 156], [17, 159], [17, 168], [17, 172], [17, 199], [17, 216], [17, 238], [17, 260], [17, 265], [18, 64], [18, 76], [18, 84], [18, 112], [18, 118], [18, 122], [18, 128], [18, 134], [18, 152], [18, 188], [18, 197], [18, 216], [18, 220], [18, 225], [18, 241], [18, 256], [18, 285], [18, 289], [18, 294], [19, 57], [19, 59], [19, 60], [19, 61], [19, 65], [19, 122], [19, 128], [19, 200], [19, 203], [19, 225], [19, 266], [19, 274], [19, 280], [20, 75], [20, 86], [20, 116], [20, 129], [20, 146], [20, 174], [20, 206], [20, 218], [20, 228], [20, 236], [20, 237], [20, 255], [20, 277], [20, 280], [20, 290], [21, 23], [21, 31], [21, 32], [21, 43], [21, 54], [21, 59], [21, 78], [21, 87], [21, 90], [21, 115], [21, 138], [21, 141], [21, 142], [21, 173], [21, 179], [21, 196], [21, 199], [21, 210], [21, 217], [21, 238], [21, 243], [21, 250], [21, 263], [21, 283], [21, 284], [22, 55], [22, 61], [22, 70], [22, 81], [22, 97], [22, 111], [22, 112], [22, 114], [22, 115], [22, 126], [22, 182], [22, 191], [22, 225], [22, 230], [22, 296], [23, 37], [23, 40], [23, 62], [23, 66], [23, 93], [23, 119], [23, 126], [23, 159], [23, 167], [23, 176], [23, 179], [23, 199], [23, 212], [23, 224], [23, 231], [23, 233], [23, 237], [23, 254], [23, 255], [23, 269], [23, 270], [23, 272], [23, 285], [24, 26], [24, 51], [24, 55], [24, 59], [24, 67], [24, 87], [24, 97], [24, 117], [24, 174], [24, 191], [24, 195], [24, 221], [24, 234], [24, 238], [24, 246], [24, 249], [24, 252], [24, 272], [24, 290], [25, 40], [25, 94], [25, 108], [25, 136], [25, 152], [25, 165], [25, 167], [25, 181], [25, 205], [25, 207], [25, 214], [25, 218], [25, 220], [25, 254], [25, 255], [25, 267], [25, 272], [25, 274], [25, 282], [26, 53], [26, 54], [26, 60], [26, 78], [26, 94], [26, 104], [26, 108], [26, 123], [26, 125], [26, 131], [26, 137], [26, 138], [26, 142], [26, 153], [26, 158], [26, 179], [26, 181], [26, 195], [26, 203], [26, 210], [26, 211], [26, 216], [26, 219], [26, 225], [26, 240], [26, 244], [27, 115], [27, 129], [27, 132], [27, 151], [27, 185], [27, 195], [27, 208], [27, 228], [27, 243], [27, 287], [27, 288], [28, 33], [28, 48], [28, 59], [28, 68], [28, 92], [28, 100], [28, 106], [28, 137], [28, 157], [28, 183], [28, 186], [28, 198], [28, 228], [28, 244], [28, 259], [28, 281], [28, 294], [28, 295], [28, 299], [29, 34], [29, 40], [29, 44], [29, 52], [29, 69], [29, 88], [29, 105], [29, 136], [29, 137], [29, 141], [29, 146], [29, 154], [29, 162], [29, 193], [29, 208], [29, 245], [29, 297], [29, 298], [30, 47], [30, 76], [30, 82], [30, 84], [30, 85], [30, 97], [30, 114], [30, 115], [30, 168], [30, 171], [30, 200], [30, 217], [30, 221], [30, 223], [30, 236], [30, 242], [30, 251], [30, 255], [31, 33], [31, 41], [31, 55], [31, 84], [31, 132], [31, 157], [31, 182], [31, 202], [31, 224], [31, 225], [31, 281], [31, 297], [32, 35], [32, 57], [32, 64], [32, 124], [32, 138], [32, 158], [32, 176], [32, 181], [32, 190], [32, 218], [32, 245], [32, 262], [33, 35], [33, 38], [33, 69], [33, 77], [33, 82], [33, 85], [33, 121], [33, 144], [33, 167], [33, 173], [33, 196], [33, 211], [33, 212], [33, 218], [33, 224], [33, 254], [33, 257], [33, 262], [33, 276], [33, 278], [33, 287], [34, 49], [34, 51], [34, 60], [34, 73], [34, 109], [34, 148], [34, 171], [34, 192], [34, 196], [34, 204], [34, 210], [34, 240], [34, 244], [35, 49], [35, 53], [35, 70], [35, 111], [35, 113], [35, 140], [35, 156], [35, 219], [35, 243], [35, 245], [35, 267], [35, 294], [36, 61], [36, 67], [36, 127], [36, 148], [36, 170], [36, 176], [36, 178], [36, 202], [36, 211], [36, 227], [36, 238], [36, 248], [36, 259], [36, 270], [36, 285], [37, 39], [37, 62], [37, 64], [37, 124], [37, 127], [37, 136], [37, 179], [37, 181], [37, 189], [37, 200], [37, 220], [37, 226], [37, 252], [37, 268], [38, 58], [38, 59], [38, 65], [38, 70], [38, 72], [38, 79], [38, 90], [38, 112], [38, 119], [38, 156], [38, 157], [38, 166], [38, 171], [38, 175], [38, 181], [38, 193], [38, 205], [38, 211], [38, 228], [38, 229], [38, 264], [38, 265], [38, 281], [38, 283], [38, 287], [39, 45], [39, 81], [39, 86], [39, 90], [39, 149], [39, 152], [39, 196], [39, 270], [40, 64], [40, 71], [40, 77], [40, 114], [40, 150], [40, 152], [40, 164], [40, 175], [40, 235], [40, 238], [40, 282], [41, 43], [41, 86], [41, 91], [41, 95], [41, 109], [41, 133], [41, 142], [41, 143], [41, 150], [41, 168], [41, 176], [41, 182], [41, 197], [41, 207], [41, 226], [41, 262], [41, 270], [41, 281], [41, 286], [41, 289], [42, 43], [42, 86], [42, 118], [42, 148], [42, 169], [42, 199], [42, 232], [42, 258], [42, 266], [42, 276], [43, 47], [43, 48], [43, 49], [43, 86], [43, 95], [43, 99], [43, 125], [43, 145], [43, 147], [43, 154], [43, 175], [43, 201], [43, 219], [43, 226], [43, 239], [44, 48], [44, 52], [44, 58], [44, 70], [44, 81], [44, 93], [44, 101], [44, 102], [44, 104], [44, 105], [44, 122], [44, 144], [44, 173], [44, 177], [44, 179], [44, 185], [44, 189], [44, 193], [44, 194], [44, 195], [44, 196], [44, 236], [44, 244], [45, 53], [45, 55], [45, 81], [45, 140], [45, 168], [45, 208], [45, 244], [45, 279], [45, 280], [45, 298], [46, 60], [46, 66], [46, 85], [46, 99], [46, 143], [46, 154], [46, 164], [46, 169], [46, 172], [46, 188], [46, 204], [46, 240], [46, 248], [46, 259], [46, 260], [46, 295], [46, 299], [47, 94], [47, 102], [47, 133], [47, 159], [47, 170], [47, 188], [47, 207], [47, 217], [47, 218], [47, 231], [47, 235], [47, 238], [47, 260], [47, 293], [47, 294], [48, 54], [48, 67], [48, 84], [48, 117], [48, 118], [48, 152], [48, 164], [48, 165], [48, 177], [48, 183], [48, 189], [48, 238], [48, 244], [48, 255], [48, 286], [49, 59], [49, 64], [49, 80], [49, 88], [49, 91], [49, 137], [49, 158], [49, 166], [49, 172], [49, 191], [49, 219], [49, 226], [49, 252], [49, 276], [49, 279], [49, 289], [49, 294], [49, 295], [49, 297], [50, 51], [50, 53], [50, 71], [50, 72], [50, 73], [50, 86], [50, 96], [50, 121], [50, 154], [50, 195], [50, 216], [50, 228], [50, 269], [50, 273], [50, 299], [51, 86], [51, 116], [51, 126], [51, 131], [51, 137], [51, 148], [51, 196], [51, 200], [51, 212], [51, 229], [51, 231], [51, 264], [52, 54], [52, 63], [52, 64], [52, 66], [52, 74], [52, 78], [52, 94], [52, 95], [52, 96], [52, 106], [52, 108], [52, 123], [52, 128], [52, 140], [52, 145], [52, 155], [52, 156], [52, 161], [52, 176], [52, 179], [52, 185], [52, 218], [52, 223], [52, 244], [52, 253], [52, 266], [52, 275], [52, 278], [52, 282], [53, 63], [53, 73], [53, 83], [53, 125], [53, 133], [53, 164], [53, 177], [53, 201], [53, 208], [53, 210], [53, 211], [53, 213], [53, 242], [53, 253], [53, 257], [53, 268], [53, 286], [53, 291], [54, 59], [54, 101], [54, 114], [54, 134], [54, 158], [54, 167], [54, 190], [54, 193], [54, 199], [54, 231], [54, 233], [54, 278], [54, 292], [55, 75], [55, 77], [55, 94], [55, 102], [55, 118], [55, 137], [55, 144], [55, 146], [55, 152], [55, 188], [55, 214], [55, 215], [55, 216], [55, 232], [55, 246], [55, 277], [55, 285], [56, 58], [56, 63], [56, 68], [56, 73], [56, 85], [56, 91], [56, 97], [56, 102], [56, 137], [56, 148], [56, 175], [56, 269], [57, 60], [57, 71], [57, 72], [57, 120], [57, 121], [57, 127], [57, 143], [57, 152], [57, 168], [57, 195], [57, 219], [57, 220], [57, 222], [57, 228], [57, 235], [57, 252], [57, 268], [58, 77], [58, 83], [58, 89], [58, 111], [58, 126], [58, 134], [58, 148], [58, 160], [58, 164], [58, 263], [58, 277], [59, 65], [59, 106], [59, 152], [59, 170], [59, 186], [59, 209], [59, 248], [59, 264], [59, 266], [59, 267], [59, 271], [60, 61], [60, 72], [60, 77], [60, 79], [60, 86], [60, 88], [60, 94], [60, 99], [60, 113], [60, 115], [60, 116], [60, 122], [60, 150], [60, 155], [60, 167], [60, 177], [60, 210], [60, 214], [60, 227], [60, 229], [60, 231], [60, 235], [60, 239], [60, 244], [60, 265], [60, 269], [60, 274], [60, 280], [60, 281], [60, 286], [60, 287], [61, 104], [61, 114], [61, 136], [61, 142], [61, 144], [61, 189], [61, 196], [61, 205], [61, 242], [61, 243], [61, 273], [61, 277], [61, 289], [62, 69], [62, 77], [62, 81], [62, 86], [62, 99], [62, 102], [62, 110], [62, 113], [62, 114], [62, 121], [62, 130], [62, 135], [62, 164], [62, 187], [62, 226], [62, 235], [62, 255], [62, 274], [63, 74], [63, 79], [63, 110], [63, 115], [63, 147], [63, 149], [63, 189], [63, 202], [63, 210], [63, 221], [63, 228], [63, 232], [63, 238], [63, 256], [63, 270], [63, 293], [64, 94], [64, 105], [64, 112], [64, 130], [64, 137], [64, 153], [64, 168], [64, 188], [64, 192], [64, 197], [64, 199], [64, 201], [64, 234], [64, 240], [64, 241], [64, 268], [64, 277], [65, 66], [65, 70], [65, 98], [65, 99], [65, 112], [65, 114], [65, 115], [65, 140], [65, 149], [65, 171], [65, 180], [65, 197], [65, 210], [65, 222], [65, 246], [65, 256], [66, 72], [66, 75], [66, 80], [66, 109], [66, 110], [66, 134], [66, 141], [66, 149], [66, 170], [66, 213], [66, 228], [66, 239], [66, 242], [66, 246], [66, 256], [66, 257], [66, 265], [66, 281], [67, 110], [67, 121], [67, 124], [67, 127], [67, 134], [67, 145], [67, 146], [67, 152], [67, 154], [67, 156], [67, 161], [67, 169], [67, 184], [67, 200], [67, 209], [67, 210], [67, 234], [67, 264], [67, 282], [67, 298], [68, 70], [68, 72], [68, 95], [68, 104], [68, 111], [68, 164], [68, 168], [68, 184], [68, 197], [68, 199], [68, 222], [68, 272], [68, 295], [68, 299], [69, 79], [69, 95], [69, 118], [69, 141], [69, 195], [69, 210], [69, 226], [69, 240], [69, 242], [69, 253], [69, 267], [69, 269], [69, 282], [70, 89], [70, 96], [70, 100], [70, 124], [70, 132], [70, 133], [70, 140], [70, 160], [70, 175], [70, 176], [70, 178], [70, 182], [70, 190], [70, 198], [70, 201], [70, 202], [70, 209], [70, 213], [70, 217], [70, 225], [70, 234], [70, 237], [70, 262], [70, 269], [70, 293], [71, 74], [71, 80], [71, 91], [71, 122], [71, 149], [71, 150], [71, 152], [71, 188], [71, 205], [71, 208], [71, 216], [71, 217], [71, 240], [71, 243], [71, 286], [71, 288], [71, 296], [72, 92], [72, 97], [72, 99], [72, 127], [72, 179], [72, 183], [72, 184], [72, 190], [72, 203], [72, 222], [72, 249], [72, 294], [73, 95], [73, 107], [73, 109], [73, 130], [73, 140], [73, 147], [73, 149], [73, 153], [73, 156], [73, 170], [73, 182], [73, 185], [73, 202], [73, 248], [73, 250], [73, 252], [73, 254], [73, 256], [73, 271], [74, 80], [74, 100], [74, 104], [74, 112], [74, 163], [74, 167], [74, 199], [74, 218], [74, 221], [74, 235], [74, 246], [74, 247], [74, 261], [74, 277], [74, 283], [74, 285], [75, 104], [75, 118], [75, 131], [75, 132], [75, 136], [75, 138], [75, 166], [75, 167], [75, 186], [75, 214], [75, 219], [75, 231], [75, 248], [75, 255], [75, 268], [75, 270], [75, 272], [75, 285], [76, 91], [76, 100], [76, 109], [76, 131], [76, 148], [76, 180], [76, 182], [76, 216], [76, 244], [76, 255], [76, 265], [76, 275], [76, 277], [77, 85], [77, 87], [77, 103], [77, 129], [77, 148], [77, 152], [77, 154], [77, 171], [77, 182], [77, 215], [77, 253], [77, 288], [78, 91], [78, 106], [78, 119], [78, 133], [78, 138], [78, 140], [78, 182], [78, 191], [78, 195], [78, 219], [78, 227], [78, 228], [78, 239], [78, 254], [78, 274], [78, 283], [79, 122], [79, 138], [79, 158], [79, 166], [79, 173], [79, 199], [79, 209], [79, 219], [79, 222], [79, 242], [79, 255], [79, 264], [79, 268], [80, 81], [80, 93], [80, 96], [80, 107], [80, 110], [80, 137], [80, 147], [80, 171], [80, 193], [80, 195], [80, 204], [80, 206], [80, 225], [80, 235], [80, 264], [80, 296], [80, 298], [81, 114], [81, 129], [81, 147], [81, 175], [81, 184], [81, 215], [81, 217], [81, 236], [81, 238], [81, 241], [81, 242], [81, 251], [81, 255], [81, 265], [81, 268], [81, 291], [81, 292], [81, 293], [82, 95], [82, 106], [82, 117], [82, 124], [82, 146], [82, 156], [82, 165], [82, 174], [82, 190], [82, 194], [82, 228], [82, 245], [82, 252], [82, 261], [82, 262], [82, 266], [82, 273], [82, 275], [82, 295], [83, 100], [83, 108], [83, 114], [83, 121], [83, 137], [83, 148], [83, 156], [83, 169], [83, 184], [83, 186], [83, 196], [83, 226], [83, 234], [83, 250], [83, 273], [84, 134], [84, 148], [84, 151], [84, 197], [84, 198], [84, 201], [84, 202], [84, 273], [84, 280], [85, 98], [85, 99], [85, 109], [85, 116], [85, 120], [85, 148], [85, 201], [85, 223], [85, 224], [85, 238], [85, 252], [85, 253], [85, 288], [85, 294], [86, 125], [86, 140], [86, 194], [86, 195], [86, 208], [86, 211], [86, 256], [86, 267], [86, 280], [86, 282], [86, 287], [86, 297], [86, 299], [87, 94], [87, 103], [87, 117], [87, 125], [87, 157], [87, 159], [87, 162], [87, 172], [87, 173], [87, 205], [87, 208], [87, 210], [87, 225], [87, 230], [87, 235], [87, 236], [87, 238], [87, 251], [87, 277], [88, 122], [88, 124], [88, 133], [88, 173], [88, 200], [88, 201], [88, 218], [88, 245], [88, 269], [88, 284], [88, 291], [89, 103], [89, 115], [89, 133], [89, 154], [89, 195], [89, 218], [89, 276], [89, 285], [89, 295], [90, 129], [90, 131], [90, 192], [90, 198], [90, 199], [90, 224], [90, 226], [90, 238], [90, 253], [90, 258], [90, 283], [90, 287], [90, 292], [91, 93], [91, 98], [91, 106], [91, 112], [91, 125], [91, 126], [91, 131], [91, 140], [91, 149], [91, 151], [91, 153], [91, 182], [91, 200], [91, 221], [91, 222], [91, 243], [91, 245], [91, 254], [91, 275], [91, 285], [91, 292], [91, 297], [92, 113], [92, 128], [92, 135], [92, 140], [92, 161], [92, 162], [92, 163], [92, 164], [92, 216], [92, 219], [92, 233], [92, 240], [92, 267], [92, 278], [92, 281], [92, 295], [93, 111], [93, 124], [93, 137], [93, 157], [93, 186], [93, 189], [93, 196], [93, 260], [93, 263], [93, 268], [93, 275], [94, 155], [94, 163], [94, 168], [94, 174], [94, 195], [94, 207], [94, 258], [94, 273], [94, 276], [94, 289], [94, 296], [95, 103], [95, 124], [95, 140], [95, 145], [95, 151], [95, 153], [95, 170], [95, 183], [95, 197], [95, 205], [95, 215], [95, 222], [95, 244], [95, 246], [95, 273], [95, 289], [95, 291], [96, 104], [96, 139], [96, 146], [96, 152], [96, 173], [96, 189], [96, 208], [96, 211], [96, 222], [96, 235], [96, 241], [96, 270], [96, 274], [96, 297], [97, 118], [97, 144], [97, 147], [97, 148], [97, 166], [97, 187], [97, 189], [97, 196], [97, 201], [97, 212], [97, 213], [97, 217], [97, 219], [97, 259], [97, 272], [97, 279], [98, 123], [98, 136], [98, 143], [98, 146], [98, 148], [98, 167], [98, 181], [98, 184], [98, 214], [98, 231], [98, 245], [98, 261], [98, 273], [98, 277], [98, 295], [99, 125], [99, 154], [99, 171], [99, 199], [99, 207], [99, 231], [99, 280], [100, 101], [100, 104], [100, 117], [100, 125], [100, 133], [100, 140], [100, 142], [100, 154], [100, 159], [100, 163], [100, 167], [100, 197], [100, 198], [100, 199], [100, 208], [100, 230], [100, 237], [100, 238], [100, 251], [100, 270], [100, 291], [101, 104], [101, 129], [101, 134], [101, 149], [101, 169], [101, 201], [101, 209], [101, 220], [101, 232], [101, 234], [101, 246], [101, 271], [101, 275], [102, 106], [102, 137], [102, 148], [102, 158], [102, 164], [102, 184], [102, 189], [102, 193], [102, 197], [102, 205], [102, 241], [102, 259], [102, 264], [102, 267], [103, 104], [103, 122], [103, 178], [103, 189], [103, 221], [103, 223], [103, 251], [103, 254], [103, 269], [103, 273], [103, 274], [104, 106], [104, 120], [104, 125], [104, 159], [104, 236], [104, 248], [104, 268], [104, 277], [104, 293], [105, 128], [105, 129], [105, 163], [105, 164], [105, 173], [105, 176], [105, 178], [105, 184], [105, 188], [105, 229], [105, 244], [105, 256], [105, 275], [105, 293], [106, 107], [106, 116], [106, 117], [106, 124], [106, 165], [106, 167], [106, 182], [106, 184], [106, 191], [106, 216], [106, 224], [106, 251], [106, 254], [106, 261], [106, 285], [106, 290], [106, 296], [107, 114], [107, 128], [107, 131], [107, 139], [107, 143], [107, 149], [107, 152], [107, 167], [107, 177], [107, 181], [107, 191], [107, 194], [107, 217], [107, 224], [107, 237], [107, 247], [107, 261], [107, 263], [107, 267], [107, 278], [107, 283], [108, 111], [108, 150], [108, 176], [108, 183], [108, 186], [108, 219], [108, 234], [109, 111], [109, 129], [109, 152], [109, 154], [109, 170], [109, 218], [109, 232], [109, 255], [109, 259], [109, 262], [109, 272], [109, 295], [110, 112], [110, 123], [110, 124], [110, 125], [110, 137], [110, 147], [110, 153], [110, 163], [110, 177], [110, 200], [110, 220], [110, 245], [110, 258], [110, 272], [110, 285], [110, 293], [111, 114], [111, 125], [111, 134], [111, 152], [111, 173], [111, 174], [111, 190], [111, 192], [111, 194], [111, 204], [111, 206], [111, 220], [111, 229], [111, 230], [111, 232], [111, 233], [111, 254], [111, 257], [111, 258], [111, 279], [111, 284], [111, 293], [111, 294], [112, 121], [112, 147], [112, 151], [112, 155], [112, 161], [112, 171], [112, 177], [112, 179], [112, 191], [112, 197], [112, 200], [112, 242], [112, 279], [112, 282], [112, 292], [112, 294], [113, 117], [113, 118], [113, 202], [113, 248], [113, 281], [114, 122], [114, 133], [114, 153], [114, 157], [114, 161], [114, 171], [114, 177], [114, 228], [114, 229], [114, 232], [114, 246], [114, 251], [114, 266], [114, 275], [114, 290], [114, 291], [115, 144], [115, 181], [115, 190], [115, 196], [115, 202], [115, 203], [115, 219], [115, 222], [115, 236], [116, 132], [116, 138], [116, 151], [116, 152], [116, 158], [116, 165], [116, 168], [116, 176], [116, 234], [116, 235], [116, 258], [116, 274], [116, 283], [117, 125], [117, 135], [117, 137], [117, 139], [117, 158], [117, 175], [117, 183], [117, 194], [117, 200], [117, 211], [117, 238], [117, 251], [117, 280], [117, 292], [118, 162], [118, 167], [118, 168], [118, 187], [118, 191], [118, 192], [118, 193], [118, 237], [118, 283], [118, 288], [119, 191], [119, 202], [119, 254], [119, 277], [120, 123], [120, 133], [120, 147], [120, 163], [120, 172], [120, 178], [120, 191], [120, 213], [120, 229], [120, 231], [120, 236], [120, 244], [120, 265], [121, 153], [121, 164], [121, 195], [121, 212], [121, 226], [121, 249], [121, 257], [121, 260], [122, 127], [122, 141], [122, 142], [122, 146], [122, 156], [122, 157], [122, 161], [122, 162], [122, 172], [122, 182], [122, 217], [122, 241], [122, 254], [122, 257], [122, 277], [122, 283], [122, 296], [123, 128], [123, 175], [123, 179], [123, 183], [123, 187], [123, 188], [123, 193], [123, 196], [123, 215], [123, 225], [123, 247], [123, 248], [123, 284], [124, 127], [124, 143], [124, 145], [124, 151], [124, 156], [124, 159], [124, 161], [124, 163], [124, 183], [124, 187], [124, 197], [124, 228], [124, 236], [124, 241], [124, 249], [124, 251], [124, 260], [124, 262], [124, 263], [124, 266], [124, 269], [124, 284], [124, 288], [124, 299], [125, 166], [125, 174], [125, 188], [125, 231], [125, 289], [126, 137], [126, 148], [126, 153], [126, 161], [126, 171], [126, 176], [126, 198], [126, 213], [126, 215], [126, 220], [126, 222], [126, 232], [126, 241], [126, 248], [126, 253], [126, 256], [126, 260], [126, 263], [127, 139], [127, 151], [127, 180], [127, 216], [127, 231], [127, 232], [127, 242], [127, 244], [127, 267], [127, 275], [127, 289], [128, 136], [128, 137], [128, 172], [128, 191], [128, 194], [128, 218], [128, 229], [128, 233], [128, 242], [128, 244], [128, 290], [129, 133], [129, 155], [129, 157], [129, 184], [129, 191], [129, 239], [129, 262], [129, 294], [129, 297], [129, 298], [130, 148], [130, 151], [130, 166], [130, 185], [130, 222], [130, 223], [130, 262], [130, 296], [131, 137], [131, 146], [131, 154], [131, 164], [131, 175], [131, 178], [131, 180], [131, 213], [131, 237], [131, 257], [131, 261], [131, 269], [131, 289], [132, 165], [132, 184], [132, 189], [132, 219], [132, 229], [132, 243], [132, 261], [132, 293], [133, 157], [133, 175], [133, 178], [133, 181], [133, 184], [133, 191], [133, 204], [133, 207], [133, 212], [133, 216], [133, 219], [133, 247], [133, 258], [133, 267], [133, 272], [133, 277], [133, 278], [134, 151], [134, 191], [134, 193], [134, 195], [134, 207], [134, 216], [134, 219], [134, 288], [134, 291], [135, 156], [135, 163], [135, 164], [135, 168], [135, 229], [135, 264], [135, 273], [135, 280], [136, 144], [136, 148], [136, 171], [136, 184], [136, 222], [136, 236], [136, 268], [136, 277], [136, 293], [137, 157], [137, 191], [137, 209], [137, 221], [137, 225], [137, 226], [137, 232], [137, 238], [137, 276], [137, 281], [137, 295], [137, 297], [138, 142], [138, 148], [138, 177], [138, 180], [138, 216], [138, 224], [138, 233], [138, 242], [138, 261], [138, 262], [138, 265], [138, 277], [138, 287], [139, 146], [139, 149], [139, 158], [139, 171], [139, 183], [139, 189], [139, 208], [139, 216], [139, 227], [139, 238], [139, 264], [139, 285], [140, 152], [140, 184], [140, 199], [140, 208], [140, 222], [140, 278], [140, 291], [141, 160], [141, 163], [141, 179], [141, 185], [141, 201], [141, 204], [141, 208], [141, 213], [141, 216], [141, 220], [141, 239], [141, 272], [141, 294], [142, 157], [142, 171], [142, 180], [142, 187], [142, 199], [142, 204], [142, 213], [142, 229], [142, 238], [142, 274], [143, 152], [143, 161], [143, 196], [143, 236], [143, 238], [143, 245], [143, 247], [143, 264], [143, 276], [143, 279], [143, 284], [144, 147], [144, 148], [144, 181], [144, 195], [144, 197], [144, 242], [144, 245], [144, 260], [144, 269], [144, 286], [144, 294], [145, 149], [145, 151], [145, 156], [145, 164], [145, 173], [145, 198], [145, 210], [145, 227], [145, 248], [145, 272], [145, 274], [145, 275], [145, 295], [146, 150], [146, 153], [146, 170], [146, 172], [146, 177], [146, 187], [146, 190], [146, 213], [146, 222], [146, 228], [146, 234], [146, 248], [146, 250], [146, 252], [146, 263], [146, 286], [146, 288], [146, 298], [147, 148], [147, 155], [147, 195], [147, 216], [147, 226], [147, 278], [147, 279], [147, 298], [148, 150], [148, 198], [148, 207], [148, 214], [148, 234], [148, 245], [148, 246], [148, 248], [148, 256], [148, 260], [148, 267], [148, 278], [149, 162], [149, 167], [149, 169], [149, 170], [149, 171], [149, 183], [149, 184], [149, 194], [149, 203], [149, 212], [149, 224], [149, 253], [149, 269], [149, 272], [150, 159], [150, 172], [150, 184], [150, 201], [150, 203], [150, 235], [150, 259], [150, 266], [150, 279], [150, 284], [150, 285], [151, 184], [151, 194], [151, 196], [151, 202], [151, 221], [151, 232], [151, 237], [151, 238], [151, 246], [151, 269], [151, 277], [152, 163], [152, 171], [152, 181], [152, 193], [152, 194], [152, 206], [152, 215], [152, 227], [152, 230], [152, 235], [152, 241], [152, 259], [152, 267], [152, 268], [152, 274], [152, 279], [153, 162], [153, 247], [153, 250], [153, 260], [153, 265], [153, 268], [153, 275], [153, 276], [153, 285], [153, 290], [154, 158], [154, 160], [154, 164], [154, 167], [154, 179], [154, 202], [154, 240], [154, 248], [154, 282], [154, 298], [155, 157], [155, 184], [155, 194], [155, 197], [155, 209], [155, 211], [155, 267], [155, 275], [155, 278], [155, 297], [156, 157], [156, 169], [156, 194], [156, 197], [156, 249], [156, 256], [156, 290], [157, 163], [157, 164], [157, 200], [157, 207], [157, 233], [157, 234], [157, 235], [157, 292], [157, 293], [158, 168], [158, 184], [158, 225], [158, 226], [158, 228], [158, 263], [158, 274], [158, 284], [158, 286], [158, 290], [159, 170], [159, 191], [159, 194], [159, 199], [159, 217], [159, 230], [159, 244], [159, 257], [159, 277], [159, 294], [160, 187], [160, 234], [160, 238], [160, 255], [160, 269], [160, 292], [160, 294], [160, 297], [161, 183], [161, 197], [161, 210], [161, 281], [162, 168], [162, 194], [162, 195], [162, 212], [162, 226], [162, 229], [162, 232], [162, 234], [162, 275], [162, 284], [163, 175], [163, 252], [163, 257], [163, 282], [163, 286], [163, 298], [164, 172], [164, 180], [164, 184], [164, 198], [164, 239], [164, 257], [164, 261], [164, 275], [164, 277], [164, 282], [165, 169], [165, 181], [165, 187], [165, 191], [165, 195], [165, 197], [165, 269], [165, 271], [165, 272], [165, 275], [165, 294], [166, 189], [166, 197], [166, 208], [166, 229], [166, 293], [167, 170], [167, 176], [167, 183], [167, 204], [167, 220], [167, 236], [167, 258], [167, 261], [167, 277], [167, 285], [167, 289], [168, 189], [168, 240], [168, 241], [168, 242], [168, 247], [168, 254], [168, 271], [168, 277], [168, 285], [168, 292], [168, 295], [168, 296], [169, 170], [169, 175], [169, 263], [169, 271], [169, 298], [169, 299], [170, 173], [170, 183], [170, 231], [170, 263], [170, 275], [170, 277], [170, 280], [170, 285], [171, 180], [171, 185], [171, 197], [171, 221], [171, 235], [171, 236], [171, 237], [171, 242], [171, 259], [171, 263], [172, 206], [172, 211], [172, 227], [172, 250], [172, 279], [172, 289], [173, 190], [173, 220], [173, 248], [173, 265], [173, 274], [173, 277], [173, 278], [174, 208], [174, 215], [174, 223], [174, 237], [174, 273], [174, 278], [175, 176], [175, 184], [175, 185], [175, 206], [175, 238], [175, 247], [175, 291], [176, 213], [176, 241], [176, 264], [176, 266], [176, 280], [176, 291], [177, 184], [177, 188], [177, 190], [177, 193], [177, 197], [177, 206], [177, 216], [177, 218], [177, 229], [177, 240], [177, 247], [177, 264], [177, 269], [178, 188], [178, 190], [178, 204], [178, 273], [179, 189], [179, 196], [179, 200], [179, 212], [179, 235], [179, 237], [179, 266], [180, 195], [180, 198], [180, 199], [180, 255], [180, 257], [180, 264], [180, 274], [180, 279], [180, 288], [180, 289], [180, 294], [181, 184], [181, 196], [181, 218], [181, 263], [182, 232], [182, 236], [182, 243], [182, 246], [182, 283], [182, 289], [183, 193], [183, 194], [183, 195], [183, 200], [183, 201], [183, 208], [183, 228], [183, 229], [183, 250], [183, 263], [183, 265], [183, 274], [184, 196], [184, 216], [184, 228], [184, 258], [184, 266], [184, 267], [184, 273], [185, 195], [185, 199], [185, 208], [185, 217], [185, 219], [185, 221], [185, 247], [185, 259], [185, 277], [185, 285], [185, 294], [186, 188], [186, 204], [186, 218], [186, 225], [186, 226], [186, 227], [186, 244], [186, 267], [186, 277], [186, 284], [186, 291], [186, 299], [187, 209], [187, 216], [187, 225], [187, 233], [187, 247], [187, 258], [187, 273], [187, 294], [187, 299], [188, 208], [188, 220], [188, 247], [188, 267], [188, 294], [189, 220], [189, 231], [189, 236], [190, 207], [190, 217], [190, 233], [190, 252], [190, 277], [190, 291], [190, 295], [191, 192], [191, 255], [192, 204], [192, 241], [192, 242], [192, 254], [192, 258], [192, 285], [192, 298], [193, 203], [193, 206], [193, 221], [193, 242], [193, 244], [193, 246], [193, 274], [193, 276], [194, 202], [194, 206], [194, 249], [194, 277], [194, 281], [194, 291], [195, 202], [195, 207], [195, 216], [195, 217], [195, 218], [195, 241], [195, 267], [195, 270], [195, 290], [195, 297], [196, 206], [196, 242], [196, 250], [196, 262], [196, 298], [197, 199], [197, 230], [197, 252], [197, 256], [197, 260], [197, 277], [197, 289], [198, 199], [198, 201], [198, 229], [199, 226], [199, 240], [199, 245], [199, 252], [199, 266], [199, 268], [199, 277], [199, 285], [200, 210], [200, 221], [200, 253], [200, 255], [200, 283], [201, 240], [201, 242], [201, 254], [201, 258], [201, 259], [201, 261], [202, 228], [202, 237], [202, 261], [202, 262], [202, 272], [202, 277], [202, 287], [203, 224], [203, 227], [203, 230], [203, 256], [203, 297], [203, 299], [204, 216], [204, 226], [204, 240], [204, 279], [205, 210], [205, 234], [205, 236], [205, 269], [205, 276], [205, 285], [205, 289], [206, 208], [206, 233], [206, 239], [206, 250], [206, 259], [206, 262], [206, 269], [206, 282], [206, 287], [207, 208], [207, 209], [207, 240], [207, 246], [207, 265], [207, 288], [208, 212], [208, 215], [208, 217], [208, 241], [208, 251], [208, 284], [208, 290], [208, 298], [209, 210], [209, 234], [209, 243], [209, 257], [209, 263], [209, 268], [209, 269], [209, 285], [210, 226], [210, 243], [210, 245], [210, 249], [210, 256], [210, 278], [211, 217], [211, 248], [211, 288], [211, 289], [211, 296], [212, 250], [212, 297], [213, 226], [213, 239], [213, 286], [214, 250], [214, 257], [214, 274], [215, 216], [215, 219], [215, 249], [215, 257], [215, 272], [215, 296], [216, 241], [216, 253], [217, 238], [217, 242], [217, 257], [217, 263], [217, 269], [217, 285], [217, 299], [218, 222], [218, 237], [218, 255], [219, 222], [219, 230], [219, 242], [219, 264], [219, 269], [219, 296], [220, 244], [220, 255], [220, 297], [221, 253], [221, 256], [221, 259], [221, 272], [221, 280], [221, 283], [221, 284], [221, 286], [222, 224], [222, 248], [222, 260], [222, 277], [222, 280], [222, 281], [223, 227], [223, 232], [223, 233], [223, 240], [223, 243], [223, 249], [223, 278], [223, 294], [224, 248], [224, 251], [224, 264], [224, 276], [224, 278], [224, 291], [225, 235], [225, 240], [225, 268], [225, 272], [225, 283], [226, 227], [226, 233], [226, 263], [226, 265], [226, 291], [226, 299], [227, 230], [227, 232], [227, 233], [227, 239], [227, 271], [227, 278], [227, 292], [228, 234], [228, 235], [228, 258], [228, 262], [229, 230], [229, 268], [229, 295], [229, 296], [230, 248], [230, 271], [231, 246], [231, 256], [231, 262], [231, 267], [231, 275], [232, 234], [232, 269], [232, 270], [233, 241], [233, 255], [233, 269], [234, 249], [234, 279], [235, 240], [235, 250], [235, 257], [235, 272], [236, 237], [236, 244], [236, 255], [236, 274], [236, 277], [236, 279], [236, 299], [237, 244], [237, 275], [237, 287], [238, 260], [238, 283], [239, 249], [239, 287], [239, 292], [240, 244], [240, 249], [240, 254], [240, 263], [240, 283], [240, 295], [240, 299], [241, 261], [241, 262], [241, 275], [241, 279], [241, 298], [242, 257], [242, 263], [242, 279], [243, 298], [244, 263], [244, 299], [245, 252], [245, 263], [245, 265], [246, 259], [246, 264], [246, 279], [246, 292], [247, 252], [247, 267], [247, 268], [247, 279], [247, 287], [247, 297], [248, 252], [248, 255], [249, 255], [249, 274], [250, 294], [251, 263], [251, 288], [251, 289], [252, 254], [252, 255], [252, 256], [252, 265], [252, 268], [252, 273], [252, 286], [253, 260], [253, 269], [254, 258], [254, 265], [254, 279], [254, 295], [255, 268], [255, 275], [256, 261], [256, 278], [257, 283], [257, 286], [257, 292], [257, 296], [258, 271], [258, 296], [258, 298], [259, 273], [259, 275], [260, 277], [260, 291], [261, 263], [261, 273], [261, 280], [261, 282], [261, 297], [262, 280], [262, 288], [263, 264], [263, 284], [263, 287], [264, 279], [264, 284], [265, 266], [265, 280], [266, 276], [267, 299], [268, 289], [269, 288], [270, 288], [271, 279], [271, 284], [272, 276], [272, 287], [273, 290], [274, 278], [274, 283], [276, 279], [276, 286], [276, 289], [276, 293], [276, 295], [277, 279], [277, 290], [277, 297], [278, 284], [278, 291], [279, 290], [280, 295], [280, 296], [281, 289], [281, 290], [281, 298], [283, 287], [287, 291], [288, 293], [288, 296], [289, 290], [290, 291], [290, 299], [291, 297], [295, 298], [296, 299], [297, 299]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l6-s2/tests/run.py b/tasks/construct-nppc-dominating-set-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-dominating-set-l6-s2/tests/test.sh b/tasks/construct-nppc-dominating-set-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-dominating-set-l6-s5/environment/Dockerfile b/tasks/construct-nppc-dominating-set-l6-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-dominating-set-l6-s5/environment/instance.json b/tasks/construct-nppc-dominating-set-l6-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..87e066e6d9f14211c02eb562b5ded9642ce2bf33 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s5/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 300, "k": 20, "edges": [[0, 12], [0, 25], [0, 26], [0, 37], [0, 78], [0, 102], [0, 117], [0, 185], [0, 212], [0, 242], [0, 265], [0, 282], [1, 2], [1, 23], [1, 50], [1, 130], [1, 134], [1, 139], [1, 143], [1, 146], [1, 147], [1, 188], [1, 205], [1, 207], [1, 234], [1, 297], [2, 16], [2, 115], [2, 140], [2, 142], [2, 149], [2, 161], [2, 162], [2, 169], [2, 182], [2, 197], [2, 222], [2, 227], [2, 258], [2, 261], [2, 262], [2, 264], [2, 269], [2, 277], [2, 291], [3, 9], [3, 15], [3, 31], [3, 36], [3, 58], [3, 78], [3, 109], [3, 112], [3, 151], [3, 158], [3, 166], [3, 175], [3, 183], [3, 189], [3, 190], [3, 208], [3, 210], [3, 239], [3, 253], [3, 261], [3, 273], [3, 278], [3, 281], [4, 21], [4, 48], [4, 100], [4, 105], [4, 111], [4, 112], [4, 144], [4, 148], [4, 187], [4, 219], [4, 246], [4, 264], [4, 276], [4, 286], [4, 297], [5, 54], [5, 73], [5, 84], [5, 155], [5, 192], [5, 221], [5, 254], [5, 260], [5, 270], [6, 7], [6, 21], [6, 30], [6, 64], [6, 86], [6, 126], [6, 161], [6, 224], [6, 236], [6, 243], [6, 245], [6, 251], [6, 264], [6, 284], [7, 13], [7, 30], [7, 44], [7, 46], [7, 106], [7, 179], [7, 180], [7, 203], [7, 204], [7, 224], [7, 233], [7, 239], [7, 247], [7, 258], [7, 268], [8, 18], [8, 24], [8, 43], [8, 50], [8, 55], [8, 57], [8, 74], [8, 80], [8, 88], [8, 102], [8, 117], [8, 124], [8, 138], [8, 169], [8, 218], [8, 245], [9, 33], [9, 44], [9, 48], [9, 60], [9, 63], [9, 64], [9, 71], [9, 84], [9, 119], [9, 139], [9, 161], [9, 204], [9, 237], [9, 262], [9, 267], [9, 297], [10, 41], [10, 75], [10, 121], [10, 154], [10, 162], [10, 209], [10, 217], [10, 241], [10, 269], [10, 280], [11, 13], [11, 19], [11, 24], [11, 29], [11, 35], [11, 60], [11, 72], [11, 74], [11, 86], [11, 118], [11, 143], [11, 185], [11, 190], [11, 197], [11, 216], [11, 241], [11, 252], [11, 255], [11, 258], [11, 286], [12, 36], [12, 69], [12, 84], [12, 86], [12, 88], [12, 99], [12, 104], [12, 106], [12, 136], [12, 156], [12, 181], [12, 198], [12, 199], [12, 218], [12, 245], [12, 255], [12, 279], [12, 285], [13, 19], [13, 26], [13, 29], [13, 31], [13, 43], [13, 53], [13, 61], [13, 68], [13, 79], [13, 84], [13, 85], [13, 92], [13, 109], [13, 110], [13, 123], [13, 195], [13, 198], [13, 213], [13, 240], [13, 246], [13, 271], [13, 280], [14, 16], [14, 30], [14, 35], [14, 61], [14, 67], [14, 75], [14, 123], [14, 141], [14, 147], [14, 148], [14, 161], [14, 162], [14, 168], [14, 181], [14, 185], [14, 195], [14, 196], [14, 210], [14, 214], [14, 224], [14, 229], [14, 243], [14, 255], [14, 274], [14, 284], [14, 287], [15, 40], [15, 53], [15, 57], [15, 62], [15, 74], [15, 97], [15, 105], [15, 113], [15, 117], [15, 121], [15, 131], [15, 141], [15, 175], [15, 196], [15, 225], [15, 238], [15, 244], [15, 249], [15, 252], [15, 255], [15, 256], [15, 268], [15, 276], [15, 279], [15, 281], [15, 284], [15, 290], [16, 64], [16, 66], [16, 78], [16, 79], [16, 85], [16, 108], [16, 127], [16, 130], [16, 141], [16, 144], [16, 162], [16, 176], [16, 182], [16, 201], [16, 208], [16, 212], [16, 221], [16, 250], [16, 251], [16, 261], [16, 266], [16, 276], [17, 25], [17, 37], [17, 56], [17, 78], [17, 94], [17, 96], [17, 139], [17, 146], [17, 148], [17, 170], [17, 178], [17, 204], [17, 209], [17, 219], [17, 257], [17, 266], [17, 270], [17, 292], [17, 296], [18, 83], [18, 121], [18, 122], [18, 158], [18, 206], [18, 220], [18, 221], [18, 241], [18, 255], [18, 290], [19, 22], [19, 23], [19, 24], [19, 42], [19, 67], [19, 71], [19, 98], [19, 105], [19, 120], [19, 135], [19, 195], [19, 196], [19, 250], [19, 260], [19, 276], [19, 283], [20, 71], [20, 73], [20, 75], [20, 78], [20, 92], [20, 106], [20, 114], [20, 119], [20, 125], [20, 138], [20, 139], [20, 150], [20, 168], [20, 196], [20, 197], [20, 204], [20, 205], [20, 246], [20, 274], [20, 289], [21, 26], [21, 43], [21, 45], [21, 69], [21, 84], [21, 97], [21, 133], [21, 137], [21, 146], [21, 151], [21, 154], [21, 161], [21, 165], [21, 173], [21, 202], [21, 229], [21, 233], [21, 235], [21, 237], [21, 238], [21, 240], [21, 289], [22, 54], [22, 64], [22, 72], [22, 86], [22, 108], [22, 152], [22, 160], [22, 195], [22, 209], [22, 224], [22, 229], [22, 240], [22, 241], [22, 250], [22, 252], [22, 262], [22, 264], [22, 266], [22, 273], [22, 280], [22, 282], [22, 287], [22, 289], [23, 38], [23, 57], [23, 59], [23, 60], [23, 84], [23, 110], [23, 173], [23, 184], [23, 186], [23, 216], [23, 230], [23, 275], [23, 278], [23, 283], [24, 46], [24, 49], [24, 56], [24, 58], [24, 113], [24, 118], [24, 120], [24, 124], [24, 177], [24, 203], [24, 261], [24, 267], [24, 270], [25, 74], [25, 88], [25, 98], [25, 105], [25, 118], [25, 136], [25, 148], [25, 156], [25, 168], [25, 225], [25, 263], [26, 38], [26, 66], [26, 110], [26, 111], [26, 115], [26, 116], [26, 126], [26, 136], [26, 154], [26, 159], [26, 160], [26, 183], [26, 185], [26, 203], [26, 214], [26, 224], [26, 230], [26, 247], [26, 270], [26, 285], [26, 286], [27, 64], [27, 113], [27, 144], [27, 145], [27, 160], [27, 173], [27, 183], [27, 187], [27, 198], [27, 209], [27, 224], [27, 234], [27, 241], [27, 242], [27, 249], [27, 250], [27, 262], [27, 291], [28, 40], [28, 47], [28, 59], [28, 62], [28, 109], [28, 145], [28, 168], [28, 183], [28, 196], [28, 203], [28, 221], [28, 267], [28, 276], [29, 54], [29, 55], [29, 61], [29, 75], [29, 87], [29, 91], [29, 121], [29, 136], [29, 156], [29, 171], [29, 180], [29, 208], [29, 246], [30, 35], [30, 60], [30, 112], [30, 115], [30, 124], [30, 155], [30, 176], [30, 216], [30, 218], [30, 224], [30, 245], [30, 267], [30, 284], [30, 292], [31, 36], [31, 52], [31, 63], [31, 80], [31, 92], [31, 105], [31, 136], [31, 168], [31, 177], [31, 205], [31, 224], [31, 229], [31, 261], [31, 264], [31, 275], [31, 284], [32, 37], [32, 48], [32, 92], [32, 101], [32, 127], [32, 138], [32, 151], [32, 158], [32, 160], [32, 164], [32, 172], [32, 222], [32, 223], [32, 236], [32, 240], [32, 270], [32, 278], [32, 288], [32, 292], [33, 102], [33, 116], [33, 120], [33, 122], [33, 123], [33, 152], [33, 163], [33, 167], [33, 170], [33, 213], [33, 237], [33, 271], [34, 74], [34, 119], [34, 121], [34, 137], [34, 144], [34, 145], [34, 146], [34, 150], [34, 160], [34, 172], [34, 173], [34, 178], [34, 182], [34, 186], [34, 203], [34, 204], [34, 218], [34, 219], [34, 224], [34, 225], [34, 254], [34, 259], [34, 262], [34, 263], [34, 276], [34, 284], [34, 297], [35, 67], [35, 81], [35, 86], [35, 91], [35, 92], [35, 99], [35, 102], [35, 144], [35, 156], [35, 175], [35, 210], [35, 254], [35, 262], [35, 270], [35, 286], [35, 289], [35, 296], [35, 297], [36, 38], [36, 41], [36, 110], [36, 120], [36, 121], [36, 139], [36, 151], [36, 156], [36, 165], [36, 197], [36, 198], [36, 208], [36, 211], [36, 230], [36, 240], [36, 246], [36, 260], [36, 263], [36, 299], [37, 56], [37, 69], [37, 72], [37, 98], [37, 100], [37, 104], [37, 110], [37, 115], [37, 117], [37, 148], [37, 149], [37, 169], [37, 209], [37, 260], [37, 264], [37, 286], [37, 289], [37, 297], [38, 92], [38, 95], [38, 102], [38, 103], [38, 105], [38, 157], [38, 165], [38, 203], [38, 245], [38, 254], [38, 273], [38, 297], [39, 64], [39, 67], [39, 84], [39, 88], [39, 98], [39, 107], [39, 110], [39, 137], [39, 151], [39, 178], [39, 207], [39, 237], [39, 254], [39, 256], [39, 268], [39, 279], [39, 291], [40, 74], [40, 85], [40, 88], [40, 101], [40, 130], [40, 134], [40, 194], [40, 199], [40, 210], [40, 217], [40, 221], [40, 247], [40, 254], [40, 263], [41, 49], [41, 55], [41, 62], [41, 68], [41, 69], [41, 73], [41, 86], [41, 88], [41, 97], [41, 99], [41, 107], [41, 114], [41, 117], [41, 145], [41, 150], [41, 152], [41, 154], [41, 155], [41, 159], [41, 160], [41, 163], [41, 164], [41, 166], [41, 179], [41, 186], [41, 206], [41, 212], [41, 222], [41, 224], [41, 239], [41, 258], [41, 259], [41, 260], [41, 262], [41, 271], [42, 57], [42, 61], [42, 81], [42, 106], [42, 108], [42, 110], [42, 111], [42, 128], [42, 138], [42, 165], [42, 166], [42, 171], [42, 210], [42, 215], [42, 231], [42, 233], [42, 259], [42, 260], [42, 262], [42, 290], [43, 53], [43, 64], [43, 78], [43, 98], [43, 121], [43, 122], [43, 140], [43, 144], [43, 163], [43, 165], [43, 187], [43, 193], [43, 198], [43, 199], [43, 201], [43, 214], [43, 220], [43, 230], [43, 235], [43, 246], [43, 263], [43, 276], [43, 280], [43, 291], [44, 52], [44, 79], [44, 92], [44, 93], [44, 103], [44, 112], [44, 119], [44, 144], [44, 150], [44, 151], [44, 164], [44, 173], [44, 182], [44, 205], [44, 211], [44, 223], [44, 225], [44, 226], [44, 231], [44, 240], [44, 243], [44, 245], [44, 256], [44, 259], [44, 266], [44, 270], [44, 274], [44, 299], [45, 90], [45, 128], [45, 142], [45, 159], [45, 168], [45, 178], [45, 185], [45, 199], [45, 201], [45, 212], [45, 221], [45, 238], [45, 240], [45, 251], [45, 264], [45, 272], [45, 276], [45, 295], [46, 68], [46, 71], [46, 81], [46, 124], [46, 138], [46, 155], [46, 159], [46, 193], [46, 243], [46, 264], [47, 51], [47, 53], [47, 74], [47, 78], [47, 87], [47, 95], [47, 100], [47, 103], [47, 125], [47, 143], [47, 148], [47, 177], [47, 193], [47, 206], [47, 211], [47, 217], [47, 250], [47, 258], [47, 259], [48, 70], [48, 71], [48, 76], [48, 98], [48, 106], [48, 123], [48, 139], [48, 143], [48, 161], [48, 173], [48, 176], [48, 180], [48, 183], [48, 185], [48, 210], [48, 215], [48, 217], [48, 218], [48, 219], [48, 249], [48, 268], [48, 277], [49, 100], [49, 109], [49, 112], [49, 118], [49, 123], [49, 135], [49, 147], [49, 151], [49, 172], [49, 185], [49, 204], [49, 247], [50, 62], [50, 74], [50, 75], [50, 82], [50, 98], [50, 102], [50, 105], [50, 115], [50, 124], [50, 141], [50, 202], [50, 219], [50, 247], [50, 266], [50, 273], [50, 284], [50, 286], [50, 290], [51, 87], [51, 117], [51, 145], [51, 159], [51, 185], [51, 217], [51, 220], [51, 223], [51, 235], [51, 242], [51, 284], [51, 292], [51, 295], [52, 67], [52, 76], [52, 99], [52, 103], [52, 153], [52, 157], [52, 168], [52, 182], [52, 186], [52, 261], [52, 288], [52, 296], [53, 81], [53, 90], [53, 101], [53, 145], [53, 161], [53, 163], [53, 173], [53, 177], [53, 183], [53, 201], [53, 212], [53, 215], [53, 227], [53, 236], [53, 257], [53, 267], [53, 297], [53, 299], [54, 58], [54, 82], [54, 86], [54, 93], [54, 114], [54, 122], [54, 137], [54, 154], [54, 180], [54, 192], [54, 218], [54, 222], [54, 251], [54, 271], [54, 291], [54, 292], [55, 64], [55, 81], [55, 93], [55, 105], [55, 119], [55, 143], [55, 144], [55, 146], [55, 166], [55, 183], [55, 192], [55, 221], [55, 231], [55, 233], [55, 246], [55, 247], [55, 267], [55, 288], [56, 71], [56, 72], [56, 96], [56, 110], [56, 120], [56, 123], [56, 134], [56, 135], [56, 146], [56, 159], [56, 171], [56, 184], [56, 224], [56, 235], [56, 253], [56, 295], [56, 297], [56, 298], [57, 65], [57, 94], [57, 119], [57, 142], [57, 148], [57, 166], [57, 183], [57, 195], [57, 241], [57, 276], [58, 59], [58, 63], [58, 88], [58, 110], [58, 129], [58, 164], [58, 177], [58, 181], [58, 184], [58, 185], [58, 204], [58, 231], [58, 284], [58, 293], [58, 296], [59, 68], [59, 69], [59, 96], [59, 111], [59, 162], [59, 189], [59, 203], [59, 207], [59, 249], [59, 254], [59, 268], [59, 269], [59, 285], [60, 71], [60, 96], [60, 101], [60, 104], [60, 106], [60, 134], [60, 149], [60, 152], [60, 159], [60, 166], [60, 174], [60, 228], [60, 261], [60, 270], [60, 275], [60, 278], [61, 68], [61, 83], [61, 105], [61, 116], [61, 147], [61, 150], [61, 169], [61, 173], [61, 181], [61, 191], [61, 204], [61, 209], [61, 216], [61, 219], [61, 231], [61, 234], [61, 242], [61, 248], [61, 261], [61, 265], [61, 273], [61, 275], [61, 281], [62, 104], [62, 136], [62, 146], [62, 160], [62, 163], [62, 167], [62, 179], [62, 190], [62, 215], [62, 246], [62, 253], [62, 259], [62, 264], [62, 274], [63, 68], [63, 109], [63, 110], [63, 147], [63, 165], [63, 181], [63, 192], [63, 194], [63, 210], [63, 276], [63, 292], [64, 78], [64, 86], [64, 110], [64, 118], [64, 124], [64, 132], [64, 137], [64, 145], [64, 151], [64, 164], [64, 185], [64, 208], [64, 252], [64, 256], [64, 259], [64, 269], [64, 294], [65, 66], [65, 115], [65, 130], [65, 143], [65, 146], [65, 150], [65, 158], [65, 160], [65, 188], [65, 196], [65, 211], [65, 221], [65, 247], [65, 262], [65, 266], [65, 287], [65, 292], [66, 118], [66, 124], [66, 127], [66, 136], [66, 137], [66, 145], [66, 191], [66, 193], [66, 220], [66, 222], [66, 223], [66, 225], [66, 235], [66, 237], [66, 260], [66, 263], [66, 296], [67, 84], [67, 85], [67, 110], [67, 154], [67, 155], [67, 162], [67, 171], [67, 183], [67, 186], [67, 201], [67, 211], [67, 236], [67, 271], [67, 286], [68, 82], [68, 95], [68, 148], [68, 152], [68, 162], [68, 167], [68, 170], [68, 178], [68, 185], [68, 186], [68, 193], [68, 200], [68, 215], [68, 276], [69, 82], [69, 95], [69, 122], [69, 123], [69, 129], [69, 165], [69, 187], [69, 188], [69, 197], [69, 205], [69, 254], [69, 281], [69, 285], [70, 71], [70, 83], [70, 120], [70, 128], [70, 130], [70, 193], [70, 220], [70, 236], [70, 255], [70, 259], [70, 261], [70, 268], [70, 271], [70, 278], [70, 294], [71, 75], [71, 76], [71, 77], [71, 90], [71, 109], [71, 111], [71, 133], [71, 138], [71, 148], [71, 160], [71, 164], [71, 191], [71, 210], [71, 218], [71, 232], [71, 256], [71, 280], [71, 281], [71, 289], [71, 294], [71, 297], [72, 77], [72, 99], [72, 112], [72, 121], [72, 128], [72, 138], [72, 143], [72, 203], [72, 217], [72, 221], [72, 232], [72, 236], [72, 243], [72, 276], [73, 98], [73, 119], [73, 124], [73, 134], [73, 168], [73, 170], [73, 187], [73, 189], [73, 200], [73, 214], [73, 230], [73, 233], [73, 258], [73, 263], [73, 276], [73, 277], [73, 299], [74, 80], [74, 92], [74, 127], [74, 131], [74, 160], [74, 192], [74, 209], [74, 247], [74, 249], [74, 286], [74, 295], [74, 298], [75, 109], [75, 126], [75, 143], [75, 171], [75, 174], [75, 189], [75, 198], [75, 199], [75, 238], [75, 289], [75, 299], [76, 82], [76, 94], [76, 140], [76, 152], [76, 167], [76, 182], [76, 206], [76, 208], [76, 213], [76, 227], [76, 229], [76, 246], [76, 254], [76, 275], [76, 278], [77, 90], [77, 135], [77, 166], [77, 173], [77, 175], [77, 177], [77, 178], [77, 185], [77, 186], [77, 188], [77, 190], [77, 200], [77, 203], [77, 212], [77, 234], [77, 237], [77, 244], [77, 258], [77, 270], [77, 287], [78, 102], [78, 118], [78, 127], [78, 137], [78, 138], [78, 148], [78, 204], [78, 231], [78, 257], [78, 267], [78, 293], [78, 296], [79, 93], [79, 100], [79, 116], [79, 133], [79, 138], [79, 144], [79, 152], [79, 168], [79, 189], [79, 237], [79, 289], [80, 81], [80, 114], [80, 116], [80, 126], [80, 149], [80, 152], [80, 166], [80, 171], [80, 204], [80, 246], [80, 249], [80, 253], [80, 260], [80, 264], [81, 104], [81, 145], [81, 150], [81, 164], [81, 171], [81, 177], [81, 180], [81, 201], [81, 258], [81, 265], [81, 272], [81, 276], [81, 281], [81, 292], [82, 84], [82, 106], [82, 144], [82, 193], [82, 249], [82, 269], [82, 270], [82, 276], [82, 299], [83, 87], [83, 103], [83, 119], [83, 138], [83, 146], [83, 149], [83, 150], [83, 158], [83, 190], [83, 191], [83, 217], [83, 246], [83, 258], [83, 292], [84, 96], [84, 97], [84, 104], [84, 108], [84, 109], [84, 110], [84, 112], [84, 122], [84, 135], [84, 142], [84, 148], [84, 154], [84, 155], [84, 161], [84, 163], [84, 185], [84, 186], [84, 192], [84, 193], [84, 214], [84, 220], [84, 226], [84, 230], [84, 256], [84, 257], [84, 272], [84, 274], [84, 278], [84, 291], [84, 293], [84, 298], [85, 124], [85, 141], [85, 151], [85, 156], [85, 198], [85, 205], [85, 229], [85, 249], [85, 254], [85, 271], [85, 291], [86, 88], [86, 97], [86, 106], [86, 108], [86, 128], [86, 139], [86, 147], [86, 162], [86, 174], [86, 190], [86, 212], [86, 213], [86, 229], [86, 233], [86, 250], [86, 292], [87, 90], [87, 109], [87, 126], [87, 145], [87, 149], [87, 162], [87, 168], [87, 178], [87, 185], [87, 198], [87, 204], [87, 261], [88, 89], [88, 90], [88, 108], [88, 124], [88, 160], [88, 177], [88, 207], [88, 226], [88, 259], [88, 270], [88, 284], [88, 288], [89, 107], [89, 131], [89, 175], [89, 253], [89, 276], [89, 285], [90, 111], [90, 141], [90, 171], [90, 172], [90, 178], [90, 213], [90, 231], [90, 252], [90, 270], [90, 288], [90, 296], [90, 297], [91, 106], [91, 122], [91, 148], [91, 150], [91, 159], [91, 173], [91, 196], [91, 217], [91, 219], [91, 228], [91, 234], [91, 251], [91, 252], [91, 270], [91, 291], [92, 110], [92, 111], [92, 123], [92, 131], [92, 181], [92, 183], [92, 190], [92, 203], [92, 254], [92, 261], [92, 290], [92, 292], [92, 296], [93, 100], [93, 121], [93, 127], [93, 144], [93, 151], [93, 169], [93, 171], [93, 192], [93, 202], [93, 207], [93, 240], [93, 256], [93, 267], [94, 98], [94, 121], [94, 174], [94, 184], [94, 194], [94, 204], [94, 206], [94, 246], [94, 251], [94, 254], [94, 288], [94, 298], [95, 100], [95, 129], [95, 131], [95, 147], [95, 158], [95, 159], [95, 217], [95, 227], [95, 229], [95, 269], [95, 272], [95, 277], [95, 288], [95, 297], [96, 101], [96, 104], [96, 161], [96, 162], [96, 174], [96, 183], [96, 218], [96, 223], [96, 233], [96, 249], [96, 271], [96, 274], [96, 295], [97, 123], [97, 158], [97, 165], [97, 173], [97, 181], [97, 198], [97, 221], [97, 250], [97, 257], [97, 274], [97, 292], [98, 122], [98, 125], [98, 131], [98, 132], [98, 138], [98, 158], [98, 165], [98, 169], [98, 178], [98, 184], [98, 186], [98, 189], [98, 196], [98, 201], [98, 205], [98, 208], [98, 221], [98, 225], [98, 234], [98, 237], [98, 238], [98, 245], [98, 275], [98, 282], [98, 292], [98, 299], [99, 100], [99, 112], [99, 128], [99, 143], [99, 146], [99, 161], [99, 171], [99, 207], [99, 257], [99, 258], [99, 276], [100, 107], [100, 114], [100, 133], [100, 136], [100, 140], [100, 150], [100, 151], [100, 155], [100, 159], [100, 164], [100, 166], [100, 183], [100, 198], [100, 207], [100, 210], [100, 216], [100, 217], [100, 219], [100, 227], [100, 233], [100, 243], [100, 274], [100, 282], [100, 296], [100, 298], [101, 105], [101, 171], [101, 202], [101, 204], [101, 212], [101, 226], [101, 241], [101, 253], [101, 254], [101, 257], [102, 107], [102, 122], [102, 123], [102, 127], [102, 129], [102, 133], [102, 134], [102, 149], [102, 155], [102, 157], [102, 170], [102, 178], [102, 184], [102, 186], [102, 190], [102, 205], [102, 207], [102, 208], [102, 228], [102, 244], [102, 252], [102, 260], [102, 269], [103, 106], [103, 120], [103, 130], [103, 132], [103, 140], [103, 154], [103, 157], [103, 160], [103, 177], [103, 199], [103, 231], [103, 234], [103, 236], [103, 238], [104, 146], [104, 197], [104, 210], [104, 223], [104, 239], [104, 271], [104, 274], [104, 279], [105, 110], [105, 158], [105, 159], [105, 164], [105, 197], [105, 280], [105, 288], [105, 291], [106, 126], [106, 141], [106, 142], [106, 151], [106, 159], [106, 166], [106, 185], [106, 221], [106, 223], [106, 246], [106, 287], [107, 114], [107, 117], [107, 120], [107, 130], [107, 144], [107, 160], [107, 167], [107, 168], [107, 203], [107, 220], [107, 238], [107, 250], [107, 253], [107, 261], [107, 263], [107, 267], [107, 279], [108, 125], [108, 132], [108, 148], [108, 236], [108, 242], [108, 248], [108, 275], [108, 281], [108, 287], [108, 299], [109, 150], [109, 155], [109, 181], [109, 184], [109, 187], [109, 199], [109, 202], [109, 217], [109, 221], [109, 274], [110, 114], [110, 143], [110, 147], [110, 153], [110, 160], [110, 189], [110, 196], [110, 226], [110, 294], [111, 121], [111, 128], [111, 129], [111, 135], [111, 146], [111, 162], [111, 171], [111, 176], [111, 178], [111, 192], [111, 212], [111, 235], [111, 236], [111, 246], [111, 262], [111, 268], [111, 280], [111, 286], [111, 292], [111, 294], [112, 143], [112, 148], [112, 160], [112, 178], [112, 188], [112, 194], [112, 209], [112, 226], [112, 244], [112, 261], [112, 269], [113, 116], [113, 128], [113, 164], [113, 168], [113, 185], [113, 230], [113, 235], [113, 236], [113, 241], [113, 244], [113, 250], [113, 253], [113, 256], [113, 257], [113, 267], [113, 281], [113, 290], [113, 297], [114, 127], [114, 128], [114, 137], [114, 154], [114, 169], [114, 227], [114, 243], [114, 252], [114, 253], [114, 268], [114, 299], [115, 121], [115, 158], [115, 164], [115, 177], [115, 191], [115, 197], [115, 205], [115, 237], [115, 241], [115, 263], [115, 270], [115, 287], [116, 159], [116, 173], [116, 181], [116, 185], [116, 213], [116, 245], [116, 280], [116, 289], [116, 292], [117, 138], [117, 158], [117, 190], [117, 208], [117, 210], [117, 235], [117, 237], [117, 243], [117, 268], [117, 294], [118, 121], [118, 197], [118, 213], [118, 215], [118, 226], [118, 245], [118, 270], [118, 286], [119, 122], [119, 143], [119, 160], [119, 170], [119, 198], [119, 204], [119, 232], [119, 255], [119, 267], [119, 282], [119, 288], [119, 291], [120, 130], [120, 150], [120, 163], [120, 174], [120, 224], [120, 255], [120, 297], [121, 127], [121, 174], [121, 179], [121, 202], [121, 210], [121, 216], [121, 239], [121, 251], [121, 253], [121, 256], [121, 263], [121, 288], [122, 127], [122, 134], [122, 139], [122, 152], [122, 170], [122, 216], [122, 238], [122, 241], [122, 258], [122, 264], [122, 284], [122, 294], [122, 298], [123, 142], [123, 166], [123, 170], [123, 180], [123, 185], [123, 188], [123, 192], [123, 246], [123, 260], [123, 278], [123, 293], [124, 125], [124, 142], [124, 164], [124, 175], [124, 214], [124, 220], [124, 230], [124, 249], [124, 292], [125, 135], [125, 162], [125, 184], [125, 188], [125, 192], [125, 206], [125, 244], [125, 253], [125, 292], [125, 298], [126, 131], [126, 138], [126, 157], [126, 201], [126, 208], [126, 237], [126, 238], [126, 241], [126, 254], [126, 277], [127, 132], [127, 140], [127, 145], [127, 151], [127, 152], [127, 153], [127, 168], [127, 172], [127, 218], [127, 227], [127, 261], [127, 268], [127, 277], [127, 285], [127, 292], [128, 145], [128, 153], [128, 164], [128, 166], [128, 201], [128, 208], [128, 212], [128, 218], [128, 234], [129, 186], [129, 192], [129, 212], [129, 231], [129, 244], [129, 255], [129, 270], [129, 295], [130, 131], [130, 155], [130, 156], [130, 175], [130, 216], [130, 232], [130, 245], [130, 264], [130, 277], [130, 288], [131, 139], [131, 148], [131, 167], [131, 182], [131, 183], [131, 196], [131, 220], [131, 234], [131, 242], [131, 267], [131, 276], [131, 279], [131, 280], [132, 135], [132, 136], [132, 154], [132, 157], [132, 182], [132, 210], [132, 212], [132, 244], [132, 249], [132, 274], [132, 291], [132, 299], [133, 137], [133, 140], [133, 177], [133, 196], [133, 206], [133, 210], [133, 223], [133, 224], [133, 259], [133, 267], [133, 274], [133, 293], [134, 138], [134, 158], [134, 216], [134, 226], [134, 242], [134, 248], [134, 249], [134, 264], [134, 271], [134, 297], [135, 145], [135, 157], [135, 159], [135, 163], [135, 189], [135, 237], [135, 271], [135, 274], [135, 293], [135, 298], [136, 145], [136, 151], [136, 160], [136, 164], [136, 199], [136, 206], [136, 228], [136, 257], [136, 273], [136, 279], [137, 140], [137, 148], [137, 156], [137, 169], [137, 177], [137, 185], [137, 208], [137, 213], [137, 249], [137, 255], [137, 260], [138, 160], [138, 164], [138, 173], [138, 188], [138, 194], [138, 209], [138, 212], [138, 235], [138, 241], [138, 242], [138, 267], [138, 275], [138, 287], [138, 289], [139, 140], [139, 144], [139, 152], [139, 153], [139, 155], [139, 157], [139, 161], [139, 162], [139, 166], [139, 168], [139, 171], [139, 176], [139, 187], [139, 192], [139, 200], [139, 202], [139, 225], [139, 254], [139, 267], [139, 270], [139, 292], [139, 297], [140, 155], [140, 169], [140, 172], [140, 229], [140, 272], [140, 275], [140, 279], [140, 281], [140, 293], [140, 296], [141, 145], [141, 154], [141, 157], [141, 165], [141, 169], [141, 188], [141, 201], [141, 205], [141, 236], [141, 266], [141, 286], [142, 153], [142, 156], [142, 182], [142, 212], [142, 229], [142, 250], [142, 262], [142, 290], [142, 293], [143, 157], [143, 180], [143, 196], [143, 222], [143, 233], [143, 246], [143, 248], [143, 278], [143, 289], [143, 298], [144, 153], [144, 183], [144, 210], [144, 215], [144, 226], [144, 236], [144, 253], [144, 257], [144, 263], [144, 271], [144, 277], [144, 285], [144, 290], [144, 291], [145, 156], [145, 157], [145, 160], [145, 162], [145, 176], [145, 178], [145, 182], [145, 191], [145, 206], [145, 211], [145, 242], [145, 245], [145, 249], [145, 270], [145, 279], [145, 284], [145, 285], [145, 286], [145, 296], [146, 151], [146, 163], [146, 185], [146, 191], [146, 251], [146, 260], [146, 261], [146, 280], [147, 154], [147, 156], [147, 162], [147, 164], [147, 190], [147, 204], [147, 207], [147, 212], [147, 232], [147, 241], [147, 274], [147, 288], [148, 159], [148, 170], [148, 200], [148, 209], [148, 230], [148, 236], [148, 243], [148, 259], [148, 262], [148, 270], [148, 282], [149, 159], [149, 160], [149, 161], [149, 190], [149, 222], [149, 226], [149, 234], [149, 240], [149, 256], [150, 158], [150, 163], [150, 178], [150, 193], [150, 205], [150, 221], [150, 235], [150, 267], [150, 274], [150, 276], [150, 282], [150, 286], [151, 163], [151, 174], [151, 181], [151, 185], [151, 235], [151, 236], [151, 239], [151, 240], [151, 248], [151, 258], [152, 163], [152, 195], [152, 221], [152, 222], [152, 227], [152, 231], [152, 268], [152, 283], [152, 286], [153, 170], [153, 173], [153, 227], [153, 230], [153, 258], [153, 265], [153, 283], [153, 291], [154, 178], [154, 195], [154, 211], [154, 224], [154, 228], [154, 239], [154, 246], [154, 253], [154, 255], [154, 263], [155, 182], [155, 183], [155, 196], [155, 210], [155, 211], [155, 222], [155, 227], [155, 237], [155, 238], [155, 242], [155, 250], [155, 270], [155, 273], [155, 287], [156, 159], [156, 165], [156, 174], [156, 198], [156, 203], [156, 212], [156, 225], [156, 240], [156, 260], [156, 262], [156, 264], [156, 269], [156, 278], [156, 281], [156, 286], [156, 292], [156, 295], [157, 159], [157, 160], [157, 190], [157, 205], [157, 210], [157, 213], [157, 235], [157, 238], [157, 245], [157, 254], [157, 260], [157, 263], [157, 278], [157, 281], [158, 172], [158, 173], [158, 175], [158, 223], [158, 294], [159, 178], [159, 195], [159, 229], [159, 239], [159, 242], [159, 243], [159, 249], [159, 267], [159, 295], [160, 162], [160, 184], [160, 214], [160, 254], [160, 267], [160, 280], [161, 165], [161, 169], [161, 182], [161, 236], [161, 245], [161, 250], [161, 255], [161, 258], [161, 266], [161, 277], [161, 288], [162, 166], [162, 195], [162, 212], [162, 229], [162, 237], [162, 240], [162, 265], [162, 278], [162, 285], [163, 209], [163, 255], [163, 259], [164, 180], [164, 205], [164, 219], [164, 224], [164, 270], [164, 274], [164, 291], [164, 293], [165, 239], [165, 248], [165, 249], [165, 267], [166, 174], [166, 180], [166, 187], [166, 188], [166, 192], [166, 199], [166, 200], [166, 205], [166, 231], [166, 259], [166, 283], [166, 293], [166, 296], [167, 178], [167, 189], [167, 202], [167, 282], [167, 283], [167, 292], [167, 298], [168, 177], [168, 189], [168, 191], [168, 197], [168, 221], [168, 225], [168, 231], [168, 241], [169, 170], [169, 172], [169, 178], [169, 193], [169, 200], [169, 201], [169, 231], [169, 242], [169, 245], [169, 247], [169, 268], [169, 274], [170, 186], [170, 208], [170, 240], [170, 241], [170, 257], [171, 179], [171, 181], [171, 184], [171, 194], [171, 218], [171, 225], [171, 288], [172, 175], [172, 187], [172, 196], [172, 207], [172, 215], [172, 233], [172, 241], [172, 250], [172, 258], [172, 266], [172, 267], [172, 288], [172, 291], [172, 292], [172, 295], [172, 298], [173, 185], [173, 187], [173, 188], [173, 190], [173, 211], [173, 212], [173, 217], [173, 227], [173, 264], [173, 272], [173, 295], [173, 299], [174, 204], [174, 220], [174, 228], [174, 246], [174, 255], [174, 258], [174, 296], [174, 299], [175, 191], [175, 193], [175, 247], [175, 254], [175, 264], [175, 267], [175, 279], [175, 286], [175, 289], [175, 298], [176, 178], [176, 198], [176, 206], [176, 237], [176, 242], [176, 255], [176, 270], [176, 289], [176, 293], [177, 183], [177, 188], [177, 199], [177, 202], [177, 208], [177, 254], [177, 278], [177, 280], [177, 283], [177, 291], [178, 218], [178, 279], [179, 189], [179, 209], [179, 229], [179, 246], [179, 254], [179, 270], [179, 281], [179, 283], [179, 293], [180, 198], [180, 205], [180, 230], [180, 270], [180, 272], [181, 185], [181, 187], [181, 199], [181, 201], [181, 207], [181, 210], [181, 211], [181, 218], [181, 236], [181, 273], [182, 188], [182, 212], [182, 233], [182, 243], [182, 254], [182, 266], [182, 274], [182, 291], [182, 296], [183, 200], [183, 224], [183, 233], [183, 270], [183, 280], [183, 290], [183, 293], [184, 186], [184, 216], [184, 269], [184, 271], [184, 272], [184, 282], [185, 197], [185, 198], [185, 203], [185, 205], [185, 213], [185, 215], [185, 221], [185, 233], [185, 237], [185, 255], [185, 257], [185, 260], [185, 266], [185, 282], [185, 290], [185, 291], [186, 187], [186, 193], [186, 206], [186, 219], [186, 234], [186, 250], [186, 265], [186, 278], [186, 289], [187, 188], [187, 201], [187, 248], [187, 272], [187, 274], [187, 278], [187, 279], [187, 284], [187, 291], [187, 295], [187, 297], [188, 208], [188, 256], [188, 258], [188, 270], [188, 282], [188, 285], [188, 291], [188, 297], [189, 191], [189, 209], [189, 210], [189, 215], [189, 258], [189, 265], [189, 270], [189, 275], [189, 276], [190, 221], [190, 229], [190, 230], [190, 247], [190, 252], [190, 269], [190, 270], [190, 280], [190, 286], [191, 195], [191, 206], [191, 213], [191, 273], [191, 283], [191, 287], [192, 194], [192, 197], [192, 204], [192, 211], [192, 216], [192, 255], [192, 287], [193, 202], [193, 211], [193, 234], [193, 244], [193, 246], [193, 250], [193, 268], [193, 270], [193, 292], [194, 200], [194, 213], [194, 226], [194, 228], [194, 231], [194, 240], [194, 246], [194, 273], [194, 278], [194, 292], [195, 205], [195, 237], [195, 251], [195, 276], [195, 292], [195, 299], [196, 214], [196, 240], [196, 241], [196, 245], [196, 291], [196, 296], [197, 219], [197, 224], [197, 233], [197, 252], [197, 298], [197, 299], [198, 243], [198, 267], [198, 275], [198, 297], [199, 221], [199, 241], [199, 294], [200, 203], [200, 222], [200, 224], [200, 247], [200, 249], [200, 267], [200, 269], [200, 270], [200, 283], [200, 289], [200, 297], [200, 299], [201, 203], [201, 205], [201, 214], [201, 232], [201, 251], [201, 268], [201, 289], [201, 291], [202, 214], [202, 219], [202, 246], [202, 271], [202, 282], [202, 289], [203, 229], [203, 248], [203, 273], [204, 231], [204, 265], [204, 278], [204, 298], [205, 235], [205, 271], [205, 272], [205, 291], [206, 238], [206, 240], [206, 243], [206, 270], [206, 274], [206, 279], [206, 297], [207, 235], [207, 239], [207, 261], [207, 293], [207, 294], [208, 222], [208, 236], [208, 267], [208, 285], [208, 299], [209, 228], [209, 230], [209, 237], [209, 242], [209, 263], [209, 268], [209, 284], [210, 237], [210, 253], [210, 266], [210, 274], [210, 293], [211, 212], [211, 225], [211, 227], [211, 248], [211, 282], [212, 233], [212, 248], [212, 259], [212, 260], [212, 276], [212, 297], [212, 298], [213, 220], [213, 226], [213, 239], [213, 254], [213, 264], [213, 272], [213, 274], [213, 282], [214, 216], [214, 265], [214, 292], [214, 296], [215, 223], [215, 241], [215, 245], [215, 250], [215, 253], [215, 254], [215, 270], [215, 290], [216, 232], [216, 238], [216, 253], [216, 254], [217, 221], [217, 246], [217, 248], [217, 260], [217, 262], [217, 267], [217, 277], [217, 294], [218, 233], [218, 256], [218, 279], [218, 292], [219, 224], [219, 245], [219, 260], [219, 278], [219, 280], [219, 292], [219, 295], [220, 228], [220, 238], [220, 242], [220, 299], [221, 227], [221, 239], [221, 244], [221, 253], [221, 255], [221, 257], [221, 276], [221, 285], [222, 240], [222, 271], [222, 284], [222, 286], [222, 295], [223, 229], [223, 230], [223, 235], [223, 242], [223, 243], [223, 276], [223, 282], [224, 260], [224, 275], [224, 294], [224, 295], [224, 296], [224, 299], [225, 237], [225, 254], [225, 289], [226, 231], [226, 264], [226, 286], [226, 291], [226, 298], [227, 247], [227, 258], [227, 287], [228, 239], [228, 284], [228, 292], [229, 236], [229, 241], [229, 270], [230, 251], [230, 254], [230, 290], [231, 233], [231, 238], [231, 243], [231, 256], [231, 258], [231, 264], [231, 282], [232, 233], [232, 235], [232, 239], [232, 241], [232, 249], [232, 274], [232, 276], [232, 278], [233, 244], [233, 264], [233, 280], [233, 281], [233, 292], [234, 241], [234, 255], [234, 272], [234, 291], [234, 295], [234, 297], [235, 245], [235, 293], [236, 246], [236, 252], [236, 297], [237, 240], [237, 276], [237, 288], [238, 243], [238, 252], [238, 272], [238, 294], [238, 299], [239, 244], [239, 264], [239, 265], [239, 275], [239, 298], [240, 241], [240, 257], [240, 297], [241, 251], [241, 262], [241, 267], [241, 283], [241, 287], [241, 288], [241, 292], [242, 250], [242, 274], [242, 276], [242, 278], [242, 281], [243, 248], [244, 285], [245, 250], [245, 252], [245, 271], [245, 292], [246, 250], [246, 261], [246, 272], [246, 280], [246, 289], [246, 293], [246, 298], [247, 276], [247, 299], [248, 265], [248, 271], [250, 288], [251, 262], [252, 257], [252, 258], [252, 262], [252, 270], [252, 290], [253, 259], [253, 270], [253, 272], [254, 272], [255, 268], [256, 258], [256, 266], [256, 270], [256, 276], [256, 295], [257, 268], [257, 272], [257, 290], [258, 275], [258, 297], [259, 271], [259, 294], [260, 263], [261, 275], [261, 295], [262, 276], [262, 281], [263, 292], [264, 266], [264, 285], [264, 291], [264, 292], [265, 277], [265, 286], [265, 292], [265, 296], [266, 271], [266, 279], [266, 292], [267, 284], [268, 280], [268, 297], [269, 271], [270, 272], [270, 275], [270, 291], [271, 273], [271, 281], [271, 282], [272, 273], [272, 274], [273, 279], [273, 291], [274, 289], [275, 284], [275, 294], [276, 277], [277, 281], [277, 286], [277, 288], [277, 296], [279, 290], [279, 298], [281, 290], [281, 298], [282, 298], [283, 296], [284, 296], [285, 288], [285, 293], [287, 294], [289, 291], [294, 297]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l6-s5/solution/solve.sh b/tasks/construct-nppc-dominating-set-l6-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..929f42b810c836db4311a37eacfa488a4329adc4 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-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' +{"dominating_set": [15, 41, 44, 56, 61, 71, 84, 98, 100, 102, 139, 145, 185, 241, 246, 254, 264, 270, 276, 292]} +RLMATH_EOF diff --git a/tasks/construct-nppc-dominating-set-l6-s5/tests/check.py b/tasks/construct-nppc-dominating-set-l6-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0677a7bcbccb02297d022ffa4b5dd15da6371bff --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s5/tests/check.py @@ -0,0 +1,23 @@ +"""Dominating set of size <= k. Accepts any valid dominating set.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier has no type/range checks (out-of-range labels and floats are silently used) + d = int_list(ans.get("dominating_set"), None, 0, n - 1, "dominating_set") + if len(set(d)) != len(d): + raise Invalid("dominating_set contains duplicates") + if not d or len(d) > k: + raise Invalid(f"dominating_set must have 1..{k} vertices, got {len(d)}") + dom = set(d) + s = set(d) + for u, v in inst["edges"]: + if u in s: + dom.add(v) + if v in s: + dom.add(u) + if len(dom) != n: + miss = min(set(range(n)) - dom) + raise Invalid(f"vertex {miss} is not dominated") + return None, {"size": len(d)} diff --git a/tasks/construct-nppc-dominating-set-l6-s5/tests/instance.json b/tasks/construct-nppc-dominating-set-l6-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..87e066e6d9f14211c02eb562b5ded9642ce2bf33 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s5/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 300, "k": 20, "edges": [[0, 12], [0, 25], [0, 26], [0, 37], [0, 78], [0, 102], [0, 117], [0, 185], [0, 212], [0, 242], [0, 265], [0, 282], [1, 2], [1, 23], [1, 50], [1, 130], [1, 134], [1, 139], [1, 143], [1, 146], [1, 147], [1, 188], [1, 205], [1, 207], [1, 234], [1, 297], [2, 16], [2, 115], [2, 140], [2, 142], [2, 149], [2, 161], [2, 162], [2, 169], [2, 182], [2, 197], [2, 222], [2, 227], [2, 258], [2, 261], [2, 262], [2, 264], [2, 269], [2, 277], [2, 291], [3, 9], [3, 15], [3, 31], [3, 36], [3, 58], [3, 78], [3, 109], [3, 112], [3, 151], [3, 158], [3, 166], [3, 175], [3, 183], [3, 189], [3, 190], [3, 208], [3, 210], [3, 239], [3, 253], [3, 261], [3, 273], [3, 278], [3, 281], [4, 21], [4, 48], [4, 100], [4, 105], [4, 111], [4, 112], [4, 144], [4, 148], [4, 187], [4, 219], [4, 246], [4, 264], [4, 276], [4, 286], [4, 297], [5, 54], [5, 73], [5, 84], [5, 155], [5, 192], [5, 221], [5, 254], [5, 260], [5, 270], [6, 7], [6, 21], [6, 30], [6, 64], [6, 86], [6, 126], [6, 161], [6, 224], [6, 236], [6, 243], [6, 245], [6, 251], [6, 264], [6, 284], [7, 13], [7, 30], [7, 44], [7, 46], [7, 106], [7, 179], [7, 180], [7, 203], [7, 204], [7, 224], [7, 233], [7, 239], [7, 247], [7, 258], [7, 268], [8, 18], [8, 24], [8, 43], [8, 50], [8, 55], [8, 57], [8, 74], [8, 80], [8, 88], [8, 102], [8, 117], [8, 124], [8, 138], [8, 169], [8, 218], [8, 245], [9, 33], [9, 44], [9, 48], [9, 60], [9, 63], [9, 64], [9, 71], [9, 84], [9, 119], [9, 139], [9, 161], [9, 204], [9, 237], [9, 262], [9, 267], [9, 297], [10, 41], [10, 75], [10, 121], [10, 154], [10, 162], [10, 209], [10, 217], [10, 241], [10, 269], [10, 280], [11, 13], [11, 19], [11, 24], [11, 29], [11, 35], [11, 60], [11, 72], [11, 74], [11, 86], [11, 118], [11, 143], [11, 185], [11, 190], [11, 197], [11, 216], [11, 241], [11, 252], [11, 255], [11, 258], [11, 286], [12, 36], [12, 69], [12, 84], [12, 86], [12, 88], [12, 99], [12, 104], [12, 106], [12, 136], [12, 156], [12, 181], [12, 198], [12, 199], [12, 218], [12, 245], [12, 255], [12, 279], [12, 285], [13, 19], [13, 26], [13, 29], [13, 31], [13, 43], [13, 53], [13, 61], [13, 68], [13, 79], [13, 84], [13, 85], [13, 92], [13, 109], [13, 110], [13, 123], [13, 195], [13, 198], [13, 213], [13, 240], [13, 246], [13, 271], [13, 280], [14, 16], [14, 30], [14, 35], [14, 61], [14, 67], [14, 75], [14, 123], [14, 141], [14, 147], [14, 148], [14, 161], [14, 162], [14, 168], [14, 181], [14, 185], [14, 195], [14, 196], [14, 210], [14, 214], [14, 224], [14, 229], [14, 243], [14, 255], [14, 274], [14, 284], [14, 287], [15, 40], [15, 53], [15, 57], [15, 62], [15, 74], [15, 97], [15, 105], [15, 113], [15, 117], [15, 121], [15, 131], [15, 141], [15, 175], [15, 196], [15, 225], [15, 238], [15, 244], [15, 249], [15, 252], [15, 255], [15, 256], [15, 268], [15, 276], [15, 279], [15, 281], [15, 284], [15, 290], [16, 64], [16, 66], [16, 78], [16, 79], [16, 85], [16, 108], [16, 127], [16, 130], [16, 141], [16, 144], [16, 162], [16, 176], [16, 182], [16, 201], [16, 208], [16, 212], [16, 221], [16, 250], [16, 251], [16, 261], [16, 266], [16, 276], [17, 25], [17, 37], [17, 56], [17, 78], [17, 94], [17, 96], [17, 139], [17, 146], [17, 148], [17, 170], [17, 178], [17, 204], [17, 209], [17, 219], [17, 257], [17, 266], [17, 270], [17, 292], [17, 296], [18, 83], [18, 121], [18, 122], [18, 158], [18, 206], [18, 220], [18, 221], [18, 241], [18, 255], [18, 290], [19, 22], [19, 23], [19, 24], [19, 42], [19, 67], [19, 71], [19, 98], [19, 105], [19, 120], [19, 135], [19, 195], [19, 196], [19, 250], [19, 260], [19, 276], [19, 283], [20, 71], [20, 73], [20, 75], [20, 78], [20, 92], [20, 106], [20, 114], [20, 119], [20, 125], [20, 138], [20, 139], [20, 150], [20, 168], [20, 196], [20, 197], [20, 204], [20, 205], [20, 246], [20, 274], [20, 289], [21, 26], [21, 43], [21, 45], [21, 69], [21, 84], [21, 97], [21, 133], [21, 137], [21, 146], [21, 151], [21, 154], [21, 161], [21, 165], [21, 173], [21, 202], [21, 229], [21, 233], [21, 235], [21, 237], [21, 238], [21, 240], [21, 289], [22, 54], [22, 64], [22, 72], [22, 86], [22, 108], [22, 152], [22, 160], [22, 195], [22, 209], [22, 224], [22, 229], [22, 240], [22, 241], [22, 250], [22, 252], [22, 262], [22, 264], [22, 266], [22, 273], [22, 280], [22, 282], [22, 287], [22, 289], [23, 38], [23, 57], [23, 59], [23, 60], [23, 84], [23, 110], [23, 173], [23, 184], [23, 186], [23, 216], [23, 230], [23, 275], [23, 278], [23, 283], [24, 46], [24, 49], [24, 56], [24, 58], [24, 113], [24, 118], [24, 120], [24, 124], [24, 177], [24, 203], [24, 261], [24, 267], [24, 270], [25, 74], [25, 88], [25, 98], [25, 105], [25, 118], [25, 136], [25, 148], [25, 156], [25, 168], [25, 225], [25, 263], [26, 38], [26, 66], [26, 110], [26, 111], [26, 115], [26, 116], [26, 126], [26, 136], [26, 154], [26, 159], [26, 160], [26, 183], [26, 185], [26, 203], [26, 214], [26, 224], [26, 230], [26, 247], [26, 270], [26, 285], [26, 286], [27, 64], [27, 113], [27, 144], [27, 145], [27, 160], [27, 173], [27, 183], [27, 187], [27, 198], [27, 209], [27, 224], [27, 234], [27, 241], [27, 242], [27, 249], [27, 250], [27, 262], [27, 291], [28, 40], [28, 47], [28, 59], [28, 62], [28, 109], [28, 145], [28, 168], [28, 183], [28, 196], [28, 203], [28, 221], [28, 267], [28, 276], [29, 54], [29, 55], [29, 61], [29, 75], [29, 87], [29, 91], [29, 121], [29, 136], [29, 156], [29, 171], [29, 180], [29, 208], [29, 246], [30, 35], [30, 60], [30, 112], [30, 115], [30, 124], [30, 155], [30, 176], [30, 216], [30, 218], [30, 224], [30, 245], [30, 267], [30, 284], [30, 292], [31, 36], [31, 52], [31, 63], [31, 80], [31, 92], [31, 105], [31, 136], [31, 168], [31, 177], [31, 205], [31, 224], [31, 229], [31, 261], [31, 264], [31, 275], [31, 284], [32, 37], [32, 48], [32, 92], [32, 101], [32, 127], [32, 138], [32, 151], [32, 158], [32, 160], [32, 164], [32, 172], [32, 222], [32, 223], [32, 236], [32, 240], [32, 270], [32, 278], [32, 288], [32, 292], [33, 102], [33, 116], [33, 120], [33, 122], [33, 123], [33, 152], [33, 163], [33, 167], [33, 170], [33, 213], [33, 237], [33, 271], [34, 74], [34, 119], [34, 121], [34, 137], [34, 144], [34, 145], [34, 146], [34, 150], [34, 160], [34, 172], [34, 173], [34, 178], [34, 182], [34, 186], [34, 203], [34, 204], [34, 218], [34, 219], [34, 224], [34, 225], [34, 254], [34, 259], [34, 262], [34, 263], [34, 276], [34, 284], [34, 297], [35, 67], [35, 81], [35, 86], [35, 91], [35, 92], [35, 99], [35, 102], [35, 144], [35, 156], [35, 175], [35, 210], [35, 254], [35, 262], [35, 270], [35, 286], [35, 289], [35, 296], [35, 297], [36, 38], [36, 41], [36, 110], [36, 120], [36, 121], [36, 139], [36, 151], [36, 156], [36, 165], [36, 197], [36, 198], [36, 208], [36, 211], [36, 230], [36, 240], [36, 246], [36, 260], [36, 263], [36, 299], [37, 56], [37, 69], [37, 72], [37, 98], [37, 100], [37, 104], [37, 110], [37, 115], [37, 117], [37, 148], [37, 149], [37, 169], [37, 209], [37, 260], [37, 264], [37, 286], [37, 289], [37, 297], [38, 92], [38, 95], [38, 102], [38, 103], [38, 105], [38, 157], [38, 165], [38, 203], [38, 245], [38, 254], [38, 273], [38, 297], [39, 64], [39, 67], [39, 84], [39, 88], [39, 98], [39, 107], [39, 110], [39, 137], [39, 151], [39, 178], [39, 207], [39, 237], [39, 254], [39, 256], [39, 268], [39, 279], [39, 291], [40, 74], [40, 85], [40, 88], [40, 101], [40, 130], [40, 134], [40, 194], [40, 199], [40, 210], [40, 217], [40, 221], [40, 247], [40, 254], [40, 263], [41, 49], [41, 55], [41, 62], [41, 68], [41, 69], [41, 73], [41, 86], [41, 88], [41, 97], [41, 99], [41, 107], [41, 114], [41, 117], [41, 145], [41, 150], [41, 152], [41, 154], [41, 155], [41, 159], [41, 160], [41, 163], [41, 164], [41, 166], [41, 179], [41, 186], [41, 206], [41, 212], [41, 222], [41, 224], [41, 239], [41, 258], [41, 259], [41, 260], [41, 262], [41, 271], [42, 57], [42, 61], [42, 81], [42, 106], [42, 108], [42, 110], [42, 111], [42, 128], [42, 138], [42, 165], [42, 166], [42, 171], [42, 210], [42, 215], [42, 231], [42, 233], [42, 259], [42, 260], [42, 262], [42, 290], [43, 53], [43, 64], [43, 78], [43, 98], [43, 121], [43, 122], [43, 140], [43, 144], [43, 163], [43, 165], [43, 187], [43, 193], [43, 198], [43, 199], [43, 201], [43, 214], [43, 220], [43, 230], [43, 235], [43, 246], [43, 263], [43, 276], [43, 280], [43, 291], [44, 52], [44, 79], [44, 92], [44, 93], [44, 103], [44, 112], [44, 119], [44, 144], [44, 150], [44, 151], [44, 164], [44, 173], [44, 182], [44, 205], [44, 211], [44, 223], [44, 225], [44, 226], [44, 231], [44, 240], [44, 243], [44, 245], [44, 256], [44, 259], [44, 266], [44, 270], [44, 274], [44, 299], [45, 90], [45, 128], [45, 142], [45, 159], [45, 168], [45, 178], [45, 185], [45, 199], [45, 201], [45, 212], [45, 221], [45, 238], [45, 240], [45, 251], [45, 264], [45, 272], [45, 276], [45, 295], [46, 68], [46, 71], [46, 81], [46, 124], [46, 138], [46, 155], [46, 159], [46, 193], [46, 243], [46, 264], [47, 51], [47, 53], [47, 74], [47, 78], [47, 87], [47, 95], [47, 100], [47, 103], [47, 125], [47, 143], [47, 148], [47, 177], [47, 193], [47, 206], [47, 211], [47, 217], [47, 250], [47, 258], [47, 259], [48, 70], [48, 71], [48, 76], [48, 98], [48, 106], [48, 123], [48, 139], [48, 143], [48, 161], [48, 173], [48, 176], [48, 180], [48, 183], [48, 185], [48, 210], [48, 215], [48, 217], [48, 218], [48, 219], [48, 249], [48, 268], [48, 277], [49, 100], [49, 109], [49, 112], [49, 118], [49, 123], [49, 135], [49, 147], [49, 151], [49, 172], [49, 185], [49, 204], [49, 247], [50, 62], [50, 74], [50, 75], [50, 82], [50, 98], [50, 102], [50, 105], [50, 115], [50, 124], [50, 141], [50, 202], [50, 219], [50, 247], [50, 266], [50, 273], [50, 284], [50, 286], [50, 290], [51, 87], [51, 117], [51, 145], [51, 159], [51, 185], [51, 217], [51, 220], [51, 223], [51, 235], [51, 242], [51, 284], [51, 292], [51, 295], [52, 67], [52, 76], [52, 99], [52, 103], [52, 153], [52, 157], [52, 168], [52, 182], [52, 186], [52, 261], [52, 288], [52, 296], [53, 81], [53, 90], [53, 101], [53, 145], [53, 161], [53, 163], [53, 173], [53, 177], [53, 183], [53, 201], [53, 212], [53, 215], [53, 227], [53, 236], [53, 257], [53, 267], [53, 297], [53, 299], [54, 58], [54, 82], [54, 86], [54, 93], [54, 114], [54, 122], [54, 137], [54, 154], [54, 180], [54, 192], [54, 218], [54, 222], [54, 251], [54, 271], [54, 291], [54, 292], [55, 64], [55, 81], [55, 93], [55, 105], [55, 119], [55, 143], [55, 144], [55, 146], [55, 166], [55, 183], [55, 192], [55, 221], [55, 231], [55, 233], [55, 246], [55, 247], [55, 267], [55, 288], [56, 71], [56, 72], [56, 96], [56, 110], [56, 120], [56, 123], [56, 134], [56, 135], [56, 146], [56, 159], [56, 171], [56, 184], [56, 224], [56, 235], [56, 253], [56, 295], [56, 297], [56, 298], [57, 65], [57, 94], [57, 119], [57, 142], [57, 148], [57, 166], [57, 183], [57, 195], [57, 241], [57, 276], [58, 59], [58, 63], [58, 88], [58, 110], [58, 129], [58, 164], [58, 177], [58, 181], [58, 184], [58, 185], [58, 204], [58, 231], [58, 284], [58, 293], [58, 296], [59, 68], [59, 69], [59, 96], [59, 111], [59, 162], [59, 189], [59, 203], [59, 207], [59, 249], [59, 254], [59, 268], [59, 269], [59, 285], [60, 71], [60, 96], [60, 101], [60, 104], [60, 106], [60, 134], [60, 149], [60, 152], [60, 159], [60, 166], [60, 174], [60, 228], [60, 261], [60, 270], [60, 275], [60, 278], [61, 68], [61, 83], [61, 105], [61, 116], [61, 147], [61, 150], [61, 169], [61, 173], [61, 181], [61, 191], [61, 204], [61, 209], [61, 216], [61, 219], [61, 231], [61, 234], [61, 242], [61, 248], [61, 261], [61, 265], [61, 273], [61, 275], [61, 281], [62, 104], [62, 136], [62, 146], [62, 160], [62, 163], [62, 167], [62, 179], [62, 190], [62, 215], [62, 246], [62, 253], [62, 259], [62, 264], [62, 274], [63, 68], [63, 109], [63, 110], [63, 147], [63, 165], [63, 181], [63, 192], [63, 194], [63, 210], [63, 276], [63, 292], [64, 78], [64, 86], [64, 110], [64, 118], [64, 124], [64, 132], [64, 137], [64, 145], [64, 151], [64, 164], [64, 185], [64, 208], [64, 252], [64, 256], [64, 259], [64, 269], [64, 294], [65, 66], [65, 115], [65, 130], [65, 143], [65, 146], [65, 150], [65, 158], [65, 160], [65, 188], [65, 196], [65, 211], [65, 221], [65, 247], [65, 262], [65, 266], [65, 287], [65, 292], [66, 118], [66, 124], [66, 127], [66, 136], [66, 137], [66, 145], [66, 191], [66, 193], [66, 220], [66, 222], [66, 223], [66, 225], [66, 235], [66, 237], [66, 260], [66, 263], [66, 296], [67, 84], [67, 85], [67, 110], [67, 154], [67, 155], [67, 162], [67, 171], [67, 183], [67, 186], [67, 201], [67, 211], [67, 236], [67, 271], [67, 286], [68, 82], [68, 95], [68, 148], [68, 152], [68, 162], [68, 167], [68, 170], [68, 178], [68, 185], [68, 186], [68, 193], [68, 200], [68, 215], [68, 276], [69, 82], [69, 95], [69, 122], [69, 123], [69, 129], [69, 165], [69, 187], [69, 188], [69, 197], [69, 205], [69, 254], [69, 281], [69, 285], [70, 71], [70, 83], [70, 120], [70, 128], [70, 130], [70, 193], [70, 220], [70, 236], [70, 255], [70, 259], [70, 261], [70, 268], [70, 271], [70, 278], [70, 294], [71, 75], [71, 76], [71, 77], [71, 90], [71, 109], [71, 111], [71, 133], [71, 138], [71, 148], [71, 160], [71, 164], [71, 191], [71, 210], [71, 218], [71, 232], [71, 256], [71, 280], [71, 281], [71, 289], [71, 294], [71, 297], [72, 77], [72, 99], [72, 112], [72, 121], [72, 128], [72, 138], [72, 143], [72, 203], [72, 217], [72, 221], [72, 232], [72, 236], [72, 243], [72, 276], [73, 98], [73, 119], [73, 124], [73, 134], [73, 168], [73, 170], [73, 187], [73, 189], [73, 200], [73, 214], [73, 230], [73, 233], [73, 258], [73, 263], [73, 276], [73, 277], [73, 299], [74, 80], [74, 92], [74, 127], [74, 131], [74, 160], [74, 192], [74, 209], [74, 247], [74, 249], [74, 286], [74, 295], [74, 298], [75, 109], [75, 126], [75, 143], [75, 171], [75, 174], [75, 189], [75, 198], [75, 199], [75, 238], [75, 289], [75, 299], [76, 82], [76, 94], [76, 140], [76, 152], [76, 167], [76, 182], [76, 206], [76, 208], [76, 213], [76, 227], [76, 229], [76, 246], [76, 254], [76, 275], [76, 278], [77, 90], [77, 135], [77, 166], [77, 173], [77, 175], [77, 177], [77, 178], [77, 185], [77, 186], [77, 188], [77, 190], [77, 200], [77, 203], [77, 212], [77, 234], [77, 237], [77, 244], [77, 258], [77, 270], [77, 287], [78, 102], [78, 118], [78, 127], [78, 137], [78, 138], [78, 148], [78, 204], [78, 231], [78, 257], [78, 267], [78, 293], [78, 296], [79, 93], [79, 100], [79, 116], [79, 133], [79, 138], [79, 144], [79, 152], [79, 168], [79, 189], [79, 237], [79, 289], [80, 81], [80, 114], [80, 116], [80, 126], [80, 149], [80, 152], [80, 166], [80, 171], [80, 204], [80, 246], [80, 249], [80, 253], [80, 260], [80, 264], [81, 104], [81, 145], [81, 150], [81, 164], [81, 171], [81, 177], [81, 180], [81, 201], [81, 258], [81, 265], [81, 272], [81, 276], [81, 281], [81, 292], [82, 84], [82, 106], [82, 144], [82, 193], [82, 249], [82, 269], [82, 270], [82, 276], [82, 299], [83, 87], [83, 103], [83, 119], [83, 138], [83, 146], [83, 149], [83, 150], [83, 158], [83, 190], [83, 191], [83, 217], [83, 246], [83, 258], [83, 292], [84, 96], [84, 97], [84, 104], [84, 108], [84, 109], [84, 110], [84, 112], [84, 122], [84, 135], [84, 142], [84, 148], [84, 154], [84, 155], [84, 161], [84, 163], [84, 185], [84, 186], [84, 192], [84, 193], [84, 214], [84, 220], [84, 226], [84, 230], [84, 256], [84, 257], [84, 272], [84, 274], [84, 278], [84, 291], [84, 293], [84, 298], [85, 124], [85, 141], [85, 151], [85, 156], [85, 198], [85, 205], [85, 229], [85, 249], [85, 254], [85, 271], [85, 291], [86, 88], [86, 97], [86, 106], [86, 108], [86, 128], [86, 139], [86, 147], [86, 162], [86, 174], [86, 190], [86, 212], [86, 213], [86, 229], [86, 233], [86, 250], [86, 292], [87, 90], [87, 109], [87, 126], [87, 145], [87, 149], [87, 162], [87, 168], [87, 178], [87, 185], [87, 198], [87, 204], [87, 261], [88, 89], [88, 90], [88, 108], [88, 124], [88, 160], [88, 177], [88, 207], [88, 226], [88, 259], [88, 270], [88, 284], [88, 288], [89, 107], [89, 131], [89, 175], [89, 253], [89, 276], [89, 285], [90, 111], [90, 141], [90, 171], [90, 172], [90, 178], [90, 213], [90, 231], [90, 252], [90, 270], [90, 288], [90, 296], [90, 297], [91, 106], [91, 122], [91, 148], [91, 150], [91, 159], [91, 173], [91, 196], [91, 217], [91, 219], [91, 228], [91, 234], [91, 251], [91, 252], [91, 270], [91, 291], [92, 110], [92, 111], [92, 123], [92, 131], [92, 181], [92, 183], [92, 190], [92, 203], [92, 254], [92, 261], [92, 290], [92, 292], [92, 296], [93, 100], [93, 121], [93, 127], [93, 144], [93, 151], [93, 169], [93, 171], [93, 192], [93, 202], [93, 207], [93, 240], [93, 256], [93, 267], [94, 98], [94, 121], [94, 174], [94, 184], [94, 194], [94, 204], [94, 206], [94, 246], [94, 251], [94, 254], [94, 288], [94, 298], [95, 100], [95, 129], [95, 131], [95, 147], [95, 158], [95, 159], [95, 217], [95, 227], [95, 229], [95, 269], [95, 272], [95, 277], [95, 288], [95, 297], [96, 101], [96, 104], [96, 161], [96, 162], [96, 174], [96, 183], [96, 218], [96, 223], [96, 233], [96, 249], [96, 271], [96, 274], [96, 295], [97, 123], [97, 158], [97, 165], [97, 173], [97, 181], [97, 198], [97, 221], [97, 250], [97, 257], [97, 274], [97, 292], [98, 122], [98, 125], [98, 131], [98, 132], [98, 138], [98, 158], [98, 165], [98, 169], [98, 178], [98, 184], [98, 186], [98, 189], [98, 196], [98, 201], [98, 205], [98, 208], [98, 221], [98, 225], [98, 234], [98, 237], [98, 238], [98, 245], [98, 275], [98, 282], [98, 292], [98, 299], [99, 100], [99, 112], [99, 128], [99, 143], [99, 146], [99, 161], [99, 171], [99, 207], [99, 257], [99, 258], [99, 276], [100, 107], [100, 114], [100, 133], [100, 136], [100, 140], [100, 150], [100, 151], [100, 155], [100, 159], [100, 164], [100, 166], [100, 183], [100, 198], [100, 207], [100, 210], [100, 216], [100, 217], [100, 219], [100, 227], [100, 233], [100, 243], [100, 274], [100, 282], [100, 296], [100, 298], [101, 105], [101, 171], [101, 202], [101, 204], [101, 212], [101, 226], [101, 241], [101, 253], [101, 254], [101, 257], [102, 107], [102, 122], [102, 123], [102, 127], [102, 129], [102, 133], [102, 134], [102, 149], [102, 155], [102, 157], [102, 170], [102, 178], [102, 184], [102, 186], [102, 190], [102, 205], [102, 207], [102, 208], [102, 228], [102, 244], [102, 252], [102, 260], [102, 269], [103, 106], [103, 120], [103, 130], [103, 132], [103, 140], [103, 154], [103, 157], [103, 160], [103, 177], [103, 199], [103, 231], [103, 234], [103, 236], [103, 238], [104, 146], [104, 197], [104, 210], [104, 223], [104, 239], [104, 271], [104, 274], [104, 279], [105, 110], [105, 158], [105, 159], [105, 164], [105, 197], [105, 280], [105, 288], [105, 291], [106, 126], [106, 141], [106, 142], [106, 151], [106, 159], [106, 166], [106, 185], [106, 221], [106, 223], [106, 246], [106, 287], [107, 114], [107, 117], [107, 120], [107, 130], [107, 144], [107, 160], [107, 167], [107, 168], [107, 203], [107, 220], [107, 238], [107, 250], [107, 253], [107, 261], [107, 263], [107, 267], [107, 279], [108, 125], [108, 132], [108, 148], [108, 236], [108, 242], [108, 248], [108, 275], [108, 281], [108, 287], [108, 299], [109, 150], [109, 155], [109, 181], [109, 184], [109, 187], [109, 199], [109, 202], [109, 217], [109, 221], [109, 274], [110, 114], [110, 143], [110, 147], [110, 153], [110, 160], [110, 189], [110, 196], [110, 226], [110, 294], [111, 121], [111, 128], [111, 129], [111, 135], [111, 146], [111, 162], [111, 171], [111, 176], [111, 178], [111, 192], [111, 212], [111, 235], [111, 236], [111, 246], [111, 262], [111, 268], [111, 280], [111, 286], [111, 292], [111, 294], [112, 143], [112, 148], [112, 160], [112, 178], [112, 188], [112, 194], [112, 209], [112, 226], [112, 244], [112, 261], [112, 269], [113, 116], [113, 128], [113, 164], [113, 168], [113, 185], [113, 230], [113, 235], [113, 236], [113, 241], [113, 244], [113, 250], [113, 253], [113, 256], [113, 257], [113, 267], [113, 281], [113, 290], [113, 297], [114, 127], [114, 128], [114, 137], [114, 154], [114, 169], [114, 227], [114, 243], [114, 252], [114, 253], [114, 268], [114, 299], [115, 121], [115, 158], [115, 164], [115, 177], [115, 191], [115, 197], [115, 205], [115, 237], [115, 241], [115, 263], [115, 270], [115, 287], [116, 159], [116, 173], [116, 181], [116, 185], [116, 213], [116, 245], [116, 280], [116, 289], [116, 292], [117, 138], [117, 158], [117, 190], [117, 208], [117, 210], [117, 235], [117, 237], [117, 243], [117, 268], [117, 294], [118, 121], [118, 197], [118, 213], [118, 215], [118, 226], [118, 245], [118, 270], [118, 286], [119, 122], [119, 143], [119, 160], [119, 170], [119, 198], [119, 204], [119, 232], [119, 255], [119, 267], [119, 282], [119, 288], [119, 291], [120, 130], [120, 150], [120, 163], [120, 174], [120, 224], [120, 255], [120, 297], [121, 127], [121, 174], [121, 179], [121, 202], [121, 210], [121, 216], [121, 239], [121, 251], [121, 253], [121, 256], [121, 263], [121, 288], [122, 127], [122, 134], [122, 139], [122, 152], [122, 170], [122, 216], [122, 238], [122, 241], [122, 258], [122, 264], [122, 284], [122, 294], [122, 298], [123, 142], [123, 166], [123, 170], [123, 180], [123, 185], [123, 188], [123, 192], [123, 246], [123, 260], [123, 278], [123, 293], [124, 125], [124, 142], [124, 164], [124, 175], [124, 214], [124, 220], [124, 230], [124, 249], [124, 292], [125, 135], [125, 162], [125, 184], [125, 188], [125, 192], [125, 206], [125, 244], [125, 253], [125, 292], [125, 298], [126, 131], [126, 138], [126, 157], [126, 201], [126, 208], [126, 237], [126, 238], [126, 241], [126, 254], [126, 277], [127, 132], [127, 140], [127, 145], [127, 151], [127, 152], [127, 153], [127, 168], [127, 172], [127, 218], [127, 227], [127, 261], [127, 268], [127, 277], [127, 285], [127, 292], [128, 145], [128, 153], [128, 164], [128, 166], [128, 201], [128, 208], [128, 212], [128, 218], [128, 234], [129, 186], [129, 192], [129, 212], [129, 231], [129, 244], [129, 255], [129, 270], [129, 295], [130, 131], [130, 155], [130, 156], [130, 175], [130, 216], [130, 232], [130, 245], [130, 264], [130, 277], [130, 288], [131, 139], [131, 148], [131, 167], [131, 182], [131, 183], [131, 196], [131, 220], [131, 234], [131, 242], [131, 267], [131, 276], [131, 279], [131, 280], [132, 135], [132, 136], [132, 154], [132, 157], [132, 182], [132, 210], [132, 212], [132, 244], [132, 249], [132, 274], [132, 291], [132, 299], [133, 137], [133, 140], [133, 177], [133, 196], [133, 206], [133, 210], [133, 223], [133, 224], [133, 259], [133, 267], [133, 274], [133, 293], [134, 138], [134, 158], [134, 216], [134, 226], [134, 242], [134, 248], [134, 249], [134, 264], [134, 271], [134, 297], [135, 145], [135, 157], [135, 159], [135, 163], [135, 189], [135, 237], [135, 271], [135, 274], [135, 293], [135, 298], [136, 145], [136, 151], [136, 160], [136, 164], [136, 199], [136, 206], [136, 228], [136, 257], [136, 273], [136, 279], [137, 140], [137, 148], [137, 156], [137, 169], [137, 177], [137, 185], [137, 208], [137, 213], [137, 249], [137, 255], [137, 260], [138, 160], [138, 164], [138, 173], [138, 188], [138, 194], [138, 209], [138, 212], [138, 235], [138, 241], [138, 242], [138, 267], [138, 275], [138, 287], [138, 289], [139, 140], [139, 144], [139, 152], [139, 153], [139, 155], [139, 157], [139, 161], [139, 162], [139, 166], [139, 168], [139, 171], [139, 176], [139, 187], [139, 192], [139, 200], [139, 202], [139, 225], [139, 254], [139, 267], [139, 270], [139, 292], [139, 297], [140, 155], [140, 169], [140, 172], [140, 229], [140, 272], [140, 275], [140, 279], [140, 281], [140, 293], [140, 296], [141, 145], [141, 154], [141, 157], [141, 165], [141, 169], [141, 188], [141, 201], [141, 205], [141, 236], [141, 266], [141, 286], [142, 153], [142, 156], [142, 182], [142, 212], [142, 229], [142, 250], [142, 262], [142, 290], [142, 293], [143, 157], [143, 180], [143, 196], [143, 222], [143, 233], [143, 246], [143, 248], [143, 278], [143, 289], [143, 298], [144, 153], [144, 183], [144, 210], [144, 215], [144, 226], [144, 236], [144, 253], [144, 257], [144, 263], [144, 271], [144, 277], [144, 285], [144, 290], [144, 291], [145, 156], [145, 157], [145, 160], [145, 162], [145, 176], [145, 178], [145, 182], [145, 191], [145, 206], [145, 211], [145, 242], [145, 245], [145, 249], [145, 270], [145, 279], [145, 284], [145, 285], [145, 286], [145, 296], [146, 151], [146, 163], [146, 185], [146, 191], [146, 251], [146, 260], [146, 261], [146, 280], [147, 154], [147, 156], [147, 162], [147, 164], [147, 190], [147, 204], [147, 207], [147, 212], [147, 232], [147, 241], [147, 274], [147, 288], [148, 159], [148, 170], [148, 200], [148, 209], [148, 230], [148, 236], [148, 243], [148, 259], [148, 262], [148, 270], [148, 282], [149, 159], [149, 160], [149, 161], [149, 190], [149, 222], [149, 226], [149, 234], [149, 240], [149, 256], [150, 158], [150, 163], [150, 178], [150, 193], [150, 205], [150, 221], [150, 235], [150, 267], [150, 274], [150, 276], [150, 282], [150, 286], [151, 163], [151, 174], [151, 181], [151, 185], [151, 235], [151, 236], [151, 239], [151, 240], [151, 248], [151, 258], [152, 163], [152, 195], [152, 221], [152, 222], [152, 227], [152, 231], [152, 268], [152, 283], [152, 286], [153, 170], [153, 173], [153, 227], [153, 230], [153, 258], [153, 265], [153, 283], [153, 291], [154, 178], [154, 195], [154, 211], [154, 224], [154, 228], [154, 239], [154, 246], [154, 253], [154, 255], [154, 263], [155, 182], [155, 183], [155, 196], [155, 210], [155, 211], [155, 222], [155, 227], [155, 237], [155, 238], [155, 242], [155, 250], [155, 270], [155, 273], [155, 287], [156, 159], [156, 165], [156, 174], [156, 198], [156, 203], [156, 212], [156, 225], [156, 240], [156, 260], [156, 262], [156, 264], [156, 269], [156, 278], [156, 281], [156, 286], [156, 292], [156, 295], [157, 159], [157, 160], [157, 190], [157, 205], [157, 210], [157, 213], [157, 235], [157, 238], [157, 245], [157, 254], [157, 260], [157, 263], [157, 278], [157, 281], [158, 172], [158, 173], [158, 175], [158, 223], [158, 294], [159, 178], [159, 195], [159, 229], [159, 239], [159, 242], [159, 243], [159, 249], [159, 267], [159, 295], [160, 162], [160, 184], [160, 214], [160, 254], [160, 267], [160, 280], [161, 165], [161, 169], [161, 182], [161, 236], [161, 245], [161, 250], [161, 255], [161, 258], [161, 266], [161, 277], [161, 288], [162, 166], [162, 195], [162, 212], [162, 229], [162, 237], [162, 240], [162, 265], [162, 278], [162, 285], [163, 209], [163, 255], [163, 259], [164, 180], [164, 205], [164, 219], [164, 224], [164, 270], [164, 274], [164, 291], [164, 293], [165, 239], [165, 248], [165, 249], [165, 267], [166, 174], [166, 180], [166, 187], [166, 188], [166, 192], [166, 199], [166, 200], [166, 205], [166, 231], [166, 259], [166, 283], [166, 293], [166, 296], [167, 178], [167, 189], [167, 202], [167, 282], [167, 283], [167, 292], [167, 298], [168, 177], [168, 189], [168, 191], [168, 197], [168, 221], [168, 225], [168, 231], [168, 241], [169, 170], [169, 172], [169, 178], [169, 193], [169, 200], [169, 201], [169, 231], [169, 242], [169, 245], [169, 247], [169, 268], [169, 274], [170, 186], [170, 208], [170, 240], [170, 241], [170, 257], [171, 179], [171, 181], [171, 184], [171, 194], [171, 218], [171, 225], [171, 288], [172, 175], [172, 187], [172, 196], [172, 207], [172, 215], [172, 233], [172, 241], [172, 250], [172, 258], [172, 266], [172, 267], [172, 288], [172, 291], [172, 292], [172, 295], [172, 298], [173, 185], [173, 187], [173, 188], [173, 190], [173, 211], [173, 212], [173, 217], [173, 227], [173, 264], [173, 272], [173, 295], [173, 299], [174, 204], [174, 220], [174, 228], [174, 246], [174, 255], [174, 258], [174, 296], [174, 299], [175, 191], [175, 193], [175, 247], [175, 254], [175, 264], [175, 267], [175, 279], [175, 286], [175, 289], [175, 298], [176, 178], [176, 198], [176, 206], [176, 237], [176, 242], [176, 255], [176, 270], [176, 289], [176, 293], [177, 183], [177, 188], [177, 199], [177, 202], [177, 208], [177, 254], [177, 278], [177, 280], [177, 283], [177, 291], [178, 218], [178, 279], [179, 189], [179, 209], [179, 229], [179, 246], [179, 254], [179, 270], [179, 281], [179, 283], [179, 293], [180, 198], [180, 205], [180, 230], [180, 270], [180, 272], [181, 185], [181, 187], [181, 199], [181, 201], [181, 207], [181, 210], [181, 211], [181, 218], [181, 236], [181, 273], [182, 188], [182, 212], [182, 233], [182, 243], [182, 254], [182, 266], [182, 274], [182, 291], [182, 296], [183, 200], [183, 224], [183, 233], [183, 270], [183, 280], [183, 290], [183, 293], [184, 186], [184, 216], [184, 269], [184, 271], [184, 272], [184, 282], [185, 197], [185, 198], [185, 203], [185, 205], [185, 213], [185, 215], [185, 221], [185, 233], [185, 237], [185, 255], [185, 257], [185, 260], [185, 266], [185, 282], [185, 290], [185, 291], [186, 187], [186, 193], [186, 206], [186, 219], [186, 234], [186, 250], [186, 265], [186, 278], [186, 289], [187, 188], [187, 201], [187, 248], [187, 272], [187, 274], [187, 278], [187, 279], [187, 284], [187, 291], [187, 295], [187, 297], [188, 208], [188, 256], [188, 258], [188, 270], [188, 282], [188, 285], [188, 291], [188, 297], [189, 191], [189, 209], [189, 210], [189, 215], [189, 258], [189, 265], [189, 270], [189, 275], [189, 276], [190, 221], [190, 229], [190, 230], [190, 247], [190, 252], [190, 269], [190, 270], [190, 280], [190, 286], [191, 195], [191, 206], [191, 213], [191, 273], [191, 283], [191, 287], [192, 194], [192, 197], [192, 204], [192, 211], [192, 216], [192, 255], [192, 287], [193, 202], [193, 211], [193, 234], [193, 244], [193, 246], [193, 250], [193, 268], [193, 270], [193, 292], [194, 200], [194, 213], [194, 226], [194, 228], [194, 231], [194, 240], [194, 246], [194, 273], [194, 278], [194, 292], [195, 205], [195, 237], [195, 251], [195, 276], [195, 292], [195, 299], [196, 214], [196, 240], [196, 241], [196, 245], [196, 291], [196, 296], [197, 219], [197, 224], [197, 233], [197, 252], [197, 298], [197, 299], [198, 243], [198, 267], [198, 275], [198, 297], [199, 221], [199, 241], [199, 294], [200, 203], [200, 222], [200, 224], [200, 247], [200, 249], [200, 267], [200, 269], [200, 270], [200, 283], [200, 289], [200, 297], [200, 299], [201, 203], [201, 205], [201, 214], [201, 232], [201, 251], [201, 268], [201, 289], [201, 291], [202, 214], [202, 219], [202, 246], [202, 271], [202, 282], [202, 289], [203, 229], [203, 248], [203, 273], [204, 231], [204, 265], [204, 278], [204, 298], [205, 235], [205, 271], [205, 272], [205, 291], [206, 238], [206, 240], [206, 243], [206, 270], [206, 274], [206, 279], [206, 297], [207, 235], [207, 239], [207, 261], [207, 293], [207, 294], [208, 222], [208, 236], [208, 267], [208, 285], [208, 299], [209, 228], [209, 230], [209, 237], [209, 242], [209, 263], [209, 268], [209, 284], [210, 237], [210, 253], [210, 266], [210, 274], [210, 293], [211, 212], [211, 225], [211, 227], [211, 248], [211, 282], [212, 233], [212, 248], [212, 259], [212, 260], [212, 276], [212, 297], [212, 298], [213, 220], [213, 226], [213, 239], [213, 254], [213, 264], [213, 272], [213, 274], [213, 282], [214, 216], [214, 265], [214, 292], [214, 296], [215, 223], [215, 241], [215, 245], [215, 250], [215, 253], [215, 254], [215, 270], [215, 290], [216, 232], [216, 238], [216, 253], [216, 254], [217, 221], [217, 246], [217, 248], [217, 260], [217, 262], [217, 267], [217, 277], [217, 294], [218, 233], [218, 256], [218, 279], [218, 292], [219, 224], [219, 245], [219, 260], [219, 278], [219, 280], [219, 292], [219, 295], [220, 228], [220, 238], [220, 242], [220, 299], [221, 227], [221, 239], [221, 244], [221, 253], [221, 255], [221, 257], [221, 276], [221, 285], [222, 240], [222, 271], [222, 284], [222, 286], [222, 295], [223, 229], [223, 230], [223, 235], [223, 242], [223, 243], [223, 276], [223, 282], [224, 260], [224, 275], [224, 294], [224, 295], [224, 296], [224, 299], [225, 237], [225, 254], [225, 289], [226, 231], [226, 264], [226, 286], [226, 291], [226, 298], [227, 247], [227, 258], [227, 287], [228, 239], [228, 284], [228, 292], [229, 236], [229, 241], [229, 270], [230, 251], [230, 254], [230, 290], [231, 233], [231, 238], [231, 243], [231, 256], [231, 258], [231, 264], [231, 282], [232, 233], [232, 235], [232, 239], [232, 241], [232, 249], [232, 274], [232, 276], [232, 278], [233, 244], [233, 264], [233, 280], [233, 281], [233, 292], [234, 241], [234, 255], [234, 272], [234, 291], [234, 295], [234, 297], [235, 245], [235, 293], [236, 246], [236, 252], [236, 297], [237, 240], [237, 276], [237, 288], [238, 243], [238, 252], [238, 272], [238, 294], [238, 299], [239, 244], [239, 264], [239, 265], [239, 275], [239, 298], [240, 241], [240, 257], [240, 297], [241, 251], [241, 262], [241, 267], [241, 283], [241, 287], [241, 288], [241, 292], [242, 250], [242, 274], [242, 276], [242, 278], [242, 281], [243, 248], [244, 285], [245, 250], [245, 252], [245, 271], [245, 292], [246, 250], [246, 261], [246, 272], [246, 280], [246, 289], [246, 293], [246, 298], [247, 276], [247, 299], [248, 265], [248, 271], [250, 288], [251, 262], [252, 257], [252, 258], [252, 262], [252, 270], [252, 290], [253, 259], [253, 270], [253, 272], [254, 272], [255, 268], [256, 258], [256, 266], [256, 270], [256, 276], [256, 295], [257, 268], [257, 272], [257, 290], [258, 275], [258, 297], [259, 271], [259, 294], [260, 263], [261, 275], [261, 295], [262, 276], [262, 281], [263, 292], [264, 266], [264, 285], [264, 291], [264, 292], [265, 277], [265, 286], [265, 292], [265, 296], [266, 271], [266, 279], [266, 292], [267, 284], [268, 280], [268, 297], [269, 271], [270, 272], [270, 275], [270, 291], [271, 273], [271, 281], [271, 282], [272, 273], [272, 274], [273, 279], [273, 291], [274, 289], [275, 284], [275, 294], [276, 277], [277, 281], [277, 286], [277, 288], [277, 296], [279, 290], [279, 298], [281, 290], [281, 298], [282, 298], [283, 296], [284, 296], [285, 288], [285, 293], [287, 294], [289, 291], [294, 297]], "family": "nppc_dominating_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-dominating-set-l6-s5/tests/run.py b/tasks/construct-nppc-dominating-set-l6-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-dominating-set-l6-s5/tests/test.sh b/tasks/construct-nppc-dominating-set-l6-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-dominating-set-l6-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-independent-set-l3-s3/environment/Dockerfile b/tasks/construct-nppc-independent-set-l3-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-independent-set-l3-s3/environment/instance.json b/tasks/construct-nppc-independent-set-l3-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2bf8e55a9a54def86d98a71881361024a9dcd602 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s3/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 1], [0, 3], [0, 5], [0, 8], [0, 12], [0, 22], [1, 5], [1, 8], [1, 10], [1, 11], [1, 13], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 23], [2, 3], [2, 6], [2, 11], [2, 15], [2, 17], [3, 5], [3, 7], [3, 9], [3, 10], [3, 11], [3, 13], [3, 16], [3, 17], [3, 20], [3, 22], [3, 23], [4, 8], [4, 9], [4, 18], [5, 6], [5, 7], [5, 9], [5, 11], [5, 18], [5, 19], [6, 9], [6, 10], [6, 11], [6, 14], [6, 18], [6, 21], [6, 22], [7, 9], [7, 11], [7, 15], [7, 18], [8, 13], [8, 14], [8, 16], [8, 17], [8, 19], [8, 20], [8, 21], [9, 10], [9, 15], [9, 19], [9, 22], [9, 23], [10, 18], [11, 12], [11, 13], [11, 14], [11, 16], [11, 17], [11, 19], [11, 20], [12, 15], [12, 17], [12, 18], [12, 19], [12, 22], [12, 23], [13, 15], [13, 17], [14, 17], [14, 18], [14, 22], [15, 17], [15, 18], [15, 20], [15, 21], [15, 22], [15, 23], [16, 17], [16, 18], [17, 18], [18, 19], [18, 20], [20, 22], [21, 22], [22, 23]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l3-s3/solution/solve.sh b/tasks/construct-nppc-independent-set-l3-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..89cb3bca654e98dd7e97ffc0e60a1b87d6889a12 --- /dev/null +++ b/tasks/construct-nppc-independent-set-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' +{"independent_set": [0, 2, 4, 7, 10, 13, 14, 16, 19, 20, 21, 23]} +RLMATH_EOF diff --git a/tasks/construct-nppc-independent-set-l3-s3/tests/check.py b/tasks/construct-nppc-independent-set-l3-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..92279a931488c7f39c08a3b11162b3f54a9c662a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s3/tests/check.py @@ -0,0 +1,19 @@ +"""Independent set of size >= k. Accepts any valid independent set.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + s = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + # upstream NPPC verifier checks len(list) >= size but only tests pairs u < v, so [v]*k passed + if len(set(s)) != len(s): + raise Invalid("independent_set contains duplicates") + if len(s) < k: + raise Invalid(f"independent_set has {len(s)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(s), 2): + if (u, v) in es: + raise Invalid(f"edge between {u} and {v}") + return None, {"size": len(s)} diff --git a/tasks/construct-nppc-independent-set-l3-s3/tests/instance.json b/tasks/construct-nppc-independent-set-l3-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2bf8e55a9a54def86d98a71881361024a9dcd602 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s3/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 1], [0, 3], [0, 5], [0, 8], [0, 12], [0, 22], [1, 5], [1, 8], [1, 10], [1, 11], [1, 13], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 23], [2, 3], [2, 6], [2, 11], [2, 15], [2, 17], [3, 5], [3, 7], [3, 9], [3, 10], [3, 11], [3, 13], [3, 16], [3, 17], [3, 20], [3, 22], [3, 23], [4, 8], [4, 9], [4, 18], [5, 6], [5, 7], [5, 9], [5, 11], [5, 18], [5, 19], [6, 9], [6, 10], [6, 11], [6, 14], [6, 18], [6, 21], [6, 22], [7, 9], [7, 11], [7, 15], [7, 18], [8, 13], [8, 14], [8, 16], [8, 17], [8, 19], [8, 20], [8, 21], [9, 10], [9, 15], [9, 19], [9, 22], [9, 23], [10, 18], [11, 12], [11, 13], [11, 14], [11, 16], [11, 17], [11, 19], [11, 20], [12, 15], [12, 17], [12, 18], [12, 19], [12, 22], [12, 23], [13, 15], [13, 17], [14, 17], [14, 18], [14, 22], [15, 17], [15, 18], [15, 20], [15, 21], [15, 22], [15, 23], [16, 17], [16, 18], [17, 18], [18, 19], [18, 20], [20, 22], [21, 22], [22, 23]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l3-s3/tests/run.py b/tasks/construct-nppc-independent-set-l3-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-independent-set-l3-s3/tests/test.sh b/tasks/construct-nppc-independent-set-l3-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-independent-set-l3-s4/environment/Dockerfile b/tasks/construct-nppc-independent-set-l3-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-nppc-independent-set-l3-s4/environment/instance.json b/tasks/construct-nppc-independent-set-l3-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5ba619714058a65b87c04c6832260228099c3196 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s4/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 1], [0, 3], [0, 4], [0, 6], [0, 8], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 18], [0, 22], [1, 3], [1, 7], [1, 8], [1, 11], [1, 13], [1, 15], [1, 16], [1, 18], [1, 21], [2, 4], [2, 9], [2, 10], [2, 12], [2, 14], [2, 16], [2, 21], [2, 22], [3, 5], [3, 7], [3, 12], [3, 14], [4, 6], [4, 8], [4, 9], [4, 11], [4, 12], [4, 16], [4, 19], [4, 20], [4, 21], [4, 22], [5, 6], [5, 8], [5, 9], [5, 13], [5, 14], [5, 15], [5, 18], [5, 20], [5, 21], [5, 22], [5, 23], [6, 11], [6, 12], [6, 14], [6, 16], [6, 17], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 16], [7, 17], [7, 18], [7, 21], [7, 23], [8, 12], [8, 14], [8, 16], [8, 21], [9, 12], [9, 16], [9, 17], [9, 21], [10, 11], [10, 16], [10, 17], [10, 21], [11, 13], [11, 14], [11, 16], [11, 18], [11, 21], [11, 22], [11, 23], [12, 13], [12, 14], [12, 15], [12, 18], [12, 19], [12, 20], [12, 21], [13, 14], [14, 15], [14, 16], [14, 17], [14, 18], [14, 20], [14, 21], [15, 21], [17, 19], [17, 20], [17, 22], [18, 21], [20, 21]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l3-s4/solution/solve.sh b/tasks/construct-nppc-independent-set-l3-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6ed000d8d652d773d2feea2f11fbc7b82fc94f51 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"independent_set": [3, 6, 8, 9, 10, 13, 15, 18, 19, 20, 22, 23]} +RLMATH_EOF diff --git a/tasks/construct-nppc-independent-set-l3-s4/tests/check.py b/tasks/construct-nppc-independent-set-l3-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..92279a931488c7f39c08a3b11162b3f54a9c662a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s4/tests/check.py @@ -0,0 +1,19 @@ +"""Independent set of size >= k. Accepts any valid independent set.""" +import itertools + +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + s = int_list(ans.get("independent_set"), None, 0, n - 1, "independent_set") + # upstream NPPC verifier checks len(list) >= size but only tests pairs u < v, so [v]*k passed + if len(set(s)) != len(s): + raise Invalid("independent_set contains duplicates") + if len(s) < k: + raise Invalid(f"independent_set has {len(s)} < {k} vertices") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for u, v in itertools.combinations(sorted(s), 2): + if (u, v) in es: + raise Invalid(f"edge between {u} and {v}") + return None, {"size": len(s)} diff --git a/tasks/construct-nppc-independent-set-l3-s4/tests/instance.json b/tasks/construct-nppc-independent-set-l3-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5ba619714058a65b87c04c6832260228099c3196 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s4/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 24, "k": 12, "edges": [[0, 1], [0, 3], [0, 4], [0, 6], [0, 8], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 18], [0, 22], [1, 3], [1, 7], [1, 8], [1, 11], [1, 13], [1, 15], [1, 16], [1, 18], [1, 21], [2, 4], [2, 9], [2, 10], [2, 12], [2, 14], [2, 16], [2, 21], [2, 22], [3, 5], [3, 7], [3, 12], [3, 14], [4, 6], [4, 8], [4, 9], [4, 11], [4, 12], [4, 16], [4, 19], [4, 20], [4, 21], [4, 22], [5, 6], [5, 8], [5, 9], [5, 13], [5, 14], [5, 15], [5, 18], [5, 20], [5, 21], [5, 22], [5, 23], [6, 11], [6, 12], [6, 14], [6, 16], [6, 17], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 16], [7, 17], [7, 18], [7, 21], [7, 23], [8, 12], [8, 14], [8, 16], [8, 21], [9, 12], [9, 16], [9, 17], [9, 21], [10, 11], [10, 16], [10, 17], [10, 21], [11, 13], [11, 14], [11, 16], [11, 18], [11, 21], [11, 22], [11, 23], [12, 13], [12, 14], [12, 15], [12, 18], [12, 19], [12, 20], [12, 21], [13, 14], [14, 15], [14, 16], [14, 17], [14, 18], [14, 20], [14, 21], [15, 21], [17, 19], [17, 20], [17, 22], [18, 21], [20, 21]], "family": "nppc_independent_set", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-independent-set-l3-s4/tests/run.py b/tasks/construct-nppc-independent-set-l3-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-nppc-independent-set-l3-s4/tests/test.sh b/tasks/construct-nppc-independent-set-l3-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-independent-set-l3-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-nppc-quad-diophantine-l2-s2/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l2-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quad-diophantine-l2-s2/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l2-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fc14c9f5f330df6dd208cf5a35dfdc404b74f81b --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s2/environment/instance.json @@ -0,0 +1 @@ +{"a": 329, "b": 976, "c": 782785, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l2-s2/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l2-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a294caa22ff509b39c5c4a64228ec8d70772664f --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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' +{"x": 3, "y": 799} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l2-s2/tests/check.py b/tasks/construct-nppc-quad-diophantine-l2-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s2/tests/check.py @@ -0,0 +1,11 @@ +"""a*x^2 + b*y = c in positive integers. Accepts any solution (exact integer arithmetic).""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier only checks x > 0 and y > 0, so non-integer (float) x, y were accepted + x = as_int(ans.get("x"), "x", lo=1) + y = as_int(ans.get("y"), "y", lo=1) + if inst["a"] * x * x + inst["b"] * y != inst["c"]: + raise Invalid("a*x^2 + b*y != c") + return None, {} diff --git a/tasks/construct-nppc-quad-diophantine-l2-s2/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l2-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fc14c9f5f330df6dd208cf5a35dfdc404b74f81b --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s2/tests/instance.json @@ -0,0 +1 @@ +{"a": 329, "b": 976, "c": 782785, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l2-s2/tests/run.py b/tasks/construct-nppc-quad-diophantine-l2-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quad-diophantine-l2-s2/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l2-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quad-diophantine-l2-s5/environment/Dockerfile b/tasks/construct-nppc-quad-diophantine-l2-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quad-diophantine-l2-s5/environment/instance.json b/tasks/construct-nppc-quad-diophantine-l2-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0f15839fff097e9daf6505c64a2f4499ef79f9e1 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s5/environment/instance.json @@ -0,0 +1 @@ +{"a": 606, "b": 922, "c": 600521258, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l2-s5/solution/solve.sh b/tasks/construct-nppc-quad-diophantine-l2-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f8e3da572f767032ad48fe10687db92b07280c5f --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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' +{"x": 995, "y": 614} +RLMATH_EOF diff --git a/tasks/construct-nppc-quad-diophantine-l2-s5/tests/check.py b/tasks/construct-nppc-quad-diophantine-l2-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..88989d2a8839b089c9b07dd2d3c26c21bfdca58c --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s5/tests/check.py @@ -0,0 +1,11 @@ +"""a*x^2 + b*y = c in positive integers. Accepts any solution (exact integer arithmetic).""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier only checks x > 0 and y > 0, so non-integer (float) x, y were accepted + x = as_int(ans.get("x"), "x", lo=1) + y = as_int(ans.get("y"), "y", lo=1) + if inst["a"] * x * x + inst["b"] * y != inst["c"]: + raise Invalid("a*x^2 + b*y != c") + return None, {} diff --git a/tasks/construct-nppc-quad-diophantine-l2-s5/tests/instance.json b/tasks/construct-nppc-quad-diophantine-l2-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0f15839fff097e9daf6505c64a2f4499ef79f9e1 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-l2-s5/tests/instance.json @@ -0,0 +1 @@ +{"a": 606, "b": 922, "c": 600521258, "family": "nppc_quad_diophantine", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quad-diophantine-l2-s5/tests/run.py b/tasks/construct-nppc-quad-diophantine-l2-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quad-diophantine-l2-s5/tests/test.sh b/tasks/construct-nppc-quad-diophantine-l2-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quad-diophantine-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-quadratic-congruence-l2-s2/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l2-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l2-s2/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l2-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fa47fb722319932e42f177cc2f4d7357a553b0c8 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s2/environment/instance.json @@ -0,0 +1 @@ +{"a": 3721, "b": 5794, "c": 8869, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s2/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l2-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..11e79ba9c1ca00c4665629040bc9b632e1f91624 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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' +{"x": 5733} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s2/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l2-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s2/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s2/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l2-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fa47fb722319932e42f177cc2f4d7357a553b0c8 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s2/tests/instance.json @@ -0,0 +1 @@ +{"a": 3721, "b": 5794, "c": 8869, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s2/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l2-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l2-s5/environment/Dockerfile b/tasks/construct-nppc-quadratic-congruence-l2-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l2-s5/environment/instance.json b/tasks/construct-nppc-quadratic-congruence-l2-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4cac0ef87698b97eb5cfcef2f6487a6226f2d121 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s5/environment/instance.json @@ -0,0 +1 @@ +{"a": 2066, "b": 8890, "c": 14318, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s5/solution/solve.sh b/tasks/construct-nppc-quadratic-congruence-l2-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..bb733548e3745a87e0194919a1f0966033c8c012 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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' +{"x": 7174} +RLMATH_EOF diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s5/tests/check.py b/tasks/construct-nppc-quadratic-congruence-l2-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..1a751c071a276ca0aae7fb05bfdcd7b6e0c6d3a6 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s5/tests/check.py @@ -0,0 +1,11 @@ +"""Quadratic congruence: integer x with 1 <= x < c and x^2 = a (mod b). Accepts any such x.""" +from run import Invalid, as_int + + +def check(inst, ans): + # upstream NPPC verifier did int(x) (accepting "12", 12.9 -> 12) and only checked x < c, so negative x + # (e.g. -r for any root r) and x = 0 passed and the bound c was meaningless + x = as_int(ans.get("x"), "x", lo=1, hi=inst["c"] - 1) + if x * x % inst["b"] != inst["a"]: + raise Invalid("x^2 mod b != a") + return None, {} diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s5/tests/instance.json b/tasks/construct-nppc-quadratic-congruence-l2-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4cac0ef87698b97eb5cfcef2f6487a6226f2d121 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-l2-s5/tests/instance.json @@ -0,0 +1 @@ +{"a": 2066, "b": 8890, "c": 14318, "family": "nppc_quadratic_congruence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-quadratic-congruence-l2-s5/tests/run.py b/tasks/construct-nppc-quadratic-congruence-l2-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-quadratic-congruence-l2-s5/tests/test.sh b/tasks/construct-nppc-quadratic-congruence-l2-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-quadratic-congruence-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-l4-s1/environment/Dockerfile b/tasks/construct-nppc-vertex-cover-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-vertex-cover-l4-s1/environment/instance.json b/tasks/construct-nppc-vertex-cover-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5fe0b8d11f799b4995d7b9ad23b87c0f0916e096 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 12], [0, 14], [0, 15], [0, 18], [0, 19], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [0, 32], [0, 33], [0, 34], [0, 35], [0, 36], [0, 37], [0, 38], [0, 39], [1, 8], [1, 13], [1, 18], [1, 23], [1, 24], [1, 25], [1, 27], [1, 31], [1, 35], [1, 36], [1, 37], [2, 8], [2, 12], [2, 14], [2, 17], [2, 22], [2, 23], [2, 25], [2, 27], [2, 30], [2, 35], [2, 36], [2, 37], [2, 39], [3, 12], [3, 13], [3, 18], [3, 22], [3, 24], [3, 25], [3, 27], [3, 30], [3, 36], [4, 12], [4, 14], [4, 17], [4, 22], [4, 23], [4, 25], [4, 31], [4, 35], [4, 36], [4, 39], [5, 6], [5, 7], [5, 8], [5, 9], [5, 12], [5, 13], [5, 14], [5, 16], [5, 17], [5, 18], [5, 21], [5, 23], [5, 24], [5, 25], [5, 26], [5, 27], [5, 28], [5, 31], [5, 34], [5, 35], [5, 36], [5, 38], [5, 39], [6, 8], [6, 12], [6, 14], [6, 17], [6, 18], [6, 22], [6, 23], [6, 27], [6, 31], [6, 37], [6, 39], [7, 13], [7, 16], [7, 18], [7, 23], [7, 24], [7, 30], [7, 35], [7, 37], [7, 39], [8, 9], [8, 10], [8, 12], [8, 13], [8, 14], [8, 16], [8, 17], [8, 18], [8, 19], [8, 20], [8, 21], [8, 22], [8, 23], [8, 24], [8, 25], [8, 26], [8, 28], [8, 29], [8, 31], [8, 32], [8, 35], [8, 36], [8, 37], [8, 38], [9, 12], [9, 14], [9, 16], [9, 17], [9, 18], [9, 25], [9, 27], [9, 31], [9, 35], [9, 37], [10, 13], [10, 14], [10, 16], [10, 18], [10, 22], [10, 24], [10, 25], [10, 27], [10, 30], [10, 31], [10, 35], [10, 39], [11, 12], [11, 14], [11, 22], [11, 24], [11, 30], [11, 31], [11, 35], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [12, 21], [12, 23], [12, 24], [12, 25], [12, 26], [12, 28], [12, 31], [12, 32], [12, 33], [12, 34], [12, 35], [12, 36], [12, 37], [12, 38], [12, 39], [13, 14], [13, 16], [13, 18], [13, 20], [13, 21], [13, 23], [13, 27], [13, 28], [13, 29], [13, 30], [13, 31], [13, 32], [13, 36], [13, 37], [13, 38], [13, 39], [14, 15], [14, 16], [14, 17], [14, 18], [14, 20], [14, 22], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 29], [14, 33], [14, 36], [14, 37], [14, 39], [15, 17], [15, 18], [15, 24], [15, 25], [15, 27], [15, 35], [15, 37], [16, 17], [16, 20], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 30], [16, 31], [16, 33], [16, 37], [16, 39], [17, 18], [17, 20], [17, 21], [17, 23], [17, 30], [17, 31], [17, 32], [17, 34], [17, 35], [17, 36], [17, 37], [17, 38], [17, 39], [18, 21], [18, 23], [18, 24], [18, 30], [18, 32], [18, 34], [18, 35], [18, 36], [18, 39], [19, 24], [19, 30], [19, 31], [19, 36], [19, 37], [19, 39], [20, 23], [20, 24], [20, 25], [20, 30], [20, 31], [20, 35], [20, 36], [20, 37], [20, 39], [21, 22], [21, 24], [21, 25], [21, 27], [21, 31], [21, 36], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [22, 28], [22, 31], [22, 36], [22, 37], [22, 38], [22, 39], [23, 25], [23, 27], [23, 28], [23, 31], [23, 34], [23, 35], [23, 36], [23, 37], [23, 39], [24, 25], [24, 26], [24, 27], [24, 32], [24, 34], [24, 35], [25, 27], [25, 28], [25, 30], [25, 32], [25, 37], [25, 39], [26, 30], [26, 31], [26, 36], [26, 39], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [27, 35], [27, 36], [27, 37], [27, 38], [27, 39], [28, 30], [28, 31], [28, 35], [29, 36], [29, 39], [30, 31], [30, 32], [30, 34], [30, 37], [31, 33], [31, 36], [31, 37], [31, 39], [32, 35], [32, 37], [32, 39], [33, 37], [34, 36], [34, 39], [35, 36], [35, 37], [36, 37], [37, 38], [37, 39], [38, 39]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l4-s1/solution/solve.sh b/tasks/construct-nppc-vertex-cover-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2252ea1c0a1ad310a3ea9fd77f14e7a78219ed14 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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' +{"cover": [0, 5, 8, 12, 13, 14, 16, 17, 18, 22, 23, 24, 25, 27, 30, 31, 35, 36, 37, 39]} +RLMATH_EOF diff --git a/tasks/construct-nppc-vertex-cover-l4-s1/tests/check.py b/tasks/construct-nppc-vertex-cover-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d8ed740cc660c4837d941a8d70ea394c3bc9f69e --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s1/tests/check.py @@ -0,0 +1,18 @@ +"""Vertex cover of size <= k. Accepts any valid cover.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier converts to a set without type checks (floats/bools slip through and + # duplicates are silently merged); here entries must be distinct ints in range + c = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(c)) != len(c): + raise Invalid("cover contains duplicates") + if len(c) > k: + raise Invalid(f"cover has {len(c)} > {k} vertices") + s = set(c) + for u, v in inst["edges"]: + if u not in s and v not in s: + raise Invalid(f"edge ({u},{v}) not covered") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-vertex-cover-l4-s1/tests/instance.json b/tasks/construct-nppc-vertex-cover-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5fe0b8d11f799b4995d7b9ad23b87c0f0916e096 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 12], [0, 14], [0, 15], [0, 18], [0, 19], [0, 22], [0, 23], [0, 24], [0, 25], [0, 26], [0, 27], [0, 28], [0, 32], [0, 33], [0, 34], [0, 35], [0, 36], [0, 37], [0, 38], [0, 39], [1, 8], [1, 13], [1, 18], [1, 23], [1, 24], [1, 25], [1, 27], [1, 31], [1, 35], [1, 36], [1, 37], [2, 8], [2, 12], [2, 14], [2, 17], [2, 22], [2, 23], [2, 25], [2, 27], [2, 30], [2, 35], [2, 36], [2, 37], [2, 39], [3, 12], [3, 13], [3, 18], [3, 22], [3, 24], [3, 25], [3, 27], [3, 30], [3, 36], [4, 12], [4, 14], [4, 17], [4, 22], [4, 23], [4, 25], [4, 31], [4, 35], [4, 36], [4, 39], [5, 6], [5, 7], [5, 8], [5, 9], [5, 12], [5, 13], [5, 14], [5, 16], [5, 17], [5, 18], [5, 21], [5, 23], [5, 24], [5, 25], [5, 26], [5, 27], [5, 28], [5, 31], [5, 34], [5, 35], [5, 36], [5, 38], [5, 39], [6, 8], [6, 12], [6, 14], [6, 17], [6, 18], [6, 22], [6, 23], [6, 27], [6, 31], [6, 37], [6, 39], [7, 13], [7, 16], [7, 18], [7, 23], [7, 24], [7, 30], [7, 35], [7, 37], [7, 39], [8, 9], [8, 10], [8, 12], [8, 13], [8, 14], [8, 16], [8, 17], [8, 18], [8, 19], [8, 20], [8, 21], [8, 22], [8, 23], [8, 24], [8, 25], [8, 26], [8, 28], [8, 29], [8, 31], [8, 32], [8, 35], [8, 36], [8, 37], [8, 38], [9, 12], [9, 14], [9, 16], [9, 17], [9, 18], [9, 25], [9, 27], [9, 31], [9, 35], [9, 37], [10, 13], [10, 14], [10, 16], [10, 18], [10, 22], [10, 24], [10, 25], [10, 27], [10, 30], [10, 31], [10, 35], [10, 39], [11, 12], [11, 14], [11, 22], [11, 24], [11, 30], [11, 31], [11, 35], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [12, 18], [12, 19], [12, 20], [12, 21], [12, 23], [12, 24], [12, 25], [12, 26], [12, 28], [12, 31], [12, 32], [12, 33], [12, 34], [12, 35], [12, 36], [12, 37], [12, 38], [12, 39], [13, 14], [13, 16], [13, 18], [13, 20], [13, 21], [13, 23], [13, 27], [13, 28], [13, 29], [13, 30], [13, 31], [13, 32], [13, 36], [13, 37], [13, 38], [13, 39], [14, 15], [14, 16], [14, 17], [14, 18], [14, 20], [14, 22], [14, 23], [14, 24], [14, 25], [14, 26], [14, 27], [14, 28], [14, 29], [14, 33], [14, 36], [14, 37], [14, 39], [15, 17], [15, 18], [15, 24], [15, 25], [15, 27], [15, 35], [15, 37], [16, 17], [16, 20], [16, 23], [16, 24], [16, 25], [16, 26], [16, 27], [16, 28], [16, 30], [16, 31], [16, 33], [16, 37], [16, 39], [17, 18], [17, 20], [17, 21], [17, 23], [17, 30], [17, 31], [17, 32], [17, 34], [17, 35], [17, 36], [17, 37], [17, 38], [17, 39], [18, 21], [18, 23], [18, 24], [18, 30], [18, 32], [18, 34], [18, 35], [18, 36], [18, 39], [19, 24], [19, 30], [19, 31], [19, 36], [19, 37], [19, 39], [20, 23], [20, 24], [20, 25], [20, 30], [20, 31], [20, 35], [20, 36], [20, 37], [20, 39], [21, 22], [21, 24], [21, 25], [21, 27], [21, 31], [21, 36], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [22, 28], [22, 31], [22, 36], [22, 37], [22, 38], [22, 39], [23, 25], [23, 27], [23, 28], [23, 31], [23, 34], [23, 35], [23, 36], [23, 37], [23, 39], [24, 25], [24, 26], [24, 27], [24, 32], [24, 34], [24, 35], [25, 27], [25, 28], [25, 30], [25, 32], [25, 37], [25, 39], [26, 30], [26, 31], [26, 36], [26, 39], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [27, 35], [27, 36], [27, 37], [27, 38], [27, 39], [28, 30], [28, 31], [28, 35], [29, 36], [29, 39], [30, 31], [30, 32], [30, 34], [30, 37], [31, 33], [31, 36], [31, 37], [31, 39], [32, 35], [32, 37], [32, 39], [33, 37], [34, 36], [34, 39], [35, 36], [35, 37], [36, 37], [37, 38], [37, 39], [38, 39]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l4-s1/tests/run.py b/tasks/construct-nppc-vertex-cover-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-vertex-cover-l4-s1/tests/test.sh b/tasks/construct-nppc-vertex-cover-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-vertex-cover-l4-s6/environment/Dockerfile b/tasks/construct-nppc-vertex-cover-l4-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-vertex-cover-l4-s6/environment/instance.json b/tasks/construct-nppc-vertex-cover-l4-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b9b145f622f5f67cd27dafb9e0d784eff7bf3dcb --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s6/environment/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 1], [0, 2], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 20], [0, 23], [0, 24], [0, 25], [0, 27], [0, 28], [0, 29], [0, 31], [0, 32], [0, 33], [0, 35], [0, 36], [0, 37], [0, 38], [0, 39], [1, 17], [1, 19], [1, 20], [1, 22], [1, 25], [1, 27], [1, 32], [1, 34], [1, 37], [2, 5], [2, 6], [2, 17], [2, 18], [2, 19], [2, 22], [2, 25], [2, 27], [2, 32], [2, 35], [2, 37], [3, 8], [3, 9], [3, 12], [3, 18], [3, 19], [3, 21], [3, 25], [3, 27], [3, 34], [3, 35], [3, 37], [4, 6], [4, 17], [4, 18], [4, 19], [4, 21], [4, 25], [4, 29], [4, 35], [4, 37], [5, 6], [5, 7], [5, 8], [5, 9], [5, 11], [5, 12], [5, 15], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 23], [5, 24], [5, 25], [5, 26], [5, 29], [5, 30], [5, 32], [5, 34], [5, 35], [5, 36], [5, 37], [6, 7], [6, 9], [6, 11], [6, 12], [6, 13], [6, 14], [6, 19], [6, 20], [6, 21], [6, 23], [6, 25], [6, 26], [6, 29], [6, 30], [6, 32], [6, 33], [6, 34], [6, 39], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 19], [7, 20], [7, 21], [7, 23], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [7, 30], [7, 32], [7, 33], [7, 34], [7, 36], [7, 38], [7, 39], [8, 9], [8, 12], [8, 13], [8, 14], [8, 15], [8, 19], [8, 26], [8, 27], [8, 28], [8, 29], [8, 30], [8, 31], [8, 32], [8, 33], [8, 34], [8, 35], [8, 37], [9, 12], [9, 13], [9, 17], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [9, 26], [9, 27], [9, 28], [9, 29], [9, 31], [9, 32], [9, 33], [9, 35], [9, 36], [9, 37], [9, 38], [10, 12], [10, 20], [10, 21], [10, 27], [10, 32], [10, 37], [11, 12], [11, 19], [11, 21], [11, 27], [11, 29], [11, 34], [12, 13], [12, 14], [12, 15], [12, 16], [12, 20], [12, 22], [12, 24], [12, 27], [12, 28], [12, 29], [12, 31], [12, 32], [12, 34], [12, 35], [12, 36], [12, 37], [12, 39], [13, 18], [13, 22], [13, 27], [13, 32], [13, 35], [13, 37], [14, 17], [14, 19], [14, 20], [14, 22], [14, 29], [14, 32], [14, 34], [14, 35], [14, 37], [15, 17], [15, 25], [15, 29], [16, 17], [16, 18], [16, 20], [16, 25], [16, 29], [16, 32], [16, 37], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 25], [17, 27], [17, 28], [17, 29], [17, 30], [17, 31], [17, 32], [17, 34], [17, 35], [18, 19], [18, 21], [18, 24], [18, 27], [18, 29], [18, 32], [18, 33], [18, 35], [18, 36], [19, 20], [19, 21], [19, 22], [19, 24], [19, 25], [19, 28], [19, 29], [19, 30], [19, 31], [19, 33], [19, 34], [19, 35], [19, 36], [19, 37], [19, 38], [19, 39], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 28], [20, 29], [20, 30], [20, 32], [20, 34], [20, 35], [20, 37], [20, 39], [21, 22], [21, 24], [21, 25], [21, 29], [21, 30], [21, 32], [21, 33], [21, 34], [21, 35], [21, 37], [21, 39], [22, 23], [22, 24], [22, 27], [22, 28], [22, 29], [22, 32], [22, 33], [22, 34], [22, 35], [22, 37], [22, 38], [22, 39], [23, 25], [23, 27], [23, 32], [23, 34], [23, 37], [24, 27], [24, 29], [24, 34], [25, 26], [25, 27], [25, 29], [25, 34], [25, 37], [25, 39], [26, 29], [26, 34], [26, 37], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [27, 34], [27, 35], [27, 36], [27, 37], [27, 39], [28, 29], [28, 32], [28, 34], [29, 32], [29, 33], [29, 35], [29, 36], [29, 37], [29, 39], [30, 32], [30, 37], [31, 34], [31, 35], [31, 37], [32, 35], [32, 37], [32, 38], [32, 39], [33, 35], [34, 37], [35, 37], [35, 38], [35, 39]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l4-s6/solution/solve.sh b/tasks/construct-nppc-vertex-cover-l4-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fe105350f9c9615d8d2fa894a8ba2fcaeac7523a --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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' +{"cover": [0, 5, 6, 7, 8, 9, 12, 17, 18, 19, 20, 21, 22, 25, 27, 29, 32, 34, 35, 37]} +RLMATH_EOF diff --git a/tasks/construct-nppc-vertex-cover-l4-s6/tests/check.py b/tasks/construct-nppc-vertex-cover-l4-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d8ed740cc660c4837d941a8d70ea394c3bc9f69e --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s6/tests/check.py @@ -0,0 +1,18 @@ +"""Vertex cover of size <= k. Accepts any valid cover.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_nodes"], inst["k"] + # upstream NPPC verifier converts to a set without type checks (floats/bools slip through and + # duplicates are silently merged); here entries must be distinct ints in range + c = int_list(ans.get("cover"), None, 0, n - 1, "cover") + if len(set(c)) != len(c): + raise Invalid("cover contains duplicates") + if len(c) > k: + raise Invalid(f"cover has {len(c)} > {k} vertices") + s = set(c) + for u, v in inst["edges"]: + if u not in s and v not in s: + raise Invalid(f"edge ({u},{v}) not covered") + return None, {"size": len(c)} diff --git a/tasks/construct-nppc-vertex-cover-l4-s6/tests/instance.json b/tasks/construct-nppc-vertex-cover-l4-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b9b145f622f5f67cd27dafb9e0d784eff7bf3dcb --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-l4-s6/tests/instance.json @@ -0,0 +1 @@ +{"num_nodes": 40, "k": 20, "edges": [[0, 1], [0, 2], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 20], [0, 23], [0, 24], [0, 25], [0, 27], [0, 28], [0, 29], [0, 31], [0, 32], [0, 33], [0, 35], [0, 36], [0, 37], [0, 38], [0, 39], [1, 17], [1, 19], [1, 20], [1, 22], [1, 25], [1, 27], [1, 32], [1, 34], [1, 37], [2, 5], [2, 6], [2, 17], [2, 18], [2, 19], [2, 22], [2, 25], [2, 27], [2, 32], [2, 35], [2, 37], [3, 8], [3, 9], [3, 12], [3, 18], [3, 19], [3, 21], [3, 25], [3, 27], [3, 34], [3, 35], [3, 37], [4, 6], [4, 17], [4, 18], [4, 19], [4, 21], [4, 25], [4, 29], [4, 35], [4, 37], [5, 6], [5, 7], [5, 8], [5, 9], [5, 11], [5, 12], [5, 15], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 23], [5, 24], [5, 25], [5, 26], [5, 29], [5, 30], [5, 32], [5, 34], [5, 35], [5, 36], [5, 37], [6, 7], [6, 9], [6, 11], [6, 12], [6, 13], [6, 14], [6, 19], [6, 20], [6, 21], [6, 23], [6, 25], [6, 26], [6, 29], [6, 30], [6, 32], [6, 33], [6, 34], [6, 39], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 19], [7, 20], [7, 21], [7, 23], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [7, 30], [7, 32], [7, 33], [7, 34], [7, 36], [7, 38], [7, 39], [8, 9], [8, 12], [8, 13], [8, 14], [8, 15], [8, 19], [8, 26], [8, 27], [8, 28], [8, 29], [8, 30], [8, 31], [8, 32], [8, 33], [8, 34], [8, 35], [8, 37], [9, 12], [9, 13], [9, 17], [9, 18], [9, 19], [9, 20], [9, 21], [9, 22], [9, 26], [9, 27], [9, 28], [9, 29], [9, 31], [9, 32], [9, 33], [9, 35], [9, 36], [9, 37], [9, 38], [10, 12], [10, 20], [10, 21], [10, 27], [10, 32], [10, 37], [11, 12], [11, 19], [11, 21], [11, 27], [11, 29], [11, 34], [12, 13], [12, 14], [12, 15], [12, 16], [12, 20], [12, 22], [12, 24], [12, 27], [12, 28], [12, 29], [12, 31], [12, 32], [12, 34], [12, 35], [12, 36], [12, 37], [12, 39], [13, 18], [13, 22], [13, 27], [13, 32], [13, 35], [13, 37], [14, 17], [14, 19], [14, 20], [14, 22], [14, 29], [14, 32], [14, 34], [14, 35], [14, 37], [15, 17], [15, 25], [15, 29], [16, 17], [16, 18], [16, 20], [16, 25], [16, 29], [16, 32], [16, 37], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [17, 25], [17, 27], [17, 28], [17, 29], [17, 30], [17, 31], [17, 32], [17, 34], [17, 35], [18, 19], [18, 21], [18, 24], [18, 27], [18, 29], [18, 32], [18, 33], [18, 35], [18, 36], [19, 20], [19, 21], [19, 22], [19, 24], [19, 25], [19, 28], [19, 29], [19, 30], [19, 31], [19, 33], [19, 34], [19, 35], [19, 36], [19, 37], [19, 38], [19, 39], [20, 23], [20, 24], [20, 25], [20, 26], [20, 27], [20, 28], [20, 29], [20, 30], [20, 32], [20, 34], [20, 35], [20, 37], [20, 39], [21, 22], [21, 24], [21, 25], [21, 29], [21, 30], [21, 32], [21, 33], [21, 34], [21, 35], [21, 37], [21, 39], [22, 23], [22, 24], [22, 27], [22, 28], [22, 29], [22, 32], [22, 33], [22, 34], [22, 35], [22, 37], [22, 38], [22, 39], [23, 25], [23, 27], [23, 32], [23, 34], [23, 37], [24, 27], [24, 29], [24, 34], [25, 26], [25, 27], [25, 29], [25, 34], [25, 37], [25, 39], [26, 29], [26, 34], [26, 37], [27, 29], [27, 30], [27, 31], [27, 32], [27, 33], [27, 34], [27, 35], [27, 36], [27, 37], [27, 39], [28, 29], [28, 32], [28, 34], [29, 32], [29, 33], [29, 35], [29, 36], [29, 37], [29, 39], [30, 32], [30, 37], [31, 34], [31, 35], [31, 37], [32, 35], [32, 37], [32, 38], [32, 39], [33, 35], [34, 37], [35, 37], [35, 38], [35, 39]], "family": "nppc_vertex_cover", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-nppc-vertex-cover-l4-s6/tests/run.py b/tasks/construct-nppc-vertex-cover-l4-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-vertex-cover-l4-s6/tests/test.sh b/tasks/construct-nppc-vertex-cover-l4-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-nppc-vertex-cover-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-graph-color-l3-s2/environment/Dockerfile b/tasks/construct-rg-graph-color-l3-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-graph-color-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-graph-color-l3-s2/environment/instance.json b/tasks/construct-rg-graph-color-l3-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bcc42b4c84567c10950653d29e28d58125d3ba93 --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s2/environment/instance.json @@ -0,0 +1 @@ +{"num_vertices": 10, "num_colors": 3, "edges": [[0, 8], [0, 9], [1, 2], [1, 8], [2, 3], [2, 6], [2, 9], [3, 5], [3, 9], [4, 9]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l3-s2/solution/solve.sh b/tasks/construct-rg-graph-color-l3-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f13b878eb9b2500ddbe761078693d8522f09ff47 --- /dev/null +++ b/tasks/construct-rg-graph-color-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' +{"coloring": [1, 1, 2, 1, 1, 2, 1, 1, 2, 3]} +RLMATH_EOF diff --git a/tasks/construct-rg-graph-color-l3-s2/tests/check.py b/tasks/construct-rg-graph-color-l3-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e9328912405d1c894970c90415be62bf9556ed36 --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s2/tests/check.py @@ -0,0 +1,13 @@ +"""Proper colouring with colours 1..k (Reasoning Gym graph_color, Apache-2.0). Any valid colouring. +Upstream note: its verifier checks `color in allowed_colors`, so True (== 1) and 1.0 were accepted as +colours, and extra keys were ignored. Here colours must be ints in 1..k, one per vertex.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_vertices"], inst["num_colors"] + c = int_list(ans.get("coloring"), n, 1, k, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"adjacent vertices {u} and {v} share colour {c[u]}") + return None, {} diff --git a/tasks/construct-rg-graph-color-l3-s2/tests/instance.json b/tasks/construct-rg-graph-color-l3-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bcc42b4c84567c10950653d29e28d58125d3ba93 --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s2/tests/instance.json @@ -0,0 +1 @@ +{"num_vertices": 10, "num_colors": 3, "edges": [[0, 8], [0, 9], [1, 2], [1, 8], [2, 3], [2, 6], [2, 9], [3, 5], [3, 9], [4, 9]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l3-s2/tests/run.py b/tasks/construct-rg-graph-color-l3-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-graph-color-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-graph-color-l3-s2/tests/test.sh b/tasks/construct-rg-graph-color-l3-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-graph-color-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-graph-color-l3-s5/environment/Dockerfile b/tasks/construct-rg-graph-color-l3-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-graph-color-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-graph-color-l3-s5/environment/instance.json b/tasks/construct-rg-graph-color-l3-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f0d2212ca886f6b936bf7680ec75e17be0d60435 --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s5/environment/instance.json @@ -0,0 +1 @@ +{"num_vertices": 10, "num_colors": 3, "edges": [[0, 1], [0, 4], [0, 5], [0, 6], [1, 2], [1, 7], [2, 4], [2, 5], [2, 7], [2, 9], [3, 7], [3, 8], [4, 7], [5, 8], [5, 9]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l3-s5/solution/solve.sh b/tasks/construct-rg-graph-color-l3-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d307daee04354ad230cd75f643e2555399ca24a1 --- /dev/null +++ b/tasks/construct-rg-graph-color-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' +{"coloring": [1, 2, 1, 1, 2, 2, 2, 3, 3, 3]} +RLMATH_EOF diff --git a/tasks/construct-rg-graph-color-l3-s5/tests/check.py b/tasks/construct-rg-graph-color-l3-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..e9328912405d1c894970c90415be62bf9556ed36 --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s5/tests/check.py @@ -0,0 +1,13 @@ +"""Proper colouring with colours 1..k (Reasoning Gym graph_color, Apache-2.0). Any valid colouring. +Upstream note: its verifier checks `color in allowed_colors`, so True (== 1) and 1.0 were accepted as +colours, and extra keys were ignored. Here colours must be ints in 1..k, one per vertex.""" +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["num_vertices"], inst["num_colors"] + c = int_list(ans.get("coloring"), n, 1, k, "coloring") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"adjacent vertices {u} and {v} share colour {c[u]}") + return None, {} diff --git a/tasks/construct-rg-graph-color-l3-s5/tests/instance.json b/tasks/construct-rg-graph-color-l3-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f0d2212ca886f6b936bf7680ec75e17be0d60435 --- /dev/null +++ b/tasks/construct-rg-graph-color-l3-s5/tests/instance.json @@ -0,0 +1 @@ +{"num_vertices": 10, "num_colors": 3, "edges": [[0, 1], [0, 4], [0, 5], [0, 6], [1, 2], [1, 7], [2, 4], [2, 5], [2, 7], [2, 9], [3, 7], [3, 8], [4, 7], [5, 8], [5, 9]], "family": "rg_graph_color", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-graph-color-l3-s5/tests/run.py b/tasks/construct-rg-graph-color-l3-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-graph-color-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-graph-color-l3-s5/tests/test.sh b/tasks/construct-rg-graph-color-l3-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-graph-color-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-intermediate-integration-l1-s9/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l1-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rg-intermediate-integration-l1-s9/environment/instance.json b/tasks/construct-rg-intermediate-integration-l1-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..68be4f184c373b6d5977cdc9d7377231afca43a1 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s9/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-3*(5*x + 5)**3", "problem_type": "linear", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l1-s9/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l1-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f6df52979df0ebbce4730786c4e1eb8248732bfc --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"antiderivative": "-375*x**4/4 - 375*x**3 - 1125*x**2/2 - 375*x + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l1-s9/tests/check.py b/tasks/construct-rg-intermediate-integration-l1-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s9/tests/check.py @@ -0,0 +1,158 @@ +"""Antiderivative check (Reasoning Gym simple_integration / intermediate_integration, Apache-2.0). + +The answer string is parsed with a whitelist AST walker (no eval), differentiated with SymPy and compared +with the integrand numerically (30-digit evaluation) at fixed points inside the integrand's real domain. +Any additive constant (e.g. "+ C") is allowed. + +Upstream notes: upstream scores with sympy.parse_expr, which calls eval() on the model's string (arbitrary +code execution), and it accepts an unevaluated "Integral(f, x)" since its derivative is f. Both are +rejected here: only arithmetic, whitelisted elementary functions, the variable, C, E and pi are allowed.""" +import ast +import math +import signal + +import sympy + +from run import Invalid + +MAX_LEN = 3000 +MAX_NODES = 600 +MAX_POW_NEST = 4 # nested powers with a variable exponent (x**x**x**...) blow up differentiation +TIME_LIMIT = 40 # seconds; a slower answer is rejected +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "cot": sympy.cot, "sec": sympy.sec, + "csc": sympy.csc, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "acot": sympy.acot, + "arcsin": sympy.asin, "arccos": sympy.acos, "arctan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "asinh": sympy.asinh, "acosh": sympy.acosh, + "atanh": sympy.atanh, "exp": sympy.exp, "log": sympy.log, "ln": sympy.log, "sqrt": sympy.sqrt, + "Abs": sympy.Abs, "abs": sympy.Abs} +POINTS = [0.3137, 0.5521, 0.8093, 1.1171, 1.4519, 1.9033, 2.3471, 2.8123, 3.3319, 3.9107, 4.6231, + -0.3547, -0.6529, -0.9511, -1.3027, -1.7519, -2.2013, -2.7131, -3.1397, -3.8203, -4.4111, + 0.1231, -0.1523, 0.2129, -0.2617, 0.0517, -0.0719, 5.4127, -5.3311, 6.3019, -6.2203, 7.2213, + -7.1117, 8.9021, -9.3107, 10.7129, -10.6337, 12.9011, -12.8231, 15.3113, -15.2719] +MIN_POINTS = 5 + + +def parse(s, var): + if not isinstance(s, str) or not s.strip(): + raise Invalid("antiderivative must be a non-empty string") + if len(s) > MAX_LEN: + raise Invalid("expression too long") + s = s.strip() + try: + tree = ast.parse(s, mode="eval") + except SyntaxError: + raise Invalid("expression does not parse (use ** for powers and * for products)") + if sum(1 for _ in ast.walk(tree)) > MAX_NODES: + raise Invalid("expression too large") + + def pow_nest(nd): + kids = [pow_nest(c) for c in ast.iter_child_nodes(nd)] + own = isinstance(nd, ast.BinOp) and isinstance(nd.op, ast.Pow) and any( + isinstance(c, ast.Name) and c.id == var for c in ast.walk(nd.right)) + return max(kids, default=0) + (1 if own else 0) + if pow_nest(tree) > MAX_POW_NEST: + raise Invalid("too many nested powers with a variable exponent") + x = sympy.Symbol(var, real=True) + names = {var: x, "C": sympy.Symbol("C"), "E": sympy.E, "pi": sympy.pi} + + def conv(nd): + if isinstance(nd, ast.Expression): + return conv(nd.body) + if isinstance(nd, ast.Constant): + v = nd.value + if isinstance(v, bool) or not isinstance(v, (int, float)): + raise Invalid(f"constant {v!r} not allowed") + if isinstance(v, int): + if abs(v) > 10 ** 18: + raise Invalid("integer constant too large") + return sympy.Integer(v) + if not math.isfinite(v): + raise Invalid("non-finite constant") + return sympy.Float(v, 30) + if isinstance(nd, ast.Name): + if nd.id not in names: + raise Invalid(f"unknown name {nd.id!r} (the variable is {var})") + return names[nd.id] + if isinstance(nd, ast.UnaryOp) and isinstance(nd.op, (ast.USub, ast.UAdd)): + a = conv(nd.operand) + return -a if isinstance(nd.op, ast.USub) else a + if isinstance(nd, ast.BinOp): + a, b = conv(nd.left), conv(nd.right) + if isinstance(nd.op, ast.Add): + return a + b + if isinstance(nd.op, ast.Sub): + return a - b + if isinstance(nd.op, ast.Mult): + return a * b + if isinstance(nd.op, ast.Div): + if b == 0: + raise Invalid("division by zero") + return a / b + if isinstance(nd.op, ast.Pow): + if not b.free_symbols: + bv = complex(b.evalf(20)) + if bv.imag != 0 or abs(bv.real) > 100: + raise Invalid("exponent too large") + if not a.free_symbols and abs(complex(a.evalf(20))) > 1e6: + raise Invalid("numeric power too large") + return a ** b + raise Invalid("only + - * / ** are allowed (use ** for powers)") + if isinstance(nd, ast.Call): + if not isinstance(nd.func, ast.Name) or nd.func.id not in FUNCS: + raise Invalid(f"function {ast.unparse(nd.func)!r} not allowed") + if nd.keywords or len(nd.args) != 1: + raise Invalid(f"{nd.func.id} takes exactly one argument") + return FUNCS[nd.func.id](conv(nd.args[0])) + raise Invalid(f"syntax element {type(nd).__name__} not allowed") + + return conv(tree), x + + +def value(expr, x, p): + v = expr.evalf(30, subs={x: sympy.Float(p, 30)}) + try: + z = complex(v) + except (TypeError, ValueError): + return None + if not (math.isfinite(z.real) and math.isfinite(z.imag)): + return None + return z + + +def _timeout(signum, frame): + raise Invalid(f"answer took more than {TIME_LIMIT} s to check") + + +def check(inst, ans): + if hasattr(signal, "SIGALRM"): + old = signal.signal(signal.SIGALRM, _timeout) + signal.alarm(TIME_LIMIT) + try: + return _check(inst, ans) + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + return _check(inst, ans) + + +def _check(inst, ans): + var = inst["variable"] + F, x = parse(ans.get("antiderivative"), var) + f, x2 = parse(inst["integrand"], var) + if not F.has(x): + raise Invalid("antiderivative does not depend on the variable") + dF = sympy.diff(F, x) + used = 0 + for p in POINTS: + fv = value(f, x2, p) + if fv is None or abs(fv.imag) > 1e-20 * (1 + abs(fv.real)): + continue # outside the integrand's real domain + gv = value(dF, x, p) + if gv is None: + raise Invalid(f"derivative of the answer cannot be evaluated at {var} = {p}") + if abs(gv - fv) > 1e-9 * max(1.0, abs(fv)): + raise Invalid(f"derivative of the answer differs from the integrand at {var} = {p}") + used += 1 + if used < MIN_POINTS: + raise Invalid("too few evaluation points in the integrand's domain") + return None, {"points": used} diff --git a/tasks/construct-rg-intermediate-integration-l1-s9/tests/instance.json b/tasks/construct-rg-intermediate-integration-l1-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..68be4f184c373b6d5977cdc9d7377231afca43a1 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s9/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-3*(5*x + 5)**3", "problem_type": "linear", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l1-s9/tests/run.py b/tasks/construct-rg-intermediate-integration-l1-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rg-intermediate-integration-l1-s9/tests/test.sh b/tasks/construct-rg-intermediate-integration-l1-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l1-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rg-intermediate-integration-l5-s1/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l5-s1/environment/instance.json b/tasks/construct-rg-intermediate-integration-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8753d939632fd04230d41962be6f881ffafbe963 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "3*exp(x)*sin(x)", "problem_type": "cyclic", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l5-s1/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f07fd8bb5e7c9027eb50084e28b5b2e6e8b45f4c --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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' +{"antiderivative": "3*exp(x)*sin(x)/2 - 3*exp(x)*cos(x)/2 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l5-s1/tests/check.py b/tasks/construct-rg-intermediate-integration-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s1/tests/check.py @@ -0,0 +1,158 @@ +"""Antiderivative check (Reasoning Gym simple_integration / intermediate_integration, Apache-2.0). + +The answer string is parsed with a whitelist AST walker (no eval), differentiated with SymPy and compared +with the integrand numerically (30-digit evaluation) at fixed points inside the integrand's real domain. +Any additive constant (e.g. "+ C") is allowed. + +Upstream notes: upstream scores with sympy.parse_expr, which calls eval() on the model's string (arbitrary +code execution), and it accepts an unevaluated "Integral(f, x)" since its derivative is f. Both are +rejected here: only arithmetic, whitelisted elementary functions, the variable, C, E and pi are allowed.""" +import ast +import math +import signal + +import sympy + +from run import Invalid + +MAX_LEN = 3000 +MAX_NODES = 600 +MAX_POW_NEST = 4 # nested powers with a variable exponent (x**x**x**...) blow up differentiation +TIME_LIMIT = 40 # seconds; a slower answer is rejected +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "cot": sympy.cot, "sec": sympy.sec, + "csc": sympy.csc, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "acot": sympy.acot, + "arcsin": sympy.asin, "arccos": sympy.acos, "arctan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "asinh": sympy.asinh, "acosh": sympy.acosh, + "atanh": sympy.atanh, "exp": sympy.exp, "log": sympy.log, "ln": sympy.log, "sqrt": sympy.sqrt, + "Abs": sympy.Abs, "abs": sympy.Abs} +POINTS = [0.3137, 0.5521, 0.8093, 1.1171, 1.4519, 1.9033, 2.3471, 2.8123, 3.3319, 3.9107, 4.6231, + -0.3547, -0.6529, -0.9511, -1.3027, -1.7519, -2.2013, -2.7131, -3.1397, -3.8203, -4.4111, + 0.1231, -0.1523, 0.2129, -0.2617, 0.0517, -0.0719, 5.4127, -5.3311, 6.3019, -6.2203, 7.2213, + -7.1117, 8.9021, -9.3107, 10.7129, -10.6337, 12.9011, -12.8231, 15.3113, -15.2719] +MIN_POINTS = 5 + + +def parse(s, var): + if not isinstance(s, str) or not s.strip(): + raise Invalid("antiderivative must be a non-empty string") + if len(s) > MAX_LEN: + raise Invalid("expression too long") + s = s.strip() + try: + tree = ast.parse(s, mode="eval") + except SyntaxError: + raise Invalid("expression does not parse (use ** for powers and * for products)") + if sum(1 for _ in ast.walk(tree)) > MAX_NODES: + raise Invalid("expression too large") + + def pow_nest(nd): + kids = [pow_nest(c) for c in ast.iter_child_nodes(nd)] + own = isinstance(nd, ast.BinOp) and isinstance(nd.op, ast.Pow) and any( + isinstance(c, ast.Name) and c.id == var for c in ast.walk(nd.right)) + return max(kids, default=0) + (1 if own else 0) + if pow_nest(tree) > MAX_POW_NEST: + raise Invalid("too many nested powers with a variable exponent") + x = sympy.Symbol(var, real=True) + names = {var: x, "C": sympy.Symbol("C"), "E": sympy.E, "pi": sympy.pi} + + def conv(nd): + if isinstance(nd, ast.Expression): + return conv(nd.body) + if isinstance(nd, ast.Constant): + v = nd.value + if isinstance(v, bool) or not isinstance(v, (int, float)): + raise Invalid(f"constant {v!r} not allowed") + if isinstance(v, int): + if abs(v) > 10 ** 18: + raise Invalid("integer constant too large") + return sympy.Integer(v) + if not math.isfinite(v): + raise Invalid("non-finite constant") + return sympy.Float(v, 30) + if isinstance(nd, ast.Name): + if nd.id not in names: + raise Invalid(f"unknown name {nd.id!r} (the variable is {var})") + return names[nd.id] + if isinstance(nd, ast.UnaryOp) and isinstance(nd.op, (ast.USub, ast.UAdd)): + a = conv(nd.operand) + return -a if isinstance(nd.op, ast.USub) else a + if isinstance(nd, ast.BinOp): + a, b = conv(nd.left), conv(nd.right) + if isinstance(nd.op, ast.Add): + return a + b + if isinstance(nd.op, ast.Sub): + return a - b + if isinstance(nd.op, ast.Mult): + return a * b + if isinstance(nd.op, ast.Div): + if b == 0: + raise Invalid("division by zero") + return a / b + if isinstance(nd.op, ast.Pow): + if not b.free_symbols: + bv = complex(b.evalf(20)) + if bv.imag != 0 or abs(bv.real) > 100: + raise Invalid("exponent too large") + if not a.free_symbols and abs(complex(a.evalf(20))) > 1e6: + raise Invalid("numeric power too large") + return a ** b + raise Invalid("only + - * / ** are allowed (use ** for powers)") + if isinstance(nd, ast.Call): + if not isinstance(nd.func, ast.Name) or nd.func.id not in FUNCS: + raise Invalid(f"function {ast.unparse(nd.func)!r} not allowed") + if nd.keywords or len(nd.args) != 1: + raise Invalid(f"{nd.func.id} takes exactly one argument") + return FUNCS[nd.func.id](conv(nd.args[0])) + raise Invalid(f"syntax element {type(nd).__name__} not allowed") + + return conv(tree), x + + +def value(expr, x, p): + v = expr.evalf(30, subs={x: sympy.Float(p, 30)}) + try: + z = complex(v) + except (TypeError, ValueError): + return None + if not (math.isfinite(z.real) and math.isfinite(z.imag)): + return None + return z + + +def _timeout(signum, frame): + raise Invalid(f"answer took more than {TIME_LIMIT} s to check") + + +def check(inst, ans): + if hasattr(signal, "SIGALRM"): + old = signal.signal(signal.SIGALRM, _timeout) + signal.alarm(TIME_LIMIT) + try: + return _check(inst, ans) + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + return _check(inst, ans) + + +def _check(inst, ans): + var = inst["variable"] + F, x = parse(ans.get("antiderivative"), var) + f, x2 = parse(inst["integrand"], var) + if not F.has(x): + raise Invalid("antiderivative does not depend on the variable") + dF = sympy.diff(F, x) + used = 0 + for p in POINTS: + fv = value(f, x2, p) + if fv is None or abs(fv.imag) > 1e-20 * (1 + abs(fv.real)): + continue # outside the integrand's real domain + gv = value(dF, x, p) + if gv is None: + raise Invalid(f"derivative of the answer cannot be evaluated at {var} = {p}") + if abs(gv - fv) > 1e-9 * max(1.0, abs(fv)): + raise Invalid(f"derivative of the answer differs from the integrand at {var} = {p}") + used += 1 + if used < MIN_POINTS: + raise Invalid("too few evaluation points in the integrand's domain") + return None, {"points": used} diff --git a/tasks/construct-rg-intermediate-integration-l5-s1/tests/instance.json b/tasks/construct-rg-intermediate-integration-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8753d939632fd04230d41962be6f881ffafbe963 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "3*exp(x)*sin(x)", "problem_type": "cyclic", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l5-s1/tests/run.py b/tasks/construct-rg-intermediate-integration-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l5-s1/tests/test.sh b/tasks/construct-rg-intermediate-integration-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-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-rg-intermediate-integration-l5-s6/environment/Dockerfile b/tasks/construct-rg-intermediate-integration-l5-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rg-intermediate-integration-l5-s6/environment/instance.json b/tasks/construct-rg-intermediate-integration-l5-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b85727af4dbc8e8846e12433593158c51c93fad7 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s6/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-2*exp(x)*sin(x)", "problem_type": "cyclic", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l5-s6/solution/solve.sh b/tasks/construct-rg-intermediate-integration-l5-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6a2cbed8e71c0094d7fa66718e5859af46bd915b --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"antiderivative": "-exp(x)*sin(x) + exp(x)*cos(x) + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-intermediate-integration-l5-s6/tests/check.py b/tasks/construct-rg-intermediate-integration-l5-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s6/tests/check.py @@ -0,0 +1,158 @@ +"""Antiderivative check (Reasoning Gym simple_integration / intermediate_integration, Apache-2.0). + +The answer string is parsed with a whitelist AST walker (no eval), differentiated with SymPy and compared +with the integrand numerically (30-digit evaluation) at fixed points inside the integrand's real domain. +Any additive constant (e.g. "+ C") is allowed. + +Upstream notes: upstream scores with sympy.parse_expr, which calls eval() on the model's string (arbitrary +code execution), and it accepts an unevaluated "Integral(f, x)" since its derivative is f. Both are +rejected here: only arithmetic, whitelisted elementary functions, the variable, C, E and pi are allowed.""" +import ast +import math +import signal + +import sympy + +from run import Invalid + +MAX_LEN = 3000 +MAX_NODES = 600 +MAX_POW_NEST = 4 # nested powers with a variable exponent (x**x**x**...) blow up differentiation +TIME_LIMIT = 40 # seconds; a slower answer is rejected +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "cot": sympy.cot, "sec": sympy.sec, + "csc": sympy.csc, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "acot": sympy.acot, + "arcsin": sympy.asin, "arccos": sympy.acos, "arctan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "asinh": sympy.asinh, "acosh": sympy.acosh, + "atanh": sympy.atanh, "exp": sympy.exp, "log": sympy.log, "ln": sympy.log, "sqrt": sympy.sqrt, + "Abs": sympy.Abs, "abs": sympy.Abs} +POINTS = [0.3137, 0.5521, 0.8093, 1.1171, 1.4519, 1.9033, 2.3471, 2.8123, 3.3319, 3.9107, 4.6231, + -0.3547, -0.6529, -0.9511, -1.3027, -1.7519, -2.2013, -2.7131, -3.1397, -3.8203, -4.4111, + 0.1231, -0.1523, 0.2129, -0.2617, 0.0517, -0.0719, 5.4127, -5.3311, 6.3019, -6.2203, 7.2213, + -7.1117, 8.9021, -9.3107, 10.7129, -10.6337, 12.9011, -12.8231, 15.3113, -15.2719] +MIN_POINTS = 5 + + +def parse(s, var): + if not isinstance(s, str) or not s.strip(): + raise Invalid("antiderivative must be a non-empty string") + if len(s) > MAX_LEN: + raise Invalid("expression too long") + s = s.strip() + try: + tree = ast.parse(s, mode="eval") + except SyntaxError: + raise Invalid("expression does not parse (use ** for powers and * for products)") + if sum(1 for _ in ast.walk(tree)) > MAX_NODES: + raise Invalid("expression too large") + + def pow_nest(nd): + kids = [pow_nest(c) for c in ast.iter_child_nodes(nd)] + own = isinstance(nd, ast.BinOp) and isinstance(nd.op, ast.Pow) and any( + isinstance(c, ast.Name) and c.id == var for c in ast.walk(nd.right)) + return max(kids, default=0) + (1 if own else 0) + if pow_nest(tree) > MAX_POW_NEST: + raise Invalid("too many nested powers with a variable exponent") + x = sympy.Symbol(var, real=True) + names = {var: x, "C": sympy.Symbol("C"), "E": sympy.E, "pi": sympy.pi} + + def conv(nd): + if isinstance(nd, ast.Expression): + return conv(nd.body) + if isinstance(nd, ast.Constant): + v = nd.value + if isinstance(v, bool) or not isinstance(v, (int, float)): + raise Invalid(f"constant {v!r} not allowed") + if isinstance(v, int): + if abs(v) > 10 ** 18: + raise Invalid("integer constant too large") + return sympy.Integer(v) + if not math.isfinite(v): + raise Invalid("non-finite constant") + return sympy.Float(v, 30) + if isinstance(nd, ast.Name): + if nd.id not in names: + raise Invalid(f"unknown name {nd.id!r} (the variable is {var})") + return names[nd.id] + if isinstance(nd, ast.UnaryOp) and isinstance(nd.op, (ast.USub, ast.UAdd)): + a = conv(nd.operand) + return -a if isinstance(nd.op, ast.USub) else a + if isinstance(nd, ast.BinOp): + a, b = conv(nd.left), conv(nd.right) + if isinstance(nd.op, ast.Add): + return a + b + if isinstance(nd.op, ast.Sub): + return a - b + if isinstance(nd.op, ast.Mult): + return a * b + if isinstance(nd.op, ast.Div): + if b == 0: + raise Invalid("division by zero") + return a / b + if isinstance(nd.op, ast.Pow): + if not b.free_symbols: + bv = complex(b.evalf(20)) + if bv.imag != 0 or abs(bv.real) > 100: + raise Invalid("exponent too large") + if not a.free_symbols and abs(complex(a.evalf(20))) > 1e6: + raise Invalid("numeric power too large") + return a ** b + raise Invalid("only + - * / ** are allowed (use ** for powers)") + if isinstance(nd, ast.Call): + if not isinstance(nd.func, ast.Name) or nd.func.id not in FUNCS: + raise Invalid(f"function {ast.unparse(nd.func)!r} not allowed") + if nd.keywords or len(nd.args) != 1: + raise Invalid(f"{nd.func.id} takes exactly one argument") + return FUNCS[nd.func.id](conv(nd.args[0])) + raise Invalid(f"syntax element {type(nd).__name__} not allowed") + + return conv(tree), x + + +def value(expr, x, p): + v = expr.evalf(30, subs={x: sympy.Float(p, 30)}) + try: + z = complex(v) + except (TypeError, ValueError): + return None + if not (math.isfinite(z.real) and math.isfinite(z.imag)): + return None + return z + + +def _timeout(signum, frame): + raise Invalid(f"answer took more than {TIME_LIMIT} s to check") + + +def check(inst, ans): + if hasattr(signal, "SIGALRM"): + old = signal.signal(signal.SIGALRM, _timeout) + signal.alarm(TIME_LIMIT) + try: + return _check(inst, ans) + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + return _check(inst, ans) + + +def _check(inst, ans): + var = inst["variable"] + F, x = parse(ans.get("antiderivative"), var) + f, x2 = parse(inst["integrand"], var) + if not F.has(x): + raise Invalid("antiderivative does not depend on the variable") + dF = sympy.diff(F, x) + used = 0 + for p in POINTS: + fv = value(f, x2, p) + if fv is None or abs(fv.imag) > 1e-20 * (1 + abs(fv.real)): + continue # outside the integrand's real domain + gv = value(dF, x, p) + if gv is None: + raise Invalid(f"derivative of the answer cannot be evaluated at {var} = {p}") + if abs(gv - fv) > 1e-9 * max(1.0, abs(fv)): + raise Invalid(f"derivative of the answer differs from the integrand at {var} = {p}") + used += 1 + if used < MIN_POINTS: + raise Invalid("too few evaluation points in the integrand's domain") + return None, {"points": used} diff --git a/tasks/construct-rg-intermediate-integration-l5-s6/tests/instance.json b/tasks/construct-rg-intermediate-integration-l5-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b85727af4dbc8e8846e12433593158c51c93fad7 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s6/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "-2*exp(x)*sin(x)", "problem_type": "cyclic", "family": "rg_intermediate_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-intermediate-integration-l5-s6/tests/run.py b/tasks/construct-rg-intermediate-integration-l5-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rg-intermediate-integration-l5-s6/tests/test.sh b/tasks/construct-rg-intermediate-integration-l5-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-intermediate-integration-l5-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rg-simple-integration-l3-s3/environment/Dockerfile b/tasks/construct-rg-simple-integration-l3-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l3-s3/environment/instance.json b/tasks/construct-rg-simple-integration-l3-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2901c2873ac1bb029e27d3b151aa26da304fb219 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s3/environment/instance.json @@ -0,0 +1 @@ +{"variable": "X", "integrand": "16*X**7 + 54*X**5 + 39*X**2/2", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l3-s3/solution/solve.sh b/tasks/construct-rg-simple-integration-l3-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..dca6e22ddefe4cff9576551d4f8bac4672e6c562 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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' +{"antiderivative": "2*X**8 + 9*X**6 + 13*X**3/2 + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-simple-integration-l3-s3/tests/check.py b/tasks/construct-rg-simple-integration-l3-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s3/tests/check.py @@ -0,0 +1,158 @@ +"""Antiderivative check (Reasoning Gym simple_integration / intermediate_integration, Apache-2.0). + +The answer string is parsed with a whitelist AST walker (no eval), differentiated with SymPy and compared +with the integrand numerically (30-digit evaluation) at fixed points inside the integrand's real domain. +Any additive constant (e.g. "+ C") is allowed. + +Upstream notes: upstream scores with sympy.parse_expr, which calls eval() on the model's string (arbitrary +code execution), and it accepts an unevaluated "Integral(f, x)" since its derivative is f. Both are +rejected here: only arithmetic, whitelisted elementary functions, the variable, C, E and pi are allowed.""" +import ast +import math +import signal + +import sympy + +from run import Invalid + +MAX_LEN = 3000 +MAX_NODES = 600 +MAX_POW_NEST = 4 # nested powers with a variable exponent (x**x**x**...) blow up differentiation +TIME_LIMIT = 40 # seconds; a slower answer is rejected +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "cot": sympy.cot, "sec": sympy.sec, + "csc": sympy.csc, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "acot": sympy.acot, + "arcsin": sympy.asin, "arccos": sympy.acos, "arctan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "asinh": sympy.asinh, "acosh": sympy.acosh, + "atanh": sympy.atanh, "exp": sympy.exp, "log": sympy.log, "ln": sympy.log, "sqrt": sympy.sqrt, + "Abs": sympy.Abs, "abs": sympy.Abs} +POINTS = [0.3137, 0.5521, 0.8093, 1.1171, 1.4519, 1.9033, 2.3471, 2.8123, 3.3319, 3.9107, 4.6231, + -0.3547, -0.6529, -0.9511, -1.3027, -1.7519, -2.2013, -2.7131, -3.1397, -3.8203, -4.4111, + 0.1231, -0.1523, 0.2129, -0.2617, 0.0517, -0.0719, 5.4127, -5.3311, 6.3019, -6.2203, 7.2213, + -7.1117, 8.9021, -9.3107, 10.7129, -10.6337, 12.9011, -12.8231, 15.3113, -15.2719] +MIN_POINTS = 5 + + +def parse(s, var): + if not isinstance(s, str) or not s.strip(): + raise Invalid("antiderivative must be a non-empty string") + if len(s) > MAX_LEN: + raise Invalid("expression too long") + s = s.strip() + try: + tree = ast.parse(s, mode="eval") + except SyntaxError: + raise Invalid("expression does not parse (use ** for powers and * for products)") + if sum(1 for _ in ast.walk(tree)) > MAX_NODES: + raise Invalid("expression too large") + + def pow_nest(nd): + kids = [pow_nest(c) for c in ast.iter_child_nodes(nd)] + own = isinstance(nd, ast.BinOp) and isinstance(nd.op, ast.Pow) and any( + isinstance(c, ast.Name) and c.id == var for c in ast.walk(nd.right)) + return max(kids, default=0) + (1 if own else 0) + if pow_nest(tree) > MAX_POW_NEST: + raise Invalid("too many nested powers with a variable exponent") + x = sympy.Symbol(var, real=True) + names = {var: x, "C": sympy.Symbol("C"), "E": sympy.E, "pi": sympy.pi} + + def conv(nd): + if isinstance(nd, ast.Expression): + return conv(nd.body) + if isinstance(nd, ast.Constant): + v = nd.value + if isinstance(v, bool) or not isinstance(v, (int, float)): + raise Invalid(f"constant {v!r} not allowed") + if isinstance(v, int): + if abs(v) > 10 ** 18: + raise Invalid("integer constant too large") + return sympy.Integer(v) + if not math.isfinite(v): + raise Invalid("non-finite constant") + return sympy.Float(v, 30) + if isinstance(nd, ast.Name): + if nd.id not in names: + raise Invalid(f"unknown name {nd.id!r} (the variable is {var})") + return names[nd.id] + if isinstance(nd, ast.UnaryOp) and isinstance(nd.op, (ast.USub, ast.UAdd)): + a = conv(nd.operand) + return -a if isinstance(nd.op, ast.USub) else a + if isinstance(nd, ast.BinOp): + a, b = conv(nd.left), conv(nd.right) + if isinstance(nd.op, ast.Add): + return a + b + if isinstance(nd.op, ast.Sub): + return a - b + if isinstance(nd.op, ast.Mult): + return a * b + if isinstance(nd.op, ast.Div): + if b == 0: + raise Invalid("division by zero") + return a / b + if isinstance(nd.op, ast.Pow): + if not b.free_symbols: + bv = complex(b.evalf(20)) + if bv.imag != 0 or abs(bv.real) > 100: + raise Invalid("exponent too large") + if not a.free_symbols and abs(complex(a.evalf(20))) > 1e6: + raise Invalid("numeric power too large") + return a ** b + raise Invalid("only + - * / ** are allowed (use ** for powers)") + if isinstance(nd, ast.Call): + if not isinstance(nd.func, ast.Name) or nd.func.id not in FUNCS: + raise Invalid(f"function {ast.unparse(nd.func)!r} not allowed") + if nd.keywords or len(nd.args) != 1: + raise Invalid(f"{nd.func.id} takes exactly one argument") + return FUNCS[nd.func.id](conv(nd.args[0])) + raise Invalid(f"syntax element {type(nd).__name__} not allowed") + + return conv(tree), x + + +def value(expr, x, p): + v = expr.evalf(30, subs={x: sympy.Float(p, 30)}) + try: + z = complex(v) + except (TypeError, ValueError): + return None + if not (math.isfinite(z.real) and math.isfinite(z.imag)): + return None + return z + + +def _timeout(signum, frame): + raise Invalid(f"answer took more than {TIME_LIMIT} s to check") + + +def check(inst, ans): + if hasattr(signal, "SIGALRM"): + old = signal.signal(signal.SIGALRM, _timeout) + signal.alarm(TIME_LIMIT) + try: + return _check(inst, ans) + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + return _check(inst, ans) + + +def _check(inst, ans): + var = inst["variable"] + F, x = parse(ans.get("antiderivative"), var) + f, x2 = parse(inst["integrand"], var) + if not F.has(x): + raise Invalid("antiderivative does not depend on the variable") + dF = sympy.diff(F, x) + used = 0 + for p in POINTS: + fv = value(f, x2, p) + if fv is None or abs(fv.imag) > 1e-20 * (1 + abs(fv.real)): + continue # outside the integrand's real domain + gv = value(dF, x, p) + if gv is None: + raise Invalid(f"derivative of the answer cannot be evaluated at {var} = {p}") + if abs(gv - fv) > 1e-9 * max(1.0, abs(fv)): + raise Invalid(f"derivative of the answer differs from the integrand at {var} = {p}") + used += 1 + if used < MIN_POINTS: + raise Invalid("too few evaluation points in the integrand's domain") + return None, {"points": used} diff --git a/tasks/construct-rg-simple-integration-l3-s3/tests/instance.json b/tasks/construct-rg-simple-integration-l3-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2901c2873ac1bb029e27d3b151aa26da304fb219 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s3/tests/instance.json @@ -0,0 +1 @@ +{"variable": "X", "integrand": "16*X**7 + 54*X**5 + 39*X**2/2", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l3-s3/tests/run.py b/tasks/construct-rg-simple-integration-l3-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l3-s3/tests/test.sh b/tasks/construct-rg-simple-integration-l3-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-simple-integration-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-rg-simple-integration-l3-s4/environment/Dockerfile b/tasks/construct-rg-simple-integration-l3-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rg-simple-integration-l3-s4/environment/instance.json b/tasks/construct-rg-simple-integration-l3-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4b4f2a7b493a313afee8a9bd44074b93503db0f3 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s4/environment/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "9*x**8 + 64*x**7/9 - 25*x**4/8 + 1", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l3-s4/solution/solve.sh b/tasks/construct-rg-simple-integration-l3-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..164522a8037ddef7469ffffa78bdfe2d107567f8 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"antiderivative": "x**9 + 8*x**8/9 - 5*x**5/8 + x + C"} +RLMATH_EOF diff --git a/tasks/construct-rg-simple-integration-l3-s4/tests/check.py b/tasks/construct-rg-simple-integration-l3-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e364a8ede6c8215a16a04ee6b0d3529adc647d --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s4/tests/check.py @@ -0,0 +1,158 @@ +"""Antiderivative check (Reasoning Gym simple_integration / intermediate_integration, Apache-2.0). + +The answer string is parsed with a whitelist AST walker (no eval), differentiated with SymPy and compared +with the integrand numerically (30-digit evaluation) at fixed points inside the integrand's real domain. +Any additive constant (e.g. "+ C") is allowed. + +Upstream notes: upstream scores with sympy.parse_expr, which calls eval() on the model's string (arbitrary +code execution), and it accepts an unevaluated "Integral(f, x)" since its derivative is f. Both are +rejected here: only arithmetic, whitelisted elementary functions, the variable, C, E and pi are allowed.""" +import ast +import math +import signal + +import sympy + +from run import Invalid + +MAX_LEN = 3000 +MAX_NODES = 600 +MAX_POW_NEST = 4 # nested powers with a variable exponent (x**x**x**...) blow up differentiation +TIME_LIMIT = 40 # seconds; a slower answer is rejected +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "cot": sympy.cot, "sec": sympy.sec, + "csc": sympy.csc, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "acot": sympy.acot, + "arcsin": sympy.asin, "arccos": sympy.acos, "arctan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "asinh": sympy.asinh, "acosh": sympy.acosh, + "atanh": sympy.atanh, "exp": sympy.exp, "log": sympy.log, "ln": sympy.log, "sqrt": sympy.sqrt, + "Abs": sympy.Abs, "abs": sympy.Abs} +POINTS = [0.3137, 0.5521, 0.8093, 1.1171, 1.4519, 1.9033, 2.3471, 2.8123, 3.3319, 3.9107, 4.6231, + -0.3547, -0.6529, -0.9511, -1.3027, -1.7519, -2.2013, -2.7131, -3.1397, -3.8203, -4.4111, + 0.1231, -0.1523, 0.2129, -0.2617, 0.0517, -0.0719, 5.4127, -5.3311, 6.3019, -6.2203, 7.2213, + -7.1117, 8.9021, -9.3107, 10.7129, -10.6337, 12.9011, -12.8231, 15.3113, -15.2719] +MIN_POINTS = 5 + + +def parse(s, var): + if not isinstance(s, str) or not s.strip(): + raise Invalid("antiderivative must be a non-empty string") + if len(s) > MAX_LEN: + raise Invalid("expression too long") + s = s.strip() + try: + tree = ast.parse(s, mode="eval") + except SyntaxError: + raise Invalid("expression does not parse (use ** for powers and * for products)") + if sum(1 for _ in ast.walk(tree)) > MAX_NODES: + raise Invalid("expression too large") + + def pow_nest(nd): + kids = [pow_nest(c) for c in ast.iter_child_nodes(nd)] + own = isinstance(nd, ast.BinOp) and isinstance(nd.op, ast.Pow) and any( + isinstance(c, ast.Name) and c.id == var for c in ast.walk(nd.right)) + return max(kids, default=0) + (1 if own else 0) + if pow_nest(tree) > MAX_POW_NEST: + raise Invalid("too many nested powers with a variable exponent") + x = sympy.Symbol(var, real=True) + names = {var: x, "C": sympy.Symbol("C"), "E": sympy.E, "pi": sympy.pi} + + def conv(nd): + if isinstance(nd, ast.Expression): + return conv(nd.body) + if isinstance(nd, ast.Constant): + v = nd.value + if isinstance(v, bool) or not isinstance(v, (int, float)): + raise Invalid(f"constant {v!r} not allowed") + if isinstance(v, int): + if abs(v) > 10 ** 18: + raise Invalid("integer constant too large") + return sympy.Integer(v) + if not math.isfinite(v): + raise Invalid("non-finite constant") + return sympy.Float(v, 30) + if isinstance(nd, ast.Name): + if nd.id not in names: + raise Invalid(f"unknown name {nd.id!r} (the variable is {var})") + return names[nd.id] + if isinstance(nd, ast.UnaryOp) and isinstance(nd.op, (ast.USub, ast.UAdd)): + a = conv(nd.operand) + return -a if isinstance(nd.op, ast.USub) else a + if isinstance(nd, ast.BinOp): + a, b = conv(nd.left), conv(nd.right) + if isinstance(nd.op, ast.Add): + return a + b + if isinstance(nd.op, ast.Sub): + return a - b + if isinstance(nd.op, ast.Mult): + return a * b + if isinstance(nd.op, ast.Div): + if b == 0: + raise Invalid("division by zero") + return a / b + if isinstance(nd.op, ast.Pow): + if not b.free_symbols: + bv = complex(b.evalf(20)) + if bv.imag != 0 or abs(bv.real) > 100: + raise Invalid("exponent too large") + if not a.free_symbols and abs(complex(a.evalf(20))) > 1e6: + raise Invalid("numeric power too large") + return a ** b + raise Invalid("only + - * / ** are allowed (use ** for powers)") + if isinstance(nd, ast.Call): + if not isinstance(nd.func, ast.Name) or nd.func.id not in FUNCS: + raise Invalid(f"function {ast.unparse(nd.func)!r} not allowed") + if nd.keywords or len(nd.args) != 1: + raise Invalid(f"{nd.func.id} takes exactly one argument") + return FUNCS[nd.func.id](conv(nd.args[0])) + raise Invalid(f"syntax element {type(nd).__name__} not allowed") + + return conv(tree), x + + +def value(expr, x, p): + v = expr.evalf(30, subs={x: sympy.Float(p, 30)}) + try: + z = complex(v) + except (TypeError, ValueError): + return None + if not (math.isfinite(z.real) and math.isfinite(z.imag)): + return None + return z + + +def _timeout(signum, frame): + raise Invalid(f"answer took more than {TIME_LIMIT} s to check") + + +def check(inst, ans): + if hasattr(signal, "SIGALRM"): + old = signal.signal(signal.SIGALRM, _timeout) + signal.alarm(TIME_LIMIT) + try: + return _check(inst, ans) + finally: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + return _check(inst, ans) + + +def _check(inst, ans): + var = inst["variable"] + F, x = parse(ans.get("antiderivative"), var) + f, x2 = parse(inst["integrand"], var) + if not F.has(x): + raise Invalid("antiderivative does not depend on the variable") + dF = sympy.diff(F, x) + used = 0 + for p in POINTS: + fv = value(f, x2, p) + if fv is None or abs(fv.imag) > 1e-20 * (1 + abs(fv.real)): + continue # outside the integrand's real domain + gv = value(dF, x, p) + if gv is None: + raise Invalid(f"derivative of the answer cannot be evaluated at {var} = {p}") + if abs(gv - fv) > 1e-9 * max(1.0, abs(fv)): + raise Invalid(f"derivative of the answer differs from the integrand at {var} = {p}") + used += 1 + if used < MIN_POINTS: + raise Invalid("too few evaluation points in the integrand's domain") + return None, {"points": used} diff --git a/tasks/construct-rg-simple-integration-l3-s4/tests/instance.json b/tasks/construct-rg-simple-integration-l3-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4b4f2a7b493a313afee8a9bd44074b93503db0f3 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s4/tests/instance.json @@ -0,0 +1 @@ +{"variable": "x", "integrand": "9*x**8 + 64*x**7/9 - 25*x**4/8 + 1", "family": "rg_simple_integration", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rg-simple-integration-l3-s4/tests/run.py b/tasks/construct-rg-simple-integration-l3-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rg-simple-integration-l3-s4/tests/test.sh b/tasks/construct-rg-simple-integration-l3-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rg-simple-integration-l3-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-antiderivative-l2-s4/environment/Dockerfile b/tasks/construct-rlve-antiderivative-l2-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l2-s4/environment/instance.json b/tasks/construct-rlve-antiderivative-l2-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..45f3dcbe36ba2c821b1f238704482b400676258a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s4/environment/instance.json @@ -0,0 +1 @@ +{"f_prime": "cos(x) + 1", "max_ops": 32, "max_len": 680, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l2-s4/solution/solve.sh b/tasks/construct-rlve-antiderivative-l2-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..88d28f3b9d853c64a45f15702b47b7d3a88e215d --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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' +{"F": "x + sin(x) + 1"} +RLMATH_EOF diff --git a/tasks/construct-rlve-antiderivative-l2-s4/tests/check.py b/tasks/construct-rlve-antiderivative-l2-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b30b93bbbb7795b54d973e43f25b23c82cb7fc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s4/tests/check.py @@ -0,0 +1,107 @@ +"""Antiderivative check. The answer string is tokenised against a whitelist (x, integers, + - * / ** ( ) and a few +elementary functions) before sympy parses it, so no Python eval of untrusted text and no `integrate`/`Integral`.""" +import re +import signal + +import sympy +from sympy.parsing.sympy_parser import auto_number, parse_expr + +from run import Invalid + +x = sympy.Symbol("x") +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "exp": sympy.exp, "log": sympy.log, + "sqrt": sympy.sqrt, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "E": sympy.E, "pi": sympy.pi, "x": x} +TOK = re.compile(r"\s*(?:(\d+)|([A-Za-z]+)|(\*\*|[-+*/()]))") +NPTS = 40 + + +def safe_parse(s, max_len): + if not isinstance(s, str) or not s.strip(): + raise Invalid("F must be a non-empty string") + if len(s) > max_len: + raise Invalid("expression too long") + pos = 0 + while pos < len(s): + m = TOK.match(s, pos) + if not m or m.end() == pos: + if s[pos:].strip() == "": + break + raise Invalid(f"illegal character near position {pos}") + if m.group(1) and len(m.group(1)) > 12: + raise Invalid("integer literal too long") + if m.group(2) and m.group(2) not in FUNCS: + raise Invalid(f"unknown name {m.group(2)!r}") + pos = m.end() + try: + e = parse_expr(s, local_dict=dict(FUNCS), global_dict={"__builtins__": {}, "Integer": sympy.Integer}, + transformations=(auto_number,)) + except Invalid: + raise + except Exception as ex: + raise Invalid(f"cannot parse F: {type(ex).__name__}") + if not isinstance(e, sympy.Expr): + raise Invalid("F is not an expression") + if e.free_symbols - {x}: + raise Invalid("F may only contain the variable x") + return e + + +def _val(e, pt): + v = e.evalf(40, subs={x: pt}) + if not v.is_number or v.has(sympy.zoo, sympy.nan, sympy.oo, -sympy.oo): + return None + return v + + +class _Timeout(Exception): + pass + + +def _alarm(*_): + raise _Timeout() + + +def check(inst, ans): + old = None + try: + old = signal.signal(signal.SIGALRM, _alarm) + signal.alarm(40) + except ValueError: # not in main thread + old = None + try: + return _check(inst, ans) + except _Timeout: + raise Invalid("evaluation timed out") + except RecursionError: + raise Invalid("expression too deep") + finally: + if old is not None: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + + +def _check(inst, ans): + F = safe_parse(ans.get("F"), inst["max_len"]) + if sympy.count_ops(F) > inst["max_ops"]: + raise Invalid("expression too complex") + if any(isinstance(a, sympy.Rational) and max(abs(a.p), abs(a.q)) > 10 ** 12 for a in F.atoms(sympy.Rational)): + raise Invalid("numeric constants too large") + D = sympy.diff(F, x) + f = sympy.sympify(inst["f_prime"]) # trusted instance data + ok = 0 + for k in range(NPTS): + pt = sympy.Rational(2 * k + 1, NPTS // 2 * 2) * 2 - 2 + sympy.Rational(1, 997) + vf = _val(f, pt) + if vf is None: + continue + vd = _val(D, pt) + if vd is None: + continue + err = sympy.Abs(vd - vf).evalf(40) + if err > sympy.Float("1e-20", 40) * (1 + sympy.Abs(vf).evalf(40)): + raise Invalid(f"F'(x) != f(x) at x = {float(pt):.4f}") + ok += 1 + if ok < NPTS // 4: + raise Invalid("F' could not be compared with f on enough test points") + return None, {"points_checked": ok} diff --git a/tasks/construct-rlve-antiderivative-l2-s4/tests/instance.json b/tasks/construct-rlve-antiderivative-l2-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..45f3dcbe36ba2c821b1f238704482b400676258a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l2-s4/tests/instance.json @@ -0,0 +1 @@ +{"f_prime": "cos(x) + 1", "max_ops": 32, "max_len": 680, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l2-s4/tests/run.py b/tasks/construct-rlve-antiderivative-l2-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l2-s4/tests/test.sh b/tasks/construct-rlve-antiderivative-l2-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l6-s2/environment/Dockerfile b/tasks/construct-rlve-antiderivative-l6-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l6-s2/environment/instance.json b/tasks/construct-rlve-antiderivative-l6-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..919c4a054b56f93870a10b51e4a10cf271efdd26 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s2/environment/instance.json @@ -0,0 +1 @@ +{"f_prime": "3*x**2 - 1", "max_ops": 32, "max_len": 640, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l6-s2/solution/solve.sh b/tasks/construct-rlve-antiderivative-l6-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a2bb5eae03fae9cfd6dda49cc09b9cda5d4bcc2a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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' +{"F": "x**3 - x - 1"} +RLMATH_EOF diff --git a/tasks/construct-rlve-antiderivative-l6-s2/tests/check.py b/tasks/construct-rlve-antiderivative-l6-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b30b93bbbb7795b54d973e43f25b23c82cb7fc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s2/tests/check.py @@ -0,0 +1,107 @@ +"""Antiderivative check. The answer string is tokenised against a whitelist (x, integers, + - * / ** ( ) and a few +elementary functions) before sympy parses it, so no Python eval of untrusted text and no `integrate`/`Integral`.""" +import re +import signal + +import sympy +from sympy.parsing.sympy_parser import auto_number, parse_expr + +from run import Invalid + +x = sympy.Symbol("x") +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "exp": sympy.exp, "log": sympy.log, + "sqrt": sympy.sqrt, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "E": sympy.E, "pi": sympy.pi, "x": x} +TOK = re.compile(r"\s*(?:(\d+)|([A-Za-z]+)|(\*\*|[-+*/()]))") +NPTS = 40 + + +def safe_parse(s, max_len): + if not isinstance(s, str) or not s.strip(): + raise Invalid("F must be a non-empty string") + if len(s) > max_len: + raise Invalid("expression too long") + pos = 0 + while pos < len(s): + m = TOK.match(s, pos) + if not m or m.end() == pos: + if s[pos:].strip() == "": + break + raise Invalid(f"illegal character near position {pos}") + if m.group(1) and len(m.group(1)) > 12: + raise Invalid("integer literal too long") + if m.group(2) and m.group(2) not in FUNCS: + raise Invalid(f"unknown name {m.group(2)!r}") + pos = m.end() + try: + e = parse_expr(s, local_dict=dict(FUNCS), global_dict={"__builtins__": {}, "Integer": sympy.Integer}, + transformations=(auto_number,)) + except Invalid: + raise + except Exception as ex: + raise Invalid(f"cannot parse F: {type(ex).__name__}") + if not isinstance(e, sympy.Expr): + raise Invalid("F is not an expression") + if e.free_symbols - {x}: + raise Invalid("F may only contain the variable x") + return e + + +def _val(e, pt): + v = e.evalf(40, subs={x: pt}) + if not v.is_number or v.has(sympy.zoo, sympy.nan, sympy.oo, -sympy.oo): + return None + return v + + +class _Timeout(Exception): + pass + + +def _alarm(*_): + raise _Timeout() + + +def check(inst, ans): + old = None + try: + old = signal.signal(signal.SIGALRM, _alarm) + signal.alarm(40) + except ValueError: # not in main thread + old = None + try: + return _check(inst, ans) + except _Timeout: + raise Invalid("evaluation timed out") + except RecursionError: + raise Invalid("expression too deep") + finally: + if old is not None: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + + +def _check(inst, ans): + F = safe_parse(ans.get("F"), inst["max_len"]) + if sympy.count_ops(F) > inst["max_ops"]: + raise Invalid("expression too complex") + if any(isinstance(a, sympy.Rational) and max(abs(a.p), abs(a.q)) > 10 ** 12 for a in F.atoms(sympy.Rational)): + raise Invalid("numeric constants too large") + D = sympy.diff(F, x) + f = sympy.sympify(inst["f_prime"]) # trusted instance data + ok = 0 + for k in range(NPTS): + pt = sympy.Rational(2 * k + 1, NPTS // 2 * 2) * 2 - 2 + sympy.Rational(1, 997) + vf = _val(f, pt) + if vf is None: + continue + vd = _val(D, pt) + if vd is None: + continue + err = sympy.Abs(vd - vf).evalf(40) + if err > sympy.Float("1e-20", 40) * (1 + sympy.Abs(vf).evalf(40)): + raise Invalid(f"F'(x) != f(x) at x = {float(pt):.4f}") + ok += 1 + if ok < NPTS // 4: + raise Invalid("F' could not be compared with f on enough test points") + return None, {"points_checked": ok} diff --git a/tasks/construct-rlve-antiderivative-l6-s2/tests/instance.json b/tasks/construct-rlve-antiderivative-l6-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..919c4a054b56f93870a10b51e4a10cf271efdd26 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s2/tests/instance.json @@ -0,0 +1 @@ +{"f_prime": "3*x**2 - 1", "max_ops": 32, "max_len": 640, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l6-s2/tests/run.py b/tasks/construct-rlve-antiderivative-l6-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l6-s2/tests/test.sh b/tasks/construct-rlve-antiderivative-l6-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l6-s5/environment/Dockerfile b/tasks/construct-rlve-antiderivative-l6-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l6-s5/environment/instance.json b/tasks/construct-rlve-antiderivative-l6-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a116cf406cba0cb18fce993395857cb8eeaef926 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s5/environment/instance.json @@ -0,0 +1 @@ +{"f_prime": "(8 - 4*cos(3*x))*log(x)*cos(x) + 12*log(x)*sin(x)*sin(3*x) - 1/2 + (8 - 4*cos(3*x))*sin(x)/x", "max_ops": 60, "max_len": 1140, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l6-s5/solution/solve.sh b/tasks/construct-rlve-antiderivative-l6-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..44d5d1a855abc3c2e21407ebd4fa5ff50c179f46 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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' +{"F": "-x/2 + (8 - 4*cos(3*x))*log(x)*sin(x)"} +RLMATH_EOF diff --git a/tasks/construct-rlve-antiderivative-l6-s5/tests/check.py b/tasks/construct-rlve-antiderivative-l6-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c6b30b93bbbb7795b54d973e43f25b23c82cb7fc --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s5/tests/check.py @@ -0,0 +1,107 @@ +"""Antiderivative check. The answer string is tokenised against a whitelist (x, integers, + - * / ** ( ) and a few +elementary functions) before sympy parses it, so no Python eval of untrusted text and no `integrate`/`Integral`.""" +import re +import signal + +import sympy +from sympy.parsing.sympy_parser import auto_number, parse_expr + +from run import Invalid + +x = sympy.Symbol("x") +FUNCS = {"sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "exp": sympy.exp, "log": sympy.log, + "sqrt": sympy.sqrt, "asin": sympy.asin, "acos": sympy.acos, "atan": sympy.atan, "sinh": sympy.sinh, + "cosh": sympy.cosh, "tanh": sympy.tanh, "E": sympy.E, "pi": sympy.pi, "x": x} +TOK = re.compile(r"\s*(?:(\d+)|([A-Za-z]+)|(\*\*|[-+*/()]))") +NPTS = 40 + + +def safe_parse(s, max_len): + if not isinstance(s, str) or not s.strip(): + raise Invalid("F must be a non-empty string") + if len(s) > max_len: + raise Invalid("expression too long") + pos = 0 + while pos < len(s): + m = TOK.match(s, pos) + if not m or m.end() == pos: + if s[pos:].strip() == "": + break + raise Invalid(f"illegal character near position {pos}") + if m.group(1) and len(m.group(1)) > 12: + raise Invalid("integer literal too long") + if m.group(2) and m.group(2) not in FUNCS: + raise Invalid(f"unknown name {m.group(2)!r}") + pos = m.end() + try: + e = parse_expr(s, local_dict=dict(FUNCS), global_dict={"__builtins__": {}, "Integer": sympy.Integer}, + transformations=(auto_number,)) + except Invalid: + raise + except Exception as ex: + raise Invalid(f"cannot parse F: {type(ex).__name__}") + if not isinstance(e, sympy.Expr): + raise Invalid("F is not an expression") + if e.free_symbols - {x}: + raise Invalid("F may only contain the variable x") + return e + + +def _val(e, pt): + v = e.evalf(40, subs={x: pt}) + if not v.is_number or v.has(sympy.zoo, sympy.nan, sympy.oo, -sympy.oo): + return None + return v + + +class _Timeout(Exception): + pass + + +def _alarm(*_): + raise _Timeout() + + +def check(inst, ans): + old = None + try: + old = signal.signal(signal.SIGALRM, _alarm) + signal.alarm(40) + except ValueError: # not in main thread + old = None + try: + return _check(inst, ans) + except _Timeout: + raise Invalid("evaluation timed out") + except RecursionError: + raise Invalid("expression too deep") + finally: + if old is not None: + signal.alarm(0) + signal.signal(signal.SIGALRM, old) + + +def _check(inst, ans): + F = safe_parse(ans.get("F"), inst["max_len"]) + if sympy.count_ops(F) > inst["max_ops"]: + raise Invalid("expression too complex") + if any(isinstance(a, sympy.Rational) and max(abs(a.p), abs(a.q)) > 10 ** 12 for a in F.atoms(sympy.Rational)): + raise Invalid("numeric constants too large") + D = sympy.diff(F, x) + f = sympy.sympify(inst["f_prime"]) # trusted instance data + ok = 0 + for k in range(NPTS): + pt = sympy.Rational(2 * k + 1, NPTS // 2 * 2) * 2 - 2 + sympy.Rational(1, 997) + vf = _val(f, pt) + if vf is None: + continue + vd = _val(D, pt) + if vd is None: + continue + err = sympy.Abs(vd - vf).evalf(40) + if err > sympy.Float("1e-20", 40) * (1 + sympy.Abs(vf).evalf(40)): + raise Invalid(f"F'(x) != f(x) at x = {float(pt):.4f}") + ok += 1 + if ok < NPTS // 4: + raise Invalid("F' could not be compared with f on enough test points") + return None, {"points_checked": ok} diff --git a/tasks/construct-rlve-antiderivative-l6-s5/tests/instance.json b/tasks/construct-rlve-antiderivative-l6-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a116cf406cba0cb18fce993395857cb8eeaef926 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s5/tests/instance.json @@ -0,0 +1 @@ +{"f_prime": "(8 - 4*cos(3*x))*log(x)*cos(x) + 12*log(x)*sin(x)*sin(3*x) - 1/2 + (8 - 4*cos(3*x))*sin(x)/x", "max_ops": 60, "max_len": 1140, "family": "rlve_antiderivative", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-antiderivative-l6-s5/tests/run.py b/tasks/construct-rlve-antiderivative-l6-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-antiderivative-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-antiderivative-l6-s5/tests/test.sh b/tasks/construct-rlve-antiderivative-l6-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-antiderivative-l6-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-bezout-identity-l3-s0/environment/Dockerfile b/tasks/construct-rlve-bezout-identity-l3-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-bezout-identity-l3-s0/environment/instance.json b/tasks/construct-rlve-bezout-identity-l3-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..db8dd890006b4e52660bd67e26327a0b2be66694 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s0/environment/instance.json @@ -0,0 +1 @@ +{"A": [400, 182, 190, -65, 286, -385], "target": 1, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l3-s0/solution/solve.sh b/tasks/construct-rlve-bezout-identity-l3-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c73844e56298d6adf02ab891aff1b11641478d4a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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": [160, -352, 0, -1, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-bezout-identity-l3-s0/tests/check.py b/tasks/construct-rlve-bezout-identity-l3-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b4cb860ed36974a12b71adc9a0fa3f1ad85c814a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s0/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + X = int_list(ans.get("X"), len(A), name="X") + S = sum(a * x for a, x in zip(A, X)) + if S != inst["target"]: + raise Invalid(f"S = {S}, required {inst['target']}") + return None, {} diff --git a/tasks/construct-rlve-bezout-identity-l3-s0/tests/instance.json b/tasks/construct-rlve-bezout-identity-l3-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..db8dd890006b4e52660bd67e26327a0b2be66694 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s0/tests/instance.json @@ -0,0 +1 @@ +{"A": [400, 182, 190, -65, 286, -385], "target": 1, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l3-s0/tests/run.py b/tasks/construct-rlve-bezout-identity-l3-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-bezout-identity-l3-s0/tests/test.sh b/tasks/construct-rlve-bezout-identity-l3-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-bezout-identity-l3-s7/environment/Dockerfile b/tasks/construct-rlve-bezout-identity-l3-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-bezout-identity-l3-s7/environment/instance.json b/tasks/construct-rlve-bezout-identity-l3-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..734fabbfe24581a5ff480f10d11f1f653af6e33a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s7/environment/instance.json @@ -0,0 +1 @@ +{"A": [-478, 390, -308, -226, -464, -282], "target": 2, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l3-s7/solution/solve.sh b/tasks/construct-rlve-bezout-identity-l3-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c2582da84f41cbf7cc6ac98ac373ceeb117b7ba7 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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": [31, 38, 0, 0, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-bezout-identity-l3-s7/tests/check.py b/tasks/construct-rlve-bezout-identity-l3-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b4cb860ed36974a12b71adc9a0fa3f1ad85c814a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s7/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + X = int_list(ans.get("X"), len(A), name="X") + S = sum(a * x for a, x in zip(A, X)) + if S != inst["target"]: + raise Invalid(f"S = {S}, required {inst['target']}") + return None, {} diff --git a/tasks/construct-rlve-bezout-identity-l3-s7/tests/instance.json b/tasks/construct-rlve-bezout-identity-l3-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..734fabbfe24581a5ff480f10d11f1f653af6e33a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-l3-s7/tests/instance.json @@ -0,0 +1 @@ +{"A": [-478, 390, -308, -226, -464, -282], "target": 2, "family": "rlve_bezout_identity", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-bezout-identity-l3-s7/tests/run.py b/tasks/construct-rlve-bezout-identity-l3-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-bezout-identity-l3-s7/tests/test.sh b/tasks/construct-rlve-bezout-identity-l3-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-bezout-identity-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-construct-hack-interval-l1-s3/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l1-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e87b6f3aaaec53eb30f83b12a5f9c00ce0ea9772 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"L": 2, "R": 7} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s3/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l1-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s3/tests/check.py @@ -0,0 +1,30 @@ +from run import Invalid, as_int + + +def digit_sum_prefix(n): + """sum of digit sums of all integers in [0, n] (exact, digit DP).""" + if n <= 0: + return 0 + s = str(n) + total, prefix_sum = 0, 0 + k = len(s) + for i, ch in enumerate(s): + d = int(ch) + rest = k - i - 1 + p = 10 ** rest + # numbers with this digit < d, free suffix of `rest` digits + total += d * prefix_sum * p + (d * (d - 1) // 2) * p + d * (45 * rest * p // 10 if rest else 0) + prefix_sum += d + return total + prefix_sum # include n itself + + +def check(inst, ans): + mod = inst["mod"] + L = as_int(ans.get("L"), "L", lo=1) + R = as_int(ans.get("R"), "R", lo=1, hi=10 * mod) + if L > R: + raise Invalid("need L <= R") + total = digit_sum_prefix(R) - digit_sum_prefix(L - 1) + if total % mod: + raise Invalid(f"sum of digit sums over [L, R] is {total}, not divisible by {mod}") + return None, {} diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s3/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l1-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bded6ae35f4b72b500e5c2bf02b6eaa268adca73 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s3/tests/instance.json @@ -0,0 +1 @@ +{"mod": 27, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s3/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l1-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s3/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l1-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s4/environment/Dockerfile b/tasks/construct-rlve-construct-hack-interval-l1-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s4/environment/instance.json b/tasks/construct-rlve-construct-hack-interval-l1-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7b3551e0ef3b281865870cc1a9ad8b433802f87c --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s4/environment/instance.json @@ -0,0 +1 @@ +{"mod": 37, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s4/solution/solve.sh b/tasks/construct-rlve-construct-hack-interval-l1-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a38678b2c006a5b30f61cd994ce9448299856bca --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"L": 9, "R": 16} +RLMATH_EOF diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s4/tests/check.py b/tasks/construct-rlve-construct-hack-interval-l1-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..34b46e9758e3a50ed16c9c2a29cfc0abe663926b --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s4/tests/check.py @@ -0,0 +1,30 @@ +from run import Invalid, as_int + + +def digit_sum_prefix(n): + """sum of digit sums of all integers in [0, n] (exact, digit DP).""" + if n <= 0: + return 0 + s = str(n) + total, prefix_sum = 0, 0 + k = len(s) + for i, ch in enumerate(s): + d = int(ch) + rest = k - i - 1 + p = 10 ** rest + # numbers with this digit < d, free suffix of `rest` digits + total += d * prefix_sum * p + (d * (d - 1) // 2) * p + d * (45 * rest * p // 10 if rest else 0) + prefix_sum += d + return total + prefix_sum # include n itself + + +def check(inst, ans): + mod = inst["mod"] + L = as_int(ans.get("L"), "L", lo=1) + R = as_int(ans.get("R"), "R", lo=1, hi=10 * mod) + if L > R: + raise Invalid("need L <= R") + total = digit_sum_prefix(R) - digit_sum_prefix(L - 1) + if total % mod: + raise Invalid(f"sum of digit sums over [L, R] is {total}, not divisible by {mod}") + return None, {} diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s4/tests/instance.json b/tasks/construct-rlve-construct-hack-interval-l1-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7b3551e0ef3b281865870cc1a9ad8b433802f87c --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s4/tests/instance.json @@ -0,0 +1 @@ +{"mod": 37, "family": "rlve_construct_hack_interval", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s4/tests/run.py b/tasks/construct-rlve-construct-hack-interval-l1-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-construct-hack-interval-l1-s4/tests/test.sh b/tasks/construct-rlve-construct-hack-interval-l1-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-construct-hack-interval-l1-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-crt-l4-s3/environment/Dockerfile b/tasks/construct-rlve-crt-l4-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l4-s3/environment/instance.json b/tasks/construct-rlve-crt-l4-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7a2fbc1f0c647decfc614fa72313ced1654b68d7 --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s3/environment/instance.json @@ -0,0 +1 @@ +{"moduli": [268045, 44160, 333282, 482041, 84905], "residues": [262300, 425, 197063, 48304, 20915], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l4-s3/solution/solve.sh b/tasks/construct-rlve-crt-l4-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ef2fb37a9f2e0d925627891613e85b36b1ffa74e --- /dev/null +++ b/tasks/construct-rlve-crt-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": 530345} +RLMATH_EOF diff --git a/tasks/construct-rlve-crt-l4-s3/tests/check.py b/tasks/construct-rlve-crt-l4-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..886d95606ef325930b24794c0959c2ba7b254ebd --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s3/tests/check.py @@ -0,0 +1,11 @@ +from run import Invalid, as_int + + +def check(inst, ans): + x = as_int(ans.get("x"), "x", lo=0) + if x.bit_length() > 20000: + raise Invalid("x is unreasonably large") + for a, b in zip(inst["residues"], inst["moduli"]): + if x % b != a: + raise Invalid(f"x mod {b} = {x % b}, need {a}") + return None, {} diff --git a/tasks/construct-rlve-crt-l4-s3/tests/instance.json b/tasks/construct-rlve-crt-l4-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7a2fbc1f0c647decfc614fa72313ced1654b68d7 --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s3/tests/instance.json @@ -0,0 +1 @@ +{"moduli": [268045, 44160, 333282, 482041, 84905], "residues": [262300, 425, 197063, 48304, 20915], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l4-s3/tests/run.py b/tasks/construct-rlve-crt-l4-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l4-s3/tests/test.sh b/tasks/construct-rlve-crt-l4-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l4-s4/environment/Dockerfile b/tasks/construct-rlve-crt-l4-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l4-s4/environment/instance.json b/tasks/construct-rlve-crt-l4-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..58bc5b15bec62a1e64565fe12da1d360a1cc09d0 --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s4/environment/instance.json @@ -0,0 +1 @@ +{"moduli": [95428, 199374, 83610, 50037, 80269], "residues": [67085, 145477, 42565, 43855, 62611], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l4-s4/solution/solve.sh b/tasks/construct-rlve-crt-l4-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8794f9a674d6ee7e6252a3654d542b2449171f61 --- /dev/null +++ b/tasks/construct-rlve-crt-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": 544225} +RLMATH_EOF diff --git a/tasks/construct-rlve-crt-l4-s4/tests/check.py b/tasks/construct-rlve-crt-l4-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..886d95606ef325930b24794c0959c2ba7b254ebd --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s4/tests/check.py @@ -0,0 +1,11 @@ +from run import Invalid, as_int + + +def check(inst, ans): + x = as_int(ans.get("x"), "x", lo=0) + if x.bit_length() > 20000: + raise Invalid("x is unreasonably large") + for a, b in zip(inst["residues"], inst["moduli"]): + if x % b != a: + raise Invalid(f"x mod {b} = {x % b}, need {a}") + return None, {} diff --git a/tasks/construct-rlve-crt-l4-s4/tests/instance.json b/tasks/construct-rlve-crt-l4-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..58bc5b15bec62a1e64565fe12da1d360a1cc09d0 --- /dev/null +++ b/tasks/construct-rlve-crt-l4-s4/tests/instance.json @@ -0,0 +1 @@ +{"moduli": [95428, 199374, 83610, 50037, 80269], "residues": [67085, 145477, 42565, 43855, 62611], "family": "rlve_crt", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-crt-l4-s4/tests/run.py b/tasks/construct-rlve-crt-l4-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-crt-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-crt-l4-s4/tests/test.sh b/tasks/construct-rlve-crt-l4-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-crt-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-distinct-subset-sum-permutation-l1-s2/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l1-s2/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ed558099b893b3cc2716e7e5b1bd9c778690bfa2 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"A": [2, 3, 0, 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-l1-s2/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b9baf265cdad82aefac11573b5a1f1656040749c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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' +{"B": [3, 4, 2, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s2/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s2/tests/check.py @@ -0,0 +1,22 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + n = len(A) + B = int_list(ans.get("B"), n, name="B") + if Counter(B) != Counter(A): + raise Invalid("B is not a permutation of A") + d = [a - b for a, b in zip(A, B)] + # count subsets (including empty and full) with sum 0; the empty and full sets always qualify + ways = Counter({0: 1}) + for x in d: + nxt = Counter(ways) + for s, c in ways.items(): + nxt[s + x] += c + ways = nxt + if ways[0] != 2: + raise Invalid(f"{ways[0] - 2} non-empty proper subsets have equal sums in A and B") + return None, {} diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s2/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ed558099b893b3cc2716e7e5b1bd9c778690bfa2 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"A": [2, 3, 0, 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-l1-s2/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l1-s2/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l1-s5/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l1-s5/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2e901404ebe735813a5101a81605396f877c7c62 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s5/environment/instance.json @@ -0,0 +1 @@ +{"A": [0, 4, 7, 5], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s5/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ec7781eccc0d2cb6145f10af8b5c9153a6fbd77a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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' +{"B": [4, 5, 0, 7]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s5/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s5/tests/check.py @@ -0,0 +1,22 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + n = len(A) + B = int_list(ans.get("B"), n, name="B") + if Counter(B) != Counter(A): + raise Invalid("B is not a permutation of A") + d = [a - b for a, b in zip(A, B)] + # count subsets (including empty and full) with sum 0; the empty and full sets always qualify + ways = Counter({0: 1}) + for x in d: + nxt = Counter(ways) + for s, c in ways.items(): + nxt[s + x] += c + ways = nxt + if ways[0] != 2: + raise Invalid(f"{ways[0] - 2} non-empty proper subsets have equal sums in A and B") + return None, {} diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s5/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2e901404ebe735813a5101a81605396f877c7c62 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s5/tests/instance.json @@ -0,0 +1 @@ +{"A": [0, 4, 7, 5], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s5/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l1-s5/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l1-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l5-s3/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l5-s3/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c047afbfaed9e5a1dc67c5c7d29337eb2603e19d --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s3/environment/instance.json @@ -0,0 +1 @@ +{"A": [21, 1, 5, 22, 29, 19, 28, 7, 4, 18, 20, 16, 15, 32, 8, 23, 0, 26], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s3/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3abd0e9b11222c8490b01f91d2be3802ccbbc94b --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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' +{"B": [22, 4, 7, 23, 32, 20, 29, 8, 5, 19, 21, 18, 16, 0, 15, 26, 1, 28]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s3/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s3/tests/check.py @@ -0,0 +1,22 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + n = len(A) + B = int_list(ans.get("B"), n, name="B") + if Counter(B) != Counter(A): + raise Invalid("B is not a permutation of A") + d = [a - b for a, b in zip(A, B)] + # count subsets (including empty and full) with sum 0; the empty and full sets always qualify + ways = Counter({0: 1}) + for x in d: + nxt = Counter(ways) + for s, c in ways.items(): + nxt[s + x] += c + ways = nxt + if ways[0] != 2: + raise Invalid(f"{ways[0] - 2} non-empty proper subsets have equal sums in A and B") + return None, {} diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s3/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c047afbfaed9e5a1dc67c5c7d29337eb2603e19d --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"A": [21, 1, 5, 22, 29, 19, 28, 7, 4, 18, 20, 16, 15, 32, 8, 23, 0, 26], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s3/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l5-s3/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l5-s4/environment/Dockerfile b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l5-s4/environment/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c1a27904e8aadd4927bb9ba7eb51003ead09e665 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s4/environment/instance.json @@ -0,0 +1 @@ +{"A": [6, 26, 10, 14, 3, 21, 24, 30, 35, 5, 33, 11, 4, 32, 7, 12, 25, 31], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s4/solution/solve.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a0ea26286ab8bfc376e4dd5f95ec96ddb7ec3370 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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' +{"B": [7, 30, 11, 21, 4, 24, 25, 31, 3, 6, 35, 12, 5, 33, 10, 14, 26, 32]} +RLMATH_EOF diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s4/tests/check.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..06bbbcf872c2fca05785f40fdfdcf85a5e5a0e7c --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s4/tests/check.py @@ -0,0 +1,22 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + A = inst["A"] + n = len(A) + B = int_list(ans.get("B"), n, name="B") + if Counter(B) != Counter(A): + raise Invalid("B is not a permutation of A") + d = [a - b for a, b in zip(A, B)] + # count subsets (including empty and full) with sum 0; the empty and full sets always qualify + ways = Counter({0: 1}) + for x in d: + nxt = Counter(ways) + for s, c in ways.items(): + nxt[s + x] += c + ways = nxt + if ways[0] != 2: + raise Invalid(f"{ways[0] - 2} non-empty proper subsets have equal sums in A and B") + return None, {} diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s4/tests/instance.json b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c1a27904e8aadd4927bb9ba7eb51003ead09e665 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s4/tests/instance.json @@ -0,0 +1 @@ +{"A": [6, 26, 10, 14, 3, 21, 24, 30, 35, 5, 33, 11, 4, 32, 7, 12, 25, 31], "family": "rlve_distinct_subset_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s4/tests/run.py b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-distinct-subset-sum-permutation-l5-s4/tests/test.sh b/tasks/construct-rlve-distinct-subset-sum-permutation-l5-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-distinct-subset-sum-permutation-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-even-degree-partition-l4-s3/environment/Dockerfile b/tasks/construct-rlve-even-degree-partition-l4-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-even-degree-partition-l4-s3/environment/instance.json b/tasks/construct-rlve-even-degree-partition-l4-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..77506b370bc1e7e7058d76d5ffa6cbea7def9304 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 18, "edges": [[1, 5], [1, 6], [1, 7], [1, 9], [1, 10], [1, 11], [1, 14], [1, 15], [2, 4], [2, 10], [2, 16], [3, 6], [3, 7], [3, 9], [3, 11], [3, 14], [3, 15], [4, 16], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 15], [6, 7], [6, 8], [6, 9], [6, 10], [6, 14], [7, 8], [7, 9], [7, 10], [7, 15], [8, 9], [8, 10], [8, 11], [9, 11], [9, 14], [10, 11], [10, 14], [10, 15], [11, 14], [11, 15]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l4-s3/solution/solve.sh b/tasks/construct-rlve-even-degree-partition-l4-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..407004dd70165f450d800b3ced67b24fe274089c --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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' +{"groups": [2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-even-degree-partition-l4-s3/tests/check.py b/tasks/construct-rlve-even-degree-partition-l4-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..9c7f0f71ea6d10264ececcc933b97a4a0e6eaf8e --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s3/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + g = int_list(ans.get("groups"), n, 1, 2, "groups") + deg = [0] * n + for u, v in inst["edges"]: + if g[u] == g[v]: + deg[u] += 1 + deg[v] += 1 + for v in range(n): + if deg[v] % 2: + raise Invalid(f"vertex {v} has {deg[v]} same-group neighbours") + return None, {} diff --git a/tasks/construct-rlve-even-degree-partition-l4-s3/tests/instance.json b/tasks/construct-rlve-even-degree-partition-l4-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..77506b370bc1e7e7058d76d5ffa6cbea7def9304 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-l4-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 18, "edges": [[1, 5], [1, 6], [1, 7], [1, 9], [1, 10], [1, 11], [1, 14], [1, 15], [2, 4], [2, 10], [2, 16], [3, 6], [3, 7], [3, 9], [3, 11], [3, 14], [3, 15], [4, 16], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 15], [6, 7], [6, 8], [6, 9], [6, 10], [6, 14], [7, 8], [7, 9], [7, 10], [7, 15], [8, 9], [8, 10], [8, 11], [9, 11], [9, 14], [10, 11], [10, 14], [10, 15], [11, 14], [11, 15]], "family": "rlve_even_degree_partition", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-even-degree-partition-l4-s3/tests/run.py b/tasks/construct-rlve-even-degree-partition-l4-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-even-degree-partition-l4-s3/tests/test.sh b/tasks/construct-rlve-even-degree-partition-l4-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-even-degree-partition-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-graph-isomorphism-l2-s0/environment/Dockerfile b/tasks/construct-rlve-graph-isomorphism-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l2-s0/environment/instance.json b/tasks/construct-rlve-graph-isomorphism-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..23c585e906dbe5be85d8ee41c099fbd684c79123 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges1": [[6, 7], [4, 7], [1, 3], [4, 6]], "edges2": [[2, 6], [5, 7], [0, 6], [0, 2]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s0/solution/solve.sh b/tasks/construct-rlve-graph-isomorphism-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a8ad28ccc917994d7293a173b782d563ac493907 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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' +{"p": [4, 7, 3, 5, 6, 1, 0, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s0/tests/check.py b/tasks/construct-rlve-graph-isomorphism-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..64b755f5ab12e7270811ccfc2f02d104715517b7 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s0/tests/check.py @@ -0,0 +1,13 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("p"), n, 0, n - 1, "p") + if len(set(p)) != n: + raise Invalid("p is not a permutation") + e2 = {(min(u, v), max(u, v)) for u, v in inst["edges2"]} + img = {(min(p[u], p[v]), max(p[u], p[v])) for u, v in inst["edges1"]} + if img != e2: + raise Invalid(f"{len(img - e2)} edges of G1 are not mapped onto edges of G2") + return None, {} diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s0/tests/instance.json b/tasks/construct-rlve-graph-isomorphism-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..23c585e906dbe5be85d8ee41c099fbd684c79123 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges1": [[6, 7], [4, 7], [1, 3], [4, 6]], "edges2": [[2, 6], [5, 7], [0, 6], [0, 2]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s0/tests/run.py b/tasks/construct-rlve-graph-isomorphism-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l2-s0/tests/test.sh b/tasks/construct-rlve-graph-isomorphism-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l2-s7/environment/Dockerfile b/tasks/construct-rlve-graph-isomorphism-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l2-s7/environment/instance.json b/tasks/construct-rlve-graph-isomorphism-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ad85ac9e946af8322ea7928e413456d2d676447b --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges1": [[2, 5], [2, 7], [5, 7], [1, 4], [4, 6], [1, 7], [3, 5], [0, 2], [1, 5], [3, 6], [6, 7], [3, 7], [1, 2], [2, 4], [4, 7], [2, 3], [0, 6], [4, 5], [1, 3], [0, 5], [2, 6]], "edges2": [[1, 4], [0, 3], [5, 7], [4, 6], [2, 6], [0, 5], [3, 4], [4, 5], [1, 3], [2, 3], [1, 6], [1, 7], [0, 1], [3, 5], [3, 6], [0, 6], [2, 4], [6, 7], [5, 6], [2, 5], [0, 2]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s7/solution/solve.sh b/tasks/construct-rlve-graph-isomorphism-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4e217f6c961bac28153f16fc6ee7fbd2595f065a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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' +{"p": [7, 2, 6, 4, 0, 5, 1, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s7/tests/check.py b/tasks/construct-rlve-graph-isomorphism-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..64b755f5ab12e7270811ccfc2f02d104715517b7 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s7/tests/check.py @@ -0,0 +1,13 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("p"), n, 0, n - 1, "p") + if len(set(p)) != n: + raise Invalid("p is not a permutation") + e2 = {(min(u, v), max(u, v)) for u, v in inst["edges2"]} + img = {(min(p[u], p[v]), max(p[u], p[v])) for u, v in inst["edges1"]} + if img != e2: + raise Invalid(f"{len(img - e2)} edges of G1 are not mapped onto edges of G2") + return None, {} diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s7/tests/instance.json b/tasks/construct-rlve-graph-isomorphism-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ad85ac9e946af8322ea7928e413456d2d676447b --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "edges1": [[2, 5], [2, 7], [5, 7], [1, 4], [4, 6], [1, 7], [3, 5], [0, 2], [1, 5], [3, 6], [6, 7], [3, 7], [1, 2], [2, 4], [4, 7], [2, 3], [0, 6], [4, 5], [1, 3], [0, 5], [2, 6]], "edges2": [[1, 4], [0, 3], [5, 7], [4, 6], [2, 6], [0, 5], [3, 4], [4, 5], [1, 3], [2, 3], [1, 6], [1, 7], [0, 1], [3, 5], [3, 6], [0, 6], [2, 4], [6, 7], [5, 6], [2, 5], [0, 2]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l2-s7/tests/run.py b/tasks/construct-rlve-graph-isomorphism-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l2-s7/tests/test.sh b/tasks/construct-rlve-graph-isomorphism-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l6-s1/environment/Dockerfile b/tasks/construct-rlve-graph-isomorphism-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l6-s1/environment/instance.json b/tasks/construct-rlve-graph-isomorphism-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b7a4864e2acd43c4e05832be903c6956927e22ce --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 40, "edges1": [[22, 38], [17, 19], [1, 25], [17, 27], [19, 25], [13, 29], [22, 30], [5, 34], [25, 32], [0, 16], [28, 30], [16, 30], [29, 38], [9, 20], [2, 29], [25, 26], [12, 26], [4, 30], [26, 36], [20, 31], [13, 33], [18, 34], [5, 33], [18, 26], [5, 37], [11, 15], [6, 9], [6, 14], [21, 39], [19, 32], [24, 39], [12, 35], [7, 25], [4, 13], [9, 28], [30, 38], [9, 14], [3, 19], [6, 22], [17, 37], [28, 38], [17, 34], [34, 38], [13, 34], [14, 37], [4, 18], [3, 39], [10, 12], [24, 29], [11, 21], [0, 11], [4, 37], [16, 34], [6, 18], [10, 36], [20, 36], [6, 12], [33, 38], [15, 20], [14, 25], [13, 22], [5, 10], [26, 32], [4, 9], [12, 33], [9, 33], [8, 31], [14, 30], [28, 31], [9, 38], [3, 25], [26, 31], [26, 29], [11, 37], [19, 27], [6, 34], [5, 21], [30, 33], [1, 7], [8, 39], [3, 38], [9, 21], [3, 12], [5, 23], [13, 15], [13, 16], [18, 27], [12, 29], [16, 23], [15, 35], [4, 25], [17, 26], [7, 12], [12, 19], [10, 16], [1, 9], [18, 33], [14, 21], [0, 7], [2, 36], [4, 38], [5, 35], [27, 37], [9, 13], [10, 26], [0, 37], [22, 29], [1, 2], [14, 18], [5, 20], [12, 39], [4, 22], [30, 37], [8, 10], [13, 32], [34, 37], [25, 31], [16, 29], [15, 21], [29, 39], [32, 35], [1, 20], [6, 36], [1, 29], [12, 13], [23, 28], [22, 34], [21, 22], [13, 25], [25, 37], [3, 11], [2, 8], [19, 30], [15, 31], [3, 22], [20, 26], [21, 30], [27, 28], [27, 38], [0, 19], [1, 17], [22, 24], [24, 33], [0, 20], [16, 24], [1, 10], [20, 27], [15, 25], [21, 38], [6, 33], [2, 4], [9, 36], [3, 18], [27, 29], [8, 11], [11, 29], [3, 7], [12, 32], [0, 27], [23, 32], [19, 28], [12, 14], [22, 31], [11, 16], [15, 32], [6, 8], [11, 22], [30, 34], [3, 36], [5, 24], [10, 19], [6, 13], [3, 35], [12, 23], [10, 21], [23, 27], [21, 35], [13, 30], [3, 29], [25, 30], [20, 25], [1, 30], [7, 37], [14, 26], [12, 28], [8, 26], [4, 5], [28, 36], [9, 10], [31, 32], [19, 22], [5, 12], [13, 35], [13, 23], [12, 27], [31, 35], [26, 33], [8, 13], [7, 15], [0, 10], [11, 14], [7, 39], [4, 31], [14, 36], [10, 28], [19, 33], [28, 35], [18, 35], [11, 12], [16, 25], [1, 21], [8, 22], [12, 16], [1, 32], [25, 39], [0, 23], [24, 34], [4, 34], [11, 20], [7, 8], [6, 32], [11, 30], [14, 27], [0, 18], [36, 37], [12, 37], [8, 16], [35, 37], [16, 17], [4, 32], [30, 31], [6, 30], [17, 29], [5, 13], [7, 26], [13, 26], [9, 25], [30, 36], [1, 27], [30, 39], [19, 35], [28, 39], [20, 28], [0, 31], [20, 21], [25, 33], [0, 6], [6, 15], [6, 10], [26, 27], [9, 18], [14, 15], [2, 30], [0, 35], [20, 37], [2, 28], [10, 29], [4, 15], [16, 18], [37, 38], [8, 29], [17, 24], [24, 32], [27, 35], [4, 24], [9, 17], [18, 38], [8, 25], [20, 22], [21, 33], [10, 22], [28, 32], [31, 33], [0, 13], [13, 19], [12, 17], [4, 12], [16, 32], [20, 35], [8, 15], [20, 38], [12, 25], [3, 4], [11, 34], [22, 25], [17, 30], [7, 9], [4, 26], [4, 19], [21, 34], [19, 38], [0, 9], [38, 39], [10, 32], [28, 34], [19, 26], [33, 39], [6, 21], [27, 39], [8, 24], [16, 26], [8, 30], [15, 19], [29, 34], [10, 25], [20, 23], [24, 37], [4, 14], [14, 22], [23, 35], [16, 28], [15, 24], [1, 18], [2, 13], [4, 39], [3, 28], [4, 6], [15, 38], [16, 36], [21, 26], [15, 27], [18, 37], [13, 28], [1, 6], [17, 32], [17, 28], [7, 22], [6, 20], [24, 31], [0, 5], [5, 16], [16, 27], [10, 35], [10, 20], [3, 10], [5, 29], [6, 16], [12, 30], [4, 33], [11, 26], [29, 35], [5, 25], [11, 28], [7, 29], [4, 11], [1, 12], [9, 16], [2, 24], [15, 22], [10, 37], [9, 29]], "edges2": [[2, 12], [1, 2], [16, 30], [6, 15], [21, 28], [29, 30], [6, 29], [4, 16], [10, 12], [15, 31], [22, 25], [14, 15], [0, 35], [18, 29], [15, 38], [0, 14], [6, 25], [5, 7], [6, 36], [1, 39], [19, 23], [3, 33], [17, 30], [15, 37], [5, 31], [0, 34], [20, 34], [15, 18], [16, 28], [6, 33], [21, 31], [5, 29], [0, 36], [0, 22], [9, 15], [17, 33], [11, 29], [37, 39], [6, 10], [1, 21], [0, 23], [27, 29], [11, 39], [16, 26], [14, 28], [31, 32], [8, 32], [5, 34], [1, 16], [3, 20], [14, 34], [3, 12], [18, 31], [4, 39], [3, 30], [16, 17], [30, 34], [5, 26], [30, 39], [18, 32], [21, 32], [10, 22], [10, 29], [11, 34], [2, 14], [5, 24], [5, 18], [5, 9], [9, 22], [30, 33], [9, 21], [9, 19], [22, 33], [1, 3], [2, 33], [0, 38], [0, 26], [15, 35], [0, 33], [12, 14], [2, 20], [19, 34], [16, 29], [13, 16], [8, 25], [19, 36], [9, 23], [1, 22], [7, 18], [0, 37], [14, 20], [8, 26], [15, 39], [6, 19], [1, 24], [12, 29], [31, 33], [25, 30], [21, 22], [0, 10], [31, 37], [24, 26], [1, 25], [21, 38], [6, 32], [13, 24], [4, 29], [31, 38], [36, 39], [21, 24], [3, 38], [4, 37], [8, 35], [5, 32], [25, 33], [14, 22], [23, 38], [5, 36], [3, 4], [31, 34], [19, 37], [26, 34], [32, 37], [34, 37], [10, 31], [9, 24], [12, 35], [2, 16], [5, 23], [25, 31], [7, 25], [3, 6], [13, 34], [4, 25], [4, 9], [24, 35], [6, 18], [8, 28], [17, 21], [22, 27], [26, 30], [4, 17], [29, 35], [5, 20], [3, 10], [9, 18], [26, 39], [15, 23], [2, 5], [0, 27], [12, 26], [18, 36], [29, 34], [6, 11], [5, 10], [27, 33], [7, 26], [26, 32], [2, 35], [2, 15], [7, 32], [20, 38], [11, 16], [30, 35], [4, 7], [3, 31], [8, 22], [10, 25], [8, 27], [9, 39], [9, 20], [18, 24], [1, 11], [2, 3], [11, 31], [9, 12], [12, 33], [1, 28], [27, 37], [7, 15], [19, 22], [19, 24], [19, 38], [3, 34], [35, 39], [19, 21], [33, 38], [10, 33], [23, 37], [12, 34], [1, 32], [24, 33], [5, 35], [14, 16], [11, 22], [30, 32], [11, 17], [27, 36], [2, 38], [19, 35], [19, 20], [3, 37], [24, 25], [5, 16], [0, 18], [5, 33], [22, 23], [9, 10], [20, 22], [9, 14], [26, 31], [34, 35], [27, 30], [20, 37], [4, 21], [16, 19], [20, 32], [5, 30], [16, 38], [22, 38], [8, 18], [11, 23], [11, 33], [19, 27], [8, 12], [25, 26], [7, 16], [28, 38], [13, 36], [6, 21], [7, 9], [7, 14], [27, 35], [20, 36], [1, 8], [4, 18], [1, 14], [15, 20], [4, 30], [15, 24], [14, 18], [5, 13], [15, 22], [26, 27], [15, 17], [33, 34], [32, 39], [13, 23], [20, 33], [9, 26], [17, 22], [16, 31], [4, 36], [8, 20], [9, 16], [0, 19], [13, 25], [3, 27], [0, 24], [4, 38], [18, 34], [8, 24], [10, 15], [8, 34], [26, 33], [23, 32], [1, 27], [0, 3], [17, 24], [1, 38], [14, 17], [0, 39], [20, 35], [18, 37], [8, 21], [5, 17], [19, 39], [12, 25], [16, 24], [4, 15], [18, 28], [3, 24], [22, 32], [17, 34], [7, 12], [20, 24], [25, 29], [14, 36], [1, 4], [8, 9], [24, 28], [2, 21], [4, 32], [11, 20], [4, 28], [12, 13], [16, 18], [33, 37], [2, 10], [3, 14], [17, 18], [10, 20], [11, 18], [19, 30], [22, 36], [18, 20], [7, 17], [27, 31], [0, 5], [16, 23], [1, 17], [6, 20], [34, 39], [19, 25], [10, 13], [8, 38], [11, 30], [24, 34], [15, 27], [36, 38], [12, 32], [1, 18], [32, 38], [0, 9], [0, 21], [10, 24], [14, 24], [17, 20], [9, 28], [32, 34], [16, 22], [30, 38], [9, 25], [5, 27], [7, 36], [11, 25], [15, 34], [25, 36], [17, 35], [9, 31], [2, 34], [20, 29], [7, 19], [18, 25], [5, 37], [21, 39], [15, 25], [27, 38], [18, 35], [18, 22], [3, 17]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s1/solution/solve.sh b/tasks/construct-rlve-graph-isomorphism-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..346e98718b90e52c2a2a2ab4bb85dbf3eaa79fb8 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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' +{"p": [21, 36, 13, 11, 34, 8, 0, 6, 10, 19, 22, 31, 18, 24, 37, 3, 9, 7, 39, 17, 38, 27, 33, 28, 12, 20, 15, 4, 16, 25, 5, 2, 14, 35, 26, 1, 23, 32, 30, 29]} +RLMATH_EOF diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s1/tests/check.py b/tasks/construct-rlve-graph-isomorphism-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..64b755f5ab12e7270811ccfc2f02d104715517b7 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s1/tests/check.py @@ -0,0 +1,13 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("p"), n, 0, n - 1, "p") + if len(set(p)) != n: + raise Invalid("p is not a permutation") + e2 = {(min(u, v), max(u, v)) for u, v in inst["edges2"]} + img = {(min(p[u], p[v]), max(p[u], p[v])) for u, v in inst["edges1"]} + if img != e2: + raise Invalid(f"{len(img - e2)} edges of G1 are not mapped onto edges of G2") + return None, {} diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s1/tests/instance.json b/tasks/construct-rlve-graph-isomorphism-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b7a4864e2acd43c4e05832be903c6956927e22ce --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 40, "edges1": [[22, 38], [17, 19], [1, 25], [17, 27], [19, 25], [13, 29], [22, 30], [5, 34], [25, 32], [0, 16], [28, 30], [16, 30], [29, 38], [9, 20], [2, 29], [25, 26], [12, 26], [4, 30], [26, 36], [20, 31], [13, 33], [18, 34], [5, 33], [18, 26], [5, 37], [11, 15], [6, 9], [6, 14], [21, 39], [19, 32], [24, 39], [12, 35], [7, 25], [4, 13], [9, 28], [30, 38], [9, 14], [3, 19], [6, 22], [17, 37], [28, 38], [17, 34], [34, 38], [13, 34], [14, 37], [4, 18], [3, 39], [10, 12], [24, 29], [11, 21], [0, 11], [4, 37], [16, 34], [6, 18], [10, 36], [20, 36], [6, 12], [33, 38], [15, 20], [14, 25], [13, 22], [5, 10], [26, 32], [4, 9], [12, 33], [9, 33], [8, 31], [14, 30], [28, 31], [9, 38], [3, 25], [26, 31], [26, 29], [11, 37], [19, 27], [6, 34], [5, 21], [30, 33], [1, 7], [8, 39], [3, 38], [9, 21], [3, 12], [5, 23], [13, 15], [13, 16], [18, 27], [12, 29], [16, 23], [15, 35], [4, 25], [17, 26], [7, 12], [12, 19], [10, 16], [1, 9], [18, 33], [14, 21], [0, 7], [2, 36], [4, 38], [5, 35], [27, 37], [9, 13], [10, 26], [0, 37], [22, 29], [1, 2], [14, 18], [5, 20], [12, 39], [4, 22], [30, 37], [8, 10], [13, 32], [34, 37], [25, 31], [16, 29], [15, 21], [29, 39], [32, 35], [1, 20], [6, 36], [1, 29], [12, 13], [23, 28], [22, 34], [21, 22], [13, 25], [25, 37], [3, 11], [2, 8], [19, 30], [15, 31], [3, 22], [20, 26], [21, 30], [27, 28], [27, 38], [0, 19], [1, 17], [22, 24], [24, 33], [0, 20], [16, 24], [1, 10], [20, 27], [15, 25], [21, 38], [6, 33], [2, 4], [9, 36], [3, 18], [27, 29], [8, 11], [11, 29], [3, 7], [12, 32], [0, 27], [23, 32], [19, 28], [12, 14], [22, 31], [11, 16], [15, 32], [6, 8], [11, 22], [30, 34], [3, 36], [5, 24], [10, 19], [6, 13], [3, 35], [12, 23], [10, 21], [23, 27], [21, 35], [13, 30], [3, 29], [25, 30], [20, 25], [1, 30], [7, 37], [14, 26], [12, 28], [8, 26], [4, 5], [28, 36], [9, 10], [31, 32], [19, 22], [5, 12], [13, 35], [13, 23], [12, 27], [31, 35], [26, 33], [8, 13], [7, 15], [0, 10], [11, 14], [7, 39], [4, 31], [14, 36], [10, 28], [19, 33], [28, 35], [18, 35], [11, 12], [16, 25], [1, 21], [8, 22], [12, 16], [1, 32], [25, 39], [0, 23], [24, 34], [4, 34], [11, 20], [7, 8], [6, 32], [11, 30], [14, 27], [0, 18], [36, 37], [12, 37], [8, 16], [35, 37], [16, 17], [4, 32], [30, 31], [6, 30], [17, 29], [5, 13], [7, 26], [13, 26], [9, 25], [30, 36], [1, 27], [30, 39], [19, 35], [28, 39], [20, 28], [0, 31], [20, 21], [25, 33], [0, 6], [6, 15], [6, 10], [26, 27], [9, 18], [14, 15], [2, 30], [0, 35], [20, 37], [2, 28], [10, 29], [4, 15], [16, 18], [37, 38], [8, 29], [17, 24], [24, 32], [27, 35], [4, 24], [9, 17], [18, 38], [8, 25], [20, 22], [21, 33], [10, 22], [28, 32], [31, 33], [0, 13], [13, 19], [12, 17], [4, 12], [16, 32], [20, 35], [8, 15], [20, 38], [12, 25], [3, 4], [11, 34], [22, 25], [17, 30], [7, 9], [4, 26], [4, 19], [21, 34], [19, 38], [0, 9], [38, 39], [10, 32], [28, 34], [19, 26], [33, 39], [6, 21], [27, 39], [8, 24], [16, 26], [8, 30], [15, 19], [29, 34], [10, 25], [20, 23], [24, 37], [4, 14], [14, 22], [23, 35], [16, 28], [15, 24], [1, 18], [2, 13], [4, 39], [3, 28], [4, 6], [15, 38], [16, 36], [21, 26], [15, 27], [18, 37], [13, 28], [1, 6], [17, 32], [17, 28], [7, 22], [6, 20], [24, 31], [0, 5], [5, 16], [16, 27], [10, 35], [10, 20], [3, 10], [5, 29], [6, 16], [12, 30], [4, 33], [11, 26], [29, 35], [5, 25], [11, 28], [7, 29], [4, 11], [1, 12], [9, 16], [2, 24], [15, 22], [10, 37], [9, 29]], "edges2": [[2, 12], [1, 2], [16, 30], [6, 15], [21, 28], [29, 30], [6, 29], [4, 16], [10, 12], [15, 31], [22, 25], [14, 15], [0, 35], [18, 29], [15, 38], [0, 14], [6, 25], [5, 7], [6, 36], [1, 39], [19, 23], [3, 33], [17, 30], [15, 37], [5, 31], [0, 34], [20, 34], [15, 18], [16, 28], [6, 33], [21, 31], [5, 29], [0, 36], [0, 22], [9, 15], [17, 33], [11, 29], [37, 39], [6, 10], [1, 21], [0, 23], [27, 29], [11, 39], [16, 26], [14, 28], [31, 32], [8, 32], [5, 34], [1, 16], [3, 20], [14, 34], [3, 12], [18, 31], [4, 39], [3, 30], [16, 17], [30, 34], [5, 26], [30, 39], [18, 32], [21, 32], [10, 22], [10, 29], [11, 34], [2, 14], [5, 24], [5, 18], [5, 9], [9, 22], [30, 33], [9, 21], [9, 19], [22, 33], [1, 3], [2, 33], [0, 38], [0, 26], [15, 35], [0, 33], [12, 14], [2, 20], [19, 34], [16, 29], [13, 16], [8, 25], [19, 36], [9, 23], [1, 22], [7, 18], [0, 37], [14, 20], [8, 26], [15, 39], [6, 19], [1, 24], [12, 29], [31, 33], [25, 30], [21, 22], [0, 10], [31, 37], [24, 26], [1, 25], [21, 38], [6, 32], [13, 24], [4, 29], [31, 38], [36, 39], [21, 24], [3, 38], [4, 37], [8, 35], [5, 32], [25, 33], [14, 22], [23, 38], [5, 36], [3, 4], [31, 34], [19, 37], [26, 34], [32, 37], [34, 37], [10, 31], [9, 24], [12, 35], [2, 16], [5, 23], [25, 31], [7, 25], [3, 6], [13, 34], [4, 25], [4, 9], [24, 35], [6, 18], [8, 28], [17, 21], [22, 27], [26, 30], [4, 17], [29, 35], [5, 20], [3, 10], [9, 18], [26, 39], [15, 23], [2, 5], [0, 27], [12, 26], [18, 36], [29, 34], [6, 11], [5, 10], [27, 33], [7, 26], [26, 32], [2, 35], [2, 15], [7, 32], [20, 38], [11, 16], [30, 35], [4, 7], [3, 31], [8, 22], [10, 25], [8, 27], [9, 39], [9, 20], [18, 24], [1, 11], [2, 3], [11, 31], [9, 12], [12, 33], [1, 28], [27, 37], [7, 15], [19, 22], [19, 24], [19, 38], [3, 34], [35, 39], [19, 21], [33, 38], [10, 33], [23, 37], [12, 34], [1, 32], [24, 33], [5, 35], [14, 16], [11, 22], [30, 32], [11, 17], [27, 36], [2, 38], [19, 35], [19, 20], [3, 37], [24, 25], [5, 16], [0, 18], [5, 33], [22, 23], [9, 10], [20, 22], [9, 14], [26, 31], [34, 35], [27, 30], [20, 37], [4, 21], [16, 19], [20, 32], [5, 30], [16, 38], [22, 38], [8, 18], [11, 23], [11, 33], [19, 27], [8, 12], [25, 26], [7, 16], [28, 38], [13, 36], [6, 21], [7, 9], [7, 14], [27, 35], [20, 36], [1, 8], [4, 18], [1, 14], [15, 20], [4, 30], [15, 24], [14, 18], [5, 13], [15, 22], [26, 27], [15, 17], [33, 34], [32, 39], [13, 23], [20, 33], [9, 26], [17, 22], [16, 31], [4, 36], [8, 20], [9, 16], [0, 19], [13, 25], [3, 27], [0, 24], [4, 38], [18, 34], [8, 24], [10, 15], [8, 34], [26, 33], [23, 32], [1, 27], [0, 3], [17, 24], [1, 38], [14, 17], [0, 39], [20, 35], [18, 37], [8, 21], [5, 17], [19, 39], [12, 25], [16, 24], [4, 15], [18, 28], [3, 24], [22, 32], [17, 34], [7, 12], [20, 24], [25, 29], [14, 36], [1, 4], [8, 9], [24, 28], [2, 21], [4, 32], [11, 20], [4, 28], [12, 13], [16, 18], [33, 37], [2, 10], [3, 14], [17, 18], [10, 20], [11, 18], [19, 30], [22, 36], [18, 20], [7, 17], [27, 31], [0, 5], [16, 23], [1, 17], [6, 20], [34, 39], [19, 25], [10, 13], [8, 38], [11, 30], [24, 34], [15, 27], [36, 38], [12, 32], [1, 18], [32, 38], [0, 9], [0, 21], [10, 24], [14, 24], [17, 20], [9, 28], [32, 34], [16, 22], [30, 38], [9, 25], [5, 27], [7, 36], [11, 25], [15, 34], [25, 36], [17, 35], [9, 31], [2, 34], [20, 29], [7, 19], [18, 25], [5, 37], [21, 39], [15, 25], [27, 38], [18, 35], [18, 22], [3, 17]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s1/tests/run.py b/tasks/construct-rlve-graph-isomorphism-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l6-s1/tests/test.sh b/tasks/construct-rlve-graph-isomorphism-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l6-s8/environment/Dockerfile b/tasks/construct-rlve-graph-isomorphism-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l6-s8/environment/instance.json b/tasks/construct-rlve-graph-isomorphism-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c2532aeda1e1d39c6e545bf3f498c790ae38cafa --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 40, "edges1": [[13, 34], [17, 28], [17, 29], [1, 26], [0, 38], [30, 31], [8, 31], [0, 37], [34, 36], [8, 28], [6, 8], [4, 5], [19, 23], [25, 31], [19, 28], [7, 39], [11, 30], [0, 22], [30, 33], [4, 27], [5, 6], [1, 32], [26, 32], [18, 34], [12, 31], [21, 36], [17, 27], [21, 24], [12, 13], [1, 22], [11, 13], [13, 15], [10, 36], [4, 24], [7, 22], [6, 13], [21, 35], [20, 34], [14, 31], [7, 12], [1, 37], [24, 33], [9, 27], [1, 31], [6, 15], [3, 6], [4, 26], [13, 25], [0, 34], [13, 18], [7, 33], [14, 19], [0, 26], [16, 24], [5, 15], [7, 11], [7, 34], [9, 19], [21, 33], [2, 36], [3, 34], [4, 31], [16, 37], [30, 32], [14, 22], [1, 17], [13, 24], [2, 19], [22, 39], [4, 10], [14, 17], [0, 27], [6, 26], [6, 11], [9, 34], [10, 15], [2, 18], [7, 30], [21, 32], [10, 13], [1, 10], [36, 39], [23, 25], [27, 38], [17, 30], [12, 27], [2, 21], [13, 19], [27, 30], [2, 15], [30, 36], [30, 38], [0, 2], [10, 21], [15, 26], [6, 18], [3, 22], [24, 31], [7, 14], [25, 33], [17, 31], [2, 28], [11, 21], [35, 38], [18, 39], [0, 6], [9, 10], [0, 39], [14, 18], [3, 25], [26, 38], [4, 13], [1, 24], [16, 23], [21, 26], [15, 35], [8, 20], [11, 38], [0, 16], [16, 38], [29, 34], [15, 37], [7, 24], [15, 38], [8, 38], [25, 26], [11, 27], [0, 10], [14, 34], [22, 32], [21, 30], [11, 14], [17, 26], [31, 37], [19, 34], [32, 38], [19, 31], [13, 28], [7, 28], [26, 33], [5, 30], [0, 32], [10, 33], [6, 9], [2, 3], [22, 27], [5, 31], [14, 16], [3, 19], [1, 35], [3, 36], [10, 11], [4, 39], [20, 23], [7, 21], [6, 32], [14, 21], [27, 39], [23, 33], [8, 39], [6, 37], [5, 18], [11, 39], [18, 31], [8, 17], [4, 6], [18, 23], [11, 17], [26, 39], [11, 32], [12, 34], [8, 36], [1, 5], [18, 22], [5, 19], [2, 26], [33, 36], [5, 9], [4, 36], [14, 37], [26, 30], [2, 10], [20, 28], [3, 16], [13, 35], [8, 26], [14, 30], [25, 37], [22, 26], [18, 33], [4, 19], [4, 29], [27, 32], [15, 31], [8, 16], [0, 18], [17, 21], [2, 14], [18, 35], [2, 24], [11, 12], [7, 10], [28, 39], [0, 28], [22, 30], [19, 29], [30, 35], [37, 38], [16, 22], [12, 19], [5, 14], [12, 35], [8, 14], [22, 24], [3, 27], [16, 19], [18, 21], [22, 23], [3, 9], [19, 33], [17, 25], [9, 33], [13, 37], [3, 26], [6, 34], [0, 12], [31, 35], [24, 39], [13, 16], [5, 20], [33, 37], [19, 36], [25, 30], [20, 37], [18, 36], [0, 35], [16, 17], [13, 26], [29, 31], [5, 11], [1, 25], [3, 39], [19, 32], [4, 14], [16, 18], [19, 21], [4, 33], [14, 28], [0, 36], [0, 5], [18, 37], [2, 25], [2, 31], [18, 24], [13, 38], [22, 25], [11, 31], [15, 24], [15, 39], [30, 39], [6, 28], [13, 14], [15, 18], [0, 13], [21, 29], [15, 21], [11, 16], [5, 28], [15, 17], [7, 18], [5, 27], [8, 19], [10, 25]], "edges2": [[18, 19], [5, 10], [13, 26], [10, 12], [7, 24], [9, 17], [3, 20], [8, 18], [6, 14], [3, 14], [17, 32], [10, 37], [15, 33], [1, 29], [6, 30], [12, 25], [7, 38], [27, 34], [15, 31], [22, 34], [12, 20], [34, 37], [25, 28], [32, 36], [7, 20], [4, 36], [33, 38], [0, 15], [4, 37], [27, 38], [11, 20], [21, 37], [0, 5], [4, 20], [30, 33], [30, 37], [30, 31], [2, 24], [10, 24], [13, 18], [4, 15], [4, 24], [9, 21], [7, 23], [2, 27], [17, 24], [9, 11], [0, 24], [14, 33], [12, 37], [8, 24], [5, 39], [0, 10], [15, 36], [34, 38], [0, 39], [8, 15], [15, 29], [14, 19], [21, 38], [20, 30], [34, 39], [6, 22], [16, 18], [14, 23], [8, 37], [0, 32], [1, 22], [1, 10], [1, 37], [33, 37], [24, 31], [19, 34], [2, 30], [28, 38], [5, 28], [24, 35], [11, 39], [12, 36], [2, 38], [4, 27], [10, 39], [24, 25], [36, 38], [5, 15], [1, 17], [6, 16], [28, 34], [6, 36], [20, 38], [19, 30], [3, 6], [4, 7], [26, 31], [24, 39], [15, 28], [7, 18], [25, 27], [25, 29], [30, 34], [5, 27], [31, 37], [11, 12], [4, 8], [18, 36], [8, 36], [29, 32], [2, 18], [18, 22], [7, 22], [1, 30], [2, 23], [3, 28], [12, 27], [9, 14], [2, 3], [6, 15], [2, 11], [14, 24], [28, 32], [3, 18], [21, 27], [0, 35], [0, 9], [31, 39], [23, 28], [24, 38], [10, 13], [12, 33], [11, 32], [13, 19], [19, 38], [13, 29], [29, 34], [10, 14], [18, 29], [6, 17], [16, 25], [18, 23], [22, 28], [8, 10], [30, 32], [12, 18], [12, 38], [9, 35], [2, 39], [8, 17], [9, 18], [8, 30], [3, 15], [13, 32], [12, 16], [15, 32], [11, 30], [16, 23], [7, 12], [3, 33], [19, 31], [14, 37], [6, 18], [14, 21], [0, 28], [2, 25], [1, 15], [14, 18], [2, 16], [0, 38], [6, 20], [0, 17], [10, 38], [30, 35], [10, 15], [10, 32], [11, 23], [21, 33], [25, 37], [9, 13], [11, 37], [1, 27], [9, 31], [1, 34], [23, 36], [4, 39], [27, 32], [21, 28], [8, 19], [17, 22], [8, 29], [23, 34], [18, 35], [10, 17], [2, 37], [1, 31], [6, 26], [13, 21], [10, 21], [0, 30], [14, 30], [20, 27], [13, 36], [17, 36], [17, 28], [0, 20], [25, 38], [19, 27], [12, 19], [2, 13], [4, 12], [7, 35], [4, 14], [9, 27], [7, 30], [20, 29], [27, 28], [2, 31], [8, 11], [1, 14], [12, 30], [19, 23], [19, 25], [26, 35], [9, 30], [15, 30], [1, 5], [32, 38], [5, 38], [7, 31], [8, 12], [19, 20], [15, 34], [5, 18], [33, 39], [23, 32], [26, 34], [17, 18], [10, 25], [1, 6], [26, 29], [30, 36], [9, 15], [14, 29], [11, 14], [2, 34], [7, 11], [21, 31], [14, 31], [10, 23], [32, 37], [4, 23], [5, 12], [18, 34], [15, 21], [2, 19], [25, 39], [20, 32], [5, 21], [13, 25], [19, 29], [14, 27], [4, 22], [2, 33], [2, 8], [9, 19], [7, 36], [0, 11], [7, 10], [6, 19], [14, 15], [3, 27], [0, 19], [9, 25], [1, 13], [1, 23]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s8/solution/solve.sh b/tasks/construct-rlve-graph-isomorphism-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6e39f17f40d33e4dada932c2f311c243c472125b --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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' +{"p": [15, 39, 8, 17, 23, 34, 1, 20, 13, 22, 4, 27, 3, 14, 19, 37, 9, 25, 30, 18, 26, 12, 0, 35, 11, 24, 10, 28, 29, 16, 38, 2, 5, 7, 6, 33, 36, 31, 21, 32]} +RLMATH_EOF diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s8/tests/check.py b/tasks/construct-rlve-graph-isomorphism-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..64b755f5ab12e7270811ccfc2f02d104715517b7 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s8/tests/check.py @@ -0,0 +1,13 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("p"), n, 0, n - 1, "p") + if len(set(p)) != n: + raise Invalid("p is not a permutation") + e2 = {(min(u, v), max(u, v)) for u, v in inst["edges2"]} + img = {(min(p[u], p[v]), max(p[u], p[v])) for u, v in inst["edges1"]} + if img != e2: + raise Invalid(f"{len(img - e2)} edges of G1 are not mapped onto edges of G2") + return None, {} diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s8/tests/instance.json b/tasks/construct-rlve-graph-isomorphism-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c2532aeda1e1d39c6e545bf3f498c790ae38cafa --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 40, "edges1": [[13, 34], [17, 28], [17, 29], [1, 26], [0, 38], [30, 31], [8, 31], [0, 37], [34, 36], [8, 28], [6, 8], [4, 5], [19, 23], [25, 31], [19, 28], [7, 39], [11, 30], [0, 22], [30, 33], [4, 27], [5, 6], [1, 32], [26, 32], [18, 34], [12, 31], [21, 36], [17, 27], [21, 24], [12, 13], [1, 22], [11, 13], [13, 15], [10, 36], [4, 24], [7, 22], [6, 13], [21, 35], [20, 34], [14, 31], [7, 12], [1, 37], [24, 33], [9, 27], [1, 31], [6, 15], [3, 6], [4, 26], [13, 25], [0, 34], [13, 18], [7, 33], [14, 19], [0, 26], [16, 24], [5, 15], [7, 11], [7, 34], [9, 19], [21, 33], [2, 36], [3, 34], [4, 31], [16, 37], [30, 32], [14, 22], [1, 17], [13, 24], [2, 19], [22, 39], [4, 10], [14, 17], [0, 27], [6, 26], [6, 11], [9, 34], [10, 15], [2, 18], [7, 30], [21, 32], [10, 13], [1, 10], [36, 39], [23, 25], [27, 38], [17, 30], [12, 27], [2, 21], [13, 19], [27, 30], [2, 15], [30, 36], [30, 38], [0, 2], [10, 21], [15, 26], [6, 18], [3, 22], [24, 31], [7, 14], [25, 33], [17, 31], [2, 28], [11, 21], [35, 38], [18, 39], [0, 6], [9, 10], [0, 39], [14, 18], [3, 25], [26, 38], [4, 13], [1, 24], [16, 23], [21, 26], [15, 35], [8, 20], [11, 38], [0, 16], [16, 38], [29, 34], [15, 37], [7, 24], [15, 38], [8, 38], [25, 26], [11, 27], [0, 10], [14, 34], [22, 32], [21, 30], [11, 14], [17, 26], [31, 37], [19, 34], [32, 38], [19, 31], [13, 28], [7, 28], [26, 33], [5, 30], [0, 32], [10, 33], [6, 9], [2, 3], [22, 27], [5, 31], [14, 16], [3, 19], [1, 35], [3, 36], [10, 11], [4, 39], [20, 23], [7, 21], [6, 32], [14, 21], [27, 39], [23, 33], [8, 39], [6, 37], [5, 18], [11, 39], [18, 31], [8, 17], [4, 6], [18, 23], [11, 17], [26, 39], [11, 32], [12, 34], [8, 36], [1, 5], [18, 22], [5, 19], [2, 26], [33, 36], [5, 9], [4, 36], [14, 37], [26, 30], [2, 10], [20, 28], [3, 16], [13, 35], [8, 26], [14, 30], [25, 37], [22, 26], [18, 33], [4, 19], [4, 29], [27, 32], [15, 31], [8, 16], [0, 18], [17, 21], [2, 14], [18, 35], [2, 24], [11, 12], [7, 10], [28, 39], [0, 28], [22, 30], [19, 29], [30, 35], [37, 38], [16, 22], [12, 19], [5, 14], [12, 35], [8, 14], [22, 24], [3, 27], [16, 19], [18, 21], [22, 23], [3, 9], [19, 33], [17, 25], [9, 33], [13, 37], [3, 26], [6, 34], [0, 12], [31, 35], [24, 39], [13, 16], [5, 20], [33, 37], [19, 36], [25, 30], [20, 37], [18, 36], [0, 35], [16, 17], [13, 26], [29, 31], [5, 11], [1, 25], [3, 39], [19, 32], [4, 14], [16, 18], [19, 21], [4, 33], [14, 28], [0, 36], [0, 5], [18, 37], [2, 25], [2, 31], [18, 24], [13, 38], [22, 25], [11, 31], [15, 24], [15, 39], [30, 39], [6, 28], [13, 14], [15, 18], [0, 13], [21, 29], [15, 21], [11, 16], [5, 28], [15, 17], [7, 18], [5, 27], [8, 19], [10, 25]], "edges2": [[18, 19], [5, 10], [13, 26], [10, 12], [7, 24], [9, 17], [3, 20], [8, 18], [6, 14], [3, 14], [17, 32], [10, 37], [15, 33], [1, 29], [6, 30], [12, 25], [7, 38], [27, 34], [15, 31], [22, 34], [12, 20], [34, 37], [25, 28], [32, 36], [7, 20], [4, 36], [33, 38], [0, 15], [4, 37], [27, 38], [11, 20], [21, 37], [0, 5], [4, 20], [30, 33], [30, 37], [30, 31], [2, 24], [10, 24], [13, 18], [4, 15], [4, 24], [9, 21], [7, 23], [2, 27], [17, 24], [9, 11], [0, 24], [14, 33], [12, 37], [8, 24], [5, 39], [0, 10], [15, 36], [34, 38], [0, 39], [8, 15], [15, 29], [14, 19], [21, 38], [20, 30], [34, 39], [6, 22], [16, 18], [14, 23], [8, 37], [0, 32], [1, 22], [1, 10], [1, 37], [33, 37], [24, 31], [19, 34], [2, 30], [28, 38], [5, 28], [24, 35], [11, 39], [12, 36], [2, 38], [4, 27], [10, 39], [24, 25], [36, 38], [5, 15], [1, 17], [6, 16], [28, 34], [6, 36], [20, 38], [19, 30], [3, 6], [4, 7], [26, 31], [24, 39], [15, 28], [7, 18], [25, 27], [25, 29], [30, 34], [5, 27], [31, 37], [11, 12], [4, 8], [18, 36], [8, 36], [29, 32], [2, 18], [18, 22], [7, 22], [1, 30], [2, 23], [3, 28], [12, 27], [9, 14], [2, 3], [6, 15], [2, 11], [14, 24], [28, 32], [3, 18], [21, 27], [0, 35], [0, 9], [31, 39], [23, 28], [24, 38], [10, 13], [12, 33], [11, 32], [13, 19], [19, 38], [13, 29], [29, 34], [10, 14], [18, 29], [6, 17], [16, 25], [18, 23], [22, 28], [8, 10], [30, 32], [12, 18], [12, 38], [9, 35], [2, 39], [8, 17], [9, 18], [8, 30], [3, 15], [13, 32], [12, 16], [15, 32], [11, 30], [16, 23], [7, 12], [3, 33], [19, 31], [14, 37], [6, 18], [14, 21], [0, 28], [2, 25], [1, 15], [14, 18], [2, 16], [0, 38], [6, 20], [0, 17], [10, 38], [30, 35], [10, 15], [10, 32], [11, 23], [21, 33], [25, 37], [9, 13], [11, 37], [1, 27], [9, 31], [1, 34], [23, 36], [4, 39], [27, 32], [21, 28], [8, 19], [17, 22], [8, 29], [23, 34], [18, 35], [10, 17], [2, 37], [1, 31], [6, 26], [13, 21], [10, 21], [0, 30], [14, 30], [20, 27], [13, 36], [17, 36], [17, 28], [0, 20], [25, 38], [19, 27], [12, 19], [2, 13], [4, 12], [7, 35], [4, 14], [9, 27], [7, 30], [20, 29], [27, 28], [2, 31], [8, 11], [1, 14], [12, 30], [19, 23], [19, 25], [26, 35], [9, 30], [15, 30], [1, 5], [32, 38], [5, 38], [7, 31], [8, 12], [19, 20], [15, 34], [5, 18], [33, 39], [23, 32], [26, 34], [17, 18], [10, 25], [1, 6], [26, 29], [30, 36], [9, 15], [14, 29], [11, 14], [2, 34], [7, 11], [21, 31], [14, 31], [10, 23], [32, 37], [4, 23], [5, 12], [18, 34], [15, 21], [2, 19], [25, 39], [20, 32], [5, 21], [13, 25], [19, 29], [14, 27], [4, 22], [2, 33], [2, 8], [9, 19], [7, 36], [0, 11], [7, 10], [6, 19], [14, 15], [3, 27], [0, 19], [9, 25], [1, 13], [1, 23]], "family": "rlve_graph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-graph-isomorphism-l6-s8/tests/run.py b/tasks/construct-rlve-graph-isomorphism-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-graph-isomorphism-l6-s8/tests/test.sh b/tasks/construct-rlve-graph-isomorphism-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-graph-isomorphism-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-grid-parity-construction-l2-s0/environment/Dockerfile b/tasks/construct-rlve-grid-parity-construction-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l2-s0/environment/instance.json b/tasks/construct-rlve-grid-parity-construction-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3a7c015a71ffbd20e27ed1a5021537f29e2edc20 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"parity": ["00000", "00000"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s0/solution/solve.sh b/tasks/construct-rlve-grid-parity-construction-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..80705ad6e513e0d4c6736d38882bbe5c38705bb5 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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' +{"grid": ["00000", "00000"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s0/tests/check.py b/tasks/construct-rlve-grid-parity-construction-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..89d5d286593348d0000ac10db74e1c6242be6c97 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s0/tests/check.py @@ -0,0 +1,22 @@ +from run import Invalid + + +def check(inst, ans): + P = inst["parity"] + N, M = len(P), len(P[0]) + G = ans.get("grid") + if not isinstance(G, list) or len(G) != N: + raise Invalid(f"grid must be a list of {N} strings") + for r in G: + if not isinstance(r, str) or len(r) != M or set(r) - {"0", "1"}: + raise Invalid(f"each row must be a string of {M} characters '0'/'1'") + for i in range(N): + for j in range(M): + v = int(G[i][j]) + for di, dj in ((-1, 0), (1, 0), (0, -1), (0, 1)): + a, b = i + di, j + dj + if 0 <= a < N and 0 <= b < M: + v ^= int(G[a][b]) + if v != int(P[i][j]): + raise Invalid(f"parity mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s0/tests/instance.json b/tasks/construct-rlve-grid-parity-construction-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3a7c015a71ffbd20e27ed1a5021537f29e2edc20 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"parity": ["00000", "00000"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s0/tests/run.py b/tasks/construct-rlve-grid-parity-construction-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l2-s0/tests/test.sh b/tasks/construct-rlve-grid-parity-construction-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l2-s7/environment/Dockerfile b/tasks/construct-rlve-grid-parity-construction-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l2-s7/environment/instance.json b/tasks/construct-rlve-grid-parity-construction-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..de3fa669f09006354737b60bd1f8cec346980aee --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"parity": ["10001", "01110", "01110", "01110", "10001"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s7/solution/solve.sh b/tasks/construct-rlve-grid-parity-construction-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3b089beda85692c5cdf7e694d2e5013e8679723e --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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' +{"grid": ["11111", "11111", "11111", "11111", "11111"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s7/tests/check.py b/tasks/construct-rlve-grid-parity-construction-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..89d5d286593348d0000ac10db74e1c6242be6c97 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s7/tests/check.py @@ -0,0 +1,22 @@ +from run import Invalid + + +def check(inst, ans): + P = inst["parity"] + N, M = len(P), len(P[0]) + G = ans.get("grid") + if not isinstance(G, list) or len(G) != N: + raise Invalid(f"grid must be a list of {N} strings") + for r in G: + if not isinstance(r, str) or len(r) != M or set(r) - {"0", "1"}: + raise Invalid(f"each row must be a string of {M} characters '0'/'1'") + for i in range(N): + for j in range(M): + v = int(G[i][j]) + for di, dj in ((-1, 0), (1, 0), (0, -1), (0, 1)): + a, b = i + di, j + dj + if 0 <= a < N and 0 <= b < M: + v ^= int(G[a][b]) + if v != int(P[i][j]): + raise Invalid(f"parity mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s7/tests/instance.json b/tasks/construct-rlve-grid-parity-construction-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..de3fa669f09006354737b60bd1f8cec346980aee --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"parity": ["10001", "01110", "01110", "01110", "10001"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s7/tests/run.py b/tasks/construct-rlve-grid-parity-construction-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l2-s7/tests/test.sh b/tasks/construct-rlve-grid-parity-construction-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l2-s9/environment/Dockerfile b/tasks/construct-rlve-grid-parity-construction-l2-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l2-s9/environment/instance.json b/tasks/construct-rlve-grid-parity-construction-l2-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..82625432aaf05dc034eb36aec322d1fbd905ad55 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s9/environment/instance.json @@ -0,0 +1 @@ +{"parity": ["1110", "0100", "0110", "0010", "0111"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s9/solution/solve.sh b/tasks/construct-rlve-grid-parity-construction-l2-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c60909e79836a9a7b6ef54a404ad4100164f9972 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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' +{"grid": ["1101", "1111", "1111", "1111", "1011"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s9/tests/check.py b/tasks/construct-rlve-grid-parity-construction-l2-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..89d5d286593348d0000ac10db74e1c6242be6c97 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s9/tests/check.py @@ -0,0 +1,22 @@ +from run import Invalid + + +def check(inst, ans): + P = inst["parity"] + N, M = len(P), len(P[0]) + G = ans.get("grid") + if not isinstance(G, list) or len(G) != N: + raise Invalid(f"grid must be a list of {N} strings") + for r in G: + if not isinstance(r, str) or len(r) != M or set(r) - {"0", "1"}: + raise Invalid(f"each row must be a string of {M} characters '0'/'1'") + for i in range(N): + for j in range(M): + v = int(G[i][j]) + for di, dj in ((-1, 0), (1, 0), (0, -1), (0, 1)): + a, b = i + di, j + dj + if 0 <= a < N and 0 <= b < M: + v ^= int(G[a][b]) + if v != int(P[i][j]): + raise Invalid(f"parity mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s9/tests/instance.json b/tasks/construct-rlve-grid-parity-construction-l2-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..82625432aaf05dc034eb36aec322d1fbd905ad55 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l2-s9/tests/instance.json @@ -0,0 +1 @@ +{"parity": ["1110", "0100", "0110", "0010", "0111"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l2-s9/tests/run.py b/tasks/construct-rlve-grid-parity-construction-l2-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l2-s9/tests/test.sh b/tasks/construct-rlve-grid-parity-construction-l2-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l6-s6/environment/Dockerfile b/tasks/construct-rlve-grid-parity-construction-l6-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l6-s6/environment/instance.json b/tasks/construct-rlve-grid-parity-construction-l6-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ca87921b5d49d9520433ac71bd9aaa4ad47ffbb4 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s6/environment/instance.json @@ -0,0 +1 @@ +{"parity": ["100110101110001001000001", "100111100001011110011111", "100001111111010010111101", "010001001111010000010111", "101000001110000111101011", "111110010101111011001001", "010011000110111001101111", "001101110110101000011110", "010000011111010100111100", "011000000110010111011100", "011100011010001011001010", "011111101100001010100100", "111011100010110110011111", "111100011111010110100100", "000111100111001110100101", "110011010011100011001101"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s6/solution/solve.sh b/tasks/construct-rlve-grid-parity-construction-l6-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9d4b8ef5359a601ddc1db69ef3272796c39cd2df --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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' +{"grid": ["111011111101001111111111", "110111010111111110111111", "011110001111101101111110", "111011111111101100111111", "011110111111111110110111", "111111101110010111010110", "111111101111110111101111", "110011101111001101111111", "111111011111101111001111", "111101111111011111110101", "111111100111110111110110", "111110111110110111011110", "111100010111111111011111", "011111101111111111001111", "101111001111010111001101", "111110111110100011011011"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s6/tests/check.py b/tasks/construct-rlve-grid-parity-construction-l6-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..89d5d286593348d0000ac10db74e1c6242be6c97 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s6/tests/check.py @@ -0,0 +1,22 @@ +from run import Invalid + + +def check(inst, ans): + P = inst["parity"] + N, M = len(P), len(P[0]) + G = ans.get("grid") + if not isinstance(G, list) or len(G) != N: + raise Invalid(f"grid must be a list of {N} strings") + for r in G: + if not isinstance(r, str) or len(r) != M or set(r) - {"0", "1"}: + raise Invalid(f"each row must be a string of {M} characters '0'/'1'") + for i in range(N): + for j in range(M): + v = int(G[i][j]) + for di, dj in ((-1, 0), (1, 0), (0, -1), (0, 1)): + a, b = i + di, j + dj + if 0 <= a < N and 0 <= b < M: + v ^= int(G[a][b]) + if v != int(P[i][j]): + raise Invalid(f"parity mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s6/tests/instance.json b/tasks/construct-rlve-grid-parity-construction-l6-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ca87921b5d49d9520433ac71bd9aaa4ad47ffbb4 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s6/tests/instance.json @@ -0,0 +1 @@ +{"parity": ["100110101110001001000001", "100111100001011110011111", "100001111111010010111101", "010001001111010000010111", "101000001110000111101011", "111110010101111011001001", "010011000110111001101111", "001101110110101000011110", "010000011111010100111100", "011000000110010111011100", "011100011010001011001010", "011111101100001010100100", "111011100010110110011111", "111100011111010110100100", "000111100111001110100101", "110011010011100011001101"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s6/tests/run.py b/tasks/construct-rlve-grid-parity-construction-l6-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l6-s6/tests/test.sh b/tasks/construct-rlve-grid-parity-construction-l6-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l6-s8/environment/Dockerfile b/tasks/construct-rlve-grid-parity-construction-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l6-s8/environment/instance.json b/tasks/construct-rlve-grid-parity-construction-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c635a5443564288369bda65a13529af06be1a5ac --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"parity": ["110011000110010100", "001001010000100010", "100111101001111011", "111000000101001111", "101101111000110010", "010011011001100010", "101011001111001000", "100101010010001010", "101111101000110101"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s8/solution/solve.sh b/tasks/construct-rlve-grid-parity-construction-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5ca0a6d41a3638772b1dfa5e1e086fc119aeffce --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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' +{"grid": ["001011001101001011", "101011110111101100", "101011111110101011", "100101100010111111", "101111101101111010", "101111011010111110", "011010110110000101", "100110010100111011", "000110010011011111"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s8/tests/check.py b/tasks/construct-rlve-grid-parity-construction-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..89d5d286593348d0000ac10db74e1c6242be6c97 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s8/tests/check.py @@ -0,0 +1,22 @@ +from run import Invalid + + +def check(inst, ans): + P = inst["parity"] + N, M = len(P), len(P[0]) + G = ans.get("grid") + if not isinstance(G, list) or len(G) != N: + raise Invalid(f"grid must be a list of {N} strings") + for r in G: + if not isinstance(r, str) or len(r) != M or set(r) - {"0", "1"}: + raise Invalid(f"each row must be a string of {M} characters '0'/'1'") + for i in range(N): + for j in range(M): + v = int(G[i][j]) + for di, dj in ((-1, 0), (1, 0), (0, -1), (0, 1)): + a, b = i + di, j + dj + if 0 <= a < N and 0 <= b < M: + v ^= int(G[a][b]) + if v != int(P[i][j]): + raise Invalid(f"parity mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s8/tests/instance.json b/tasks/construct-rlve-grid-parity-construction-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c635a5443564288369bda65a13529af06be1a5ac --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"parity": ["110011000110010100", "001001010000100010", "100111101001111011", "111000000101001111", "101101111000110010", "010011011001100010", "101011001111001000", "100101010010001010", "101111101000110101"], "family": "rlve_grid_parity_construction", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-grid-parity-construction-l6-s8/tests/run.py b/tasks/construct-rlve-grid-parity-construction-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-grid-parity-construction-l6-s8/tests/test.sh b/tasks/construct-rlve-grid-parity-construction-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-grid-parity-construction-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-imp-party-l4-s9/environment/Dockerfile b/tasks/construct-rlve-imp-party-l4-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-imp-party-l4-s9/environment/instance.json b/tasks/construct-rlve-imp-party-l4-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0f79343e59293791283243c87c26f83bc54a6bfb --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 14], [0, 15], [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, 30], [0, 31], [0, 32], [0, 33], [0, 34], [0, 35], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 12], [1, 14], [1, 15], [1, 16], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 25], [1, 26], [1, 28], [1, 29], [1, 31], [1, 32], [1, 33], [1, 34], [1, 35], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 12], [2, 13], [2, 15], [2, 17], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 28], [2, 30], [2, 31], [2, 32], [2, 33], [2, 34], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 28], [3, 29], [3, 31], [3, 32], [3, 33], [3, 34], [3, 35], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 21], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 28], [4, 29], [4, 30], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 22], [5, 23], [5, 24], [5, 25], [5, 26], [5, 27], [5, 28], [5, 29], [5, 31], [5, 32], [5, 33], [5, 34], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 14], [6, 15], [6, 16], [6, 18], [6, 19], [6, 20], [6, 21], [6, 22], [6, 23], [6, 25], [6, 26], [6, 27], [6, 28], [6, 29], [6, 30], [6, 31], [6, 32], [6, 33], [6, 34], [6, 35], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [7, 17], [7, 18], [7, 19], [7, 21], [7, 22], [7, 23], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [7, 30], [7, 31], [7, 32], [7, 33], [7, 34], [7, 35], [8, 9], [8, 10], [8, 11], [8, 12], [8, 15], [8, 17], [8, 18], [8, 19], [8, 21], [8, 22], [8, 23], [8, 25], [8, 26], [8, 28], [8, 29], [8, 31], [8, 32], [8, 33], [8, 34], [8, 35], [9, 10], [9, 12], [9, 13], [9, 15], [9, 17], [9, 18], [9, 19], [9, 21], [9, 22], [9, 23], [9, 24], [9, 25], [9, 26], [9, 27], [9, 28], [9, 29], [9, 31], [9, 32], [9, 33], [9, 34], [10, 12], [10, 13], [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], [11, 18], [11, 19], [11, 21], [11, 22], [11, 23], [11, 25], [11, 26], [11, 28], [11, 31], [11, 32], [11, 33], [11, 34], [12, 18], [12, 19], [12, 21], [12, 22], [12, 23], [12, 25], [12, 28], [12, 31], [12, 33], [12, 34], [13, 15], [13, 19], [13, 21], [13, 22], [13, 23], [14, 15], [14, 18], [14, 19], [14, 22], [14, 25], [14, 26], [14, 31], [14, 32], [14, 33], [14, 34], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 25], [15, 26], [15, 28], [15, 29], [15, 30], [15, 31], [15, 32], [15, 33], [15, 34], [16, 18], [16, 22], [16, 23], [16, 31], [16, 33], [16, 34], [17, 18], [17, 23], [17, 28], [17, 32], [17, 33], [17, 34], [18, 19], [18, 21], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [19, 21], [19, 22], [19, 23], [19, 24], [19, 25], [19, 26], [19, 27], [19, 28], [19, 30], [19, 31], [19, 32], [19, 33], [19, 34], [20, 22], [20, 23], [20, 28], [20, 31], [20, 33], [21, 22], [21, 23], [21, 25], [21, 26], [21, 28], [21, 29], [21, 31], [21, 32], [21, 33], [21, 34], [21, 35], [22, 23], [22, 24], [22, 25], [22, 26], [22, 28], [22, 29], [22, 31], [22, 32], [22, 33], [22, 34], [22, 35], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [23, 30], [23, 31], [23, 32], [23, 33], [23, 34], [23, 35], [24, 26], [24, 28], [24, 32], [24, 33], [24, 34], [25, 26], [25, 28], [25, 31], [25, 32], [25, 33], [25, 34], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 35], [27, 28], [27, 31], [27, 33], [27, 34], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [28, 35], [29, 31], [29, 32], [29, 33], [29, 34], [30, 31], [30, 34], [31, 32], [31, 33], [31, 34], [32, 33], [32, 34], [32, 35], [33, 34], [33, 35], [34, 35]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l4-s9/solution/solve.sh b/tasks/construct-rlve-imp-party-l4-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a9ce3857ed0dc6cc89b0d290e5bff297606ce5f5 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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, 1, 2, 4, 8, 15, 21, 22, 23, 26, 31, 33]} +RLMATH_EOF diff --git a/tasks/construct-rlve-imp-party-l4-s9/tests/check.py b/tasks/construct-rlve-imp-party-l4-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..97b5a037a2ba8bf4495cf87cc074d1c60b11311c --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s9/tests/check.py @@ -0,0 +1,14 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + c = int_list(ans.get("clique"), n, 0, 3 * n - 1, "clique") + if len(set(c)) != n: + raise Invalid("vertices must be distinct") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(n): + for j in range(i + 1, n): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-imp-party-l4-s9/tests/instance.json b/tasks/construct-rlve-imp-party-l4-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0f79343e59293791283243c87c26f83bc54a6bfb --- /dev/null +++ b/tasks/construct-rlve-imp-party-l4-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "edges": [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 14], [0, 15], [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, 30], [0, 31], [0, 32], [0, 33], [0, 34], [0, 35], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 12], [1, 14], [1, 15], [1, 16], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 25], [1, 26], [1, 28], [1, 29], [1, 31], [1, 32], [1, 33], [1, 34], [1, 35], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 12], [2, 13], [2, 15], [2, 17], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 28], [2, 30], [2, 31], [2, 32], [2, 33], [2, 34], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 28], [3, 29], [3, 31], [3, 32], [3, 33], [3, 34], [3, 35], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 21], [4, 22], [4, 23], [4, 24], [4, 25], [4, 26], [4, 28], [4, 29], [4, 30], [4, 31], [4, 32], [4, 33], [4, 34], [4, 35], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20], [5, 21], [5, 22], [5, 23], [5, 24], [5, 25], [5, 26], [5, 27], [5, 28], [5, 29], [5, 31], [5, 32], [5, 33], [5, 34], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 14], [6, 15], [6, 16], [6, 18], [6, 19], [6, 20], [6, 21], [6, 22], [6, 23], [6, 25], [6, 26], [6, 27], [6, 28], [6, 29], [6, 30], [6, 31], [6, 32], [6, 33], [6, 34], [6, 35], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15], [7, 16], [7, 17], [7, 18], [7, 19], [7, 21], [7, 22], [7, 23], [7, 25], [7, 26], [7, 27], [7, 28], [7, 29], [7, 30], [7, 31], [7, 32], [7, 33], [7, 34], [7, 35], [8, 9], [8, 10], [8, 11], [8, 12], [8, 15], [8, 17], [8, 18], [8, 19], [8, 21], [8, 22], [8, 23], [8, 25], [8, 26], [8, 28], [8, 29], [8, 31], [8, 32], [8, 33], [8, 34], [8, 35], [9, 10], [9, 12], [9, 13], [9, 15], [9, 17], [9, 18], [9, 19], [9, 21], [9, 22], [9, 23], [9, 24], [9, 25], [9, 26], [9, 27], [9, 28], [9, 29], [9, 31], [9, 32], [9, 33], [9, 34], [10, 12], [10, 13], [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], [11, 18], [11, 19], [11, 21], [11, 22], [11, 23], [11, 25], [11, 26], [11, 28], [11, 31], [11, 32], [11, 33], [11, 34], [12, 18], [12, 19], [12, 21], [12, 22], [12, 23], [12, 25], [12, 28], [12, 31], [12, 33], [12, 34], [13, 15], [13, 19], [13, 21], [13, 22], [13, 23], [14, 15], [14, 18], [14, 19], [14, 22], [14, 25], [14, 26], [14, 31], [14, 32], [14, 33], [14, 34], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [15, 22], [15, 23], [15, 24], [15, 25], [15, 26], [15, 28], [15, 29], [15, 30], [15, 31], [15, 32], [15, 33], [15, 34], [16, 18], [16, 22], [16, 23], [16, 31], [16, 33], [16, 34], [17, 18], [17, 23], [17, 28], [17, 32], [17, 33], [17, 34], [18, 19], [18, 21], [18, 22], [18, 23], [18, 24], [18, 25], [18, 26], [18, 27], [18, 28], [18, 29], [18, 31], [18, 32], [18, 33], [18, 34], [18, 35], [19, 21], [19, 22], [19, 23], [19, 24], [19, 25], [19, 26], [19, 27], [19, 28], [19, 30], [19, 31], [19, 32], [19, 33], [19, 34], [20, 22], [20, 23], [20, 28], [20, 31], [20, 33], [21, 22], [21, 23], [21, 25], [21, 26], [21, 28], [21, 29], [21, 31], [21, 32], [21, 33], [21, 34], [21, 35], [22, 23], [22, 24], [22, 25], [22, 26], [22, 28], [22, 29], [22, 31], [22, 32], [22, 33], [22, 34], [22, 35], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [23, 30], [23, 31], [23, 32], [23, 33], [23, 34], [23, 35], [24, 26], [24, 28], [24, 32], [24, 33], [24, 34], [25, 26], [25, 28], [25, 31], [25, 32], [25, 33], [25, 34], [26, 28], [26, 29], [26, 30], [26, 31], [26, 32], [26, 33], [26, 34], [26, 35], [27, 28], [27, 31], [27, 33], [27, 34], [28, 29], [28, 30], [28, 31], [28, 32], [28, 33], [28, 34], [28, 35], [29, 31], [29, 32], [29, 33], [29, 34], [30, 31], [30, 34], [31, 32], [31, 33], [31, 34], [32, 33], [32, 34], [32, 35], [33, 34], [33, 35], [34, 35]], "family": "rlve_imp_party", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-imp-party-l4-s9/tests/run.py b/tasks/construct-rlve-imp-party-l4-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-imp-party-l4-s9/tests/test.sh b/tasks/construct-rlve-imp-party-l4-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-imp-party-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-integer-linear-system-l3-s9/environment/Dockerfile b/tasks/construct-rlve-integer-linear-system-l3-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-integer-linear-system-l3-s9/environment/instance.json b/tasks/construct-rlve-integer-linear-system-l3-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..926026afed2549d4de248907e6744d710e61c913 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s9/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [[1, 1, 1, 0, 0, 1, 1, 0], [1, 0, 0, 1, 0, 0, 0, 0], [0, 1, 1, 0, 0, 0, 1, 0], [1, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 0, 0, 0, 0], [1, 0, 0, 1, 1, 1, 1, 0], [0, 1, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [1, 1, 0, 1, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 0], [1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 0, 1, 0, 1, 1, 0], [1, 1, 1, 1, 1, 1, 0, 1], [0, 1, 1, 0, 1, 1, 0, 1], [1, 1, 0, 1, 1, 1, 0, 0], [1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 1, 0], [1, 1, 0, 1, 1, 1, 1, 0], [0, 1, 1, 0, 0, 1, 1, 0]], "rhs": [25, 3, 18, 16, 3, 18, 10, 2, 19, 29, 15, 16, 23, 20, 17, 8, 21, 24, 24], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l3-s9/solution/solve.sh b/tasks/construct-rlve-integer-linear-system-l3-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..176a8c97efa7337323489f96ae4fbdfd4ee45ad6 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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' +{"x": [1, 6, 5, 2, 2, 6, 7, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-integer-linear-system-l3-s9/tests/check.py b/tasks/construct-rlve-integer-linear-system-l3-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..ff19002b3fddc9597f84ee31ef5ffbee5d3fac32 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s9/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = len(inst["coeffs"][0]) + x = int_list(ans.get("x"), n, name="x") + for k, (e, r) in enumerate(zip(inst["coeffs"], inst["rhs"])): + if sum(c * v for c, v in zip(e, x)) != r: + raise Invalid(f"equation {k} is violated") + return None, {} diff --git a/tasks/construct-rlve-integer-linear-system-l3-s9/tests/instance.json b/tasks/construct-rlve-integer-linear-system-l3-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..926026afed2549d4de248907e6744d710e61c913 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-l3-s9/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [[1, 1, 1, 0, 0, 1, 1, 0], [1, 0, 0, 1, 0, 0, 0, 0], [0, 1, 1, 0, 0, 0, 1, 0], [1, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 0, 0, 0, 0], [1, 0, 0, 1, 1, 1, 1, 0], [0, 1, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [1, 1, 0, 1, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 0], [1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 0, 1, 0, 1, 1, 0], [1, 1, 1, 1, 1, 1, 0, 1], [0, 1, 1, 0, 1, 1, 0, 1], [1, 1, 0, 1, 1, 1, 0, 0], [1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 1, 0], [1, 1, 0, 1, 1, 1, 1, 0], [0, 1, 1, 0, 0, 1, 1, 0]], "rhs": [25, 3, 18, 16, 3, 18, 10, 2, 19, 29, 15, 16, 23, 20, 17, 8, 21, 24, 24], "family": "rlve_integer_linear_system", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-integer-linear-system-l3-s9/tests/run.py b/tasks/construct-rlve-integer-linear-system-l3-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-integer-linear-system-l3-s9/tests/test.sh b/tasks/construct-rlve-integer-linear-system-l3-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-integer-linear-system-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-largest-convex-polygon-l4-s6/environment/Dockerfile b/tasks/construct-rlve-largest-convex-polygon-l4-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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-largest-convex-polygon-l4-s6/environment/instance.json b/tasks/construct-rlve-largest-convex-polygon-l4-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5e8154f8066fbcb1f10db26362aa51b7e884e9c2 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s6/environment/instance.json @@ -0,0 +1 @@ +{"points": [[0, 1], [14, 7], [5, 4], [15, 17], [10, 1], [3, 16], [7, 3], [11, 12], [12, 9], [16, 2], [7, 6], [1, 13], [6, 10], [18, 6], [12, 15], [2, 9], [0, 8], [1, 3]], "k": 8, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s6/solution/solve.sh b/tasks/construct-rlve-largest-convex-polygon-l4-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..511a76ef61ca99e915950698b02e6d762f9daa3a --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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' +{"indices": [0, 16, 11, 5, 14, 7, 10, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s6/tests/check.py b/tasks/construct-rlve-largest-convex-polygon-l4-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3a09cc858f41ce5745e4e491188cd42360c65dae --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s6/tests/check.py @@ -0,0 +1,27 @@ +from run import Invalid, int_list + + +def _cross(o, a, b): + return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]) + + +def check(inst, ans): + P, k = inst["points"], inst["k"] + idx = int_list(ans.get("indices"), None, 0, len(P) - 1, "indices") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + if len(idx) < k: + raise Invalid(f"{len(idx)} points given, need {k}") + pts = sorted(tuple(P[i]) for i in idx) + lower, upper = [], [] + for p in pts: # monotone chain, strict (collinear points dropped) + while len(lower) >= 2 and _cross(lower[-2], lower[-1], p) <= 0: + lower.pop() + lower.append(p) + for p in reversed(pts): + while len(upper) >= 2 and _cross(upper[-2], upper[-1], p) <= 0: + upper.pop() + upper.append(p) + if len(lower) + len(upper) - 2 != len(pts): + raise Invalid("the chosen points are not in convex position") + return None, {} diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s6/tests/instance.json b/tasks/construct-rlve-largest-convex-polygon-l4-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5e8154f8066fbcb1f10db26362aa51b7e884e9c2 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s6/tests/instance.json @@ -0,0 +1 @@ +{"points": [[0, 1], [14, 7], [5, 4], [15, 17], [10, 1], [3, 16], [7, 3], [11, 12], [12, 9], [16, 2], [7, 6], [1, 13], [6, 10], [18, 6], [12, 15], [2, 9], [0, 8], [1, 3]], "k": 8, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s6/tests/run.py b/tasks/construct-rlve-largest-convex-polygon-l4-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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-largest-convex-polygon-l4-s6/tests/test.sh b/tasks/construct-rlve-largest-convex-polygon-l4-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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-largest-convex-polygon-l4-s8/environment/Dockerfile b/tasks/construct-rlve-largest-convex-polygon-l4-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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-largest-convex-polygon-l4-s8/environment/instance.json b/tasks/construct-rlve-largest-convex-polygon-l4-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0ed76b2f0b4e4054ae56cac766f02709d8896ae7 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s8/environment/instance.json @@ -0,0 +1 @@ +{"points": [[11, 7], [5, 5], [16, 10], [4, 13], [5, 8], [18, 10], [15, 17], [10, 17], [2, 16], [4, 2], [16, 6], [7, 9], [9, 5], [1, 4], [6, 13], [17, 2], [0, 15], [15, 0]], "k": 9, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s8/solution/solve.sh b/tasks/construct-rlve-largest-convex-polygon-l4-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..88188fda4f1a53b6d48d00ec2ce678b728df63b7 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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' +{"indices": [16, 8, 7, 6, 2, 10, 17, 9, 13]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s8/tests/check.py b/tasks/construct-rlve-largest-convex-polygon-l4-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3a09cc858f41ce5745e4e491188cd42360c65dae --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s8/tests/check.py @@ -0,0 +1,27 @@ +from run import Invalid, int_list + + +def _cross(o, a, b): + return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]) + + +def check(inst, ans): + P, k = inst["points"], inst["k"] + idx = int_list(ans.get("indices"), None, 0, len(P) - 1, "indices") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + if len(idx) < k: + raise Invalid(f"{len(idx)} points given, need {k}") + pts = sorted(tuple(P[i]) for i in idx) + lower, upper = [], [] + for p in pts: # monotone chain, strict (collinear points dropped) + while len(lower) >= 2 and _cross(lower[-2], lower[-1], p) <= 0: + lower.pop() + lower.append(p) + for p in reversed(pts): + while len(upper) >= 2 and _cross(upper[-2], upper[-1], p) <= 0: + upper.pop() + upper.append(p) + if len(lower) + len(upper) - 2 != len(pts): + raise Invalid("the chosen points are not in convex position") + return None, {} diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s8/tests/instance.json b/tasks/construct-rlve-largest-convex-polygon-l4-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0ed76b2f0b4e4054ae56cac766f02709d8896ae7 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-l4-s8/tests/instance.json @@ -0,0 +1 @@ +{"points": [[11, 7], [5, 5], [16, 10], [4, 13], [5, 8], [18, 10], [15, 17], [10, 17], [2, 16], [4, 2], [16, 6], [7, 9], [9, 5], [1, 4], [6, 13], [17, 2], [0, 15], [15, 0]], "k": 9, "family": "rlve_largest_convex_polygon", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-convex-polygon-l4-s8/tests/run.py b/tasks/construct-rlve-largest-convex-polygon-l4-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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-largest-convex-polygon-l4-s8/tests/test.sh b/tasks/construct-rlve-largest-convex-polygon-l4-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-convex-polygon-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-largest-rectangle-l2-s0/environment/Dockerfile b/tasks/construct-rlve-largest-rectangle-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l2-s0/environment/instance.json b/tasks/construct-rlve-largest-rectangle-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f6c91265f2a45acd269f5aac55592678a1a7275b --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"points": [[7, 6], [4, 11], [6, -7], [-2, 8], [2, 3], [-8, 10], [5, -9], [-1, 8], [-10, 9], [6, -10]], "area": 34, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l2-s0/solution/solve.sh b/tasks/construct-rlve-largest-rectangle-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1085169b3a8dc41e87cae3d49d0285372a31afcb --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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' +{"indices": [0, 1, 7, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-rectangle-l2-s0/tests/check.py b/tasks/construct-rlve-largest-rectangle-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2251b2af23a481e598fa1e48d0a8249f70b6cc44 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s0/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid, int_list + + +def check(inst, ans): + P = inst["points"] + idx = int_list(ans.get("indices"), 4, 0, len(P) - 1, "indices") + if len(set(idx)) != 4: + raise Invalid("indices must be distinct") + A, *rest = [tuple(P[i]) for i in idx] + if len(set([A] + rest)) != 4: + raise Invalid("points must be distinct") + # the vertex farthest from A is opposite; the other two are A's neighbours + rest.sort(key=lambda X: (X[0] - A[0]) ** 2 + (X[1] - A[1]) ** 2) + B, D, C = rest + u = (B[0] - A[0], B[1] - A[1]) + v = (D[0] - A[0], D[1] - A[1]) + if u[0] * v[0] + u[1] * v[1] != 0: + raise Invalid("not a rectangle (no right angle at the first vertex)") + if (B[0] + D[0] - A[0], B[1] + D[1] - A[1]) != C: + raise Invalid("not a rectangle") + area = abs(u[0] * v[1] - u[1] * v[0]) + if area < inst["area"]: + raise Invalid(f"area {area} < {inst['area']}") + return None, {"area": area} diff --git a/tasks/construct-rlve-largest-rectangle-l2-s0/tests/instance.json b/tasks/construct-rlve-largest-rectangle-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f6c91265f2a45acd269f5aac55592678a1a7275b --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"points": [[7, 6], [4, 11], [6, -7], [-2, 8], [2, 3], [-8, 10], [5, -9], [-1, 8], [-10, 9], [6, -10]], "area": 34, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l2-s0/tests/run.py b/tasks/construct-rlve-largest-rectangle-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l2-s0/tests/test.sh b/tasks/construct-rlve-largest-rectangle-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l2-s7/environment/Dockerfile b/tasks/construct-rlve-largest-rectangle-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l2-s7/environment/instance.json b/tasks/construct-rlve-largest-rectangle-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a909b7e9b0a69f0fa7b5f466978f8985780c4bd6 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"points": [[-5, -6], [5, 7], [9, -9], [2, 6], [-1, -8], [2, -3], [-6, -5], [-3, 0], [1, -5], [9, -4]], "area": 34, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l2-s7/solution/solve.sh b/tasks/construct-rlve-largest-rectangle-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..667e674247fa80a92904ba74a00a05bfcf6fb44d --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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' +{"indices": [4, 5, 7, 6]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-rectangle-l2-s7/tests/check.py b/tasks/construct-rlve-largest-rectangle-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2251b2af23a481e598fa1e48d0a8249f70b6cc44 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s7/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-l2-s7/tests/instance.json b/tasks/construct-rlve-largest-rectangle-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a909b7e9b0a69f0fa7b5f466978f8985780c4bd6 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"points": [[-5, -6], [5, 7], [9, -9], [2, 6], [-1, -8], [2, -3], [-6, -5], [-3, 0], [1, -5], [9, -4]], "area": 34, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l2-s7/tests/run.py b/tasks/construct-rlve-largest-rectangle-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l2-s7/tests/test.sh b/tasks/construct-rlve-largest-rectangle-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l2-s9/environment/Dockerfile b/tasks/construct-rlve-largest-rectangle-l2-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l2-s9/environment/instance.json b/tasks/construct-rlve-largest-rectangle-l2-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..88c86bde0e83627ef482bf31138fca97b4c87146 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s9/environment/instance.json @@ -0,0 +1 @@ +{"points": [[-4, 4], [0, 0], [-8, -7], [-6, 10], [0, 4], [3, 7], [-4, 6], [-4, 0], [-10, -3], [1, 5]], "area": 16, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l2-s9/solution/solve.sh b/tasks/construct-rlve-largest-rectangle-l2-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0170c50155e426cb0b1c51b4a1700c6b91eace86 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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' +{"indices": [0, 4, 1, 7]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-rectangle-l2-s9/tests/check.py b/tasks/construct-rlve-largest-rectangle-l2-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2251b2af23a481e598fa1e48d0a8249f70b6cc44 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s9/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-l2-s9/tests/instance.json b/tasks/construct-rlve-largest-rectangle-l2-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..88c86bde0e83627ef482bf31138fca97b4c87146 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l2-s9/tests/instance.json @@ -0,0 +1 @@ +{"points": [[-4, 4], [0, 0], [-8, -7], [-6, 10], [0, 4], [3, 7], [-4, 6], [-4, 0], [-10, -3], [1, 5]], "area": 16, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l2-s9/tests/run.py b/tasks/construct-rlve-largest-rectangle-l2-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l2-s9/tests/test.sh b/tasks/construct-rlve-largest-rectangle-l2-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l6-s6/environment/Dockerfile b/tasks/construct-rlve-largest-rectangle-l6-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l6-s6/environment/instance.json b/tasks/construct-rlve-largest-rectangle-l6-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f7d5b17cfc727b4ca91a9a3d648fb5f34c7a9577 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s6/environment/instance.json @@ -0,0 +1 @@ +{"points": [[-50, 7], [17, 0], [59, 24], [10, 17], [5, 58], [52, -36], [-58, -18], [-26, -35], [-34, -23], [-28, -3], [47, 52], [56, 8], [-4, -40], [-12, 14], [-12, -44], [-6, -18], [-10, -28], [59, 44], [55, 45], [-41, -3], [22, 15], [2, 39], [-45, 33], [-22, 55], [2, 7], [-52, 21], [56, -29], [34, 7], [50, 37], [38, -4], [-17, -26], [60, -22], [-43, -4], [30, 17], [-15, 4], [17, 13], [-55, -55], [-9, 42], [13, 8], [-49, 48], [2, 48], [-51, 41], [47, -1], [35, 23], [0, 46], [-52, -30], [11, 33], [31, -31], [15, -31], [60, 44], [45, -4], [-33, -2], [-46, -34], [27, 24], [47, -48], [-48, -48], [27, 56], [60, -3], [-6, -57], [-47, 7]], "area": 338, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l6-s6/solution/solve.sh b/tasks/construct-rlve-largest-rectangle-l6-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a68d5a27d815dc5473cd014e153bafe7f48a0d43 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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' +{"indices": [1, 3, 53, 27]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-rectangle-l6-s6/tests/check.py b/tasks/construct-rlve-largest-rectangle-l6-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2251b2af23a481e598fa1e48d0a8249f70b6cc44 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s6/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid, int_list + + +def check(inst, ans): + P = inst["points"] + idx = int_list(ans.get("indices"), 4, 0, len(P) - 1, "indices") + if len(set(idx)) != 4: + raise Invalid("indices must be distinct") + A, *rest = [tuple(P[i]) for i in idx] + if len(set([A] + rest)) != 4: + raise Invalid("points must be distinct") + # the vertex farthest from A is opposite; the other two are A's neighbours + rest.sort(key=lambda X: (X[0] - A[0]) ** 2 + (X[1] - A[1]) ** 2) + B, D, C = rest + u = (B[0] - A[0], B[1] - A[1]) + v = (D[0] - A[0], D[1] - A[1]) + if u[0] * v[0] + u[1] * v[1] != 0: + raise Invalid("not a rectangle (no right angle at the first vertex)") + if (B[0] + D[0] - A[0], B[1] + D[1] - A[1]) != C: + raise Invalid("not a rectangle") + area = abs(u[0] * v[1] - u[1] * v[0]) + if area < inst["area"]: + raise Invalid(f"area {area} < {inst['area']}") + return None, {"area": area} diff --git a/tasks/construct-rlve-largest-rectangle-l6-s6/tests/instance.json b/tasks/construct-rlve-largest-rectangle-l6-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f7d5b17cfc727b4ca91a9a3d648fb5f34c7a9577 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s6/tests/instance.json @@ -0,0 +1 @@ +{"points": [[-50, 7], [17, 0], [59, 24], [10, 17], [5, 58], [52, -36], [-58, -18], [-26, -35], [-34, -23], [-28, -3], [47, 52], [56, 8], [-4, -40], [-12, 14], [-12, -44], [-6, -18], [-10, -28], [59, 44], [55, 45], [-41, -3], [22, 15], [2, 39], [-45, 33], [-22, 55], [2, 7], [-52, 21], [56, -29], [34, 7], [50, 37], [38, -4], [-17, -26], [60, -22], [-43, -4], [30, 17], [-15, 4], [17, 13], [-55, -55], [-9, 42], [13, 8], [-49, 48], [2, 48], [-51, 41], [47, -1], [35, 23], [0, 46], [-52, -30], [11, 33], [31, -31], [15, -31], [60, 44], [45, -4], [-33, -2], [-46, -34], [27, 24], [47, -48], [-48, -48], [27, 56], [60, -3], [-6, -57], [-47, 7]], "area": 338, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l6-s6/tests/run.py b/tasks/construct-rlve-largest-rectangle-l6-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l6-s6/tests/test.sh b/tasks/construct-rlve-largest-rectangle-l6-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l6-s8/environment/Dockerfile b/tasks/construct-rlve-largest-rectangle-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l6-s8/environment/instance.json b/tasks/construct-rlve-largest-rectangle-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c690cc97c184f98acb8752e74546d9dd14c12a2a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"points": [[41, -23], [-15, 1], [-22, -13], [-5, -51], [-33, 51], [-58, 42], [56, 27], [3, 42], [32, -34], [22, 0], [55, -10], [33, 27], [-45, -23], [3, 32], [31, 60], [-41, -44], [-45, -20], [-49, -37], [43, 52], [60, 47], [26, -20], [13, 3], [-21, 18], [-15, -37], [41, 45], [-57, -25], [3, 59], [6, -24], [23, -43], [53, -56], [53, 43], [0, -36], [16, 40], [18, -46], [-11, 44], [15, 49], [6, -58], [22, 4], [18, -29], [2, -4], [6, -9], [18, -4], [-20, 6], [58, 2], [24, -8], [-14, -27], [17, 35], [-34, -9], [29, 31], [46, -12], [14, 48], [-36, -45], [-35, -45], [-30, 49], [-5, 38], [-37, 47], [-10, -44], [0, -52], [29, 27], [15, -52]], "area": 416, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l6-s8/solution/solve.sh b/tasks/construct-rlve-largest-rectangle-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5890e6ef2c76245d1737b1c25572bdb7a07b9f80 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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' +{"indices": [9, 20, 27, 39]} +RLMATH_EOF diff --git a/tasks/construct-rlve-largest-rectangle-l6-s8/tests/check.py b/tasks/construct-rlve-largest-rectangle-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2251b2af23a481e598fa1e48d0a8249f70b6cc44 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s8/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid, int_list + + +def check(inst, ans): + P = inst["points"] + idx = int_list(ans.get("indices"), 4, 0, len(P) - 1, "indices") + if len(set(idx)) != 4: + raise Invalid("indices must be distinct") + A, *rest = [tuple(P[i]) for i in idx] + if len(set([A] + rest)) != 4: + raise Invalid("points must be distinct") + # the vertex farthest from A is opposite; the other two are A's neighbours + rest.sort(key=lambda X: (X[0] - A[0]) ** 2 + (X[1] - A[1]) ** 2) + B, D, C = rest + u = (B[0] - A[0], B[1] - A[1]) + v = (D[0] - A[0], D[1] - A[1]) + if u[0] * v[0] + u[1] * v[1] != 0: + raise Invalid("not a rectangle (no right angle at the first vertex)") + if (B[0] + D[0] - A[0], B[1] + D[1] - A[1]) != C: + raise Invalid("not a rectangle") + area = abs(u[0] * v[1] - u[1] * v[0]) + if area < inst["area"]: + raise Invalid(f"area {area} < {inst['area']}") + return None, {"area": area} diff --git a/tasks/construct-rlve-largest-rectangle-l6-s8/tests/instance.json b/tasks/construct-rlve-largest-rectangle-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..c690cc97c184f98acb8752e74546d9dd14c12a2a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"points": [[41, -23], [-15, 1], [-22, -13], [-5, -51], [-33, 51], [-58, 42], [56, 27], [3, 42], [32, -34], [22, 0], [55, -10], [33, 27], [-45, -23], [3, 32], [31, 60], [-41, -44], [-45, -20], [-49, -37], [43, 52], [60, 47], [26, -20], [13, 3], [-21, 18], [-15, -37], [41, 45], [-57, -25], [3, 59], [6, -24], [23, -43], [53, -56], [53, 43], [0, -36], [16, 40], [18, -46], [-11, 44], [15, 49], [6, -58], [22, 4], [18, -29], [2, -4], [6, -9], [18, -4], [-20, 6], [58, 2], [24, -8], [-14, -27], [17, 35], [-34, -9], [29, 31], [46, -12], [14, 48], [-36, -45], [-35, -45], [-30, 49], [-5, 38], [-37, 47], [-10, -44], [0, -52], [29, 27], [15, -52]], "area": 416, "family": "rlve_largest_rectangle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-largest-rectangle-l6-s8/tests/run.py b/tasks/construct-rlve-largest-rectangle-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-largest-rectangle-l6-s8/tests/test.sh b/tasks/construct-rlve-largest-rectangle-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-largest-rectangle-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-matrix-permutation-equivalence-l1-s3/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s3/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..31241a34df07a9037b49727dbfe95d2cf1964808 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s3/environment/instance.json @@ -0,0 +1 @@ +{"A": ["10", "11", "01"], "B": ["01", "10", "11"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s3/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e4ca0cf562b5c792a2538d247d324bfbe5a58a14 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s3/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"a": [2, 0, 1], "b": [0, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s3/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s3/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A, B = inst["A"], inst["B"] + N, M = len(A), len(A[0]) + a = int_list(ans.get("a"), N, 0, N - 1, "a") + b = int_list(ans.get("b"), M, 0, M - 1, "b") + if len(set(a)) != N or len(set(b)) != M: + raise Invalid("a and b must be permutations") + for i in range(N): + for j in range(M): + if A[a[i]][b[j]] != B[i][j]: + raise Invalid(f"mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s3/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..31241a34df07a9037b49727dbfe95d2cf1964808 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s3/tests/instance.json @@ -0,0 +1 @@ +{"A": ["10", "11", "01"], "B": ["01", "10", "11"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s3/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s3/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s4/environment/Dockerfile b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s4/environment/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5c14b9eaa0b697d278258174192cc63505fb3dbc --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s4/environment/instance.json @@ -0,0 +1 @@ +{"A": ["000", "100", "000"], "B": ["000", "000", "010"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s4/solution/solve.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f1ca14d754ec61f47a155ab8358544785926490e --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"a": [2, 0, 1], "b": [1, 0, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s4/tests/check.py b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..310a1d2c8b6afd7a82a35ba2a4c802c1ce289d03 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s4/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + A, B = inst["A"], inst["B"] + N, M = len(A), len(A[0]) + a = int_list(ans.get("a"), N, 0, N - 1, "a") + b = int_list(ans.get("b"), M, 0, M - 1, "b") + if len(set(a)) != N or len(set(b)) != M: + raise Invalid("a and b must be permutations") + for i in range(N): + for j in range(M): + if A[a[i]][b[j]] != B[i][j]: + raise Invalid(f"mismatch at ({i}, {j})") + return None, {} diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s4/tests/instance.json b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5c14b9eaa0b697d278258174192cc63505fb3dbc --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s4/tests/instance.json @@ -0,0 +1 @@ +{"A": ["000", "100", "000"], "B": ["000", "000", "010"], "family": "rlve_matrix_permutation_equivalence", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s4/tests/run.py b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-matrix-permutation-equivalence-l1-s4/tests/test.sh b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-matrix-permutation-equivalence-l1-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s7/environment/Dockerfile b/tasks/construct-rlve-max-achromatic-coloring-l4-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-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-max-achromatic-coloring-l4-s7/environment/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l4-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..98d962997c795a17fcccf8c7d4e9e086dcd3a079 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "k": 8, "edges": [[0, 2], [0, 3], [0, 6], [0, 8], [0, 9], [0, 10], [0, 11], [1, 4], [1, 5], [1, 7], [1, 8], [1, 9], [2, 5], [2, 6], [2, 8], [2, 9], [2, 10], [2, 11], [3, 5], [3, 7], [3, 9], [3, 10], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 11], [5, 8], [5, 9], [5, 11], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [7, 8], [7, 9], [7, 10], [8, 9], [8, 10], [9, 11]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s7/solution/solve.sh b/tasks/construct-rlve-max-achromatic-coloring-l4-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..39f369b6db80bf1660c7121af2e74b85215b26ab --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 0, 1, 2, 3, 4, 2, 1, 5, 6, 7, 7]} +RLMATH_EOF diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s7/tests/check.py b/tasks/construct-rlve-max-achromatic-coloring-l4-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..bb676a518264e5db4fb0964e27ccffccf6980807 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s7/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + if len(set(c)) != k: + raise Invalid(f"uses {len(set(c))} colours, need all {k}") + pairs = set() + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + pairs.add((min(c[u], c[v]), max(c[u], c[v]))) + if len(pairs) != k * (k - 1) // 2: + raise Invalid("some pair of colours is not joined by an edge") + return None, {} diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s7/tests/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l4-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..98d962997c795a17fcccf8c7d4e9e086dcd3a079 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "k": 8, "edges": [[0, 2], [0, 3], [0, 6], [0, 8], [0, 9], [0, 10], [0, 11], [1, 4], [1, 5], [1, 7], [1, 8], [1, 9], [2, 5], [2, 6], [2, 8], [2, 9], [2, 10], [2, 11], [3, 5], [3, 7], [3, 9], [3, 10], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 11], [5, 8], [5, 9], [5, 11], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [7, 8], [7, 9], [7, 10], [8, 9], [8, 10], [9, 11]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s7/tests/run.py b/tasks/construct-rlve-max-achromatic-coloring-l4-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-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-max-achromatic-coloring-l4-s7/tests/test.sh b/tasks/construct-rlve-max-achromatic-coloring-l4-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-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-max-achromatic-coloring-l4-s9/environment/Dockerfile b/tasks/construct-rlve-max-achromatic-coloring-l4-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s9/environment/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l4-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f62cf371a0638458a2a4ff5a6a99c8dffcd16bb7 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s9/environment/instance.json @@ -0,0 +1 @@ +{"n": 12, "k": 8, "edges": [[0, 1], [0, 2], [0, 3], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [1, 2], [1, 3], [1, 4], [1, 5], [1, 7], [1, 8], [2, 5], [2, 7], [2, 8], [2, 9], [2, 10], [3, 8], [3, 9], [4, 5], [4, 7], [4, 8], [4, 9], [4, 10], [5, 6], [5, 7], [5, 8], [5, 9], [6, 8], [6, 10], [6, 11], [7, 8], [7, 9], [7, 11], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s9/solution/solve.sh b/tasks/construct-rlve-max-achromatic-coloring-l4-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d0d673a9c264dc70187bb2da05b932785ae95340 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 1, 2, 2, 3, 4, 3, 5, 6, 7, 1, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s9/tests/check.py b/tasks/construct-rlve-max-achromatic-coloring-l4-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..bb676a518264e5db4fb0964e27ccffccf6980807 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s9/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + if len(set(c)) != k: + raise Invalid(f"uses {len(set(c))} colours, need all {k}") + pairs = set() + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + pairs.add((min(c[u], c[v]), max(c[u], c[v]))) + if len(pairs) != k * (k - 1) // 2: + raise Invalid("some pair of colours is not joined by an edge") + return None, {} diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s9/tests/instance.json b/tasks/construct-rlve-max-achromatic-coloring-l4-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f62cf371a0638458a2a4ff5a6a99c8dffcd16bb7 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s9/tests/instance.json @@ -0,0 +1 @@ +{"n": 12, "k": 8, "edges": [[0, 1], [0, 2], [0, 3], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [1, 2], [1, 3], [1, 4], [1, 5], [1, 7], [1, 8], [2, 5], [2, 7], [2, 8], [2, 9], [2, 10], [3, 8], [3, 9], [4, 5], [4, 7], [4, 8], [4, 9], [4, 10], [5, 6], [5, 7], [5, 8], [5, 9], [6, 8], [6, 10], [6, 11], [7, 8], [7, 9], [7, 11], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11]], "family": "rlve_max_achromatic_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s9/tests/run.py b/tasks/construct-rlve-max-achromatic-coloring-l4-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-max-achromatic-coloring-l4-s9/tests/test.sh b/tasks/construct-rlve-max-achromatic-coloring-l4-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-max-achromatic-coloring-l4-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-maximum-clique-l2-s2/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l2-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-maximum-clique-l2-s2/environment/instance.json b/tasks/construct-rlve-maximum-clique-l2-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7ff3870d261da03c9db50a68c7e79e37d2e486d5 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 14, "k": 6, "edges": [[0, 1], [0, 2], [0, 3], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [1, 2], [1, 4], [1, 5], [1, 8], [1, 10], [1, 11], [1, 13], [2, 5], [2, 7], [2, 8], [2, 9], [2, 11], [2, 12], [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, 11], [4, 12], [5, 6], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [6, 8], [6, 10], [6, 11], [6, 12], [6, 13], [7, 8], [7, 9], [7, 11], [7, 12], [7, 13], [8, 9], [8, 10], [8, 12], [8, 13], [9, 11], [9, 13], [10, 11], [10, 12], [12, 13]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l2-s2/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l2-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c85ddc742d815de4f01329a77b4ffcab366fa2a9 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [0, 2, 7, 8, 9, 13]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l2-s2/tests/check.py b/tasks/construct-rlve-maximum-clique-l2-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s2/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(c)) != len(c): + raise Invalid("vertices must be distinct") + if len(c) < k: + raise Invalid(f"clique has {len(c)} vertices, need {k}") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(len(c)): + for j in range(i + 1, len(c)): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-maximum-clique-l2-s2/tests/instance.json b/tasks/construct-rlve-maximum-clique-l2-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7ff3870d261da03c9db50a68c7e79e37d2e486d5 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 14, "k": 6, "edges": [[0, 1], [0, 2], [0, 3], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [1, 2], [1, 4], [1, 5], [1, 8], [1, 10], [1, 11], [1, 13], [2, 5], [2, 7], [2, 8], [2, 9], [2, 11], [2, 12], [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, 11], [4, 12], [5, 6], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [6, 8], [6, 10], [6, 11], [6, 12], [6, 13], [7, 8], [7, 9], [7, 11], [7, 12], [7, 13], [8, 9], [8, 10], [8, 12], [8, 13], [9, 11], [9, 13], [10, 11], [10, 12], [12, 13]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l2-s2/tests/run.py b/tasks/construct-rlve-maximum-clique-l2-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-maximum-clique-l2-s2/tests/test.sh b/tasks/construct-rlve-maximum-clique-l2-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-maximum-clique-l2-s5/environment/Dockerfile b/tasks/construct-rlve-maximum-clique-l2-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-maximum-clique-l2-s5/environment/instance.json b/tasks/construct-rlve-maximum-clique-l2-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..012ba043f041f490ec725d19ec39e90593bd79d7 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 14, "k": 5, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 6], [0, 8], [0, 10], [0, 11], [0, 12], [0, 13], [1, 4], [1, 9], [1, 12], [2, 5], [2, 8], [2, 9], [2, 10], [2, 11], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 11], [3, 12], [3, 13], [4, 6], [4, 7], [4, 9], [4, 11], [4, 13], [5, 6], [5, 13], [6, 8], [6, 9], [6, 11], [6, 13], [7, 9], [7, 10], [7, 11], [7, 13], [8, 10], [8, 13], [9, 11], [9, 12], [9, 13], [10, 11], [10, 13], [11, 12]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l2-s5/solution/solve.sh b/tasks/construct-rlve-maximum-clique-l2-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e84c1942b5f6948dcc460d77dd4e58e198bd3477 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"clique": [0, 3, 4, 6, 11]} +RLMATH_EOF diff --git a/tasks/construct-rlve-maximum-clique-l2-s5/tests/check.py b/tasks/construct-rlve-maximum-clique-l2-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..95e00c78f7c986ba3aecbdc8af3cf8ed221abd05 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s5/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("clique"), None, 0, n - 1, "clique") + if len(set(c)) != len(c): + raise Invalid("vertices must be distinct") + if len(c) < k: + raise Invalid(f"clique has {len(c)} vertices, need {k}") + es = {(min(u, v), max(u, v)) for u, v in inst["edges"]} + for i in range(len(c)): + for j in range(i + 1, len(c)): + if (min(c[i], c[j]), max(c[i], c[j])) not in es: + raise Invalid(f"{c[i]} and {c[j]} are not adjacent") + return None, {} diff --git a/tasks/construct-rlve-maximum-clique-l2-s5/tests/instance.json b/tasks/construct-rlve-maximum-clique-l2-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..012ba043f041f490ec725d19ec39e90593bd79d7 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 14, "k": 5, "edges": [[0, 1], [0, 3], [0, 4], [0, 5], [0, 6], [0, 8], [0, 10], [0, 11], [0, 12], [0, 13], [1, 4], [1, 9], [1, 12], [2, 5], [2, 8], [2, 9], [2, 10], [2, 11], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 11], [3, 12], [3, 13], [4, 6], [4, 7], [4, 9], [4, 11], [4, 13], [5, 6], [5, 13], [6, 8], [6, 9], [6, 11], [6, 13], [7, 9], [7, 10], [7, 11], [7, 13], [8, 10], [8, 13], [9, 11], [9, 12], [9, 13], [10, 11], [10, 13], [11, 12]], "family": "rlve_maximum_clique", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-maximum-clique-l2-s5/tests/run.py b/tasks/construct-rlve-maximum-clique-l2-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-maximum-clique-l2-s5/tests/test.sh b/tasks/construct-rlve-maximum-clique-l2-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-maximum-clique-l2-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s1/environment/Dockerfile b/tasks/construct-rlve-min-chromatic-number-l1-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l1-s1/environment/instance.json b/tasks/construct-rlve-min-chromatic-number-l1-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d9cc2346938281d25c232a29198b73bbc6d28207 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s1/environment/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 1], [0, 3], [1, 3], [2, 4], [2, 5], [3, 5]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s1/solution/solve.sh b/tasks/construct-rlve-min-chromatic-number-l1-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4cd1eb1077e39fdedb72c7ab0146f30023438165 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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, 1, 0, 2, 1, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s1/tests/check.py b/tasks/construct-rlve-min-chromatic-number-l1-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b77793fb15e0d97174b3c28e69a86e2a26996f --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s1/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s1/tests/instance.json b/tasks/construct-rlve-min-chromatic-number-l1-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..d9cc2346938281d25c232a29198b73bbc6d28207 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s1/tests/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 1], [0, 3], [1, 3], [2, 4], [2, 5], [3, 5]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s1/tests/run.py b/tasks/construct-rlve-min-chromatic-number-l1-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l1-s1/tests/test.sh b/tasks/construct-rlve-min-chromatic-number-l1-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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-min-chromatic-number-l1-s6/environment/Dockerfile b/tasks/construct-rlve-min-chromatic-number-l1-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s6/environment/instance.json b/tasks/construct-rlve-min-chromatic-number-l1-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..06916de6fdab9f08dacfa2e0bfca29ea18ea758e --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s6/environment/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 4, "edges": [[0, 3], [0, 4], [0, 5], [1, 2], [1, 5], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s6/solution/solve.sh b/tasks/construct-rlve-min-chromatic-number-l1-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1472fee40c7062b99c49548b0057dbdb00f764f1 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-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, 1, 0, 1, 2, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s6/tests/check.py b/tasks/construct-rlve-min-chromatic-number-l1-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b77793fb15e0d97174b3c28e69a86e2a26996f --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s6/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s6/tests/instance.json b/tasks/construct-rlve-min-chromatic-number-l1-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..06916de6fdab9f08dacfa2e0bfca29ea18ea758e --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s6/tests/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 4, "edges": [[0, 3], [0, 4], [0, 5], [1, 2], [1, 5], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s6/tests/run.py b/tasks/construct-rlve-min-chromatic-number-l1-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s6/tests/test.sh b/tasks/construct-rlve-min-chromatic-number-l1-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s8/environment/Dockerfile b/tasks/construct-rlve-min-chromatic-number-l1-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s8/environment/instance.json b/tasks/construct-rlve-min-chromatic-number-l1-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0351263054896c9775b1cba6492de07c523a0492 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s8/environment/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 1], [0, 3], [1, 3], [3, 4], [3, 5]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s8/solution/solve.sh b/tasks/construct-rlve-min-chromatic-number-l1-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..da40560d9187ab0875c9213e5899c016efd644d0 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 1, 0, 2, 0, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s8/tests/check.py b/tasks/construct-rlve-min-chromatic-number-l1-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b77793fb15e0d97174b3c28e69a86e2a26996f --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s8/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s8/tests/instance.json b/tasks/construct-rlve-min-chromatic-number-l1-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0351263054896c9775b1cba6492de07c523a0492 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s8/tests/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 1], [0, 3], [1, 3], [3, 4], [3, 5]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s8/tests/run.py b/tasks/construct-rlve-min-chromatic-number-l1-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-min-chromatic-number-l1-s8/tests/test.sh b/tasks/construct-rlve-min-chromatic-number-l1-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l1-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s0/environment/Dockerfile b/tasks/construct-rlve-min-chromatic-number-l5-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s0/environment/instance.json b/tasks/construct-rlve-min-chromatic-number-l5-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..75a194355b42b0e53c54ba6d322da5cb397513a0 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s0/environment/instance.json @@ -0,0 +1 @@ +{"n": 24, "k": 6, "edges": [[0, 2], [0, 6], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 16], [0, 17], [0, 20], [1, 4], [1, 6], [1, 8], [1, 14], [1, 17], [1, 19], [1, 20], [1, 21], [1, 23], [2, 3], [2, 5], [2, 9], [2, 10], [2, 13], [2, 19], [2, 20], [2, 22], [3, 4], [3, 7], [3, 10], [3, 11], [3, 14], [3, 15], [3, 16], [3, 17], [3, 20], [3, 23], [4, 7], [4, 10], [4, 15], [4, 16], [4, 18], [4, 21], [4, 22], [5, 11], [5, 14], [5, 15], [5, 16], [5, 22], [6, 9], [6, 11], [6, 12], [6, 13], [6, 17], [6, 20], [6, 21], [6, 23], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 19], [7, 21], [7, 22], [7, 23], [8, 9], [8, 11], [8, 12], [8, 14], [8, 15], [8, 19], [8, 20], [8, 21], [8, 22], [9, 10], [9, 13], [9, 20], [9, 21], [9, 23], [10, 11], [10, 14], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 23], [11, 13], [11, 15], [11, 16], [11, 17], [11, 20], [11, 22], [11, 23], [12, 13], [12, 14], [12, 15], [12, 19], [12, 21], [13, 14], [13, 15], [13, 17], [13, 20], [13, 21], [14, 22], [14, 23], [15, 20], [15, 21], [16, 18], [16, 19], [16, 23], [17, 19], [17, 20], [17, 21], [17, 22], [18, 19], [18, 20], [18, 21], [18, 22], [19, 21], [19, 22], [20, 21], [20, 23]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s0/solution/solve.sh b/tasks/construct-rlve-min-chromatic-number-l5-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..22b9cda05877c43e6d70e82a9d28b4738656c02f --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 1, 1, 0, 2, 2, 3, 4, 3, 5, 3, 1, 1, 2, 4, 5, 3, 5, 1, 2, 4, 0, 0, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s0/tests/check.py b/tasks/construct-rlve-min-chromatic-number-l5-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b77793fb15e0d97174b3c28e69a86e2a26996f --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s0/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s0/tests/instance.json b/tasks/construct-rlve-min-chromatic-number-l5-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..75a194355b42b0e53c54ba6d322da5cb397513a0 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s0/tests/instance.json @@ -0,0 +1 @@ +{"n": 24, "k": 6, "edges": [[0, 2], [0, 6], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 16], [0, 17], [0, 20], [1, 4], [1, 6], [1, 8], [1, 14], [1, 17], [1, 19], [1, 20], [1, 21], [1, 23], [2, 3], [2, 5], [2, 9], [2, 10], [2, 13], [2, 19], [2, 20], [2, 22], [3, 4], [3, 7], [3, 10], [3, 11], [3, 14], [3, 15], [3, 16], [3, 17], [3, 20], [3, 23], [4, 7], [4, 10], [4, 15], [4, 16], [4, 18], [4, 21], [4, 22], [5, 11], [5, 14], [5, 15], [5, 16], [5, 22], [6, 9], [6, 11], [6, 12], [6, 13], [6, 17], [6, 20], [6, 21], [6, 23], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 19], [7, 21], [7, 22], [7, 23], [8, 9], [8, 11], [8, 12], [8, 14], [8, 15], [8, 19], [8, 20], [8, 21], [8, 22], [9, 10], [9, 13], [9, 20], [9, 21], [9, 23], [10, 11], [10, 14], [10, 17], [10, 18], [10, 19], [10, 20], [10, 21], [10, 23], [11, 13], [11, 15], [11, 16], [11, 17], [11, 20], [11, 22], [11, 23], [12, 13], [12, 14], [12, 15], [12, 19], [12, 21], [13, 14], [13, 15], [13, 17], [13, 20], [13, 21], [14, 22], [14, 23], [15, 20], [15, 21], [16, 18], [16, 19], [16, 23], [17, 19], [17, 20], [17, 21], [17, 22], [18, 19], [18, 20], [18, 21], [18, 22], [19, 21], [19, 22], [20, 21], [20, 23]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s0/tests/run.py b/tasks/construct-rlve-min-chromatic-number-l5-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s0/tests/test.sh b/tasks/construct-rlve-min-chromatic-number-l5-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s7/environment/Dockerfile b/tasks/construct-rlve-min-chromatic-number-l5-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s7/environment/instance.json b/tasks/construct-rlve-min-chromatic-number-l5-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0b56010e5a7b0b521523cf4f8ca9acc9a852cfd9 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s7/environment/instance.json @@ -0,0 +1 @@ +{"n": 24, "k": 4, "edges": [[0, 8], [0, 11], [0, 12], [0, 14], [0, 17], [0, 18], [0, 19], [0, 22], [1, 7], [1, 9], [1, 10], [1, 15], [1, 18], [1, 20], [1, 21], [1, 23], [2, 3], [2, 5], [2, 7], [2, 9], [2, 11], [2, 12], [2, 14], [2, 23], [3, 7], [3, 9], [3, 10], [3, 13], [3, 22], [4, 6], [4, 9], [4, 14], [4, 19], [4, 20], [5, 9], [5, 10], [5, 11], [5, 14], [5, 16], [5, 17], [5, 21], [6, 7], [6, 10], [6, 11], [6, 14], [6, 16], [6, 21], [7, 8], [7, 9], [7, 12], [7, 15], [7, 16], [7, 17], [7, 19], [7, 21], [8, 9], [8, 10], [8, 18], [8, 20], [9, 10], [9, 15], [9, 16], [9, 18], [9, 22], [9, 23], [10, 16], [10, 22], [11, 14], [11, 16], [11, 18], [11, 22], [12, 13], [12, 16], [12, 18], [13, 19], [13, 20], [13, 21], [13, 22], [13, 23], [14, 19], [14, 21], [14, 22], [14, 23], [15, 16], [15, 18], [15, 19], [15, 21], [16, 18], [16, 19], [17, 21], [18, 20], [18, 21], [19, 22], [19, 23], [20, 22], [21, 22]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s7/solution/solve.sh b/tasks/construct-rlve-min-chromatic-number-l5-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..47b5f7bcafbd03cdbbbe069b40dcd369cbc5d723 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 1, 1, 0, 1, 0, 0, 2, 1, 3, 2, 3, 3, 2, 2, 0, 1, 1, 2, 3, 0, 3, 1, 0]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s7/tests/check.py b/tasks/construct-rlve-min-chromatic-number-l5-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..d2b77793fb15e0d97174b3c28e69a86e2a26996f --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s7/tests/check.py @@ -0,0 +1,10 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + return None, {} diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s7/tests/instance.json b/tasks/construct-rlve-min-chromatic-number-l5-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0b56010e5a7b0b521523cf4f8ca9acc9a852cfd9 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s7/tests/instance.json @@ -0,0 +1 @@ +{"n": 24, "k": 4, "edges": [[0, 8], [0, 11], [0, 12], [0, 14], [0, 17], [0, 18], [0, 19], [0, 22], [1, 7], [1, 9], [1, 10], [1, 15], [1, 18], [1, 20], [1, 21], [1, 23], [2, 3], [2, 5], [2, 7], [2, 9], [2, 11], [2, 12], [2, 14], [2, 23], [3, 7], [3, 9], [3, 10], [3, 13], [3, 22], [4, 6], [4, 9], [4, 14], [4, 19], [4, 20], [5, 9], [5, 10], [5, 11], [5, 14], [5, 16], [5, 17], [5, 21], [6, 7], [6, 10], [6, 11], [6, 14], [6, 16], [6, 21], [7, 8], [7, 9], [7, 12], [7, 15], [7, 16], [7, 17], [7, 19], [7, 21], [8, 9], [8, 10], [8, 18], [8, 20], [9, 10], [9, 15], [9, 16], [9, 18], [9, 22], [9, 23], [10, 16], [10, 22], [11, 14], [11, 16], [11, 18], [11, 22], [12, 13], [12, 16], [12, 18], [13, 19], [13, 20], [13, 21], [13, 22], [13, 23], [14, 19], [14, 21], [14, 22], [14, 23], [15, 16], [15, 18], [15, 19], [15, 21], [16, 18], [16, 19], [17, 21], [18, 20], [18, 21], [19, 22], [19, 23], [20, 22], [21, 22]], "family": "rlve_min_chromatic_number", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s7/tests/run.py b/tasks/construct-rlve-min-chromatic-number-l5-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-min-chromatic-number-l5-s7/tests/test.sh b/tasks/construct-rlve-min-chromatic-number-l5-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-chromatic-number-l5-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s2/environment/Dockerfile b/tasks/construct-rlve-min-harmonious-coloring-l1-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s2/environment/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l1-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0479fc2a0850b3a5be1dce3f8e6c59914cb6af4f --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 4, "edges": [[0, 3], [0, 4], [1, 2], [3, 5]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s2/solution/solve.sh b/tasks/construct-rlve-min-harmonious-coloring-l1-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..8ab349a1c68c936424b3b39ad53101d3040206c0 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 0, 1, 2, 3, 1]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s2/tests/check.py b/tasks/construct-rlve-min-harmonious-coloring-l1-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..91282a31c765b6103e6575180adb47abddb6a506 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s2/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + seen = set() + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + pair = (min(c[u], c[v]), max(c[u], c[v])) + if pair in seen: + raise Invalid(f"colour pair {pair} appears on two edges") + seen.add(pair) + return None, {} diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s2/tests/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l1-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0479fc2a0850b3a5be1dce3f8e6c59914cb6af4f --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 4, "edges": [[0, 3], [0, 4], [1, 2], [3, 5]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s2/tests/run.py b/tasks/construct-rlve-min-harmonious-coloring-l1-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s2/tests/test.sh b/tasks/construct-rlve-min-harmonious-coloring-l1-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s5/environment/Dockerfile b/tasks/construct-rlve-min-harmonious-coloring-l1-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s5/environment/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l1-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..30bd907963b78e4e514fe26bd62b11a79d2b0d23 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 3], [1, 2], [1, 5]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s5/solution/solve.sh b/tasks/construct-rlve-min-harmonious-coloring-l1-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ead7e7a713e7a4ae2602b9692d27ea21d0884640 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 1, 0, 2, 0, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s5/tests/check.py b/tasks/construct-rlve-min-harmonious-coloring-l1-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..91282a31c765b6103e6575180adb47abddb6a506 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s5/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + seen = set() + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + pair = (min(c[u], c[v]), max(c[u], c[v])) + if pair in seen: + raise Invalid(f"colour pair {pair} appears on two edges") + seen.add(pair) + return None, {} diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s5/tests/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l1-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..30bd907963b78e4e514fe26bd62b11a79d2b0d23 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 6, "k": 3, "edges": [[0, 3], [1, 2], [1, 5]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s5/tests/run.py b/tasks/construct-rlve-min-harmonious-coloring-l1-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-min-harmonious-coloring-l1-s5/tests/test.sh b/tasks/construct-rlve-min-harmonious-coloring-l1-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l1-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s4/environment/Dockerfile b/tasks/construct-rlve-min-harmonious-coloring-l5-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s4/environment/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l5-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..97c4d6f33b214371f51a57c215fe7c07a589bb97 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 15, "k": 8, "edges": [[0, 1], [0, 11], [1, 3], [1, 4], [1, 5], [1, 10], [2, 4], [2, 8], [2, 10], [2, 14], [3, 8], [3, 9], [3, 12], [4, 7], [5, 8], [5, 12], [6, 10], [6, 11], [7, 8], [7, 10], [9, 10]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s4/solution/solve.sh b/tasks/construct-rlve-min-harmonious-coloring-l5-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3543f942f012bb426181bd7ebccc6af6399ba192 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"colors": [0, 1, 0, 2, 3, 4, 2, 5, 6, 3, 7, 4, 5, 0, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s4/tests/check.py b/tasks/construct-rlve-min-harmonious-coloring-l5-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..91282a31c765b6103e6575180adb47abddb6a506 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s4/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n, k = inst["n"], inst["k"] + c = int_list(ans.get("colors"), n, 0, k - 1, "colors") + seen = set() + for u, v in inst["edges"]: + if c[u] == c[v]: + raise Invalid(f"edge ({u},{v}) is monochromatic") + pair = (min(c[u], c[v]), max(c[u], c[v])) + if pair in seen: + raise Invalid(f"colour pair {pair} appears on two edges") + seen.add(pair) + return None, {} diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s4/tests/instance.json b/tasks/construct-rlve-min-harmonious-coloring-l5-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..97c4d6f33b214371f51a57c215fe7c07a589bb97 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 15, "k": 8, "edges": [[0, 1], [0, 11], [1, 3], [1, 4], [1, 5], [1, 10], [2, 4], [2, 8], [2, 10], [2, 14], [3, 8], [3, 9], [3, 12], [4, 7], [5, 8], [5, 12], [6, 10], [6, 11], [7, 8], [7, 10], [9, 10]], "family": "rlve_min_harmonious_coloring", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s4/tests/run.py b/tasks/construct-rlve-min-harmonious-coloring-l5-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-l5-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-min-harmonious-coloring-l5-s4/tests/test.sh b/tasks/construct-rlve-min-harmonious-coloring-l5-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-min-harmonious-coloring-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-pairwise-sums-recovery-l3-s2/environment/Dockerfile b/tasks/construct-rlve-pairwise-sums-recovery-l3-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s2/environment/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l3-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..84c996992c4bbf5f32b845263babc6b398873b20 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s2/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "sums": [9, 17, 15, 13, 11, 17, 12, 22, 21, 10, 24, 18, 14, 19, 5, 12, 7, 11, 11, 14, 4, 18, 18, 15, 25, 8, 21, 15], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s2/solution/solve.sh b/tasks/construct-rlve-pairwise-sums-recovery-l3-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..4defe900ccd76c3c9e7bc1b7ab3b25696c1c328e --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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' +{"numbers": [1, 3, 4, 7, 8, 10, 11, 14]} +RLMATH_EOF diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s2/tests/check.py b/tasks/construct-rlve-pairwise-sums-recovery-l3-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..01b5b475e927688c0209fb93478a95f6dd1d3407 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s2/tests/check.py @@ -0,0 +1,14 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("numbers"), n, 1, None, "numbers") + if len(set(x)) != n: + raise Invalid("numbers must be distinct") + got = Counter(x[i] + x[j] for i in range(n) for j in range(i + 1, n)) + if got != Counter(inst["sums"]): + raise Invalid("pairwise sums do not match") + return None, {} diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s2/tests/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l3-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..84c996992c4bbf5f32b845263babc6b398873b20 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s2/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "sums": [9, 17, 15, 13, 11, 17, 12, 22, 21, 10, 24, 18, 14, 19, 5, 12, 7, 11, 11, 14, 4, 18, 18, 15, 25, 8, 21, 15], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s2/tests/run.py b/tasks/construct-rlve-pairwise-sums-recovery-l3-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s2/tests/test.sh b/tasks/construct-rlve-pairwise-sums-recovery-l3-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s5/environment/Dockerfile b/tasks/construct-rlve-pairwise-sums-recovery-l3-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s5/environment/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l3-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..eec4c0a4ada0188c9848fbc65fc1a35e37a04f28 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s5/environment/instance.json @@ -0,0 +1 @@ +{"n": 8, "sums": [22, 11, 21, 12, 18, 15, 17, 12, 21, 13, 23, 5, 25, 20, 15, 16, 19, 22, 10, 14, 9, 14, 18, 8, 19, 16, 11, 15], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s5/solution/solve.sh b/tasks/construct-rlve-pairwise-sums-recovery-l3-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9b02d41757768eec36b31a36111daa26f34006e9 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-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' +{"numbers": [2, 3, 6, 8, 9, 10, 12, 13]} +RLMATH_EOF diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s5/tests/check.py b/tasks/construct-rlve-pairwise-sums-recovery-l3-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..01b5b475e927688c0209fb93478a95f6dd1d3407 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s5/tests/check.py @@ -0,0 +1,14 @@ +from collections import Counter + +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + x = int_list(ans.get("numbers"), n, 1, None, "numbers") + if len(set(x)) != n: + raise Invalid("numbers must be distinct") + got = Counter(x[i] + x[j] for i in range(n) for j in range(i + 1, n)) + if got != Counter(inst["sums"]): + raise Invalid("pairwise sums do not match") + return None, {} diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s5/tests/instance.json b/tasks/construct-rlve-pairwise-sums-recovery-l3-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..eec4c0a4ada0188c9848fbc65fc1a35e37a04f28 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s5/tests/instance.json @@ -0,0 +1 @@ +{"n": 8, "sums": [22, 11, 21, 12, 18, 15, 17, 12, 21, 13, 23, 5, 25, 20, 15, 16, 19, 22, 10, 14, 9, 14, 18, 8, 19, 16, 11, 15], "family": "rlve_pairwise_sums_recovery", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s5/tests/run.py b/tasks/construct-rlve-pairwise-sums-recovery-l3-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-pairwise-sums-recovery-l3-s5/tests/test.sh b/tasks/construct-rlve-pairwise-sums-recovery-l3-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pairwise-sums-recovery-l3-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s0/environment/Dockerfile b/tasks/construct-rlve-pan-solar-panels-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l2-s0/environment/instance.json b/tasks/construct-rlve-pan-solar-panels-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b89e920ffbeac68c56854a93d907efdca9148565 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"A": 53, "B": 242, "C": 267, "D": 634, "target": 242, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s0/solution/solve.sh b/tasks/construct-rlve-pan-solar-panels-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0facbb47eedbbfa72c68c5c4b07ba769de3ee6a1 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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": 242, "Y": 484} +RLMATH_EOF diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s0/tests/check.py b/tasks/construct-rlve-pan-solar-panels-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8bb2e7cc0b0280ab877755cc5d97b510680f7aa3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s0/tests/check.py @@ -0,0 +1,12 @@ +import math + +from run import Invalid, as_int + + +def check(inst, ans): + X = as_int(ans.get("X"), "X", lo=inst["A"], hi=inst["B"]) + Y = as_int(ans.get("Y"), "Y", lo=inst["C"], hi=inst["D"]) + g = math.gcd(X, Y) + if g < inst["target"]: + raise Invalid(f"gcd(X, Y) = {g} < {inst['target']}") + return None, {"gcd": g} diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s0/tests/instance.json b/tasks/construct-rlve-pan-solar-panels-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b89e920ffbeac68c56854a93d907efdca9148565 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"A": 53, "B": 242, "C": 267, "D": 634, "target": 242, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s0/tests/run.py b/tasks/construct-rlve-pan-solar-panels-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l2-s0/tests/test.sh b/tasks/construct-rlve-pan-solar-panels-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l2-s7/environment/Dockerfile b/tasks/construct-rlve-pan-solar-panels-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l2-s7/environment/instance.json b/tasks/construct-rlve-pan-solar-panels-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fba8064101867f12125f432d80c963cb689cb75f --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"A": 6, "B": 23, "C": 220, "D": 579, "target": 23, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s7/solution/solve.sh b/tasks/construct-rlve-pan-solar-panels-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..9819d125f88221a0576cababb1f4003bd938d6b3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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' +{"X": 23, "Y": 575} +RLMATH_EOF diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s7/tests/check.py b/tasks/construct-rlve-pan-solar-panels-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8bb2e7cc0b0280ab877755cc5d97b510680f7aa3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s7/tests/check.py @@ -0,0 +1,12 @@ +import math + +from run import Invalid, as_int + + +def check(inst, ans): + X = as_int(ans.get("X"), "X", lo=inst["A"], hi=inst["B"]) + Y = as_int(ans.get("Y"), "Y", lo=inst["C"], hi=inst["D"]) + g = math.gcd(X, Y) + if g < inst["target"]: + raise Invalid(f"gcd(X, Y) = {g} < {inst['target']}") + return None, {"gcd": g} diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s7/tests/instance.json b/tasks/construct-rlve-pan-solar-panels-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..fba8064101867f12125f432d80c963cb689cb75f --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"A": 6, "B": 23, "C": 220, "D": 579, "target": 23, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l2-s7/tests/run.py b/tasks/construct-rlve-pan-solar-panels-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l2-s7/tests/test.sh b/tasks/construct-rlve-pan-solar-panels-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l6-s1/environment/Dockerfile b/tasks/construct-rlve-pan-solar-panels-l6-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l6-s1/environment/instance.json b/tasks/construct-rlve-pan-solar-panels-l6-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bd066df3ec525b75d9e4b096de365c408175f2a3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s1/environment/instance.json @@ -0,0 +1 @@ +{"A": 9915828182, "B": 23618272831, "C": 64936631330, "D": 98483709841, "target": 23618272831, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s1/solution/solve.sh b/tasks/construct-rlve-pan-solar-panels-l6-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d68b9c363441af5a510cbe34006a2526b08c4971 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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": 23618272831, "Y": 94473091324} +RLMATH_EOF diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s1/tests/check.py b/tasks/construct-rlve-pan-solar-panels-l6-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8bb2e7cc0b0280ab877755cc5d97b510680f7aa3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s1/tests/check.py @@ -0,0 +1,12 @@ +import math + +from run import Invalid, as_int + + +def check(inst, ans): + X = as_int(ans.get("X"), "X", lo=inst["A"], hi=inst["B"]) + Y = as_int(ans.get("Y"), "Y", lo=inst["C"], hi=inst["D"]) + g = math.gcd(X, Y) + if g < inst["target"]: + raise Invalid(f"gcd(X, Y) = {g} < {inst['target']}") + return None, {"gcd": g} diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s1/tests/instance.json b/tasks/construct-rlve-pan-solar-panels-l6-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bd066df3ec525b75d9e4b096de365c408175f2a3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s1/tests/instance.json @@ -0,0 +1 @@ +{"A": 9915828182, "B": 23618272831, "C": 64936631330, "D": 98483709841, "target": 23618272831, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s1/tests/run.py b/tasks/construct-rlve-pan-solar-panels-l6-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l6-s1/tests/test.sh b/tasks/construct-rlve-pan-solar-panels-l6-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l6-s8/environment/Dockerfile b/tasks/construct-rlve-pan-solar-panels-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l6-s8/environment/instance.json b/tasks/construct-rlve-pan-solar-panels-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2ceca1427c3218b627420e1b1df08e0a45f2cce4 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"A": 54697587910, "B": 64922233593, "C": 7490625801, "D": 54198831201, "target": 32461116796, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s8/solution/solve.sh b/tasks/construct-rlve-pan-solar-panels-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..5669570ebb40ff4db3f444f2c2371eabb840a43b --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"X": 64922233592, "Y": 32461116796} +RLMATH_EOF diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s8/tests/check.py b/tasks/construct-rlve-pan-solar-panels-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..8bb2e7cc0b0280ab877755cc5d97b510680f7aa3 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s8/tests/check.py @@ -0,0 +1,12 @@ +import math + +from run import Invalid, as_int + + +def check(inst, ans): + X = as_int(ans.get("X"), "X", lo=inst["A"], hi=inst["B"]) + Y = as_int(ans.get("Y"), "Y", lo=inst["C"], hi=inst["D"]) + g = math.gcd(X, Y) + if g < inst["target"]: + raise Invalid(f"gcd(X, Y) = {g} < {inst['target']}") + return None, {"gcd": g} diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s8/tests/instance.json b/tasks/construct-rlve-pan-solar-panels-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2ceca1427c3218b627420e1b1df08e0a45f2cce4 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"A": 54697587910, "B": 64922233593, "C": 7490625801, "D": 54198831201, "target": 32461116796, "family": "rlve_pan_solar_panels", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-pan-solar-panels-l6-s8/tests/run.py b/tasks/construct-rlve-pan-solar-panels-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-pan-solar-panels-l6-s8/tests/test.sh b/tasks/construct-rlve-pan-solar-panels-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-pan-solar-panels-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-polynomial-global-minimum-l3-s4/environment/Dockerfile b/tasks/construct-rlve-polynomial-global-minimum-l3-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s4/environment/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l3-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..99280ac4978c57fec1f3ecd88b81689c193c905b --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s4/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [3, 14, 31, 40, 31, 12, 2], "fmin": "0.297571300705168110536450164339969018404943177", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s4/solution/solve.sh b/tasks/construct-rlve-polynomial-global-minimum-l3-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c9fc72035049a8306cbe2530ccaff8c15420cf7f --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"x0": -0.607497107756472} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s4/tests/check.py b/tasks/construct-rlve-polynomial-global-minimum-l3-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3be068f4391ad0838c29a4f7d521b8072cf39991 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s4/tests/check.py @@ -0,0 +1,19 @@ +from fractions import Fraction + +from run import Invalid, num + + +def check(inst, ans): + x0 = Fraction(num(ans.get("x0"), "x0")) + if abs(x0) > 10 ** 6: + raise Invalid("x0 out of range") + v = Fraction(0) + for a in reversed(inst["coeffs"]): + v = v * x0 + a + fmin = Fraction(inst["fmin"]) + tol = Fraction(1, 10 ** 9) * max(Fraction(1), abs(fmin)) + if v > fmin + tol: + raise Invalid(f"f(x0) = {float(v)} is above the global minimum {float(fmin)}") + if v < fmin - tol: # cannot happen for a correct f_min; guards against a bad instance + raise Invalid("internal: f(x0) below recorded minimum") + return None, {"f_x0": float(v)} diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s4/tests/instance.json b/tasks/construct-rlve-polynomial-global-minimum-l3-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..99280ac4978c57fec1f3ecd88b81689c193c905b --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s4/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [3, 14, 31, 40, 31, 12, 2], "fmin": "0.297571300705168110536450164339969018404943177", "family": "rlve_polynomial_global_minimum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s4/tests/run.py b/tasks/construct-rlve-polynomial-global-minimum-l3-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-polynomial-global-minimum-l3-s4/tests/test.sh b/tasks/construct-rlve-polynomial-global-minimum-l3-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-global-minimum-l3-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s1/environment/Dockerfile b/tasks/construct-rlve-polynomial-integer-roots-l4-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-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-polynomial-integer-roots-l4-s1/environment/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l4-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..08d0c593a79d0a6caa8efb7f0709c276c1ba4a9b --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s1/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [-434649600, 322176960, 209263936, -55765748, -40332612, -2461927, 1555355, 231549, -13609, -4213, -111, 19, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s1/solution/solve.sh b/tasks/construct-rlve-polynomial-integer-roots-l4-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6c8215606d83a54a412288ae706249506c7adf5f --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-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' +{"roots": [-11, -8, -7, -7, -5, -5, -4, 1, 2, 6, 7, 12]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s1/tests/check.py b/tasks/construct-rlve-polynomial-integer-roots-l4-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2d30553cb884c5e03c8afe73ef652efc483ab791 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s1/tests/check.py @@ -0,0 +1,20 @@ +from run import Invalid, int_list + + +def check(inst, ans): + c = inst["coeffs"] # c[i] = coefficient of x^i, monic of degree len(c) - 1 + n = len(c) - 1 + r = int_list(ans.get("roots"), n, name="roots") + bound = 1 + max(abs(v) for v in c) # Cauchy bound on roots + if any(abs(a) > bound for a in r): # any integer root divides the constant term / is bounded by max|c_i| + raise Invalid("root out of range") + prod = [1] + for a in r: # multiply by (x - a) + nxt = [0] * (len(prod) + 1) + for i, v in enumerate(prod): + nxt[i + 1] += v + nxt[i] -= a * v + prod = nxt + if prod != c: + raise Invalid("the product does not expand to P(x)") + return None, {} diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s1/tests/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l4-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..08d0c593a79d0a6caa8efb7f0709c276c1ba4a9b --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s1/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [-434649600, 322176960, 209263936, -55765748, -40332612, -2461927, 1555355, 231549, -13609, -4213, -111, 19, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s1/tests/run.py b/tasks/construct-rlve-polynomial-integer-roots-l4-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-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-polynomial-integer-roots-l4-s1/tests/test.sh b/tasks/construct-rlve-polynomial-integer-roots-l4-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-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-polynomial-integer-roots-l4-s8/environment/Dockerfile b/tasks/construct-rlve-polynomial-integer-roots-l4-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-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-polynomial-integer-roots-l4-s8/environment/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l4-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..34e3ec1cac27194d1c1f9fbc9fbb2cfc2ead7481 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s8/environment/instance.json @@ -0,0 +1 @@ +{"coeffs": [1128960000, -162624000, -1231740800, 174284640, 106063912, -11936684, -3332294, 278701, 49537, -2666, -356, 9, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s8/solution/solve.sh b/tasks/construct-rlve-polynomial-integer-roots-l4-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..361a2828e34776f780dad8c4b104f0ef3875c2e7 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-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' +{"roots": [-12, -12, -10, -8, -5, -1, 1, 4, 7, 7, 10, 10]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s8/tests/check.py b/tasks/construct-rlve-polynomial-integer-roots-l4-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..2d30553cb884c5e03c8afe73ef652efc483ab791 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s8/tests/check.py @@ -0,0 +1,20 @@ +from run import Invalid, int_list + + +def check(inst, ans): + c = inst["coeffs"] # c[i] = coefficient of x^i, monic of degree len(c) - 1 + n = len(c) - 1 + r = int_list(ans.get("roots"), n, name="roots") + bound = 1 + max(abs(v) for v in c) # Cauchy bound on roots + if any(abs(a) > bound for a in r): # any integer root divides the constant term / is bounded by max|c_i| + raise Invalid("root out of range") + prod = [1] + for a in r: # multiply by (x - a) + nxt = [0] * (len(prod) + 1) + for i, v in enumerate(prod): + nxt[i + 1] += v + nxt[i] -= a * v + prod = nxt + if prod != c: + raise Invalid("the product does not expand to P(x)") + return None, {} diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s8/tests/instance.json b/tasks/construct-rlve-polynomial-integer-roots-l4-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..34e3ec1cac27194d1c1f9fbc9fbb2cfc2ead7481 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-l4-s8/tests/instance.json @@ -0,0 +1 @@ +{"coeffs": [1128960000, -162624000, -1231740800, 174284640, 106063912, -11936684, -3332294, 278701, 49537, -2666, -356, 9, 1], "family": "rlve_polynomial_integer_roots", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-integer-roots-l4-s8/tests/run.py b/tasks/construct-rlve-polynomial-integer-roots-l4-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-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-polynomial-integer-roots-l4-s8/tests/test.sh b/tasks/construct-rlve-polynomial-integer-roots-l4-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-integer-roots-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-polynomial-interpolation-l3-s1/environment/Dockerfile b/tasks/construct-rlve-polynomial-interpolation-l3-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-polynomial-interpolation-l3-s1/environment/instance.json b/tasks/construct-rlve-polynomial-interpolation-l3-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b50e9f2b2b098eada31a4782c4c3238d0877db88 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s1/environment/instance.json @@ -0,0 +1 @@ +{"X": [0, -4, -5, 6, -2, 1, 3], "Y": [0, 11392, 44275, 151272, 136, 7, 2691], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s1/solution/solve.sh b/tasks/construct-rlve-polynomial-interpolation-l3-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ed217c20727ad22502e55168604c6bf6ea112c4e --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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' +{"coeffs": [0, 0, -4, 5, 2, 1, 3]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s1/tests/check.py b/tasks/construct-rlve-polynomial-interpolation-l3-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f05264e3fd4584db7cb3768800e4a2497564b4f5 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s1/tests/check.py @@ -0,0 +1,13 @@ +from run import Invalid, int_list + + +def check(inst, ans): + X, Y = inst["X"], inst["Y"] + c = int_list(ans.get("coeffs"), len(X), name="coeffs") + for x, y in zip(X, Y): + v = 0 + for a in reversed(c): + v = v * x + a + if v != y: + raise Invalid(f"f({x}) = {v}, need {y}") + return None, {} diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s1/tests/instance.json b/tasks/construct-rlve-polynomial-interpolation-l3-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b50e9f2b2b098eada31a4782c4c3238d0877db88 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s1/tests/instance.json @@ -0,0 +1 @@ +{"X": [0, -4, -5, 6, -2, 1, 3], "Y": [0, 11392, 44275, 151272, 136, 7, 2691], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s1/tests/run.py b/tasks/construct-rlve-polynomial-interpolation-l3-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-polynomial-interpolation-l3-s1/tests/test.sh b/tasks/construct-rlve-polynomial-interpolation-l3-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-polynomial-interpolation-l3-s6/environment/Dockerfile b/tasks/construct-rlve-polynomial-interpolation-l3-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-polynomial-interpolation-l3-s6/environment/instance.json b/tasks/construct-rlve-polynomial-interpolation-l3-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0727700adbca5e30a97e7b31d786794ae0d952c1 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s6/environment/instance.json @@ -0,0 +1 @@ +{"X": [-1, 4, 1, -2, 5, -3, 2], "Y": [-6, 13294, 10, -26, 46818, 274, 294], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s6/solution/solve.sh b/tasks/construct-rlve-polynomial-interpolation-l3-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c9b8498a901af0dd5d6ef1fdb9b57378ef065e6c --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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' +{"coeffs": [-2, 4, 2, -1, 0, 5, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s6/tests/check.py b/tasks/construct-rlve-polynomial-interpolation-l3-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f05264e3fd4584db7cb3768800e4a2497564b4f5 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s6/tests/check.py @@ -0,0 +1,13 @@ +from run import Invalid, int_list + + +def check(inst, ans): + X, Y = inst["X"], inst["Y"] + c = int_list(ans.get("coeffs"), len(X), name="coeffs") + for x, y in zip(X, Y): + v = 0 + for a in reversed(c): + v = v * x + a + if v != y: + raise Invalid(f"f({x}) = {v}, need {y}") + return None, {} diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s6/tests/instance.json b/tasks/construct-rlve-polynomial-interpolation-l3-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..0727700adbca5e30a97e7b31d786794ae0d952c1 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s6/tests/instance.json @@ -0,0 +1 @@ +{"X": [-1, 4, 1, -2, 5, -3, 2], "Y": [-6, 13294, 10, -26, 46818, 274, 294], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s6/tests/run.py b/tasks/construct-rlve-polynomial-interpolation-l3-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-polynomial-interpolation-l3-s6/tests/test.sh b/tasks/construct-rlve-polynomial-interpolation-l3-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-polynomial-interpolation-l3-s8/environment/Dockerfile b/tasks/construct-rlve-polynomial-interpolation-l3-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-polynomial-interpolation-l3-s8/environment/instance.json b/tasks/construct-rlve-polynomial-interpolation-l3-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a1b34f727b04609003a0e1589d1d3af2fe917f67 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s8/environment/instance.json @@ -0,0 +1 @@ +{"X": [2, -5, -1, -2, -4, -6, 4], "Y": [139, 93120, 4, 459, 25339, 270859, 15099], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s8/solution/solve.sh b/tasks/construct-rlve-polynomial-interpolation-l3-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..573f0226b41608f689cd402c694a3d2f1b885eee --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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' +{"coeffs": [-5, 0, 0, 0, -1, -5, 5]} +RLMATH_EOF diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s8/tests/check.py b/tasks/construct-rlve-polynomial-interpolation-l3-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..f05264e3fd4584db7cb3768800e4a2497564b4f5 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s8/tests/check.py @@ -0,0 +1,13 @@ +from run import Invalid, int_list + + +def check(inst, ans): + X, Y = inst["X"], inst["Y"] + c = int_list(ans.get("coeffs"), len(X), name="coeffs") + for x, y in zip(X, Y): + v = 0 + for a in reversed(c): + v = v * x + a + if v != y: + raise Invalid(f"f({x}) = {v}, need {y}") + return None, {} diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s8/tests/instance.json b/tasks/construct-rlve-polynomial-interpolation-l3-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a1b34f727b04609003a0e1589d1d3af2fe917f67 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-l3-s8/tests/instance.json @@ -0,0 +1 @@ +{"X": [2, -5, -1, -2, -4, -6, 4], "Y": [139, 93120, 4, 459, 25339, 270859, 15099], "family": "rlve_polynomial_interpolation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-polynomial-interpolation-l3-s8/tests/run.py b/tasks/construct-rlve-polynomial-interpolation-l3-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-polynomial-interpolation-l3-s8/tests/test.sh b/tasks/construct-rlve-polynomial-interpolation-l3-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-polynomial-interpolation-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-prefix-product-permutation-l3-s3/environment/Dockerfile b/tasks/construct-rlve-prefix-product-permutation-l3-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s3/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s3/environment/instance.json b/tasks/construct-rlve-prefix-product-permutation-l3-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..eee2950e7156cde49d11f2f6fbe7e3dbc7a8cda0 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 229, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s3/solution/solve.sh b/tasks/construct-rlve-prefix-product-permutation-l3-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..acd9febb32d5fe09d3895b70e6b955ea1b8eecfa --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-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' +{"perm": [1, 2, 116, 154, 173, 47, 192, 132, 87, 52, 24, 126, 211, 142, 181, 169, 44, 28, 141, 218, 127, 121, 178, 11, 106, 56, 186, 18, 91, 80, 85, 134, 137, 119, 129, 73, 71, 131, 224, 48, 64, 163, 61, 17, 204, 57, 6, 40, 168, 216, 143, 10, 208, 122, 124, 26, 46, 226, 155, 67, 43, 215, 182, 41, 69, 75, 60, 189, 65, 157, 37, 101, 36, 161, 66, 172, 227, 117, 139, 30, 147, 83, 82, 150, 31, 98, 9, 180, 217, 212, 29, 152, 118, 198, 135, 136, 199, 86, 223, 193, 72, 196, 120, 210, 219, 25, 176, 123, 177, 209, 128, 197, 138, 153, 228, 3, 78, 93, 34, 103, 22, 54, 108, 55, 206, 12, 21, 111, 35, 159, 38, 8, 145, 32, 95, 96, 33, 113, 79, 202, 19, 14, 51, 222, 133, 200, 81, 149, 148, 84, 201, 92, 114, 4, 59, 165, 70, 195, 130, 194, 74, 166, 42, 171, 156, 162, 190, 49, 16, 188, 164, 76, 5, 185, 205, 107, 109, 23, 221, 88, 15, 63, 191, 225, 174, 27, 214, 170, 68, 167, 183, 7, 100, 160, 158, 102, 112, 94, 97, 146, 151, 140, 213, 45, 175, 125, 220, 53, 110, 104, 13, 90, 203, 187, 62, 50, 89, 20, 105, 207, 179, 144, 99, 39, 184, 58, 77, 115, 229]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s3/tests/check.py b/tasks/construct-rlve-prefix-product-permutation-l3-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3d93850acd79cc0f8fff05cdbb0c63aabc484815 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s3/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 1 + for v in p: + acc = acc * v % n + if acc in seen: + raise Invalid(f"prefix product residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s3/tests/instance.json b/tasks/construct-rlve-prefix-product-permutation-l3-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..eee2950e7156cde49d11f2f6fbe7e3dbc7a8cda0 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 229, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s3/tests/run.py b/tasks/construct-rlve-prefix-product-permutation-l3-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s3/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s3/tests/test.sh b/tasks/construct-rlve-prefix-product-permutation-l3-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s3/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s4/environment/Dockerfile b/tasks/construct-rlve-prefix-product-permutation-l3-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s4/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s4/environment/instance.json b/tasks/construct-rlve-prefix-product-permutation-l3-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5ed59f4a152cbefa26597c1d629fd7eaa982f79a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 149, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s4/solution/solve.sh b/tasks/construct-rlve-prefix-product-permutation-l3-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..c5abdfcf250ba9362f7d0ae8a7d68137a14d141e --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s4/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"perm": [1, 2, 76, 51, 113, 31, 26, 65, 57, 117, 16, 123, 88, 24, 33, 11, 29, 115, 59, 103, 83, 72, 62, 14, 119, 7, 87, 139, 17, 37, 6, 126, 15, 141, 58, 133, 30, 146, 52, 108, 42, 41, 111, 53, 106, 54, 82, 131, 60, 74, 4, 39, 44, 46, 70, 85, 9, 35, 19, 49, 78, 23, 138, 124, 8, 95, 71, 130, 104, 55, 67, 22, 90, 50, 148, 3, 101, 61, 129, 84, 96, 47, 21, 80, 56, 143, 27, 13, 128, 73, 102, 132, 116, 142, 66, 81, 105, 107, 112, 147, 77, 91, 20, 69, 97, 45, 98, 40, 110, 109, 43, 99, 5, 121, 18, 93, 10, 136, 25, 145, 114, 134, 12, 64, 144, 32, 137, 89, 79, 68, 48, 92, 36, 122, 140, 118, 127, 63, 28, 135, 34, 94, 86, 125, 120, 38, 100, 75, 149]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s4/tests/check.py b/tasks/construct-rlve-prefix-product-permutation-l3-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..3d93850acd79cc0f8fff05cdbb0c63aabc484815 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s4/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 1 + for v in p: + acc = acc * v % n + if acc in seen: + raise Invalid(f"prefix product residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s4/tests/instance.json b/tasks/construct-rlve-prefix-product-permutation-l3-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5ed59f4a152cbefa26597c1d629fd7eaa982f79a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 149, "family": "rlve_prefix_product_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s4/tests/run.py b/tasks/construct-rlve-prefix-product-permutation-l3-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s4/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-prefix-product-permutation-l3-s4/tests/test.sh b/tasks/construct-rlve-prefix-product-permutation-l3-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-product-permutation-l3-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s3/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l6-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l6-s3/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l6-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ef5492b01b3be47bb8205d31471b980125937b24 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s3/environment/instance.json @@ -0,0 +1 @@ +{"n": 26738, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s3/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l6-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..cbefb7e951f378cb00ef4e283c7d3cf68cde4f63 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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' +{"perm": [26738, 1, 26736, 3, 26734, 5, 26732, 7, 26730, 9, 26728, 11, 26726, 13, 26724, 15, 26722, 17, 26720, 19, 26718, 21, 26716, 23, 26714, 25, 26712, 27, 26710, 29, 26708, 31, 26706, 33, 26704, 35, 26702, 37, 26700, 39, 26698, 41, 26696, 43, 26694, 45, 26692, 47, 26690, 49, 26688, 51, 26686, 53, 26684, 55, 26682, 57, 26680, 59, 26678, 61, 26676, 63, 26674, 65, 26672, 67, 26670, 69, 26668, 71, 26666, 73, 26664, 75, 26662, 77, 26660, 79, 26658, 81, 26656, 83, 26654, 85, 26652, 87, 26650, 89, 26648, 91, 26646, 93, 26644, 95, 26642, 97, 26640, 99, 26638, 101, 26636, 103, 26634, 105, 26632, 107, 26630, 109, 26628, 111, 26626, 113, 26624, 115, 26622, 117, 26620, 119, 26618, 121, 26616, 123, 26614, 125, 26612, 127, 26610, 129, 26608, 131, 26606, 133, 26604, 135, 26602, 137, 26600, 139, 26598, 141, 26596, 143, 26594, 145, 26592, 147, 26590, 149, 26588, 151, 26586, 153, 26584, 155, 26582, 157, 26580, 159, 26578, 161, 26576, 163, 26574, 165, 26572, 167, 26570, 169, 26568, 171, 26566, 173, 26564, 175, 26562, 177, 26560, 179, 26558, 181, 26556, 183, 26554, 185, 26552, 187, 26550, 189, 26548, 191, 26546, 193, 26544, 195, 26542, 197, 26540, 199, 26538, 201, 26536, 203, 26534, 205, 26532, 207, 26530, 209, 26528, 211, 26526, 213, 26524, 215, 26522, 217, 26520, 219, 26518, 221, 26516, 223, 26514, 225, 26512, 227, 26510, 229, 26508, 231, 26506, 233, 26504, 235, 26502, 237, 26500, 239, 26498, 241, 26496, 243, 26494, 245, 26492, 247, 26490, 249, 26488, 251, 26486, 253, 26484, 255, 26482, 257, 26480, 259, 26478, 261, 26476, 263, 26474, 265, 26472, 267, 26470, 269, 26468, 271, 26466, 273, 26464, 275, 26462, 277, 26460, 279, 26458, 281, 26456, 283, 26454, 285, 26452, 287, 26450, 289, 26448, 291, 26446, 293, 26444, 295, 26442, 297, 26440, 299, 26438, 301, 26436, 303, 26434, 305, 26432, 307, 26430, 309, 26428, 311, 26426, 313, 26424, 315, 26422, 317, 26420, 319, 26418, 321, 26416, 323, 26414, 325, 26412, 327, 26410, 329, 26408, 331, 26406, 333, 26404, 335, 26402, 337, 26400, 339, 26398, 341, 26396, 343, 26394, 345, 26392, 347, 26390, 349, 26388, 351, 26386, 353, 26384, 355, 26382, 357, 26380, 359, 26378, 361, 26376, 363, 26374, 365, 26372, 367, 26370, 369, 26368, 371, 26366, 373, 26364, 375, 26362, 377, 26360, 379, 26358, 381, 26356, 383, 26354, 385, 26352, 387, 26350, 389, 26348, 391, 26346, 393, 26344, 395, 26342, 397, 26340, 399, 26338, 401, 26336, 403, 26334, 405, 26332, 407, 26330, 409, 26328, 411, 26326, 413, 26324, 415, 26322, 417, 26320, 419, 26318, 421, 26316, 423, 26314, 425, 26312, 427, 26310, 429, 26308, 431, 26306, 433, 26304, 435, 26302, 437, 26300, 439, 26298, 441, 26296, 443, 26294, 445, 26292, 447, 26290, 449, 26288, 451, 26286, 453, 26284, 455, 26282, 457, 26280, 459, 26278, 461, 26276, 463, 26274, 465, 26272, 467, 26270, 469, 26268, 471, 26266, 473, 26264, 475, 26262, 477, 26260, 479, 26258, 481, 26256, 483, 26254, 485, 26252, 487, 26250, 489, 26248, 491, 26246, 493, 26244, 495, 26242, 497, 26240, 499, 26238, 501, 26236, 503, 26234, 505, 26232, 507, 26230, 509, 26228, 511, 26226, 513, 26224, 515, 26222, 517, 26220, 519, 26218, 521, 26216, 523, 26214, 525, 26212, 527, 26210, 529, 26208, 531, 26206, 533, 26204, 535, 26202, 537, 26200, 539, 26198, 541, 26196, 543, 26194, 545, 26192, 547, 26190, 549, 26188, 551, 26186, 553, 26184, 555, 26182, 557, 26180, 559, 26178, 561, 26176, 563, 26174, 565, 26172, 567, 26170, 569, 26168, 571, 26166, 573, 26164, 575, 26162, 577, 26160, 579, 26158, 581, 26156, 583, 26154, 585, 26152, 587, 26150, 589, 26148, 591, 26146, 593, 26144, 595, 26142, 597, 26140, 599, 26138, 601, 26136, 603, 26134, 605, 26132, 607, 26130, 609, 26128, 611, 26126, 613, 26124, 615, 26122, 617, 26120, 619, 26118, 621, 26116, 623, 26114, 625, 26112, 627, 26110, 629, 26108, 631, 26106, 633, 26104, 635, 26102, 637, 26100, 639, 26098, 641, 26096, 643, 26094, 645, 26092, 647, 26090, 649, 26088, 651, 26086, 653, 26084, 655, 26082, 657, 26080, 659, 26078, 661, 26076, 663, 26074, 665, 26072, 667, 26070, 669, 26068, 671, 26066, 673, 26064, 675, 26062, 677, 26060, 679, 26058, 681, 26056, 683, 26054, 685, 26052, 687, 26050, 689, 26048, 691, 26046, 693, 26044, 695, 26042, 697, 26040, 699, 26038, 701, 26036, 703, 26034, 705, 26032, 707, 26030, 709, 26028, 711, 26026, 713, 26024, 715, 26022, 717, 26020, 719, 26018, 721, 26016, 723, 26014, 725, 26012, 727, 26010, 729, 26008, 731, 26006, 733, 26004, 735, 26002, 737, 26000, 739, 25998, 741, 25996, 743, 25994, 745, 25992, 747, 25990, 749, 25988, 751, 25986, 753, 25984, 755, 25982, 757, 25980, 759, 25978, 761, 25976, 763, 25974, 765, 25972, 767, 25970, 769, 25968, 771, 25966, 773, 25964, 775, 25962, 777, 25960, 779, 25958, 781, 25956, 783, 25954, 785, 25952, 787, 25950, 789, 25948, 791, 25946, 793, 25944, 795, 25942, 797, 25940, 799, 25938, 801, 25936, 803, 25934, 805, 25932, 807, 25930, 809, 25928, 811, 25926, 813, 25924, 815, 25922, 817, 25920, 819, 25918, 821, 25916, 823, 25914, 825, 25912, 827, 25910, 829, 25908, 831, 25906, 833, 25904, 835, 25902, 837, 25900, 839, 25898, 841, 25896, 843, 25894, 845, 25892, 847, 25890, 849, 25888, 851, 25886, 853, 25884, 855, 25882, 857, 25880, 859, 25878, 861, 25876, 863, 25874, 865, 25872, 867, 25870, 869, 25868, 871, 25866, 873, 25864, 875, 25862, 877, 25860, 879, 25858, 881, 25856, 883, 25854, 885, 25852, 887, 25850, 889, 25848, 891, 25846, 893, 25844, 895, 25842, 897, 25840, 899, 25838, 901, 25836, 903, 25834, 905, 25832, 907, 25830, 909, 25828, 911, 25826, 913, 25824, 915, 25822, 917, 25820, 919, 25818, 921, 25816, 923, 25814, 925, 25812, 927, 25810, 929, 25808, 931, 25806, 933, 25804, 935, 25802, 937, 25800, 939, 25798, 941, 25796, 943, 25794, 945, 25792, 947, 25790, 949, 25788, 951, 25786, 953, 25784, 955, 25782, 957, 25780, 959, 25778, 961, 25776, 963, 25774, 965, 25772, 967, 25770, 969, 25768, 971, 25766, 973, 25764, 975, 25762, 977, 25760, 979, 25758, 981, 25756, 983, 25754, 985, 25752, 987, 25750, 989, 25748, 991, 25746, 993, 25744, 995, 25742, 997, 25740, 999, 25738, 1001, 25736, 1003, 25734, 1005, 25732, 1007, 25730, 1009, 25728, 1011, 25726, 1013, 25724, 1015, 25722, 1017, 25720, 1019, 25718, 1021, 25716, 1023, 25714, 1025, 25712, 1027, 25710, 1029, 25708, 1031, 25706, 1033, 25704, 1035, 25702, 1037, 25700, 1039, 25698, 1041, 25696, 1043, 25694, 1045, 25692, 1047, 25690, 1049, 25688, 1051, 25686, 1053, 25684, 1055, 25682, 1057, 25680, 1059, 25678, 1061, 25676, 1063, 25674, 1065, 25672, 1067, 25670, 1069, 25668, 1071, 25666, 1073, 25664, 1075, 25662, 1077, 25660, 1079, 25658, 1081, 25656, 1083, 25654, 1085, 25652, 1087, 25650, 1089, 25648, 1091, 25646, 1093, 25644, 1095, 25642, 1097, 25640, 1099, 25638, 1101, 25636, 1103, 25634, 1105, 25632, 1107, 25630, 1109, 25628, 1111, 25626, 1113, 25624, 1115, 25622, 1117, 25620, 1119, 25618, 1121, 25616, 1123, 25614, 1125, 25612, 1127, 25610, 1129, 25608, 1131, 25606, 1133, 25604, 1135, 25602, 1137, 25600, 1139, 25598, 1141, 25596, 1143, 25594, 1145, 25592, 1147, 25590, 1149, 25588, 1151, 25586, 1153, 25584, 1155, 25582, 1157, 25580, 1159, 25578, 1161, 25576, 1163, 25574, 1165, 25572, 1167, 25570, 1169, 25568, 1171, 25566, 1173, 25564, 1175, 25562, 1177, 25560, 1179, 25558, 1181, 25556, 1183, 25554, 1185, 25552, 1187, 25550, 1189, 25548, 1191, 25546, 1193, 25544, 1195, 25542, 1197, 25540, 1199, 25538, 1201, 25536, 1203, 25534, 1205, 25532, 1207, 25530, 1209, 25528, 1211, 25526, 1213, 25524, 1215, 25522, 1217, 25520, 1219, 25518, 1221, 25516, 1223, 25514, 1225, 25512, 1227, 25510, 1229, 25508, 1231, 25506, 1233, 25504, 1235, 25502, 1237, 25500, 1239, 25498, 1241, 25496, 1243, 25494, 1245, 25492, 1247, 25490, 1249, 25488, 1251, 25486, 1253, 25484, 1255, 25482, 1257, 25480, 1259, 25478, 1261, 25476, 1263, 25474, 1265, 25472, 1267, 25470, 1269, 25468, 1271, 25466, 1273, 25464, 1275, 25462, 1277, 25460, 1279, 25458, 1281, 25456, 1283, 25454, 1285, 25452, 1287, 25450, 1289, 25448, 1291, 25446, 1293, 25444, 1295, 25442, 1297, 25440, 1299, 25438, 1301, 25436, 1303, 25434, 1305, 25432, 1307, 25430, 1309, 25428, 1311, 25426, 1313, 25424, 1315, 25422, 1317, 25420, 1319, 25418, 1321, 25416, 1323, 25414, 1325, 25412, 1327, 25410, 1329, 25408, 1331, 25406, 1333, 25404, 1335, 25402, 1337, 25400, 1339, 25398, 1341, 25396, 1343, 25394, 1345, 25392, 1347, 25390, 1349, 25388, 1351, 25386, 1353, 25384, 1355, 25382, 1357, 25380, 1359, 25378, 1361, 25376, 1363, 25374, 1365, 25372, 1367, 25370, 1369, 25368, 1371, 25366, 1373, 25364, 1375, 25362, 1377, 25360, 1379, 25358, 1381, 25356, 1383, 25354, 1385, 25352, 1387, 25350, 1389, 25348, 1391, 25346, 1393, 25344, 1395, 25342, 1397, 25340, 1399, 25338, 1401, 25336, 1403, 25334, 1405, 25332, 1407, 25330, 1409, 25328, 1411, 25326, 1413, 25324, 1415, 25322, 1417, 25320, 1419, 25318, 1421, 25316, 1423, 25314, 1425, 25312, 1427, 25310, 1429, 25308, 1431, 25306, 1433, 25304, 1435, 25302, 1437, 25300, 1439, 25298, 1441, 25296, 1443, 25294, 1445, 25292, 1447, 25290, 1449, 25288, 1451, 25286, 1453, 25284, 1455, 25282, 1457, 25280, 1459, 25278, 1461, 25276, 1463, 25274, 1465, 25272, 1467, 25270, 1469, 25268, 1471, 25266, 1473, 25264, 1475, 25262, 1477, 25260, 1479, 25258, 1481, 25256, 1483, 25254, 1485, 25252, 1487, 25250, 1489, 25248, 1491, 25246, 1493, 25244, 1495, 25242, 1497, 25240, 1499, 25238, 1501, 25236, 1503, 25234, 1505, 25232, 1507, 25230, 1509, 25228, 1511, 25226, 1513, 25224, 1515, 25222, 1517, 25220, 1519, 25218, 1521, 25216, 1523, 25214, 1525, 25212, 1527, 25210, 1529, 25208, 1531, 25206, 1533, 25204, 1535, 25202, 1537, 25200, 1539, 25198, 1541, 25196, 1543, 25194, 1545, 25192, 1547, 25190, 1549, 25188, 1551, 25186, 1553, 25184, 1555, 25182, 1557, 25180, 1559, 25178, 1561, 25176, 1563, 25174, 1565, 25172, 1567, 25170, 1569, 25168, 1571, 25166, 1573, 25164, 1575, 25162, 1577, 25160, 1579, 25158, 1581, 25156, 1583, 25154, 1585, 25152, 1587, 25150, 1589, 25148, 1591, 25146, 1593, 25144, 1595, 25142, 1597, 25140, 1599, 25138, 1601, 25136, 1603, 25134, 1605, 25132, 1607, 25130, 1609, 25128, 1611, 25126, 1613, 25124, 1615, 25122, 1617, 25120, 1619, 25118, 1621, 25116, 1623, 25114, 1625, 25112, 1627, 25110, 1629, 25108, 1631, 25106, 1633, 25104, 1635, 25102, 1637, 25100, 1639, 25098, 1641, 25096, 1643, 25094, 1645, 25092, 1647, 25090, 1649, 25088, 1651, 25086, 1653, 25084, 1655, 25082, 1657, 25080, 1659, 25078, 1661, 25076, 1663, 25074, 1665, 25072, 1667, 25070, 1669, 25068, 1671, 25066, 1673, 25064, 1675, 25062, 1677, 25060, 1679, 25058, 1681, 25056, 1683, 25054, 1685, 25052, 1687, 25050, 1689, 25048, 1691, 25046, 1693, 25044, 1695, 25042, 1697, 25040, 1699, 25038, 1701, 25036, 1703, 25034, 1705, 25032, 1707, 25030, 1709, 25028, 1711, 25026, 1713, 25024, 1715, 25022, 1717, 25020, 1719, 25018, 1721, 25016, 1723, 25014, 1725, 25012, 1727, 25010, 1729, 25008, 1731, 25006, 1733, 25004, 1735, 25002, 1737, 25000, 1739, 24998, 1741, 24996, 1743, 24994, 1745, 24992, 1747, 24990, 1749, 24988, 1751, 24986, 1753, 24984, 1755, 24982, 1757, 24980, 1759, 24978, 1761, 24976, 1763, 24974, 1765, 24972, 1767, 24970, 1769, 24968, 1771, 24966, 1773, 24964, 1775, 24962, 1777, 24960, 1779, 24958, 1781, 24956, 1783, 24954, 1785, 24952, 1787, 24950, 1789, 24948, 1791, 24946, 1793, 24944, 1795, 24942, 1797, 24940, 1799, 24938, 1801, 24936, 1803, 24934, 1805, 24932, 1807, 24930, 1809, 24928, 1811, 24926, 1813, 24924, 1815, 24922, 1817, 24920, 1819, 24918, 1821, 24916, 1823, 24914, 1825, 24912, 1827, 24910, 1829, 24908, 1831, 24906, 1833, 24904, 1835, 24902, 1837, 24900, 1839, 24898, 1841, 24896, 1843, 24894, 1845, 24892, 1847, 24890, 1849, 24888, 1851, 24886, 1853, 24884, 1855, 24882, 1857, 24880, 1859, 24878, 1861, 24876, 1863, 24874, 1865, 24872, 1867, 24870, 1869, 24868, 1871, 24866, 1873, 24864, 1875, 24862, 1877, 24860, 1879, 24858, 1881, 24856, 1883, 24854, 1885, 24852, 1887, 24850, 1889, 24848, 1891, 24846, 1893, 24844, 1895, 24842, 1897, 24840, 1899, 24838, 1901, 24836, 1903, 24834, 1905, 24832, 1907, 24830, 1909, 24828, 1911, 24826, 1913, 24824, 1915, 24822, 1917, 24820, 1919, 24818, 1921, 24816, 1923, 24814, 1925, 24812, 1927, 24810, 1929, 24808, 1931, 24806, 1933, 24804, 1935, 24802, 1937, 24800, 1939, 24798, 1941, 24796, 1943, 24794, 1945, 24792, 1947, 24790, 1949, 24788, 1951, 24786, 1953, 24784, 1955, 24782, 1957, 24780, 1959, 24778, 1961, 24776, 1963, 24774, 1965, 24772, 1967, 24770, 1969, 24768, 1971, 24766, 1973, 24764, 1975, 24762, 1977, 24760, 1979, 24758, 1981, 24756, 1983, 24754, 1985, 24752, 1987, 24750, 1989, 24748, 1991, 24746, 1993, 24744, 1995, 24742, 1997, 24740, 1999, 24738, 2001, 24736, 2003, 24734, 2005, 24732, 2007, 24730, 2009, 24728, 2011, 24726, 2013, 24724, 2015, 24722, 2017, 24720, 2019, 24718, 2021, 24716, 2023, 24714, 2025, 24712, 2027, 24710, 2029, 24708, 2031, 24706, 2033, 24704, 2035, 24702, 2037, 24700, 2039, 24698, 2041, 24696, 2043, 24694, 2045, 24692, 2047, 24690, 2049, 24688, 2051, 24686, 2053, 24684, 2055, 24682, 2057, 24680, 2059, 24678, 2061, 24676, 2063, 24674, 2065, 24672, 2067, 24670, 2069, 24668, 2071, 24666, 2073, 24664, 2075, 24662, 2077, 24660, 2079, 24658, 2081, 24656, 2083, 24654, 2085, 24652, 2087, 24650, 2089, 24648, 2091, 24646, 2093, 24644, 2095, 24642, 2097, 24640, 2099, 24638, 2101, 24636, 2103, 24634, 2105, 24632, 2107, 24630, 2109, 24628, 2111, 24626, 2113, 24624, 2115, 24622, 2117, 24620, 2119, 24618, 2121, 24616, 2123, 24614, 2125, 24612, 2127, 24610, 2129, 24608, 2131, 24606, 2133, 24604, 2135, 24602, 2137, 24600, 2139, 24598, 2141, 24596, 2143, 24594, 2145, 24592, 2147, 24590, 2149, 24588, 2151, 24586, 2153, 24584, 2155, 24582, 2157, 24580, 2159, 24578, 2161, 24576, 2163, 24574, 2165, 24572, 2167, 24570, 2169, 24568, 2171, 24566, 2173, 24564, 2175, 24562, 2177, 24560, 2179, 24558, 2181, 24556, 2183, 24554, 2185, 24552, 2187, 24550, 2189, 24548, 2191, 24546, 2193, 24544, 2195, 24542, 2197, 24540, 2199, 24538, 2201, 24536, 2203, 24534, 2205, 24532, 2207, 24530, 2209, 24528, 2211, 24526, 2213, 24524, 2215, 24522, 2217, 24520, 2219, 24518, 2221, 24516, 2223, 24514, 2225, 24512, 2227, 24510, 2229, 24508, 2231, 24506, 2233, 24504, 2235, 24502, 2237, 24500, 2239, 24498, 2241, 24496, 2243, 24494, 2245, 24492, 2247, 24490, 2249, 24488, 2251, 24486, 2253, 24484, 2255, 24482, 2257, 24480, 2259, 24478, 2261, 24476, 2263, 24474, 2265, 24472, 2267, 24470, 2269, 24468, 2271, 24466, 2273, 24464, 2275, 24462, 2277, 24460, 2279, 24458, 2281, 24456, 2283, 24454, 2285, 24452, 2287, 24450, 2289, 24448, 2291, 24446, 2293, 24444, 2295, 24442, 2297, 24440, 2299, 24438, 2301, 24436, 2303, 24434, 2305, 24432, 2307, 24430, 2309, 24428, 2311, 24426, 2313, 24424, 2315, 24422, 2317, 24420, 2319, 24418, 2321, 24416, 2323, 24414, 2325, 24412, 2327, 24410, 2329, 24408, 2331, 24406, 2333, 24404, 2335, 24402, 2337, 24400, 2339, 24398, 2341, 24396, 2343, 24394, 2345, 24392, 2347, 24390, 2349, 24388, 2351, 24386, 2353, 24384, 2355, 24382, 2357, 24380, 2359, 24378, 2361, 24376, 2363, 24374, 2365, 24372, 2367, 24370, 2369, 24368, 2371, 24366, 2373, 24364, 2375, 24362, 2377, 24360, 2379, 24358, 2381, 24356, 2383, 24354, 2385, 24352, 2387, 24350, 2389, 24348, 2391, 24346, 2393, 24344, 2395, 24342, 2397, 24340, 2399, 24338, 2401, 24336, 2403, 24334, 2405, 24332, 2407, 24330, 2409, 24328, 2411, 24326, 2413, 24324, 2415, 24322, 2417, 24320, 2419, 24318, 2421, 24316, 2423, 24314, 2425, 24312, 2427, 24310, 2429, 24308, 2431, 24306, 2433, 24304, 2435, 24302, 2437, 24300, 2439, 24298, 2441, 24296, 2443, 24294, 2445, 24292, 2447, 24290, 2449, 24288, 2451, 24286, 2453, 24284, 2455, 24282, 2457, 24280, 2459, 24278, 2461, 24276, 2463, 24274, 2465, 24272, 2467, 24270, 2469, 24268, 2471, 24266, 2473, 24264, 2475, 24262, 2477, 24260, 2479, 24258, 2481, 24256, 2483, 24254, 2485, 24252, 2487, 24250, 2489, 24248, 2491, 24246, 2493, 24244, 2495, 24242, 2497, 24240, 2499, 24238, 2501, 24236, 2503, 24234, 2505, 24232, 2507, 24230, 2509, 24228, 2511, 24226, 2513, 24224, 2515, 24222, 2517, 24220, 2519, 24218, 2521, 24216, 2523, 24214, 2525, 24212, 2527, 24210, 2529, 24208, 2531, 24206, 2533, 24204, 2535, 24202, 2537, 24200, 2539, 24198, 2541, 24196, 2543, 24194, 2545, 24192, 2547, 24190, 2549, 24188, 2551, 24186, 2553, 24184, 2555, 24182, 2557, 24180, 2559, 24178, 2561, 24176, 2563, 24174, 2565, 24172, 2567, 24170, 2569, 24168, 2571, 24166, 2573, 24164, 2575, 24162, 2577, 24160, 2579, 24158, 2581, 24156, 2583, 24154, 2585, 24152, 2587, 24150, 2589, 24148, 2591, 24146, 2593, 24144, 2595, 24142, 2597, 24140, 2599, 24138, 2601, 24136, 2603, 24134, 2605, 24132, 2607, 24130, 2609, 24128, 2611, 24126, 2613, 24124, 2615, 24122, 2617, 24120, 2619, 24118, 2621, 24116, 2623, 24114, 2625, 24112, 2627, 24110, 2629, 24108, 2631, 24106, 2633, 24104, 2635, 24102, 2637, 24100, 2639, 24098, 2641, 24096, 2643, 24094, 2645, 24092, 2647, 24090, 2649, 24088, 2651, 24086, 2653, 24084, 2655, 24082, 2657, 24080, 2659, 24078, 2661, 24076, 2663, 24074, 2665, 24072, 2667, 24070, 2669, 24068, 2671, 24066, 2673, 24064, 2675, 24062, 2677, 24060, 2679, 24058, 2681, 24056, 2683, 24054, 2685, 24052, 2687, 24050, 2689, 24048, 2691, 24046, 2693, 24044, 2695, 24042, 2697, 24040, 2699, 24038, 2701, 24036, 2703, 24034, 2705, 24032, 2707, 24030, 2709, 24028, 2711, 24026, 2713, 24024, 2715, 24022, 2717, 24020, 2719, 24018, 2721, 24016, 2723, 24014, 2725, 24012, 2727, 24010, 2729, 24008, 2731, 24006, 2733, 24004, 2735, 24002, 2737, 24000, 2739, 23998, 2741, 23996, 2743, 23994, 2745, 23992, 2747, 23990, 2749, 23988, 2751, 23986, 2753, 23984, 2755, 23982, 2757, 23980, 2759, 23978, 2761, 23976, 2763, 23974, 2765, 23972, 2767, 23970, 2769, 23968, 2771, 23966, 2773, 23964, 2775, 23962, 2777, 23960, 2779, 23958, 2781, 23956, 2783, 23954, 2785, 23952, 2787, 23950, 2789, 23948, 2791, 23946, 2793, 23944, 2795, 23942, 2797, 23940, 2799, 23938, 2801, 23936, 2803, 23934, 2805, 23932, 2807, 23930, 2809, 23928, 2811, 23926, 2813, 23924, 2815, 23922, 2817, 23920, 2819, 23918, 2821, 23916, 2823, 23914, 2825, 23912, 2827, 23910, 2829, 23908, 2831, 23906, 2833, 23904, 2835, 23902, 2837, 23900, 2839, 23898, 2841, 23896, 2843, 23894, 2845, 23892, 2847, 23890, 2849, 23888, 2851, 23886, 2853, 23884, 2855, 23882, 2857, 23880, 2859, 23878, 2861, 23876, 2863, 23874, 2865, 23872, 2867, 23870, 2869, 23868, 2871, 23866, 2873, 23864, 2875, 23862, 2877, 23860, 2879, 23858, 2881, 23856, 2883, 23854, 2885, 23852, 2887, 23850, 2889, 23848, 2891, 23846, 2893, 23844, 2895, 23842, 2897, 23840, 2899, 23838, 2901, 23836, 2903, 23834, 2905, 23832, 2907, 23830, 2909, 23828, 2911, 23826, 2913, 23824, 2915, 23822, 2917, 23820, 2919, 23818, 2921, 23816, 2923, 23814, 2925, 23812, 2927, 23810, 2929, 23808, 2931, 23806, 2933, 23804, 2935, 23802, 2937, 23800, 2939, 23798, 2941, 23796, 2943, 23794, 2945, 23792, 2947, 23790, 2949, 23788, 2951, 23786, 2953, 23784, 2955, 23782, 2957, 23780, 2959, 23778, 2961, 23776, 2963, 23774, 2965, 23772, 2967, 23770, 2969, 23768, 2971, 23766, 2973, 23764, 2975, 23762, 2977, 23760, 2979, 23758, 2981, 23756, 2983, 23754, 2985, 23752, 2987, 23750, 2989, 23748, 2991, 23746, 2993, 23744, 2995, 23742, 2997, 23740, 2999, 23738, 3001, 23736, 3003, 23734, 3005, 23732, 3007, 23730, 3009, 23728, 3011, 23726, 3013, 23724, 3015, 23722, 3017, 23720, 3019, 23718, 3021, 23716, 3023, 23714, 3025, 23712, 3027, 23710, 3029, 23708, 3031, 23706, 3033, 23704, 3035, 23702, 3037, 23700, 3039, 23698, 3041, 23696, 3043, 23694, 3045, 23692, 3047, 23690, 3049, 23688, 3051, 23686, 3053, 23684, 3055, 23682, 3057, 23680, 3059, 23678, 3061, 23676, 3063, 23674, 3065, 23672, 3067, 23670, 3069, 23668, 3071, 23666, 3073, 23664, 3075, 23662, 3077, 23660, 3079, 23658, 3081, 23656, 3083, 23654, 3085, 23652, 3087, 23650, 3089, 23648, 3091, 23646, 3093, 23644, 3095, 23642, 3097, 23640, 3099, 23638, 3101, 23636, 3103, 23634, 3105, 23632, 3107, 23630, 3109, 23628, 3111, 23626, 3113, 23624, 3115, 23622, 3117, 23620, 3119, 23618, 3121, 23616, 3123, 23614, 3125, 23612, 3127, 23610, 3129, 23608, 3131, 23606, 3133, 23604, 3135, 23602, 3137, 23600, 3139, 23598, 3141, 23596, 3143, 23594, 3145, 23592, 3147, 23590, 3149, 23588, 3151, 23586, 3153, 23584, 3155, 23582, 3157, 23580, 3159, 23578, 3161, 23576, 3163, 23574, 3165, 23572, 3167, 23570, 3169, 23568, 3171, 23566, 3173, 23564, 3175, 23562, 3177, 23560, 3179, 23558, 3181, 23556, 3183, 23554, 3185, 23552, 3187, 23550, 3189, 23548, 3191, 23546, 3193, 23544, 3195, 23542, 3197, 23540, 3199, 23538, 3201, 23536, 3203, 23534, 3205, 23532, 3207, 23530, 3209, 23528, 3211, 23526, 3213, 23524, 3215, 23522, 3217, 23520, 3219, 23518, 3221, 23516, 3223, 23514, 3225, 23512, 3227, 23510, 3229, 23508, 3231, 23506, 3233, 23504, 3235, 23502, 3237, 23500, 3239, 23498, 3241, 23496, 3243, 23494, 3245, 23492, 3247, 23490, 3249, 23488, 3251, 23486, 3253, 23484, 3255, 23482, 3257, 23480, 3259, 23478, 3261, 23476, 3263, 23474, 3265, 23472, 3267, 23470, 3269, 23468, 3271, 23466, 3273, 23464, 3275, 23462, 3277, 23460, 3279, 23458, 3281, 23456, 3283, 23454, 3285, 23452, 3287, 23450, 3289, 23448, 3291, 23446, 3293, 23444, 3295, 23442, 3297, 23440, 3299, 23438, 3301, 23436, 3303, 23434, 3305, 23432, 3307, 23430, 3309, 23428, 3311, 23426, 3313, 23424, 3315, 23422, 3317, 23420, 3319, 23418, 3321, 23416, 3323, 23414, 3325, 23412, 3327, 23410, 3329, 23408, 3331, 23406, 3333, 23404, 3335, 23402, 3337, 23400, 3339, 23398, 3341, 23396, 3343, 23394, 3345, 23392, 3347, 23390, 3349, 23388, 3351, 23386, 3353, 23384, 3355, 23382, 3357, 23380, 3359, 23378, 3361, 23376, 3363, 23374, 3365, 23372, 3367, 23370, 3369, 23368, 3371, 23366, 3373, 23364, 3375, 23362, 3377, 23360, 3379, 23358, 3381, 23356, 3383, 23354, 3385, 23352, 3387, 23350, 3389, 23348, 3391, 23346, 3393, 23344, 3395, 23342, 3397, 23340, 3399, 23338, 3401, 23336, 3403, 23334, 3405, 23332, 3407, 23330, 3409, 23328, 3411, 23326, 3413, 23324, 3415, 23322, 3417, 23320, 3419, 23318, 3421, 23316, 3423, 23314, 3425, 23312, 3427, 23310, 3429, 23308, 3431, 23306, 3433, 23304, 3435, 23302, 3437, 23300, 3439, 23298, 3441, 23296, 3443, 23294, 3445, 23292, 3447, 23290, 3449, 23288, 3451, 23286, 3453, 23284, 3455, 23282, 3457, 23280, 3459, 23278, 3461, 23276, 3463, 23274, 3465, 23272, 3467, 23270, 3469, 23268, 3471, 23266, 3473, 23264, 3475, 23262, 3477, 23260, 3479, 23258, 3481, 23256, 3483, 23254, 3485, 23252, 3487, 23250, 3489, 23248, 3491, 23246, 3493, 23244, 3495, 23242, 3497, 23240, 3499, 23238, 3501, 23236, 3503, 23234, 3505, 23232, 3507, 23230, 3509, 23228, 3511, 23226, 3513, 23224, 3515, 23222, 3517, 23220, 3519, 23218, 3521, 23216, 3523, 23214, 3525, 23212, 3527, 23210, 3529, 23208, 3531, 23206, 3533, 23204, 3535, 23202, 3537, 23200, 3539, 23198, 3541, 23196, 3543, 23194, 3545, 23192, 3547, 23190, 3549, 23188, 3551, 23186, 3553, 23184, 3555, 23182, 3557, 23180, 3559, 23178, 3561, 23176, 3563, 23174, 3565, 23172, 3567, 23170, 3569, 23168, 3571, 23166, 3573, 23164, 3575, 23162, 3577, 23160, 3579, 23158, 3581, 23156, 3583, 23154, 3585, 23152, 3587, 23150, 3589, 23148, 3591, 23146, 3593, 23144, 3595, 23142, 3597, 23140, 3599, 23138, 3601, 23136, 3603, 23134, 3605, 23132, 3607, 23130, 3609, 23128, 3611, 23126, 3613, 23124, 3615, 23122, 3617, 23120, 3619, 23118, 3621, 23116, 3623, 23114, 3625, 23112, 3627, 23110, 3629, 23108, 3631, 23106, 3633, 23104, 3635, 23102, 3637, 23100, 3639, 23098, 3641, 23096, 3643, 23094, 3645, 23092, 3647, 23090, 3649, 23088, 3651, 23086, 3653, 23084, 3655, 23082, 3657, 23080, 3659, 23078, 3661, 23076, 3663, 23074, 3665, 23072, 3667, 23070, 3669, 23068, 3671, 23066, 3673, 23064, 3675, 23062, 3677, 23060, 3679, 23058, 3681, 23056, 3683, 23054, 3685, 23052, 3687, 23050, 3689, 23048, 3691, 23046, 3693, 23044, 3695, 23042, 3697, 23040, 3699, 23038, 3701, 23036, 3703, 23034, 3705, 23032, 3707, 23030, 3709, 23028, 3711, 23026, 3713, 23024, 3715, 23022, 3717, 23020, 3719, 23018, 3721, 23016, 3723, 23014, 3725, 23012, 3727, 23010, 3729, 23008, 3731, 23006, 3733, 23004, 3735, 23002, 3737, 23000, 3739, 22998, 3741, 22996, 3743, 22994, 3745, 22992, 3747, 22990, 3749, 22988, 3751, 22986, 3753, 22984, 3755, 22982, 3757, 22980, 3759, 22978, 3761, 22976, 3763, 22974, 3765, 22972, 3767, 22970, 3769, 22968, 3771, 22966, 3773, 22964, 3775, 22962, 3777, 22960, 3779, 22958, 3781, 22956, 3783, 22954, 3785, 22952, 3787, 22950, 3789, 22948, 3791, 22946, 3793, 22944, 3795, 22942, 3797, 22940, 3799, 22938, 3801, 22936, 3803, 22934, 3805, 22932, 3807, 22930, 3809, 22928, 3811, 22926, 3813, 22924, 3815, 22922, 3817, 22920, 3819, 22918, 3821, 22916, 3823, 22914, 3825, 22912, 3827, 22910, 3829, 22908, 3831, 22906, 3833, 22904, 3835, 22902, 3837, 22900, 3839, 22898, 3841, 22896, 3843, 22894, 3845, 22892, 3847, 22890, 3849, 22888, 3851, 22886, 3853, 22884, 3855, 22882, 3857, 22880, 3859, 22878, 3861, 22876, 3863, 22874, 3865, 22872, 3867, 22870, 3869, 22868, 3871, 22866, 3873, 22864, 3875, 22862, 3877, 22860, 3879, 22858, 3881, 22856, 3883, 22854, 3885, 22852, 3887, 22850, 3889, 22848, 3891, 22846, 3893, 22844, 3895, 22842, 3897, 22840, 3899, 22838, 3901, 22836, 3903, 22834, 3905, 22832, 3907, 22830, 3909, 22828, 3911, 22826, 3913, 22824, 3915, 22822, 3917, 22820, 3919, 22818, 3921, 22816, 3923, 22814, 3925, 22812, 3927, 22810, 3929, 22808, 3931, 22806, 3933, 22804, 3935, 22802, 3937, 22800, 3939, 22798, 3941, 22796, 3943, 22794, 3945, 22792, 3947, 22790, 3949, 22788, 3951, 22786, 3953, 22784, 3955, 22782, 3957, 22780, 3959, 22778, 3961, 22776, 3963, 22774, 3965, 22772, 3967, 22770, 3969, 22768, 3971, 22766, 3973, 22764, 3975, 22762, 3977, 22760, 3979, 22758, 3981, 22756, 3983, 22754, 3985, 22752, 3987, 22750, 3989, 22748, 3991, 22746, 3993, 22744, 3995, 22742, 3997, 22740, 3999, 22738, 4001, 22736, 4003, 22734, 4005, 22732, 4007, 22730, 4009, 22728, 4011, 22726, 4013, 22724, 4015, 22722, 4017, 22720, 4019, 22718, 4021, 22716, 4023, 22714, 4025, 22712, 4027, 22710, 4029, 22708, 4031, 22706, 4033, 22704, 4035, 22702, 4037, 22700, 4039, 22698, 4041, 22696, 4043, 22694, 4045, 22692, 4047, 22690, 4049, 22688, 4051, 22686, 4053, 22684, 4055, 22682, 4057, 22680, 4059, 22678, 4061, 22676, 4063, 22674, 4065, 22672, 4067, 22670, 4069, 22668, 4071, 22666, 4073, 22664, 4075, 22662, 4077, 22660, 4079, 22658, 4081, 22656, 4083, 22654, 4085, 22652, 4087, 22650, 4089, 22648, 4091, 22646, 4093, 22644, 4095, 22642, 4097, 22640, 4099, 22638, 4101, 22636, 4103, 22634, 4105, 22632, 4107, 22630, 4109, 22628, 4111, 22626, 4113, 22624, 4115, 22622, 4117, 22620, 4119, 22618, 4121, 22616, 4123, 22614, 4125, 22612, 4127, 22610, 4129, 22608, 4131, 22606, 4133, 22604, 4135, 22602, 4137, 22600, 4139, 22598, 4141, 22596, 4143, 22594, 4145, 22592, 4147, 22590, 4149, 22588, 4151, 22586, 4153, 22584, 4155, 22582, 4157, 22580, 4159, 22578, 4161, 22576, 4163, 22574, 4165, 22572, 4167, 22570, 4169, 22568, 4171, 22566, 4173, 22564, 4175, 22562, 4177, 22560, 4179, 22558, 4181, 22556, 4183, 22554, 4185, 22552, 4187, 22550, 4189, 22548, 4191, 22546, 4193, 22544, 4195, 22542, 4197, 22540, 4199, 22538, 4201, 22536, 4203, 22534, 4205, 22532, 4207, 22530, 4209, 22528, 4211, 22526, 4213, 22524, 4215, 22522, 4217, 22520, 4219, 22518, 4221, 22516, 4223, 22514, 4225, 22512, 4227, 22510, 4229, 22508, 4231, 22506, 4233, 22504, 4235, 22502, 4237, 22500, 4239, 22498, 4241, 22496, 4243, 22494, 4245, 22492, 4247, 22490, 4249, 22488, 4251, 22486, 4253, 22484, 4255, 22482, 4257, 22480, 4259, 22478, 4261, 22476, 4263, 22474, 4265, 22472, 4267, 22470, 4269, 22468, 4271, 22466, 4273, 22464, 4275, 22462, 4277, 22460, 4279, 22458, 4281, 22456, 4283, 22454, 4285, 22452, 4287, 22450, 4289, 22448, 4291, 22446, 4293, 22444, 4295, 22442, 4297, 22440, 4299, 22438, 4301, 22436, 4303, 22434, 4305, 22432, 4307, 22430, 4309, 22428, 4311, 22426, 4313, 22424, 4315, 22422, 4317, 22420, 4319, 22418, 4321, 22416, 4323, 22414, 4325, 22412, 4327, 22410, 4329, 22408, 4331, 22406, 4333, 22404, 4335, 22402, 4337, 22400, 4339, 22398, 4341, 22396, 4343, 22394, 4345, 22392, 4347, 22390, 4349, 22388, 4351, 22386, 4353, 22384, 4355, 22382, 4357, 22380, 4359, 22378, 4361, 22376, 4363, 22374, 4365, 22372, 4367, 22370, 4369, 22368, 4371, 22366, 4373, 22364, 4375, 22362, 4377, 22360, 4379, 22358, 4381, 22356, 4383, 22354, 4385, 22352, 4387, 22350, 4389, 22348, 4391, 22346, 4393, 22344, 4395, 22342, 4397, 22340, 4399, 22338, 4401, 22336, 4403, 22334, 4405, 22332, 4407, 22330, 4409, 22328, 4411, 22326, 4413, 22324, 4415, 22322, 4417, 22320, 4419, 22318, 4421, 22316, 4423, 22314, 4425, 22312, 4427, 22310, 4429, 22308, 4431, 22306, 4433, 22304, 4435, 22302, 4437, 22300, 4439, 22298, 4441, 22296, 4443, 22294, 4445, 22292, 4447, 22290, 4449, 22288, 4451, 22286, 4453, 22284, 4455, 22282, 4457, 22280, 4459, 22278, 4461, 22276, 4463, 22274, 4465, 22272, 4467, 22270, 4469, 22268, 4471, 22266, 4473, 22264, 4475, 22262, 4477, 22260, 4479, 22258, 4481, 22256, 4483, 22254, 4485, 22252, 4487, 22250, 4489, 22248, 4491, 22246, 4493, 22244, 4495, 22242, 4497, 22240, 4499, 22238, 4501, 22236, 4503, 22234, 4505, 22232, 4507, 22230, 4509, 22228, 4511, 22226, 4513, 22224, 4515, 22222, 4517, 22220, 4519, 22218, 4521, 22216, 4523, 22214, 4525, 22212, 4527, 22210, 4529, 22208, 4531, 22206, 4533, 22204, 4535, 22202, 4537, 22200, 4539, 22198, 4541, 22196, 4543, 22194, 4545, 22192, 4547, 22190, 4549, 22188, 4551, 22186, 4553, 22184, 4555, 22182, 4557, 22180, 4559, 22178, 4561, 22176, 4563, 22174, 4565, 22172, 4567, 22170, 4569, 22168, 4571, 22166, 4573, 22164, 4575, 22162, 4577, 22160, 4579, 22158, 4581, 22156, 4583, 22154, 4585, 22152, 4587, 22150, 4589, 22148, 4591, 22146, 4593, 22144, 4595, 22142, 4597, 22140, 4599, 22138, 4601, 22136, 4603, 22134, 4605, 22132, 4607, 22130, 4609, 22128, 4611, 22126, 4613, 22124, 4615, 22122, 4617, 22120, 4619, 22118, 4621, 22116, 4623, 22114, 4625, 22112, 4627, 22110, 4629, 22108, 4631, 22106, 4633, 22104, 4635, 22102, 4637, 22100, 4639, 22098, 4641, 22096, 4643, 22094, 4645, 22092, 4647, 22090, 4649, 22088, 4651, 22086, 4653, 22084, 4655, 22082, 4657, 22080, 4659, 22078, 4661, 22076, 4663, 22074, 4665, 22072, 4667, 22070, 4669, 22068, 4671, 22066, 4673, 22064, 4675, 22062, 4677, 22060, 4679, 22058, 4681, 22056, 4683, 22054, 4685, 22052, 4687, 22050, 4689, 22048, 4691, 22046, 4693, 22044, 4695, 22042, 4697, 22040, 4699, 22038, 4701, 22036, 4703, 22034, 4705, 22032, 4707, 22030, 4709, 22028, 4711, 22026, 4713, 22024, 4715, 22022, 4717, 22020, 4719, 22018, 4721, 22016, 4723, 22014, 4725, 22012, 4727, 22010, 4729, 22008, 4731, 22006, 4733, 22004, 4735, 22002, 4737, 22000, 4739, 21998, 4741, 21996, 4743, 21994, 4745, 21992, 4747, 21990, 4749, 21988, 4751, 21986, 4753, 21984, 4755, 21982, 4757, 21980, 4759, 21978, 4761, 21976, 4763, 21974, 4765, 21972, 4767, 21970, 4769, 21968, 4771, 21966, 4773, 21964, 4775, 21962, 4777, 21960, 4779, 21958, 4781, 21956, 4783, 21954, 4785, 21952, 4787, 21950, 4789, 21948, 4791, 21946, 4793, 21944, 4795, 21942, 4797, 21940, 4799, 21938, 4801, 21936, 4803, 21934, 4805, 21932, 4807, 21930, 4809, 21928, 4811, 21926, 4813, 21924, 4815, 21922, 4817, 21920, 4819, 21918, 4821, 21916, 4823, 21914, 4825, 21912, 4827, 21910, 4829, 21908, 4831, 21906, 4833, 21904, 4835, 21902, 4837, 21900, 4839, 21898, 4841, 21896, 4843, 21894, 4845, 21892, 4847, 21890, 4849, 21888, 4851, 21886, 4853, 21884, 4855, 21882, 4857, 21880, 4859, 21878, 4861, 21876, 4863, 21874, 4865, 21872, 4867, 21870, 4869, 21868, 4871, 21866, 4873, 21864, 4875, 21862, 4877, 21860, 4879, 21858, 4881, 21856, 4883, 21854, 4885, 21852, 4887, 21850, 4889, 21848, 4891, 21846, 4893, 21844, 4895, 21842, 4897, 21840, 4899, 21838, 4901, 21836, 4903, 21834, 4905, 21832, 4907, 21830, 4909, 21828, 4911, 21826, 4913, 21824, 4915, 21822, 4917, 21820, 4919, 21818, 4921, 21816, 4923, 21814, 4925, 21812, 4927, 21810, 4929, 21808, 4931, 21806, 4933, 21804, 4935, 21802, 4937, 21800, 4939, 21798, 4941, 21796, 4943, 21794, 4945, 21792, 4947, 21790, 4949, 21788, 4951, 21786, 4953, 21784, 4955, 21782, 4957, 21780, 4959, 21778, 4961, 21776, 4963, 21774, 4965, 21772, 4967, 21770, 4969, 21768, 4971, 21766, 4973, 21764, 4975, 21762, 4977, 21760, 4979, 21758, 4981, 21756, 4983, 21754, 4985, 21752, 4987, 21750, 4989, 21748, 4991, 21746, 4993, 21744, 4995, 21742, 4997, 21740, 4999, 21738, 5001, 21736, 5003, 21734, 5005, 21732, 5007, 21730, 5009, 21728, 5011, 21726, 5013, 21724, 5015, 21722, 5017, 21720, 5019, 21718, 5021, 21716, 5023, 21714, 5025, 21712, 5027, 21710, 5029, 21708, 5031, 21706, 5033, 21704, 5035, 21702, 5037, 21700, 5039, 21698, 5041, 21696, 5043, 21694, 5045, 21692, 5047, 21690, 5049, 21688, 5051, 21686, 5053, 21684, 5055, 21682, 5057, 21680, 5059, 21678, 5061, 21676, 5063, 21674, 5065, 21672, 5067, 21670, 5069, 21668, 5071, 21666, 5073, 21664, 5075, 21662, 5077, 21660, 5079, 21658, 5081, 21656, 5083, 21654, 5085, 21652, 5087, 21650, 5089, 21648, 5091, 21646, 5093, 21644, 5095, 21642, 5097, 21640, 5099, 21638, 5101, 21636, 5103, 21634, 5105, 21632, 5107, 21630, 5109, 21628, 5111, 21626, 5113, 21624, 5115, 21622, 5117, 21620, 5119, 21618, 5121, 21616, 5123, 21614, 5125, 21612, 5127, 21610, 5129, 21608, 5131, 21606, 5133, 21604, 5135, 21602, 5137, 21600, 5139, 21598, 5141, 21596, 5143, 21594, 5145, 21592, 5147, 21590, 5149, 21588, 5151, 21586, 5153, 21584, 5155, 21582, 5157, 21580, 5159, 21578, 5161, 21576, 5163, 21574, 5165, 21572, 5167, 21570, 5169, 21568, 5171, 21566, 5173, 21564, 5175, 21562, 5177, 21560, 5179, 21558, 5181, 21556, 5183, 21554, 5185, 21552, 5187, 21550, 5189, 21548, 5191, 21546, 5193, 21544, 5195, 21542, 5197, 21540, 5199, 21538, 5201, 21536, 5203, 21534, 5205, 21532, 5207, 21530, 5209, 21528, 5211, 21526, 5213, 21524, 5215, 21522, 5217, 21520, 5219, 21518, 5221, 21516, 5223, 21514, 5225, 21512, 5227, 21510, 5229, 21508, 5231, 21506, 5233, 21504, 5235, 21502, 5237, 21500, 5239, 21498, 5241, 21496, 5243, 21494, 5245, 21492, 5247, 21490, 5249, 21488, 5251, 21486, 5253, 21484, 5255, 21482, 5257, 21480, 5259, 21478, 5261, 21476, 5263, 21474, 5265, 21472, 5267, 21470, 5269, 21468, 5271, 21466, 5273, 21464, 5275, 21462, 5277, 21460, 5279, 21458, 5281, 21456, 5283, 21454, 5285, 21452, 5287, 21450, 5289, 21448, 5291, 21446, 5293, 21444, 5295, 21442, 5297, 21440, 5299, 21438, 5301, 21436, 5303, 21434, 5305, 21432, 5307, 21430, 5309, 21428, 5311, 21426, 5313, 21424, 5315, 21422, 5317, 21420, 5319, 21418, 5321, 21416, 5323, 21414, 5325, 21412, 5327, 21410, 5329, 21408, 5331, 21406, 5333, 21404, 5335, 21402, 5337, 21400, 5339, 21398, 5341, 21396, 5343, 21394, 5345, 21392, 5347, 21390, 5349, 21388, 5351, 21386, 5353, 21384, 5355, 21382, 5357, 21380, 5359, 21378, 5361, 21376, 5363, 21374, 5365, 21372, 5367, 21370, 5369, 21368, 5371, 21366, 5373, 21364, 5375, 21362, 5377, 21360, 5379, 21358, 5381, 21356, 5383, 21354, 5385, 21352, 5387, 21350, 5389, 21348, 5391, 21346, 5393, 21344, 5395, 21342, 5397, 21340, 5399, 21338, 5401, 21336, 5403, 21334, 5405, 21332, 5407, 21330, 5409, 21328, 5411, 21326, 5413, 21324, 5415, 21322, 5417, 21320, 5419, 21318, 5421, 21316, 5423, 21314, 5425, 21312, 5427, 21310, 5429, 21308, 5431, 21306, 5433, 21304, 5435, 21302, 5437, 21300, 5439, 21298, 5441, 21296, 5443, 21294, 5445, 21292, 5447, 21290, 5449, 21288, 5451, 21286, 5453, 21284, 5455, 21282, 5457, 21280, 5459, 21278, 5461, 21276, 5463, 21274, 5465, 21272, 5467, 21270, 5469, 21268, 5471, 21266, 5473, 21264, 5475, 21262, 5477, 21260, 5479, 21258, 5481, 21256, 5483, 21254, 5485, 21252, 5487, 21250, 5489, 21248, 5491, 21246, 5493, 21244, 5495, 21242, 5497, 21240, 5499, 21238, 5501, 21236, 5503, 21234, 5505, 21232, 5507, 21230, 5509, 21228, 5511, 21226, 5513, 21224, 5515, 21222, 5517, 21220, 5519, 21218, 5521, 21216, 5523, 21214, 5525, 21212, 5527, 21210, 5529, 21208, 5531, 21206, 5533, 21204, 5535, 21202, 5537, 21200, 5539, 21198, 5541, 21196, 5543, 21194, 5545, 21192, 5547, 21190, 5549, 21188, 5551, 21186, 5553, 21184, 5555, 21182, 5557, 21180, 5559, 21178, 5561, 21176, 5563, 21174, 5565, 21172, 5567, 21170, 5569, 21168, 5571, 21166, 5573, 21164, 5575, 21162, 5577, 21160, 5579, 21158, 5581, 21156, 5583, 21154, 5585, 21152, 5587, 21150, 5589, 21148, 5591, 21146, 5593, 21144, 5595, 21142, 5597, 21140, 5599, 21138, 5601, 21136, 5603, 21134, 5605, 21132, 5607, 21130, 5609, 21128, 5611, 21126, 5613, 21124, 5615, 21122, 5617, 21120, 5619, 21118, 5621, 21116, 5623, 21114, 5625, 21112, 5627, 21110, 5629, 21108, 5631, 21106, 5633, 21104, 5635, 21102, 5637, 21100, 5639, 21098, 5641, 21096, 5643, 21094, 5645, 21092, 5647, 21090, 5649, 21088, 5651, 21086, 5653, 21084, 5655, 21082, 5657, 21080, 5659, 21078, 5661, 21076, 5663, 21074, 5665, 21072, 5667, 21070, 5669, 21068, 5671, 21066, 5673, 21064, 5675, 21062, 5677, 21060, 5679, 21058, 5681, 21056, 5683, 21054, 5685, 21052, 5687, 21050, 5689, 21048, 5691, 21046, 5693, 21044, 5695, 21042, 5697, 21040, 5699, 21038, 5701, 21036, 5703, 21034, 5705, 21032, 5707, 21030, 5709, 21028, 5711, 21026, 5713, 21024, 5715, 21022, 5717, 21020, 5719, 21018, 5721, 21016, 5723, 21014, 5725, 21012, 5727, 21010, 5729, 21008, 5731, 21006, 5733, 21004, 5735, 21002, 5737, 21000, 5739, 20998, 5741, 20996, 5743, 20994, 5745, 20992, 5747, 20990, 5749, 20988, 5751, 20986, 5753, 20984, 5755, 20982, 5757, 20980, 5759, 20978, 5761, 20976, 5763, 20974, 5765, 20972, 5767, 20970, 5769, 20968, 5771, 20966, 5773, 20964, 5775, 20962, 5777, 20960, 5779, 20958, 5781, 20956, 5783, 20954, 5785, 20952, 5787, 20950, 5789, 20948, 5791, 20946, 5793, 20944, 5795, 20942, 5797, 20940, 5799, 20938, 5801, 20936, 5803, 20934, 5805, 20932, 5807, 20930, 5809, 20928, 5811, 20926, 5813, 20924, 5815, 20922, 5817, 20920, 5819, 20918, 5821, 20916, 5823, 20914, 5825, 20912, 5827, 20910, 5829, 20908, 5831, 20906, 5833, 20904, 5835, 20902, 5837, 20900, 5839, 20898, 5841, 20896, 5843, 20894, 5845, 20892, 5847, 20890, 5849, 20888, 5851, 20886, 5853, 20884, 5855, 20882, 5857, 20880, 5859, 20878, 5861, 20876, 5863, 20874, 5865, 20872, 5867, 20870, 5869, 20868, 5871, 20866, 5873, 20864, 5875, 20862, 5877, 20860, 5879, 20858, 5881, 20856, 5883, 20854, 5885, 20852, 5887, 20850, 5889, 20848, 5891, 20846, 5893, 20844, 5895, 20842, 5897, 20840, 5899, 20838, 5901, 20836, 5903, 20834, 5905, 20832, 5907, 20830, 5909, 20828, 5911, 20826, 5913, 20824, 5915, 20822, 5917, 20820, 5919, 20818, 5921, 20816, 5923, 20814, 5925, 20812, 5927, 20810, 5929, 20808, 5931, 20806, 5933, 20804, 5935, 20802, 5937, 20800, 5939, 20798, 5941, 20796, 5943, 20794, 5945, 20792, 5947, 20790, 5949, 20788, 5951, 20786, 5953, 20784, 5955, 20782, 5957, 20780, 5959, 20778, 5961, 20776, 5963, 20774, 5965, 20772, 5967, 20770, 5969, 20768, 5971, 20766, 5973, 20764, 5975, 20762, 5977, 20760, 5979, 20758, 5981, 20756, 5983, 20754, 5985, 20752, 5987, 20750, 5989, 20748, 5991, 20746, 5993, 20744, 5995, 20742, 5997, 20740, 5999, 20738, 6001, 20736, 6003, 20734, 6005, 20732, 6007, 20730, 6009, 20728, 6011, 20726, 6013, 20724, 6015, 20722, 6017, 20720, 6019, 20718, 6021, 20716, 6023, 20714, 6025, 20712, 6027, 20710, 6029, 20708, 6031, 20706, 6033, 20704, 6035, 20702, 6037, 20700, 6039, 20698, 6041, 20696, 6043, 20694, 6045, 20692, 6047, 20690, 6049, 20688, 6051, 20686, 6053, 20684, 6055, 20682, 6057, 20680, 6059, 20678, 6061, 20676, 6063, 20674, 6065, 20672, 6067, 20670, 6069, 20668, 6071, 20666, 6073, 20664, 6075, 20662, 6077, 20660, 6079, 20658, 6081, 20656, 6083, 20654, 6085, 20652, 6087, 20650, 6089, 20648, 6091, 20646, 6093, 20644, 6095, 20642, 6097, 20640, 6099, 20638, 6101, 20636, 6103, 20634, 6105, 20632, 6107, 20630, 6109, 20628, 6111, 20626, 6113, 20624, 6115, 20622, 6117, 20620, 6119, 20618, 6121, 20616, 6123, 20614, 6125, 20612, 6127, 20610, 6129, 20608, 6131, 20606, 6133, 20604, 6135, 20602, 6137, 20600, 6139, 20598, 6141, 20596, 6143, 20594, 6145, 20592, 6147, 20590, 6149, 20588, 6151, 20586, 6153, 20584, 6155, 20582, 6157, 20580, 6159, 20578, 6161, 20576, 6163, 20574, 6165, 20572, 6167, 20570, 6169, 20568, 6171, 20566, 6173, 20564, 6175, 20562, 6177, 20560, 6179, 20558, 6181, 20556, 6183, 20554, 6185, 20552, 6187, 20550, 6189, 20548, 6191, 20546, 6193, 20544, 6195, 20542, 6197, 20540, 6199, 20538, 6201, 20536, 6203, 20534, 6205, 20532, 6207, 20530, 6209, 20528, 6211, 20526, 6213, 20524, 6215, 20522, 6217, 20520, 6219, 20518, 6221, 20516, 6223, 20514, 6225, 20512, 6227, 20510, 6229, 20508, 6231, 20506, 6233, 20504, 6235, 20502, 6237, 20500, 6239, 20498, 6241, 20496, 6243, 20494, 6245, 20492, 6247, 20490, 6249, 20488, 6251, 20486, 6253, 20484, 6255, 20482, 6257, 20480, 6259, 20478, 6261, 20476, 6263, 20474, 6265, 20472, 6267, 20470, 6269, 20468, 6271, 20466, 6273, 20464, 6275, 20462, 6277, 20460, 6279, 20458, 6281, 20456, 6283, 20454, 6285, 20452, 6287, 20450, 6289, 20448, 6291, 20446, 6293, 20444, 6295, 20442, 6297, 20440, 6299, 20438, 6301, 20436, 6303, 20434, 6305, 20432, 6307, 20430, 6309, 20428, 6311, 20426, 6313, 20424, 6315, 20422, 6317, 20420, 6319, 20418, 6321, 20416, 6323, 20414, 6325, 20412, 6327, 20410, 6329, 20408, 6331, 20406, 6333, 20404, 6335, 20402, 6337, 20400, 6339, 20398, 6341, 20396, 6343, 20394, 6345, 20392, 6347, 20390, 6349, 20388, 6351, 20386, 6353, 20384, 6355, 20382, 6357, 20380, 6359, 20378, 6361, 20376, 6363, 20374, 6365, 20372, 6367, 20370, 6369, 20368, 6371, 20366, 6373, 20364, 6375, 20362, 6377, 20360, 6379, 20358, 6381, 20356, 6383, 20354, 6385, 20352, 6387, 20350, 6389, 20348, 6391, 20346, 6393, 20344, 6395, 20342, 6397, 20340, 6399, 20338, 6401, 20336, 6403, 20334, 6405, 20332, 6407, 20330, 6409, 20328, 6411, 20326, 6413, 20324, 6415, 20322, 6417, 20320, 6419, 20318, 6421, 20316, 6423, 20314, 6425, 20312, 6427, 20310, 6429, 20308, 6431, 20306, 6433, 20304, 6435, 20302, 6437, 20300, 6439, 20298, 6441, 20296, 6443, 20294, 6445, 20292, 6447, 20290, 6449, 20288, 6451, 20286, 6453, 20284, 6455, 20282, 6457, 20280, 6459, 20278, 6461, 20276, 6463, 20274, 6465, 20272, 6467, 20270, 6469, 20268, 6471, 20266, 6473, 20264, 6475, 20262, 6477, 20260, 6479, 20258, 6481, 20256, 6483, 20254, 6485, 20252, 6487, 20250, 6489, 20248, 6491, 20246, 6493, 20244, 6495, 20242, 6497, 20240, 6499, 20238, 6501, 20236, 6503, 20234, 6505, 20232, 6507, 20230, 6509, 20228, 6511, 20226, 6513, 20224, 6515, 20222, 6517, 20220, 6519, 20218, 6521, 20216, 6523, 20214, 6525, 20212, 6527, 20210, 6529, 20208, 6531, 20206, 6533, 20204, 6535, 20202, 6537, 20200, 6539, 20198, 6541, 20196, 6543, 20194, 6545, 20192, 6547, 20190, 6549, 20188, 6551, 20186, 6553, 20184, 6555, 20182, 6557, 20180, 6559, 20178, 6561, 20176, 6563, 20174, 6565, 20172, 6567, 20170, 6569, 20168, 6571, 20166, 6573, 20164, 6575, 20162, 6577, 20160, 6579, 20158, 6581, 20156, 6583, 20154, 6585, 20152, 6587, 20150, 6589, 20148, 6591, 20146, 6593, 20144, 6595, 20142, 6597, 20140, 6599, 20138, 6601, 20136, 6603, 20134, 6605, 20132, 6607, 20130, 6609, 20128, 6611, 20126, 6613, 20124, 6615, 20122, 6617, 20120, 6619, 20118, 6621, 20116, 6623, 20114, 6625, 20112, 6627, 20110, 6629, 20108, 6631, 20106, 6633, 20104, 6635, 20102, 6637, 20100, 6639, 20098, 6641, 20096, 6643, 20094, 6645, 20092, 6647, 20090, 6649, 20088, 6651, 20086, 6653, 20084, 6655, 20082, 6657, 20080, 6659, 20078, 6661, 20076, 6663, 20074, 6665, 20072, 6667, 20070, 6669, 20068, 6671, 20066, 6673, 20064, 6675, 20062, 6677, 20060, 6679, 20058, 6681, 20056, 6683, 20054, 6685, 20052, 6687, 20050, 6689, 20048, 6691, 20046, 6693, 20044, 6695, 20042, 6697, 20040, 6699, 20038, 6701, 20036, 6703, 20034, 6705, 20032, 6707, 20030, 6709, 20028, 6711, 20026, 6713, 20024, 6715, 20022, 6717, 20020, 6719, 20018, 6721, 20016, 6723, 20014, 6725, 20012, 6727, 20010, 6729, 20008, 6731, 20006, 6733, 20004, 6735, 20002, 6737, 20000, 6739, 19998, 6741, 19996, 6743, 19994, 6745, 19992, 6747, 19990, 6749, 19988, 6751, 19986, 6753, 19984, 6755, 19982, 6757, 19980, 6759, 19978, 6761, 19976, 6763, 19974, 6765, 19972, 6767, 19970, 6769, 19968, 6771, 19966, 6773, 19964, 6775, 19962, 6777, 19960, 6779, 19958, 6781, 19956, 6783, 19954, 6785, 19952, 6787, 19950, 6789, 19948, 6791, 19946, 6793, 19944, 6795, 19942, 6797, 19940, 6799, 19938, 6801, 19936, 6803, 19934, 6805, 19932, 6807, 19930, 6809, 19928, 6811, 19926, 6813, 19924, 6815, 19922, 6817, 19920, 6819, 19918, 6821, 19916, 6823, 19914, 6825, 19912, 6827, 19910, 6829, 19908, 6831, 19906, 6833, 19904, 6835, 19902, 6837, 19900, 6839, 19898, 6841, 19896, 6843, 19894, 6845, 19892, 6847, 19890, 6849, 19888, 6851, 19886, 6853, 19884, 6855, 19882, 6857, 19880, 6859, 19878, 6861, 19876, 6863, 19874, 6865, 19872, 6867, 19870, 6869, 19868, 6871, 19866, 6873, 19864, 6875, 19862, 6877, 19860, 6879, 19858, 6881, 19856, 6883, 19854, 6885, 19852, 6887, 19850, 6889, 19848, 6891, 19846, 6893, 19844, 6895, 19842, 6897, 19840, 6899, 19838, 6901, 19836, 6903, 19834, 6905, 19832, 6907, 19830, 6909, 19828, 6911, 19826, 6913, 19824, 6915, 19822, 6917, 19820, 6919, 19818, 6921, 19816, 6923, 19814, 6925, 19812, 6927, 19810, 6929, 19808, 6931, 19806, 6933, 19804, 6935, 19802, 6937, 19800, 6939, 19798, 6941, 19796, 6943, 19794, 6945, 19792, 6947, 19790, 6949, 19788, 6951, 19786, 6953, 19784, 6955, 19782, 6957, 19780, 6959, 19778, 6961, 19776, 6963, 19774, 6965, 19772, 6967, 19770, 6969, 19768, 6971, 19766, 6973, 19764, 6975, 19762, 6977, 19760, 6979, 19758, 6981, 19756, 6983, 19754, 6985, 19752, 6987, 19750, 6989, 19748, 6991, 19746, 6993, 19744, 6995, 19742, 6997, 19740, 6999, 19738, 7001, 19736, 7003, 19734, 7005, 19732, 7007, 19730, 7009, 19728, 7011, 19726, 7013, 19724, 7015, 19722, 7017, 19720, 7019, 19718, 7021, 19716, 7023, 19714, 7025, 19712, 7027, 19710, 7029, 19708, 7031, 19706, 7033, 19704, 7035, 19702, 7037, 19700, 7039, 19698, 7041, 19696, 7043, 19694, 7045, 19692, 7047, 19690, 7049, 19688, 7051, 19686, 7053, 19684, 7055, 19682, 7057, 19680, 7059, 19678, 7061, 19676, 7063, 19674, 7065, 19672, 7067, 19670, 7069, 19668, 7071, 19666, 7073, 19664, 7075, 19662, 7077, 19660, 7079, 19658, 7081, 19656, 7083, 19654, 7085, 19652, 7087, 19650, 7089, 19648, 7091, 19646, 7093, 19644, 7095, 19642, 7097, 19640, 7099, 19638, 7101, 19636, 7103, 19634, 7105, 19632, 7107, 19630, 7109, 19628, 7111, 19626, 7113, 19624, 7115, 19622, 7117, 19620, 7119, 19618, 7121, 19616, 7123, 19614, 7125, 19612, 7127, 19610, 7129, 19608, 7131, 19606, 7133, 19604, 7135, 19602, 7137, 19600, 7139, 19598, 7141, 19596, 7143, 19594, 7145, 19592, 7147, 19590, 7149, 19588, 7151, 19586, 7153, 19584, 7155, 19582, 7157, 19580, 7159, 19578, 7161, 19576, 7163, 19574, 7165, 19572, 7167, 19570, 7169, 19568, 7171, 19566, 7173, 19564, 7175, 19562, 7177, 19560, 7179, 19558, 7181, 19556, 7183, 19554, 7185, 19552, 7187, 19550, 7189, 19548, 7191, 19546, 7193, 19544, 7195, 19542, 7197, 19540, 7199, 19538, 7201, 19536, 7203, 19534, 7205, 19532, 7207, 19530, 7209, 19528, 7211, 19526, 7213, 19524, 7215, 19522, 7217, 19520, 7219, 19518, 7221, 19516, 7223, 19514, 7225, 19512, 7227, 19510, 7229, 19508, 7231, 19506, 7233, 19504, 7235, 19502, 7237, 19500, 7239, 19498, 7241, 19496, 7243, 19494, 7245, 19492, 7247, 19490, 7249, 19488, 7251, 19486, 7253, 19484, 7255, 19482, 7257, 19480, 7259, 19478, 7261, 19476, 7263, 19474, 7265, 19472, 7267, 19470, 7269, 19468, 7271, 19466, 7273, 19464, 7275, 19462, 7277, 19460, 7279, 19458, 7281, 19456, 7283, 19454, 7285, 19452, 7287, 19450, 7289, 19448, 7291, 19446, 7293, 19444, 7295, 19442, 7297, 19440, 7299, 19438, 7301, 19436, 7303, 19434, 7305, 19432, 7307, 19430, 7309, 19428, 7311, 19426, 7313, 19424, 7315, 19422, 7317, 19420, 7319, 19418, 7321, 19416, 7323, 19414, 7325, 19412, 7327, 19410, 7329, 19408, 7331, 19406, 7333, 19404, 7335, 19402, 7337, 19400, 7339, 19398, 7341, 19396, 7343, 19394, 7345, 19392, 7347, 19390, 7349, 19388, 7351, 19386, 7353, 19384, 7355, 19382, 7357, 19380, 7359, 19378, 7361, 19376, 7363, 19374, 7365, 19372, 7367, 19370, 7369, 19368, 7371, 19366, 7373, 19364, 7375, 19362, 7377, 19360, 7379, 19358, 7381, 19356, 7383, 19354, 7385, 19352, 7387, 19350, 7389, 19348, 7391, 19346, 7393, 19344, 7395, 19342, 7397, 19340, 7399, 19338, 7401, 19336, 7403, 19334, 7405, 19332, 7407, 19330, 7409, 19328, 7411, 19326, 7413, 19324, 7415, 19322, 7417, 19320, 7419, 19318, 7421, 19316, 7423, 19314, 7425, 19312, 7427, 19310, 7429, 19308, 7431, 19306, 7433, 19304, 7435, 19302, 7437, 19300, 7439, 19298, 7441, 19296, 7443, 19294, 7445, 19292, 7447, 19290, 7449, 19288, 7451, 19286, 7453, 19284, 7455, 19282, 7457, 19280, 7459, 19278, 7461, 19276, 7463, 19274, 7465, 19272, 7467, 19270, 7469, 19268, 7471, 19266, 7473, 19264, 7475, 19262, 7477, 19260, 7479, 19258, 7481, 19256, 7483, 19254, 7485, 19252, 7487, 19250, 7489, 19248, 7491, 19246, 7493, 19244, 7495, 19242, 7497, 19240, 7499, 19238, 7501, 19236, 7503, 19234, 7505, 19232, 7507, 19230, 7509, 19228, 7511, 19226, 7513, 19224, 7515, 19222, 7517, 19220, 7519, 19218, 7521, 19216, 7523, 19214, 7525, 19212, 7527, 19210, 7529, 19208, 7531, 19206, 7533, 19204, 7535, 19202, 7537, 19200, 7539, 19198, 7541, 19196, 7543, 19194, 7545, 19192, 7547, 19190, 7549, 19188, 7551, 19186, 7553, 19184, 7555, 19182, 7557, 19180, 7559, 19178, 7561, 19176, 7563, 19174, 7565, 19172, 7567, 19170, 7569, 19168, 7571, 19166, 7573, 19164, 7575, 19162, 7577, 19160, 7579, 19158, 7581, 19156, 7583, 19154, 7585, 19152, 7587, 19150, 7589, 19148, 7591, 19146, 7593, 19144, 7595, 19142, 7597, 19140, 7599, 19138, 7601, 19136, 7603, 19134, 7605, 19132, 7607, 19130, 7609, 19128, 7611, 19126, 7613, 19124, 7615, 19122, 7617, 19120, 7619, 19118, 7621, 19116, 7623, 19114, 7625, 19112, 7627, 19110, 7629, 19108, 7631, 19106, 7633, 19104, 7635, 19102, 7637, 19100, 7639, 19098, 7641, 19096, 7643, 19094, 7645, 19092, 7647, 19090, 7649, 19088, 7651, 19086, 7653, 19084, 7655, 19082, 7657, 19080, 7659, 19078, 7661, 19076, 7663, 19074, 7665, 19072, 7667, 19070, 7669, 19068, 7671, 19066, 7673, 19064, 7675, 19062, 7677, 19060, 7679, 19058, 7681, 19056, 7683, 19054, 7685, 19052, 7687, 19050, 7689, 19048, 7691, 19046, 7693, 19044, 7695, 19042, 7697, 19040, 7699, 19038, 7701, 19036, 7703, 19034, 7705, 19032, 7707, 19030, 7709, 19028, 7711, 19026, 7713, 19024, 7715, 19022, 7717, 19020, 7719, 19018, 7721, 19016, 7723, 19014, 7725, 19012, 7727, 19010, 7729, 19008, 7731, 19006, 7733, 19004, 7735, 19002, 7737, 19000, 7739, 18998, 7741, 18996, 7743, 18994, 7745, 18992, 7747, 18990, 7749, 18988, 7751, 18986, 7753, 18984, 7755, 18982, 7757, 18980, 7759, 18978, 7761, 18976, 7763, 18974, 7765, 18972, 7767, 18970, 7769, 18968, 7771, 18966, 7773, 18964, 7775, 18962, 7777, 18960, 7779, 18958, 7781, 18956, 7783, 18954, 7785, 18952, 7787, 18950, 7789, 18948, 7791, 18946, 7793, 18944, 7795, 18942, 7797, 18940, 7799, 18938, 7801, 18936, 7803, 18934, 7805, 18932, 7807, 18930, 7809, 18928, 7811, 18926, 7813, 18924, 7815, 18922, 7817, 18920, 7819, 18918, 7821, 18916, 7823, 18914, 7825, 18912, 7827, 18910, 7829, 18908, 7831, 18906, 7833, 18904, 7835, 18902, 7837, 18900, 7839, 18898, 7841, 18896, 7843, 18894, 7845, 18892, 7847, 18890, 7849, 18888, 7851, 18886, 7853, 18884, 7855, 18882, 7857, 18880, 7859, 18878, 7861, 18876, 7863, 18874, 7865, 18872, 7867, 18870, 7869, 18868, 7871, 18866, 7873, 18864, 7875, 18862, 7877, 18860, 7879, 18858, 7881, 18856, 7883, 18854, 7885, 18852, 7887, 18850, 7889, 18848, 7891, 18846, 7893, 18844, 7895, 18842, 7897, 18840, 7899, 18838, 7901, 18836, 7903, 18834, 7905, 18832, 7907, 18830, 7909, 18828, 7911, 18826, 7913, 18824, 7915, 18822, 7917, 18820, 7919, 18818, 7921, 18816, 7923, 18814, 7925, 18812, 7927, 18810, 7929, 18808, 7931, 18806, 7933, 18804, 7935, 18802, 7937, 18800, 7939, 18798, 7941, 18796, 7943, 18794, 7945, 18792, 7947, 18790, 7949, 18788, 7951, 18786, 7953, 18784, 7955, 18782, 7957, 18780, 7959, 18778, 7961, 18776, 7963, 18774, 7965, 18772, 7967, 18770, 7969, 18768, 7971, 18766, 7973, 18764, 7975, 18762, 7977, 18760, 7979, 18758, 7981, 18756, 7983, 18754, 7985, 18752, 7987, 18750, 7989, 18748, 7991, 18746, 7993, 18744, 7995, 18742, 7997, 18740, 7999, 18738, 8001, 18736, 8003, 18734, 8005, 18732, 8007, 18730, 8009, 18728, 8011, 18726, 8013, 18724, 8015, 18722, 8017, 18720, 8019, 18718, 8021, 18716, 8023, 18714, 8025, 18712, 8027, 18710, 8029, 18708, 8031, 18706, 8033, 18704, 8035, 18702, 8037, 18700, 8039, 18698, 8041, 18696, 8043, 18694, 8045, 18692, 8047, 18690, 8049, 18688, 8051, 18686, 8053, 18684, 8055, 18682, 8057, 18680, 8059, 18678, 8061, 18676, 8063, 18674, 8065, 18672, 8067, 18670, 8069, 18668, 8071, 18666, 8073, 18664, 8075, 18662, 8077, 18660, 8079, 18658, 8081, 18656, 8083, 18654, 8085, 18652, 8087, 18650, 8089, 18648, 8091, 18646, 8093, 18644, 8095, 18642, 8097, 18640, 8099, 18638, 8101, 18636, 8103, 18634, 8105, 18632, 8107, 18630, 8109, 18628, 8111, 18626, 8113, 18624, 8115, 18622, 8117, 18620, 8119, 18618, 8121, 18616, 8123, 18614, 8125, 18612, 8127, 18610, 8129, 18608, 8131, 18606, 8133, 18604, 8135, 18602, 8137, 18600, 8139, 18598, 8141, 18596, 8143, 18594, 8145, 18592, 8147, 18590, 8149, 18588, 8151, 18586, 8153, 18584, 8155, 18582, 8157, 18580, 8159, 18578, 8161, 18576, 8163, 18574, 8165, 18572, 8167, 18570, 8169, 18568, 8171, 18566, 8173, 18564, 8175, 18562, 8177, 18560, 8179, 18558, 8181, 18556, 8183, 18554, 8185, 18552, 8187, 18550, 8189, 18548, 8191, 18546, 8193, 18544, 8195, 18542, 8197, 18540, 8199, 18538, 8201, 18536, 8203, 18534, 8205, 18532, 8207, 18530, 8209, 18528, 8211, 18526, 8213, 18524, 8215, 18522, 8217, 18520, 8219, 18518, 8221, 18516, 8223, 18514, 8225, 18512, 8227, 18510, 8229, 18508, 8231, 18506, 8233, 18504, 8235, 18502, 8237, 18500, 8239, 18498, 8241, 18496, 8243, 18494, 8245, 18492, 8247, 18490, 8249, 18488, 8251, 18486, 8253, 18484, 8255, 18482, 8257, 18480, 8259, 18478, 8261, 18476, 8263, 18474, 8265, 18472, 8267, 18470, 8269, 18468, 8271, 18466, 8273, 18464, 8275, 18462, 8277, 18460, 8279, 18458, 8281, 18456, 8283, 18454, 8285, 18452, 8287, 18450, 8289, 18448, 8291, 18446, 8293, 18444, 8295, 18442, 8297, 18440, 8299, 18438, 8301, 18436, 8303, 18434, 8305, 18432, 8307, 18430, 8309, 18428, 8311, 18426, 8313, 18424, 8315, 18422, 8317, 18420, 8319, 18418, 8321, 18416, 8323, 18414, 8325, 18412, 8327, 18410, 8329, 18408, 8331, 18406, 8333, 18404, 8335, 18402, 8337, 18400, 8339, 18398, 8341, 18396, 8343, 18394, 8345, 18392, 8347, 18390, 8349, 18388, 8351, 18386, 8353, 18384, 8355, 18382, 8357, 18380, 8359, 18378, 8361, 18376, 8363, 18374, 8365, 18372, 8367, 18370, 8369, 18368, 8371, 18366, 8373, 18364, 8375, 18362, 8377, 18360, 8379, 18358, 8381, 18356, 8383, 18354, 8385, 18352, 8387, 18350, 8389, 18348, 8391, 18346, 8393, 18344, 8395, 18342, 8397, 18340, 8399, 18338, 8401, 18336, 8403, 18334, 8405, 18332, 8407, 18330, 8409, 18328, 8411, 18326, 8413, 18324, 8415, 18322, 8417, 18320, 8419, 18318, 8421, 18316, 8423, 18314, 8425, 18312, 8427, 18310, 8429, 18308, 8431, 18306, 8433, 18304, 8435, 18302, 8437, 18300, 8439, 18298, 8441, 18296, 8443, 18294, 8445, 18292, 8447, 18290, 8449, 18288, 8451, 18286, 8453, 18284, 8455, 18282, 8457, 18280, 8459, 18278, 8461, 18276, 8463, 18274, 8465, 18272, 8467, 18270, 8469, 18268, 8471, 18266, 8473, 18264, 8475, 18262, 8477, 18260, 8479, 18258, 8481, 18256, 8483, 18254, 8485, 18252, 8487, 18250, 8489, 18248, 8491, 18246, 8493, 18244, 8495, 18242, 8497, 18240, 8499, 18238, 8501, 18236, 8503, 18234, 8505, 18232, 8507, 18230, 8509, 18228, 8511, 18226, 8513, 18224, 8515, 18222, 8517, 18220, 8519, 18218, 8521, 18216, 8523, 18214, 8525, 18212, 8527, 18210, 8529, 18208, 8531, 18206, 8533, 18204, 8535, 18202, 8537, 18200, 8539, 18198, 8541, 18196, 8543, 18194, 8545, 18192, 8547, 18190, 8549, 18188, 8551, 18186, 8553, 18184, 8555, 18182, 8557, 18180, 8559, 18178, 8561, 18176, 8563, 18174, 8565, 18172, 8567, 18170, 8569, 18168, 8571, 18166, 8573, 18164, 8575, 18162, 8577, 18160, 8579, 18158, 8581, 18156, 8583, 18154, 8585, 18152, 8587, 18150, 8589, 18148, 8591, 18146, 8593, 18144, 8595, 18142, 8597, 18140, 8599, 18138, 8601, 18136, 8603, 18134, 8605, 18132, 8607, 18130, 8609, 18128, 8611, 18126, 8613, 18124, 8615, 18122, 8617, 18120, 8619, 18118, 8621, 18116, 8623, 18114, 8625, 18112, 8627, 18110, 8629, 18108, 8631, 18106, 8633, 18104, 8635, 18102, 8637, 18100, 8639, 18098, 8641, 18096, 8643, 18094, 8645, 18092, 8647, 18090, 8649, 18088, 8651, 18086, 8653, 18084, 8655, 18082, 8657, 18080, 8659, 18078, 8661, 18076, 8663, 18074, 8665, 18072, 8667, 18070, 8669, 18068, 8671, 18066, 8673, 18064, 8675, 18062, 8677, 18060, 8679, 18058, 8681, 18056, 8683, 18054, 8685, 18052, 8687, 18050, 8689, 18048, 8691, 18046, 8693, 18044, 8695, 18042, 8697, 18040, 8699, 18038, 8701, 18036, 8703, 18034, 8705, 18032, 8707, 18030, 8709, 18028, 8711, 18026, 8713, 18024, 8715, 18022, 8717, 18020, 8719, 18018, 8721, 18016, 8723, 18014, 8725, 18012, 8727, 18010, 8729, 18008, 8731, 18006, 8733, 18004, 8735, 18002, 8737, 18000, 8739, 17998, 8741, 17996, 8743, 17994, 8745, 17992, 8747, 17990, 8749, 17988, 8751, 17986, 8753, 17984, 8755, 17982, 8757, 17980, 8759, 17978, 8761, 17976, 8763, 17974, 8765, 17972, 8767, 17970, 8769, 17968, 8771, 17966, 8773, 17964, 8775, 17962, 8777, 17960, 8779, 17958, 8781, 17956, 8783, 17954, 8785, 17952, 8787, 17950, 8789, 17948, 8791, 17946, 8793, 17944, 8795, 17942, 8797, 17940, 8799, 17938, 8801, 17936, 8803, 17934, 8805, 17932, 8807, 17930, 8809, 17928, 8811, 17926, 8813, 17924, 8815, 17922, 8817, 17920, 8819, 17918, 8821, 17916, 8823, 17914, 8825, 17912, 8827, 17910, 8829, 17908, 8831, 17906, 8833, 17904, 8835, 17902, 8837, 17900, 8839, 17898, 8841, 17896, 8843, 17894, 8845, 17892, 8847, 17890, 8849, 17888, 8851, 17886, 8853, 17884, 8855, 17882, 8857, 17880, 8859, 17878, 8861, 17876, 8863, 17874, 8865, 17872, 8867, 17870, 8869, 17868, 8871, 17866, 8873, 17864, 8875, 17862, 8877, 17860, 8879, 17858, 8881, 17856, 8883, 17854, 8885, 17852, 8887, 17850, 8889, 17848, 8891, 17846, 8893, 17844, 8895, 17842, 8897, 17840, 8899, 17838, 8901, 17836, 8903, 17834, 8905, 17832, 8907, 17830, 8909, 17828, 8911, 17826, 8913, 17824, 8915, 17822, 8917, 17820, 8919, 17818, 8921, 17816, 8923, 17814, 8925, 17812, 8927, 17810, 8929, 17808, 8931, 17806, 8933, 17804, 8935, 17802, 8937, 17800, 8939, 17798, 8941, 17796, 8943, 17794, 8945, 17792, 8947, 17790, 8949, 17788, 8951, 17786, 8953, 17784, 8955, 17782, 8957, 17780, 8959, 17778, 8961, 17776, 8963, 17774, 8965, 17772, 8967, 17770, 8969, 17768, 8971, 17766, 8973, 17764, 8975, 17762, 8977, 17760, 8979, 17758, 8981, 17756, 8983, 17754, 8985, 17752, 8987, 17750, 8989, 17748, 8991, 17746, 8993, 17744, 8995, 17742, 8997, 17740, 8999, 17738, 9001, 17736, 9003, 17734, 9005, 17732, 9007, 17730, 9009, 17728, 9011, 17726, 9013, 17724, 9015, 17722, 9017, 17720, 9019, 17718, 9021, 17716, 9023, 17714, 9025, 17712, 9027, 17710, 9029, 17708, 9031, 17706, 9033, 17704, 9035, 17702, 9037, 17700, 9039, 17698, 9041, 17696, 9043, 17694, 9045, 17692, 9047, 17690, 9049, 17688, 9051, 17686, 9053, 17684, 9055, 17682, 9057, 17680, 9059, 17678, 9061, 17676, 9063, 17674, 9065, 17672, 9067, 17670, 9069, 17668, 9071, 17666, 9073, 17664, 9075, 17662, 9077, 17660, 9079, 17658, 9081, 17656, 9083, 17654, 9085, 17652, 9087, 17650, 9089, 17648, 9091, 17646, 9093, 17644, 9095, 17642, 9097, 17640, 9099, 17638, 9101, 17636, 9103, 17634, 9105, 17632, 9107, 17630, 9109, 17628, 9111, 17626, 9113, 17624, 9115, 17622, 9117, 17620, 9119, 17618, 9121, 17616, 9123, 17614, 9125, 17612, 9127, 17610, 9129, 17608, 9131, 17606, 9133, 17604, 9135, 17602, 9137, 17600, 9139, 17598, 9141, 17596, 9143, 17594, 9145, 17592, 9147, 17590, 9149, 17588, 9151, 17586, 9153, 17584, 9155, 17582, 9157, 17580, 9159, 17578, 9161, 17576, 9163, 17574, 9165, 17572, 9167, 17570, 9169, 17568, 9171, 17566, 9173, 17564, 9175, 17562, 9177, 17560, 9179, 17558, 9181, 17556, 9183, 17554, 9185, 17552, 9187, 17550, 9189, 17548, 9191, 17546, 9193, 17544, 9195, 17542, 9197, 17540, 9199, 17538, 9201, 17536, 9203, 17534, 9205, 17532, 9207, 17530, 9209, 17528, 9211, 17526, 9213, 17524, 9215, 17522, 9217, 17520, 9219, 17518, 9221, 17516, 9223, 17514, 9225, 17512, 9227, 17510, 9229, 17508, 9231, 17506, 9233, 17504, 9235, 17502, 9237, 17500, 9239, 17498, 9241, 17496, 9243, 17494, 9245, 17492, 9247, 17490, 9249, 17488, 9251, 17486, 9253, 17484, 9255, 17482, 9257, 17480, 9259, 17478, 9261, 17476, 9263, 17474, 9265, 17472, 9267, 17470, 9269, 17468, 9271, 17466, 9273, 17464, 9275, 17462, 9277, 17460, 9279, 17458, 9281, 17456, 9283, 17454, 9285, 17452, 9287, 17450, 9289, 17448, 9291, 17446, 9293, 17444, 9295, 17442, 9297, 17440, 9299, 17438, 9301, 17436, 9303, 17434, 9305, 17432, 9307, 17430, 9309, 17428, 9311, 17426, 9313, 17424, 9315, 17422, 9317, 17420, 9319, 17418, 9321, 17416, 9323, 17414, 9325, 17412, 9327, 17410, 9329, 17408, 9331, 17406, 9333, 17404, 9335, 17402, 9337, 17400, 9339, 17398, 9341, 17396, 9343, 17394, 9345, 17392, 9347, 17390, 9349, 17388, 9351, 17386, 9353, 17384, 9355, 17382, 9357, 17380, 9359, 17378, 9361, 17376, 9363, 17374, 9365, 17372, 9367, 17370, 9369, 17368, 9371, 17366, 9373, 17364, 9375, 17362, 9377, 17360, 9379, 17358, 9381, 17356, 9383, 17354, 9385, 17352, 9387, 17350, 9389, 17348, 9391, 17346, 9393, 17344, 9395, 17342, 9397, 17340, 9399, 17338, 9401, 17336, 9403, 17334, 9405, 17332, 9407, 17330, 9409, 17328, 9411, 17326, 9413, 17324, 9415, 17322, 9417, 17320, 9419, 17318, 9421, 17316, 9423, 17314, 9425, 17312, 9427, 17310, 9429, 17308, 9431, 17306, 9433, 17304, 9435, 17302, 9437, 17300, 9439, 17298, 9441, 17296, 9443, 17294, 9445, 17292, 9447, 17290, 9449, 17288, 9451, 17286, 9453, 17284, 9455, 17282, 9457, 17280, 9459, 17278, 9461, 17276, 9463, 17274, 9465, 17272, 9467, 17270, 9469, 17268, 9471, 17266, 9473, 17264, 9475, 17262, 9477, 17260, 9479, 17258, 9481, 17256, 9483, 17254, 9485, 17252, 9487, 17250, 9489, 17248, 9491, 17246, 9493, 17244, 9495, 17242, 9497, 17240, 9499, 17238, 9501, 17236, 9503, 17234, 9505, 17232, 9507, 17230, 9509, 17228, 9511, 17226, 9513, 17224, 9515, 17222, 9517, 17220, 9519, 17218, 9521, 17216, 9523, 17214, 9525, 17212, 9527, 17210, 9529, 17208, 9531, 17206, 9533, 17204, 9535, 17202, 9537, 17200, 9539, 17198, 9541, 17196, 9543, 17194, 9545, 17192, 9547, 17190, 9549, 17188, 9551, 17186, 9553, 17184, 9555, 17182, 9557, 17180, 9559, 17178, 9561, 17176, 9563, 17174, 9565, 17172, 9567, 17170, 9569, 17168, 9571, 17166, 9573, 17164, 9575, 17162, 9577, 17160, 9579, 17158, 9581, 17156, 9583, 17154, 9585, 17152, 9587, 17150, 9589, 17148, 9591, 17146, 9593, 17144, 9595, 17142, 9597, 17140, 9599, 17138, 9601, 17136, 9603, 17134, 9605, 17132, 9607, 17130, 9609, 17128, 9611, 17126, 9613, 17124, 9615, 17122, 9617, 17120, 9619, 17118, 9621, 17116, 9623, 17114, 9625, 17112, 9627, 17110, 9629, 17108, 9631, 17106, 9633, 17104, 9635, 17102, 9637, 17100, 9639, 17098, 9641, 17096, 9643, 17094, 9645, 17092, 9647, 17090, 9649, 17088, 9651, 17086, 9653, 17084, 9655, 17082, 9657, 17080, 9659, 17078, 9661, 17076, 9663, 17074, 9665, 17072, 9667, 17070, 9669, 17068, 9671, 17066, 9673, 17064, 9675, 17062, 9677, 17060, 9679, 17058, 9681, 17056, 9683, 17054, 9685, 17052, 9687, 17050, 9689, 17048, 9691, 17046, 9693, 17044, 9695, 17042, 9697, 17040, 9699, 17038, 9701, 17036, 9703, 17034, 9705, 17032, 9707, 17030, 9709, 17028, 9711, 17026, 9713, 17024, 9715, 17022, 9717, 17020, 9719, 17018, 9721, 17016, 9723, 17014, 9725, 17012, 9727, 17010, 9729, 17008, 9731, 17006, 9733, 17004, 9735, 17002, 9737, 17000, 9739, 16998, 9741, 16996, 9743, 16994, 9745, 16992, 9747, 16990, 9749, 16988, 9751, 16986, 9753, 16984, 9755, 16982, 9757, 16980, 9759, 16978, 9761, 16976, 9763, 16974, 9765, 16972, 9767, 16970, 9769, 16968, 9771, 16966, 9773, 16964, 9775, 16962, 9777, 16960, 9779, 16958, 9781, 16956, 9783, 16954, 9785, 16952, 9787, 16950, 9789, 16948, 9791, 16946, 9793, 16944, 9795, 16942, 9797, 16940, 9799, 16938, 9801, 16936, 9803, 16934, 9805, 16932, 9807, 16930, 9809, 16928, 9811, 16926, 9813, 16924, 9815, 16922, 9817, 16920, 9819, 16918, 9821, 16916, 9823, 16914, 9825, 16912, 9827, 16910, 9829, 16908, 9831, 16906, 9833, 16904, 9835, 16902, 9837, 16900, 9839, 16898, 9841, 16896, 9843, 16894, 9845, 16892, 9847, 16890, 9849, 16888, 9851, 16886, 9853, 16884, 9855, 16882, 9857, 16880, 9859, 16878, 9861, 16876, 9863, 16874, 9865, 16872, 9867, 16870, 9869, 16868, 9871, 16866, 9873, 16864, 9875, 16862, 9877, 16860, 9879, 16858, 9881, 16856, 9883, 16854, 9885, 16852, 9887, 16850, 9889, 16848, 9891, 16846, 9893, 16844, 9895, 16842, 9897, 16840, 9899, 16838, 9901, 16836, 9903, 16834, 9905, 16832, 9907, 16830, 9909, 16828, 9911, 16826, 9913, 16824, 9915, 16822, 9917, 16820, 9919, 16818, 9921, 16816, 9923, 16814, 9925, 16812, 9927, 16810, 9929, 16808, 9931, 16806, 9933, 16804, 9935, 16802, 9937, 16800, 9939, 16798, 9941, 16796, 9943, 16794, 9945, 16792, 9947, 16790, 9949, 16788, 9951, 16786, 9953, 16784, 9955, 16782, 9957, 16780, 9959, 16778, 9961, 16776, 9963, 16774, 9965, 16772, 9967, 16770, 9969, 16768, 9971, 16766, 9973, 16764, 9975, 16762, 9977, 16760, 9979, 16758, 9981, 16756, 9983, 16754, 9985, 16752, 9987, 16750, 9989, 16748, 9991, 16746, 9993, 16744, 9995, 16742, 9997, 16740, 9999, 16738, 10001, 16736, 10003, 16734, 10005, 16732, 10007, 16730, 10009, 16728, 10011, 16726, 10013, 16724, 10015, 16722, 10017, 16720, 10019, 16718, 10021, 16716, 10023, 16714, 10025, 16712, 10027, 16710, 10029, 16708, 10031, 16706, 10033, 16704, 10035, 16702, 10037, 16700, 10039, 16698, 10041, 16696, 10043, 16694, 10045, 16692, 10047, 16690, 10049, 16688, 10051, 16686, 10053, 16684, 10055, 16682, 10057, 16680, 10059, 16678, 10061, 16676, 10063, 16674, 10065, 16672, 10067, 16670, 10069, 16668, 10071, 16666, 10073, 16664, 10075, 16662, 10077, 16660, 10079, 16658, 10081, 16656, 10083, 16654, 10085, 16652, 10087, 16650, 10089, 16648, 10091, 16646, 10093, 16644, 10095, 16642, 10097, 16640, 10099, 16638, 10101, 16636, 10103, 16634, 10105, 16632, 10107, 16630, 10109, 16628, 10111, 16626, 10113, 16624, 10115, 16622, 10117, 16620, 10119, 16618, 10121, 16616, 10123, 16614, 10125, 16612, 10127, 16610, 10129, 16608, 10131, 16606, 10133, 16604, 10135, 16602, 10137, 16600, 10139, 16598, 10141, 16596, 10143, 16594, 10145, 16592, 10147, 16590, 10149, 16588, 10151, 16586, 10153, 16584, 10155, 16582, 10157, 16580, 10159, 16578, 10161, 16576, 10163, 16574, 10165, 16572, 10167, 16570, 10169, 16568, 10171, 16566, 10173, 16564, 10175, 16562, 10177, 16560, 10179, 16558, 10181, 16556, 10183, 16554, 10185, 16552, 10187, 16550, 10189, 16548, 10191, 16546, 10193, 16544, 10195, 16542, 10197, 16540, 10199, 16538, 10201, 16536, 10203, 16534, 10205, 16532, 10207, 16530, 10209, 16528, 10211, 16526, 10213, 16524, 10215, 16522, 10217, 16520, 10219, 16518, 10221, 16516, 10223, 16514, 10225, 16512, 10227, 16510, 10229, 16508, 10231, 16506, 10233, 16504, 10235, 16502, 10237, 16500, 10239, 16498, 10241, 16496, 10243, 16494, 10245, 16492, 10247, 16490, 10249, 16488, 10251, 16486, 10253, 16484, 10255, 16482, 10257, 16480, 10259, 16478, 10261, 16476, 10263, 16474, 10265, 16472, 10267, 16470, 10269, 16468, 10271, 16466, 10273, 16464, 10275, 16462, 10277, 16460, 10279, 16458, 10281, 16456, 10283, 16454, 10285, 16452, 10287, 16450, 10289, 16448, 10291, 16446, 10293, 16444, 10295, 16442, 10297, 16440, 10299, 16438, 10301, 16436, 10303, 16434, 10305, 16432, 10307, 16430, 10309, 16428, 10311, 16426, 10313, 16424, 10315, 16422, 10317, 16420, 10319, 16418, 10321, 16416, 10323, 16414, 10325, 16412, 10327, 16410, 10329, 16408, 10331, 16406, 10333, 16404, 10335, 16402, 10337, 16400, 10339, 16398, 10341, 16396, 10343, 16394, 10345, 16392, 10347, 16390, 10349, 16388, 10351, 16386, 10353, 16384, 10355, 16382, 10357, 16380, 10359, 16378, 10361, 16376, 10363, 16374, 10365, 16372, 10367, 16370, 10369, 16368, 10371, 16366, 10373, 16364, 10375, 16362, 10377, 16360, 10379, 16358, 10381, 16356, 10383, 16354, 10385, 16352, 10387, 16350, 10389, 16348, 10391, 16346, 10393, 16344, 10395, 16342, 10397, 16340, 10399, 16338, 10401, 16336, 10403, 16334, 10405, 16332, 10407, 16330, 10409, 16328, 10411, 16326, 10413, 16324, 10415, 16322, 10417, 16320, 10419, 16318, 10421, 16316, 10423, 16314, 10425, 16312, 10427, 16310, 10429, 16308, 10431, 16306, 10433, 16304, 10435, 16302, 10437, 16300, 10439, 16298, 10441, 16296, 10443, 16294, 10445, 16292, 10447, 16290, 10449, 16288, 10451, 16286, 10453, 16284, 10455, 16282, 10457, 16280, 10459, 16278, 10461, 16276, 10463, 16274, 10465, 16272, 10467, 16270, 10469, 16268, 10471, 16266, 10473, 16264, 10475, 16262, 10477, 16260, 10479, 16258, 10481, 16256, 10483, 16254, 10485, 16252, 10487, 16250, 10489, 16248, 10491, 16246, 10493, 16244, 10495, 16242, 10497, 16240, 10499, 16238, 10501, 16236, 10503, 16234, 10505, 16232, 10507, 16230, 10509, 16228, 10511, 16226, 10513, 16224, 10515, 16222, 10517, 16220, 10519, 16218, 10521, 16216, 10523, 16214, 10525, 16212, 10527, 16210, 10529, 16208, 10531, 16206, 10533, 16204, 10535, 16202, 10537, 16200, 10539, 16198, 10541, 16196, 10543, 16194, 10545, 16192, 10547, 16190, 10549, 16188, 10551, 16186, 10553, 16184, 10555, 16182, 10557, 16180, 10559, 16178, 10561, 16176, 10563, 16174, 10565, 16172, 10567, 16170, 10569, 16168, 10571, 16166, 10573, 16164, 10575, 16162, 10577, 16160, 10579, 16158, 10581, 16156, 10583, 16154, 10585, 16152, 10587, 16150, 10589, 16148, 10591, 16146, 10593, 16144, 10595, 16142, 10597, 16140, 10599, 16138, 10601, 16136, 10603, 16134, 10605, 16132, 10607, 16130, 10609, 16128, 10611, 16126, 10613, 16124, 10615, 16122, 10617, 16120, 10619, 16118, 10621, 16116, 10623, 16114, 10625, 16112, 10627, 16110, 10629, 16108, 10631, 16106, 10633, 16104, 10635, 16102, 10637, 16100, 10639, 16098, 10641, 16096, 10643, 16094, 10645, 16092, 10647, 16090, 10649, 16088, 10651, 16086, 10653, 16084, 10655, 16082, 10657, 16080, 10659, 16078, 10661, 16076, 10663, 16074, 10665, 16072, 10667, 16070, 10669, 16068, 10671, 16066, 10673, 16064, 10675, 16062, 10677, 16060, 10679, 16058, 10681, 16056, 10683, 16054, 10685, 16052, 10687, 16050, 10689, 16048, 10691, 16046, 10693, 16044, 10695, 16042, 10697, 16040, 10699, 16038, 10701, 16036, 10703, 16034, 10705, 16032, 10707, 16030, 10709, 16028, 10711, 16026, 10713, 16024, 10715, 16022, 10717, 16020, 10719, 16018, 10721, 16016, 10723, 16014, 10725, 16012, 10727, 16010, 10729, 16008, 10731, 16006, 10733, 16004, 10735, 16002, 10737, 16000, 10739, 15998, 10741, 15996, 10743, 15994, 10745, 15992, 10747, 15990, 10749, 15988, 10751, 15986, 10753, 15984, 10755, 15982, 10757, 15980, 10759, 15978, 10761, 15976, 10763, 15974, 10765, 15972, 10767, 15970, 10769, 15968, 10771, 15966, 10773, 15964, 10775, 15962, 10777, 15960, 10779, 15958, 10781, 15956, 10783, 15954, 10785, 15952, 10787, 15950, 10789, 15948, 10791, 15946, 10793, 15944, 10795, 15942, 10797, 15940, 10799, 15938, 10801, 15936, 10803, 15934, 10805, 15932, 10807, 15930, 10809, 15928, 10811, 15926, 10813, 15924, 10815, 15922, 10817, 15920, 10819, 15918, 10821, 15916, 10823, 15914, 10825, 15912, 10827, 15910, 10829, 15908, 10831, 15906, 10833, 15904, 10835, 15902, 10837, 15900, 10839, 15898, 10841, 15896, 10843, 15894, 10845, 15892, 10847, 15890, 10849, 15888, 10851, 15886, 10853, 15884, 10855, 15882, 10857, 15880, 10859, 15878, 10861, 15876, 10863, 15874, 10865, 15872, 10867, 15870, 10869, 15868, 10871, 15866, 10873, 15864, 10875, 15862, 10877, 15860, 10879, 15858, 10881, 15856, 10883, 15854, 10885, 15852, 10887, 15850, 10889, 15848, 10891, 15846, 10893, 15844, 10895, 15842, 10897, 15840, 10899, 15838, 10901, 15836, 10903, 15834, 10905, 15832, 10907, 15830, 10909, 15828, 10911, 15826, 10913, 15824, 10915, 15822, 10917, 15820, 10919, 15818, 10921, 15816, 10923, 15814, 10925, 15812, 10927, 15810, 10929, 15808, 10931, 15806, 10933, 15804, 10935, 15802, 10937, 15800, 10939, 15798, 10941, 15796, 10943, 15794, 10945, 15792, 10947, 15790, 10949, 15788, 10951, 15786, 10953, 15784, 10955, 15782, 10957, 15780, 10959, 15778, 10961, 15776, 10963, 15774, 10965, 15772, 10967, 15770, 10969, 15768, 10971, 15766, 10973, 15764, 10975, 15762, 10977, 15760, 10979, 15758, 10981, 15756, 10983, 15754, 10985, 15752, 10987, 15750, 10989, 15748, 10991, 15746, 10993, 15744, 10995, 15742, 10997, 15740, 10999, 15738, 11001, 15736, 11003, 15734, 11005, 15732, 11007, 15730, 11009, 15728, 11011, 15726, 11013, 15724, 11015, 15722, 11017, 15720, 11019, 15718, 11021, 15716, 11023, 15714, 11025, 15712, 11027, 15710, 11029, 15708, 11031, 15706, 11033, 15704, 11035, 15702, 11037, 15700, 11039, 15698, 11041, 15696, 11043, 15694, 11045, 15692, 11047, 15690, 11049, 15688, 11051, 15686, 11053, 15684, 11055, 15682, 11057, 15680, 11059, 15678, 11061, 15676, 11063, 15674, 11065, 15672, 11067, 15670, 11069, 15668, 11071, 15666, 11073, 15664, 11075, 15662, 11077, 15660, 11079, 15658, 11081, 15656, 11083, 15654, 11085, 15652, 11087, 15650, 11089, 15648, 11091, 15646, 11093, 15644, 11095, 15642, 11097, 15640, 11099, 15638, 11101, 15636, 11103, 15634, 11105, 15632, 11107, 15630, 11109, 15628, 11111, 15626, 11113, 15624, 11115, 15622, 11117, 15620, 11119, 15618, 11121, 15616, 11123, 15614, 11125, 15612, 11127, 15610, 11129, 15608, 11131, 15606, 11133, 15604, 11135, 15602, 11137, 15600, 11139, 15598, 11141, 15596, 11143, 15594, 11145, 15592, 11147, 15590, 11149, 15588, 11151, 15586, 11153, 15584, 11155, 15582, 11157, 15580, 11159, 15578, 11161, 15576, 11163, 15574, 11165, 15572, 11167, 15570, 11169, 15568, 11171, 15566, 11173, 15564, 11175, 15562, 11177, 15560, 11179, 15558, 11181, 15556, 11183, 15554, 11185, 15552, 11187, 15550, 11189, 15548, 11191, 15546, 11193, 15544, 11195, 15542, 11197, 15540, 11199, 15538, 11201, 15536, 11203, 15534, 11205, 15532, 11207, 15530, 11209, 15528, 11211, 15526, 11213, 15524, 11215, 15522, 11217, 15520, 11219, 15518, 11221, 15516, 11223, 15514, 11225, 15512, 11227, 15510, 11229, 15508, 11231, 15506, 11233, 15504, 11235, 15502, 11237, 15500, 11239, 15498, 11241, 15496, 11243, 15494, 11245, 15492, 11247, 15490, 11249, 15488, 11251, 15486, 11253, 15484, 11255, 15482, 11257, 15480, 11259, 15478, 11261, 15476, 11263, 15474, 11265, 15472, 11267, 15470, 11269, 15468, 11271, 15466, 11273, 15464, 11275, 15462, 11277, 15460, 11279, 15458, 11281, 15456, 11283, 15454, 11285, 15452, 11287, 15450, 11289, 15448, 11291, 15446, 11293, 15444, 11295, 15442, 11297, 15440, 11299, 15438, 11301, 15436, 11303, 15434, 11305, 15432, 11307, 15430, 11309, 15428, 11311, 15426, 11313, 15424, 11315, 15422, 11317, 15420, 11319, 15418, 11321, 15416, 11323, 15414, 11325, 15412, 11327, 15410, 11329, 15408, 11331, 15406, 11333, 15404, 11335, 15402, 11337, 15400, 11339, 15398, 11341, 15396, 11343, 15394, 11345, 15392, 11347, 15390, 11349, 15388, 11351, 15386, 11353, 15384, 11355, 15382, 11357, 15380, 11359, 15378, 11361, 15376, 11363, 15374, 11365, 15372, 11367, 15370, 11369, 15368, 11371, 15366, 11373, 15364, 11375, 15362, 11377, 15360, 11379, 15358, 11381, 15356, 11383, 15354, 11385, 15352, 11387, 15350, 11389, 15348, 11391, 15346, 11393, 15344, 11395, 15342, 11397, 15340, 11399, 15338, 11401, 15336, 11403, 15334, 11405, 15332, 11407, 15330, 11409, 15328, 11411, 15326, 11413, 15324, 11415, 15322, 11417, 15320, 11419, 15318, 11421, 15316, 11423, 15314, 11425, 15312, 11427, 15310, 11429, 15308, 11431, 15306, 11433, 15304, 11435, 15302, 11437, 15300, 11439, 15298, 11441, 15296, 11443, 15294, 11445, 15292, 11447, 15290, 11449, 15288, 11451, 15286, 11453, 15284, 11455, 15282, 11457, 15280, 11459, 15278, 11461, 15276, 11463, 15274, 11465, 15272, 11467, 15270, 11469, 15268, 11471, 15266, 11473, 15264, 11475, 15262, 11477, 15260, 11479, 15258, 11481, 15256, 11483, 15254, 11485, 15252, 11487, 15250, 11489, 15248, 11491, 15246, 11493, 15244, 11495, 15242, 11497, 15240, 11499, 15238, 11501, 15236, 11503, 15234, 11505, 15232, 11507, 15230, 11509, 15228, 11511, 15226, 11513, 15224, 11515, 15222, 11517, 15220, 11519, 15218, 11521, 15216, 11523, 15214, 11525, 15212, 11527, 15210, 11529, 15208, 11531, 15206, 11533, 15204, 11535, 15202, 11537, 15200, 11539, 15198, 11541, 15196, 11543, 15194, 11545, 15192, 11547, 15190, 11549, 15188, 11551, 15186, 11553, 15184, 11555, 15182, 11557, 15180, 11559, 15178, 11561, 15176, 11563, 15174, 11565, 15172, 11567, 15170, 11569, 15168, 11571, 15166, 11573, 15164, 11575, 15162, 11577, 15160, 11579, 15158, 11581, 15156, 11583, 15154, 11585, 15152, 11587, 15150, 11589, 15148, 11591, 15146, 11593, 15144, 11595, 15142, 11597, 15140, 11599, 15138, 11601, 15136, 11603, 15134, 11605, 15132, 11607, 15130, 11609, 15128, 11611, 15126, 11613, 15124, 11615, 15122, 11617, 15120, 11619, 15118, 11621, 15116, 11623, 15114, 11625, 15112, 11627, 15110, 11629, 15108, 11631, 15106, 11633, 15104, 11635, 15102, 11637, 15100, 11639, 15098, 11641, 15096, 11643, 15094, 11645, 15092, 11647, 15090, 11649, 15088, 11651, 15086, 11653, 15084, 11655, 15082, 11657, 15080, 11659, 15078, 11661, 15076, 11663, 15074, 11665, 15072, 11667, 15070, 11669, 15068, 11671, 15066, 11673, 15064, 11675, 15062, 11677, 15060, 11679, 15058, 11681, 15056, 11683, 15054, 11685, 15052, 11687, 15050, 11689, 15048, 11691, 15046, 11693, 15044, 11695, 15042, 11697, 15040, 11699, 15038, 11701, 15036, 11703, 15034, 11705, 15032, 11707, 15030, 11709, 15028, 11711, 15026, 11713, 15024, 11715, 15022, 11717, 15020, 11719, 15018, 11721, 15016, 11723, 15014, 11725, 15012, 11727, 15010, 11729, 15008, 11731, 15006, 11733, 15004, 11735, 15002, 11737, 15000, 11739, 14998, 11741, 14996, 11743, 14994, 11745, 14992, 11747, 14990, 11749, 14988, 11751, 14986, 11753, 14984, 11755, 14982, 11757, 14980, 11759, 14978, 11761, 14976, 11763, 14974, 11765, 14972, 11767, 14970, 11769, 14968, 11771, 14966, 11773, 14964, 11775, 14962, 11777, 14960, 11779, 14958, 11781, 14956, 11783, 14954, 11785, 14952, 11787, 14950, 11789, 14948, 11791, 14946, 11793, 14944, 11795, 14942, 11797, 14940, 11799, 14938, 11801, 14936, 11803, 14934, 11805, 14932, 11807, 14930, 11809, 14928, 11811, 14926, 11813, 14924, 11815, 14922, 11817, 14920, 11819, 14918, 11821, 14916, 11823, 14914, 11825, 14912, 11827, 14910, 11829, 14908, 11831, 14906, 11833, 14904, 11835, 14902, 11837, 14900, 11839, 14898, 11841, 14896, 11843, 14894, 11845, 14892, 11847, 14890, 11849, 14888, 11851, 14886, 11853, 14884, 11855, 14882, 11857, 14880, 11859, 14878, 11861, 14876, 11863, 14874, 11865, 14872, 11867, 14870, 11869, 14868, 11871, 14866, 11873, 14864, 11875, 14862, 11877, 14860, 11879, 14858, 11881, 14856, 11883, 14854, 11885, 14852, 11887, 14850, 11889, 14848, 11891, 14846, 11893, 14844, 11895, 14842, 11897, 14840, 11899, 14838, 11901, 14836, 11903, 14834, 11905, 14832, 11907, 14830, 11909, 14828, 11911, 14826, 11913, 14824, 11915, 14822, 11917, 14820, 11919, 14818, 11921, 14816, 11923, 14814, 11925, 14812, 11927, 14810, 11929, 14808, 11931, 14806, 11933, 14804, 11935, 14802, 11937, 14800, 11939, 14798, 11941, 14796, 11943, 14794, 11945, 14792, 11947, 14790, 11949, 14788, 11951, 14786, 11953, 14784, 11955, 14782, 11957, 14780, 11959, 14778, 11961, 14776, 11963, 14774, 11965, 14772, 11967, 14770, 11969, 14768, 11971, 14766, 11973, 14764, 11975, 14762, 11977, 14760, 11979, 14758, 11981, 14756, 11983, 14754, 11985, 14752, 11987, 14750, 11989, 14748, 11991, 14746, 11993, 14744, 11995, 14742, 11997, 14740, 11999, 14738, 12001, 14736, 12003, 14734, 12005, 14732, 12007, 14730, 12009, 14728, 12011, 14726, 12013, 14724, 12015, 14722, 12017, 14720, 12019, 14718, 12021, 14716, 12023, 14714, 12025, 14712, 12027, 14710, 12029, 14708, 12031, 14706, 12033, 14704, 12035, 14702, 12037, 14700, 12039, 14698, 12041, 14696, 12043, 14694, 12045, 14692, 12047, 14690, 12049, 14688, 12051, 14686, 12053, 14684, 12055, 14682, 12057, 14680, 12059, 14678, 12061, 14676, 12063, 14674, 12065, 14672, 12067, 14670, 12069, 14668, 12071, 14666, 12073, 14664, 12075, 14662, 12077, 14660, 12079, 14658, 12081, 14656, 12083, 14654, 12085, 14652, 12087, 14650, 12089, 14648, 12091, 14646, 12093, 14644, 12095, 14642, 12097, 14640, 12099, 14638, 12101, 14636, 12103, 14634, 12105, 14632, 12107, 14630, 12109, 14628, 12111, 14626, 12113, 14624, 12115, 14622, 12117, 14620, 12119, 14618, 12121, 14616, 12123, 14614, 12125, 14612, 12127, 14610, 12129, 14608, 12131, 14606, 12133, 14604, 12135, 14602, 12137, 14600, 12139, 14598, 12141, 14596, 12143, 14594, 12145, 14592, 12147, 14590, 12149, 14588, 12151, 14586, 12153, 14584, 12155, 14582, 12157, 14580, 12159, 14578, 12161, 14576, 12163, 14574, 12165, 14572, 12167, 14570, 12169, 14568, 12171, 14566, 12173, 14564, 12175, 14562, 12177, 14560, 12179, 14558, 12181, 14556, 12183, 14554, 12185, 14552, 12187, 14550, 12189, 14548, 12191, 14546, 12193, 14544, 12195, 14542, 12197, 14540, 12199, 14538, 12201, 14536, 12203, 14534, 12205, 14532, 12207, 14530, 12209, 14528, 12211, 14526, 12213, 14524, 12215, 14522, 12217, 14520, 12219, 14518, 12221, 14516, 12223, 14514, 12225, 14512, 12227, 14510, 12229, 14508, 12231, 14506, 12233, 14504, 12235, 14502, 12237, 14500, 12239, 14498, 12241, 14496, 12243, 14494, 12245, 14492, 12247, 14490, 12249, 14488, 12251, 14486, 12253, 14484, 12255, 14482, 12257, 14480, 12259, 14478, 12261, 14476, 12263, 14474, 12265, 14472, 12267, 14470, 12269, 14468, 12271, 14466, 12273, 14464, 12275, 14462, 12277, 14460, 12279, 14458, 12281, 14456, 12283, 14454, 12285, 14452, 12287, 14450, 12289, 14448, 12291, 14446, 12293, 14444, 12295, 14442, 12297, 14440, 12299, 14438, 12301, 14436, 12303, 14434, 12305, 14432, 12307, 14430, 12309, 14428, 12311, 14426, 12313, 14424, 12315, 14422, 12317, 14420, 12319, 14418, 12321, 14416, 12323, 14414, 12325, 14412, 12327, 14410, 12329, 14408, 12331, 14406, 12333, 14404, 12335, 14402, 12337, 14400, 12339, 14398, 12341, 14396, 12343, 14394, 12345, 14392, 12347, 14390, 12349, 14388, 12351, 14386, 12353, 14384, 12355, 14382, 12357, 14380, 12359, 14378, 12361, 14376, 12363, 14374, 12365, 14372, 12367, 14370, 12369, 14368, 12371, 14366, 12373, 14364, 12375, 14362, 12377, 14360, 12379, 14358, 12381, 14356, 12383, 14354, 12385, 14352, 12387, 14350, 12389, 14348, 12391, 14346, 12393, 14344, 12395, 14342, 12397, 14340, 12399, 14338, 12401, 14336, 12403, 14334, 12405, 14332, 12407, 14330, 12409, 14328, 12411, 14326, 12413, 14324, 12415, 14322, 12417, 14320, 12419, 14318, 12421, 14316, 12423, 14314, 12425, 14312, 12427, 14310, 12429, 14308, 12431, 14306, 12433, 14304, 12435, 14302, 12437, 14300, 12439, 14298, 12441, 14296, 12443, 14294, 12445, 14292, 12447, 14290, 12449, 14288, 12451, 14286, 12453, 14284, 12455, 14282, 12457, 14280, 12459, 14278, 12461, 14276, 12463, 14274, 12465, 14272, 12467, 14270, 12469, 14268, 12471, 14266, 12473, 14264, 12475, 14262, 12477, 14260, 12479, 14258, 12481, 14256, 12483, 14254, 12485, 14252, 12487, 14250, 12489, 14248, 12491, 14246, 12493, 14244, 12495, 14242, 12497, 14240, 12499, 14238, 12501, 14236, 12503, 14234, 12505, 14232, 12507, 14230, 12509, 14228, 12511, 14226, 12513, 14224, 12515, 14222, 12517, 14220, 12519, 14218, 12521, 14216, 12523, 14214, 12525, 14212, 12527, 14210, 12529, 14208, 12531, 14206, 12533, 14204, 12535, 14202, 12537, 14200, 12539, 14198, 12541, 14196, 12543, 14194, 12545, 14192, 12547, 14190, 12549, 14188, 12551, 14186, 12553, 14184, 12555, 14182, 12557, 14180, 12559, 14178, 12561, 14176, 12563, 14174, 12565, 14172, 12567, 14170, 12569, 14168, 12571, 14166, 12573, 14164, 12575, 14162, 12577, 14160, 12579, 14158, 12581, 14156, 12583, 14154, 12585, 14152, 12587, 14150, 12589, 14148, 12591, 14146, 12593, 14144, 12595, 14142, 12597, 14140, 12599, 14138, 12601, 14136, 12603, 14134, 12605, 14132, 12607, 14130, 12609, 14128, 12611, 14126, 12613, 14124, 12615, 14122, 12617, 14120, 12619, 14118, 12621, 14116, 12623, 14114, 12625, 14112, 12627, 14110, 12629, 14108, 12631, 14106, 12633, 14104, 12635, 14102, 12637, 14100, 12639, 14098, 12641, 14096, 12643, 14094, 12645, 14092, 12647, 14090, 12649, 14088, 12651, 14086, 12653, 14084, 12655, 14082, 12657, 14080, 12659, 14078, 12661, 14076, 12663, 14074, 12665, 14072, 12667, 14070, 12669, 14068, 12671, 14066, 12673, 14064, 12675, 14062, 12677, 14060, 12679, 14058, 12681, 14056, 12683, 14054, 12685, 14052, 12687, 14050, 12689, 14048, 12691, 14046, 12693, 14044, 12695, 14042, 12697, 14040, 12699, 14038, 12701, 14036, 12703, 14034, 12705, 14032, 12707, 14030, 12709, 14028, 12711, 14026, 12713, 14024, 12715, 14022, 12717, 14020, 12719, 14018, 12721, 14016, 12723, 14014, 12725, 14012, 12727, 14010, 12729, 14008, 12731, 14006, 12733, 14004, 12735, 14002, 12737, 14000, 12739, 13998, 12741, 13996, 12743, 13994, 12745, 13992, 12747, 13990, 12749, 13988, 12751, 13986, 12753, 13984, 12755, 13982, 12757, 13980, 12759, 13978, 12761, 13976, 12763, 13974, 12765, 13972, 12767, 13970, 12769, 13968, 12771, 13966, 12773, 13964, 12775, 13962, 12777, 13960, 12779, 13958, 12781, 13956, 12783, 13954, 12785, 13952, 12787, 13950, 12789, 13948, 12791, 13946, 12793, 13944, 12795, 13942, 12797, 13940, 12799, 13938, 12801, 13936, 12803, 13934, 12805, 13932, 12807, 13930, 12809, 13928, 12811, 13926, 12813, 13924, 12815, 13922, 12817, 13920, 12819, 13918, 12821, 13916, 12823, 13914, 12825, 13912, 12827, 13910, 12829, 13908, 12831, 13906, 12833, 13904, 12835, 13902, 12837, 13900, 12839, 13898, 12841, 13896, 12843, 13894, 12845, 13892, 12847, 13890, 12849, 13888, 12851, 13886, 12853, 13884, 12855, 13882, 12857, 13880, 12859, 13878, 12861, 13876, 12863, 13874, 12865, 13872, 12867, 13870, 12869, 13868, 12871, 13866, 12873, 13864, 12875, 13862, 12877, 13860, 12879, 13858, 12881, 13856, 12883, 13854, 12885, 13852, 12887, 13850, 12889, 13848, 12891, 13846, 12893, 13844, 12895, 13842, 12897, 13840, 12899, 13838, 12901, 13836, 12903, 13834, 12905, 13832, 12907, 13830, 12909, 13828, 12911, 13826, 12913, 13824, 12915, 13822, 12917, 13820, 12919, 13818, 12921, 13816, 12923, 13814, 12925, 13812, 12927, 13810, 12929, 13808, 12931, 13806, 12933, 13804, 12935, 13802, 12937, 13800, 12939, 13798, 12941, 13796, 12943, 13794, 12945, 13792, 12947, 13790, 12949, 13788, 12951, 13786, 12953, 13784, 12955, 13782, 12957, 13780, 12959, 13778, 12961, 13776, 12963, 13774, 12965, 13772, 12967, 13770, 12969, 13768, 12971, 13766, 12973, 13764, 12975, 13762, 12977, 13760, 12979, 13758, 12981, 13756, 12983, 13754, 12985, 13752, 12987, 13750, 12989, 13748, 12991, 13746, 12993, 13744, 12995, 13742, 12997, 13740, 12999, 13738, 13001, 13736, 13003, 13734, 13005, 13732, 13007, 13730, 13009, 13728, 13011, 13726, 13013, 13724, 13015, 13722, 13017, 13720, 13019, 13718, 13021, 13716, 13023, 13714, 13025, 13712, 13027, 13710, 13029, 13708, 13031, 13706, 13033, 13704, 13035, 13702, 13037, 13700, 13039, 13698, 13041, 13696, 13043, 13694, 13045, 13692, 13047, 13690, 13049, 13688, 13051, 13686, 13053, 13684, 13055, 13682, 13057, 13680, 13059, 13678, 13061, 13676, 13063, 13674, 13065, 13672, 13067, 13670, 13069, 13668, 13071, 13666, 13073, 13664, 13075, 13662, 13077, 13660, 13079, 13658, 13081, 13656, 13083, 13654, 13085, 13652, 13087, 13650, 13089, 13648, 13091, 13646, 13093, 13644, 13095, 13642, 13097, 13640, 13099, 13638, 13101, 13636, 13103, 13634, 13105, 13632, 13107, 13630, 13109, 13628, 13111, 13626, 13113, 13624, 13115, 13622, 13117, 13620, 13119, 13618, 13121, 13616, 13123, 13614, 13125, 13612, 13127, 13610, 13129, 13608, 13131, 13606, 13133, 13604, 13135, 13602, 13137, 13600, 13139, 13598, 13141, 13596, 13143, 13594, 13145, 13592, 13147, 13590, 13149, 13588, 13151, 13586, 13153, 13584, 13155, 13582, 13157, 13580, 13159, 13578, 13161, 13576, 13163, 13574, 13165, 13572, 13167, 13570, 13169, 13568, 13171, 13566, 13173, 13564, 13175, 13562, 13177, 13560, 13179, 13558, 13181, 13556, 13183, 13554, 13185, 13552, 13187, 13550, 13189, 13548, 13191, 13546, 13193, 13544, 13195, 13542, 13197, 13540, 13199, 13538, 13201, 13536, 13203, 13534, 13205, 13532, 13207, 13530, 13209, 13528, 13211, 13526, 13213, 13524, 13215, 13522, 13217, 13520, 13219, 13518, 13221, 13516, 13223, 13514, 13225, 13512, 13227, 13510, 13229, 13508, 13231, 13506, 13233, 13504, 13235, 13502, 13237, 13500, 13239, 13498, 13241, 13496, 13243, 13494, 13245, 13492, 13247, 13490, 13249, 13488, 13251, 13486, 13253, 13484, 13255, 13482, 13257, 13480, 13259, 13478, 13261, 13476, 13263, 13474, 13265, 13472, 13267, 13470, 13269, 13468, 13271, 13466, 13273, 13464, 13275, 13462, 13277, 13460, 13279, 13458, 13281, 13456, 13283, 13454, 13285, 13452, 13287, 13450, 13289, 13448, 13291, 13446, 13293, 13444, 13295, 13442, 13297, 13440, 13299, 13438, 13301, 13436, 13303, 13434, 13305, 13432, 13307, 13430, 13309, 13428, 13311, 13426, 13313, 13424, 13315, 13422, 13317, 13420, 13319, 13418, 13321, 13416, 13323, 13414, 13325, 13412, 13327, 13410, 13329, 13408, 13331, 13406, 13333, 13404, 13335, 13402, 13337, 13400, 13339, 13398, 13341, 13396, 13343, 13394, 13345, 13392, 13347, 13390, 13349, 13388, 13351, 13386, 13353, 13384, 13355, 13382, 13357, 13380, 13359, 13378, 13361, 13376, 13363, 13374, 13365, 13372, 13367, 13370, 13369, 13368, 13371, 13366, 13373, 13364, 13375, 13362, 13377, 13360, 13379, 13358, 13381, 13356, 13383, 13354, 13385, 13352, 13387, 13350, 13389, 13348, 13391, 13346, 13393, 13344, 13395, 13342, 13397, 13340, 13399, 13338, 13401, 13336, 13403, 13334, 13405, 13332, 13407, 13330, 13409, 13328, 13411, 13326, 13413, 13324, 13415, 13322, 13417, 13320, 13419, 13318, 13421, 13316, 13423, 13314, 13425, 13312, 13427, 13310, 13429, 13308, 13431, 13306, 13433, 13304, 13435, 13302, 13437, 13300, 13439, 13298, 13441, 13296, 13443, 13294, 13445, 13292, 13447, 13290, 13449, 13288, 13451, 13286, 13453, 13284, 13455, 13282, 13457, 13280, 13459, 13278, 13461, 13276, 13463, 13274, 13465, 13272, 13467, 13270, 13469, 13268, 13471, 13266, 13473, 13264, 13475, 13262, 13477, 13260, 13479, 13258, 13481, 13256, 13483, 13254, 13485, 13252, 13487, 13250, 13489, 13248, 13491, 13246, 13493, 13244, 13495, 13242, 13497, 13240, 13499, 13238, 13501, 13236, 13503, 13234, 13505, 13232, 13507, 13230, 13509, 13228, 13511, 13226, 13513, 13224, 13515, 13222, 13517, 13220, 13519, 13218, 13521, 13216, 13523, 13214, 13525, 13212, 13527, 13210, 13529, 13208, 13531, 13206, 13533, 13204, 13535, 13202, 13537, 13200, 13539, 13198, 13541, 13196, 13543, 13194, 13545, 13192, 13547, 13190, 13549, 13188, 13551, 13186, 13553, 13184, 13555, 13182, 13557, 13180, 13559, 13178, 13561, 13176, 13563, 13174, 13565, 13172, 13567, 13170, 13569, 13168, 13571, 13166, 13573, 13164, 13575, 13162, 13577, 13160, 13579, 13158, 13581, 13156, 13583, 13154, 13585, 13152, 13587, 13150, 13589, 13148, 13591, 13146, 13593, 13144, 13595, 13142, 13597, 13140, 13599, 13138, 13601, 13136, 13603, 13134, 13605, 13132, 13607, 13130, 13609, 13128, 13611, 13126, 13613, 13124, 13615, 13122, 13617, 13120, 13619, 13118, 13621, 13116, 13623, 13114, 13625, 13112, 13627, 13110, 13629, 13108, 13631, 13106, 13633, 13104, 13635, 13102, 13637, 13100, 13639, 13098, 13641, 13096, 13643, 13094, 13645, 13092, 13647, 13090, 13649, 13088, 13651, 13086, 13653, 13084, 13655, 13082, 13657, 13080, 13659, 13078, 13661, 13076, 13663, 13074, 13665, 13072, 13667, 13070, 13669, 13068, 13671, 13066, 13673, 13064, 13675, 13062, 13677, 13060, 13679, 13058, 13681, 13056, 13683, 13054, 13685, 13052, 13687, 13050, 13689, 13048, 13691, 13046, 13693, 13044, 13695, 13042, 13697, 13040, 13699, 13038, 13701, 13036, 13703, 13034, 13705, 13032, 13707, 13030, 13709, 13028, 13711, 13026, 13713, 13024, 13715, 13022, 13717, 13020, 13719, 13018, 13721, 13016, 13723, 13014, 13725, 13012, 13727, 13010, 13729, 13008, 13731, 13006, 13733, 13004, 13735, 13002, 13737, 13000, 13739, 12998, 13741, 12996, 13743, 12994, 13745, 12992, 13747, 12990, 13749, 12988, 13751, 12986, 13753, 12984, 13755, 12982, 13757, 12980, 13759, 12978, 13761, 12976, 13763, 12974, 13765, 12972, 13767, 12970, 13769, 12968, 13771, 12966, 13773, 12964, 13775, 12962, 13777, 12960, 13779, 12958, 13781, 12956, 13783, 12954, 13785, 12952, 13787, 12950, 13789, 12948, 13791, 12946, 13793, 12944, 13795, 12942, 13797, 12940, 13799, 12938, 13801, 12936, 13803, 12934, 13805, 12932, 13807, 12930, 13809, 12928, 13811, 12926, 13813, 12924, 13815, 12922, 13817, 12920, 13819, 12918, 13821, 12916, 13823, 12914, 13825, 12912, 13827, 12910, 13829, 12908, 13831, 12906, 13833, 12904, 13835, 12902, 13837, 12900, 13839, 12898, 13841, 12896, 13843, 12894, 13845, 12892, 13847, 12890, 13849, 12888, 13851, 12886, 13853, 12884, 13855, 12882, 13857, 12880, 13859, 12878, 13861, 12876, 13863, 12874, 13865, 12872, 13867, 12870, 13869, 12868, 13871, 12866, 13873, 12864, 13875, 12862, 13877, 12860, 13879, 12858, 13881, 12856, 13883, 12854, 13885, 12852, 13887, 12850, 13889, 12848, 13891, 12846, 13893, 12844, 13895, 12842, 13897, 12840, 13899, 12838, 13901, 12836, 13903, 12834, 13905, 12832, 13907, 12830, 13909, 12828, 13911, 12826, 13913, 12824, 13915, 12822, 13917, 12820, 13919, 12818, 13921, 12816, 13923, 12814, 13925, 12812, 13927, 12810, 13929, 12808, 13931, 12806, 13933, 12804, 13935, 12802, 13937, 12800, 13939, 12798, 13941, 12796, 13943, 12794, 13945, 12792, 13947, 12790, 13949, 12788, 13951, 12786, 13953, 12784, 13955, 12782, 13957, 12780, 13959, 12778, 13961, 12776, 13963, 12774, 13965, 12772, 13967, 12770, 13969, 12768, 13971, 12766, 13973, 12764, 13975, 12762, 13977, 12760, 13979, 12758, 13981, 12756, 13983, 12754, 13985, 12752, 13987, 12750, 13989, 12748, 13991, 12746, 13993, 12744, 13995, 12742, 13997, 12740, 13999, 12738, 14001, 12736, 14003, 12734, 14005, 12732, 14007, 12730, 14009, 12728, 14011, 12726, 14013, 12724, 14015, 12722, 14017, 12720, 14019, 12718, 14021, 12716, 14023, 12714, 14025, 12712, 14027, 12710, 14029, 12708, 14031, 12706, 14033, 12704, 14035, 12702, 14037, 12700, 14039, 12698, 14041, 12696, 14043, 12694, 14045, 12692, 14047, 12690, 14049, 12688, 14051, 12686, 14053, 12684, 14055, 12682, 14057, 12680, 14059, 12678, 14061, 12676, 14063, 12674, 14065, 12672, 14067, 12670, 14069, 12668, 14071, 12666, 14073, 12664, 14075, 12662, 14077, 12660, 14079, 12658, 14081, 12656, 14083, 12654, 14085, 12652, 14087, 12650, 14089, 12648, 14091, 12646, 14093, 12644, 14095, 12642, 14097, 12640, 14099, 12638, 14101, 12636, 14103, 12634, 14105, 12632, 14107, 12630, 14109, 12628, 14111, 12626, 14113, 12624, 14115, 12622, 14117, 12620, 14119, 12618, 14121, 12616, 14123, 12614, 14125, 12612, 14127, 12610, 14129, 12608, 14131, 12606, 14133, 12604, 14135, 12602, 14137, 12600, 14139, 12598, 14141, 12596, 14143, 12594, 14145, 12592, 14147, 12590, 14149, 12588, 14151, 12586, 14153, 12584, 14155, 12582, 14157, 12580, 14159, 12578, 14161, 12576, 14163, 12574, 14165, 12572, 14167, 12570, 14169, 12568, 14171, 12566, 14173, 12564, 14175, 12562, 14177, 12560, 14179, 12558, 14181, 12556, 14183, 12554, 14185, 12552, 14187, 12550, 14189, 12548, 14191, 12546, 14193, 12544, 14195, 12542, 14197, 12540, 14199, 12538, 14201, 12536, 14203, 12534, 14205, 12532, 14207, 12530, 14209, 12528, 14211, 12526, 14213, 12524, 14215, 12522, 14217, 12520, 14219, 12518, 14221, 12516, 14223, 12514, 14225, 12512, 14227, 12510, 14229, 12508, 14231, 12506, 14233, 12504, 14235, 12502, 14237, 12500, 14239, 12498, 14241, 12496, 14243, 12494, 14245, 12492, 14247, 12490, 14249, 12488, 14251, 12486, 14253, 12484, 14255, 12482, 14257, 12480, 14259, 12478, 14261, 12476, 14263, 12474, 14265, 12472, 14267, 12470, 14269, 12468, 14271, 12466, 14273, 12464, 14275, 12462, 14277, 12460, 14279, 12458, 14281, 12456, 14283, 12454, 14285, 12452, 14287, 12450, 14289, 12448, 14291, 12446, 14293, 12444, 14295, 12442, 14297, 12440, 14299, 12438, 14301, 12436, 14303, 12434, 14305, 12432, 14307, 12430, 14309, 12428, 14311, 12426, 14313, 12424, 14315, 12422, 14317, 12420, 14319, 12418, 14321, 12416, 14323, 12414, 14325, 12412, 14327, 12410, 14329, 12408, 14331, 12406, 14333, 12404, 14335, 12402, 14337, 12400, 14339, 12398, 14341, 12396, 14343, 12394, 14345, 12392, 14347, 12390, 14349, 12388, 14351, 12386, 14353, 12384, 14355, 12382, 14357, 12380, 14359, 12378, 14361, 12376, 14363, 12374, 14365, 12372, 14367, 12370, 14369, 12368, 14371, 12366, 14373, 12364, 14375, 12362, 14377, 12360, 14379, 12358, 14381, 12356, 14383, 12354, 14385, 12352, 14387, 12350, 14389, 12348, 14391, 12346, 14393, 12344, 14395, 12342, 14397, 12340, 14399, 12338, 14401, 12336, 14403, 12334, 14405, 12332, 14407, 12330, 14409, 12328, 14411, 12326, 14413, 12324, 14415, 12322, 14417, 12320, 14419, 12318, 14421, 12316, 14423, 12314, 14425, 12312, 14427, 12310, 14429, 12308, 14431, 12306, 14433, 12304, 14435, 12302, 14437, 12300, 14439, 12298, 14441, 12296, 14443, 12294, 14445, 12292, 14447, 12290, 14449, 12288, 14451, 12286, 14453, 12284, 14455, 12282, 14457, 12280, 14459, 12278, 14461, 12276, 14463, 12274, 14465, 12272, 14467, 12270, 14469, 12268, 14471, 12266, 14473, 12264, 14475, 12262, 14477, 12260, 14479, 12258, 14481, 12256, 14483, 12254, 14485, 12252, 14487, 12250, 14489, 12248, 14491, 12246, 14493, 12244, 14495, 12242, 14497, 12240, 14499, 12238, 14501, 12236, 14503, 12234, 14505, 12232, 14507, 12230, 14509, 12228, 14511, 12226, 14513, 12224, 14515, 12222, 14517, 12220, 14519, 12218, 14521, 12216, 14523, 12214, 14525, 12212, 14527, 12210, 14529, 12208, 14531, 12206, 14533, 12204, 14535, 12202, 14537, 12200, 14539, 12198, 14541, 12196, 14543, 12194, 14545, 12192, 14547, 12190, 14549, 12188, 14551, 12186, 14553, 12184, 14555, 12182, 14557, 12180, 14559, 12178, 14561, 12176, 14563, 12174, 14565, 12172, 14567, 12170, 14569, 12168, 14571, 12166, 14573, 12164, 14575, 12162, 14577, 12160, 14579, 12158, 14581, 12156, 14583, 12154, 14585, 12152, 14587, 12150, 14589, 12148, 14591, 12146, 14593, 12144, 14595, 12142, 14597, 12140, 14599, 12138, 14601, 12136, 14603, 12134, 14605, 12132, 14607, 12130, 14609, 12128, 14611, 12126, 14613, 12124, 14615, 12122, 14617, 12120, 14619, 12118, 14621, 12116, 14623, 12114, 14625, 12112, 14627, 12110, 14629, 12108, 14631, 12106, 14633, 12104, 14635, 12102, 14637, 12100, 14639, 12098, 14641, 12096, 14643, 12094, 14645, 12092, 14647, 12090, 14649, 12088, 14651, 12086, 14653, 12084, 14655, 12082, 14657, 12080, 14659, 12078, 14661, 12076, 14663, 12074, 14665, 12072, 14667, 12070, 14669, 12068, 14671, 12066, 14673, 12064, 14675, 12062, 14677, 12060, 14679, 12058, 14681, 12056, 14683, 12054, 14685, 12052, 14687, 12050, 14689, 12048, 14691, 12046, 14693, 12044, 14695, 12042, 14697, 12040, 14699, 12038, 14701, 12036, 14703, 12034, 14705, 12032, 14707, 12030, 14709, 12028, 14711, 12026, 14713, 12024, 14715, 12022, 14717, 12020, 14719, 12018, 14721, 12016, 14723, 12014, 14725, 12012, 14727, 12010, 14729, 12008, 14731, 12006, 14733, 12004, 14735, 12002, 14737, 12000, 14739, 11998, 14741, 11996, 14743, 11994, 14745, 11992, 14747, 11990, 14749, 11988, 14751, 11986, 14753, 11984, 14755, 11982, 14757, 11980, 14759, 11978, 14761, 11976, 14763, 11974, 14765, 11972, 14767, 11970, 14769, 11968, 14771, 11966, 14773, 11964, 14775, 11962, 14777, 11960, 14779, 11958, 14781, 11956, 14783, 11954, 14785, 11952, 14787, 11950, 14789, 11948, 14791, 11946, 14793, 11944, 14795, 11942, 14797, 11940, 14799, 11938, 14801, 11936, 14803, 11934, 14805, 11932, 14807, 11930, 14809, 11928, 14811, 11926, 14813, 11924, 14815, 11922, 14817, 11920, 14819, 11918, 14821, 11916, 14823, 11914, 14825, 11912, 14827, 11910, 14829, 11908, 14831, 11906, 14833, 11904, 14835, 11902, 14837, 11900, 14839, 11898, 14841, 11896, 14843, 11894, 14845, 11892, 14847, 11890, 14849, 11888, 14851, 11886, 14853, 11884, 14855, 11882, 14857, 11880, 14859, 11878, 14861, 11876, 14863, 11874, 14865, 11872, 14867, 11870, 14869, 11868, 14871, 11866, 14873, 11864, 14875, 11862, 14877, 11860, 14879, 11858, 14881, 11856, 14883, 11854, 14885, 11852, 14887, 11850, 14889, 11848, 14891, 11846, 14893, 11844, 14895, 11842, 14897, 11840, 14899, 11838, 14901, 11836, 14903, 11834, 14905, 11832, 14907, 11830, 14909, 11828, 14911, 11826, 14913, 11824, 14915, 11822, 14917, 11820, 14919, 11818, 14921, 11816, 14923, 11814, 14925, 11812, 14927, 11810, 14929, 11808, 14931, 11806, 14933, 11804, 14935, 11802, 14937, 11800, 14939, 11798, 14941, 11796, 14943, 11794, 14945, 11792, 14947, 11790, 14949, 11788, 14951, 11786, 14953, 11784, 14955, 11782, 14957, 11780, 14959, 11778, 14961, 11776, 14963, 11774, 14965, 11772, 14967, 11770, 14969, 11768, 14971, 11766, 14973, 11764, 14975, 11762, 14977, 11760, 14979, 11758, 14981, 11756, 14983, 11754, 14985, 11752, 14987, 11750, 14989, 11748, 14991, 11746, 14993, 11744, 14995, 11742, 14997, 11740, 14999, 11738, 15001, 11736, 15003, 11734, 15005, 11732, 15007, 11730, 15009, 11728, 15011, 11726, 15013, 11724, 15015, 11722, 15017, 11720, 15019, 11718, 15021, 11716, 15023, 11714, 15025, 11712, 15027, 11710, 15029, 11708, 15031, 11706, 15033, 11704, 15035, 11702, 15037, 11700, 15039, 11698, 15041, 11696, 15043, 11694, 15045, 11692, 15047, 11690, 15049, 11688, 15051, 11686, 15053, 11684, 15055, 11682, 15057, 11680, 15059, 11678, 15061, 11676, 15063, 11674, 15065, 11672, 15067, 11670, 15069, 11668, 15071, 11666, 15073, 11664, 15075, 11662, 15077, 11660, 15079, 11658, 15081, 11656, 15083, 11654, 15085, 11652, 15087, 11650, 15089, 11648, 15091, 11646, 15093, 11644, 15095, 11642, 15097, 11640, 15099, 11638, 15101, 11636, 15103, 11634, 15105, 11632, 15107, 11630, 15109, 11628, 15111, 11626, 15113, 11624, 15115, 11622, 15117, 11620, 15119, 11618, 15121, 11616, 15123, 11614, 15125, 11612, 15127, 11610, 15129, 11608, 15131, 11606, 15133, 11604, 15135, 11602, 15137, 11600, 15139, 11598, 15141, 11596, 15143, 11594, 15145, 11592, 15147, 11590, 15149, 11588, 15151, 11586, 15153, 11584, 15155, 11582, 15157, 11580, 15159, 11578, 15161, 11576, 15163, 11574, 15165, 11572, 15167, 11570, 15169, 11568, 15171, 11566, 15173, 11564, 15175, 11562, 15177, 11560, 15179, 11558, 15181, 11556, 15183, 11554, 15185, 11552, 15187, 11550, 15189, 11548, 15191, 11546, 15193, 11544, 15195, 11542, 15197, 11540, 15199, 11538, 15201, 11536, 15203, 11534, 15205, 11532, 15207, 11530, 15209, 11528, 15211, 11526, 15213, 11524, 15215, 11522, 15217, 11520, 15219, 11518, 15221, 11516, 15223, 11514, 15225, 11512, 15227, 11510, 15229, 11508, 15231, 11506, 15233, 11504, 15235, 11502, 15237, 11500, 15239, 11498, 15241, 11496, 15243, 11494, 15245, 11492, 15247, 11490, 15249, 11488, 15251, 11486, 15253, 11484, 15255, 11482, 15257, 11480, 15259, 11478, 15261, 11476, 15263, 11474, 15265, 11472, 15267, 11470, 15269, 11468, 15271, 11466, 15273, 11464, 15275, 11462, 15277, 11460, 15279, 11458, 15281, 11456, 15283, 11454, 15285, 11452, 15287, 11450, 15289, 11448, 15291, 11446, 15293, 11444, 15295, 11442, 15297, 11440, 15299, 11438, 15301, 11436, 15303, 11434, 15305, 11432, 15307, 11430, 15309, 11428, 15311, 11426, 15313, 11424, 15315, 11422, 15317, 11420, 15319, 11418, 15321, 11416, 15323, 11414, 15325, 11412, 15327, 11410, 15329, 11408, 15331, 11406, 15333, 11404, 15335, 11402, 15337, 11400, 15339, 11398, 15341, 11396, 15343, 11394, 15345, 11392, 15347, 11390, 15349, 11388, 15351, 11386, 15353, 11384, 15355, 11382, 15357, 11380, 15359, 11378, 15361, 11376, 15363, 11374, 15365, 11372, 15367, 11370, 15369, 11368, 15371, 11366, 15373, 11364, 15375, 11362, 15377, 11360, 15379, 11358, 15381, 11356, 15383, 11354, 15385, 11352, 15387, 11350, 15389, 11348, 15391, 11346, 15393, 11344, 15395, 11342, 15397, 11340, 15399, 11338, 15401, 11336, 15403, 11334, 15405, 11332, 15407, 11330, 15409, 11328, 15411, 11326, 15413, 11324, 15415, 11322, 15417, 11320, 15419, 11318, 15421, 11316, 15423, 11314, 15425, 11312, 15427, 11310, 15429, 11308, 15431, 11306, 15433, 11304, 15435, 11302, 15437, 11300, 15439, 11298, 15441, 11296, 15443, 11294, 15445, 11292, 15447, 11290, 15449, 11288, 15451, 11286, 15453, 11284, 15455, 11282, 15457, 11280, 15459, 11278, 15461, 11276, 15463, 11274, 15465, 11272, 15467, 11270, 15469, 11268, 15471, 11266, 15473, 11264, 15475, 11262, 15477, 11260, 15479, 11258, 15481, 11256, 15483, 11254, 15485, 11252, 15487, 11250, 15489, 11248, 15491, 11246, 15493, 11244, 15495, 11242, 15497, 11240, 15499, 11238, 15501, 11236, 15503, 11234, 15505, 11232, 15507, 11230, 15509, 11228, 15511, 11226, 15513, 11224, 15515, 11222, 15517, 11220, 15519, 11218, 15521, 11216, 15523, 11214, 15525, 11212, 15527, 11210, 15529, 11208, 15531, 11206, 15533, 11204, 15535, 11202, 15537, 11200, 15539, 11198, 15541, 11196, 15543, 11194, 15545, 11192, 15547, 11190, 15549, 11188, 15551, 11186, 15553, 11184, 15555, 11182, 15557, 11180, 15559, 11178, 15561, 11176, 15563, 11174, 15565, 11172, 15567, 11170, 15569, 11168, 15571, 11166, 15573, 11164, 15575, 11162, 15577, 11160, 15579, 11158, 15581, 11156, 15583, 11154, 15585, 11152, 15587, 11150, 15589, 11148, 15591, 11146, 15593, 11144, 15595, 11142, 15597, 11140, 15599, 11138, 15601, 11136, 15603, 11134, 15605, 11132, 15607, 11130, 15609, 11128, 15611, 11126, 15613, 11124, 15615, 11122, 15617, 11120, 15619, 11118, 15621, 11116, 15623, 11114, 15625, 11112, 15627, 11110, 15629, 11108, 15631, 11106, 15633, 11104, 15635, 11102, 15637, 11100, 15639, 11098, 15641, 11096, 15643, 11094, 15645, 11092, 15647, 11090, 15649, 11088, 15651, 11086, 15653, 11084, 15655, 11082, 15657, 11080, 15659, 11078, 15661, 11076, 15663, 11074, 15665, 11072, 15667, 11070, 15669, 11068, 15671, 11066, 15673, 11064, 15675, 11062, 15677, 11060, 15679, 11058, 15681, 11056, 15683, 11054, 15685, 11052, 15687, 11050, 15689, 11048, 15691, 11046, 15693, 11044, 15695, 11042, 15697, 11040, 15699, 11038, 15701, 11036, 15703, 11034, 15705, 11032, 15707, 11030, 15709, 11028, 15711, 11026, 15713, 11024, 15715, 11022, 15717, 11020, 15719, 11018, 15721, 11016, 15723, 11014, 15725, 11012, 15727, 11010, 15729, 11008, 15731, 11006, 15733, 11004, 15735, 11002, 15737, 11000, 15739, 10998, 15741, 10996, 15743, 10994, 15745, 10992, 15747, 10990, 15749, 10988, 15751, 10986, 15753, 10984, 15755, 10982, 15757, 10980, 15759, 10978, 15761, 10976, 15763, 10974, 15765, 10972, 15767, 10970, 15769, 10968, 15771, 10966, 15773, 10964, 15775, 10962, 15777, 10960, 15779, 10958, 15781, 10956, 15783, 10954, 15785, 10952, 15787, 10950, 15789, 10948, 15791, 10946, 15793, 10944, 15795, 10942, 15797, 10940, 15799, 10938, 15801, 10936, 15803, 10934, 15805, 10932, 15807, 10930, 15809, 10928, 15811, 10926, 15813, 10924, 15815, 10922, 15817, 10920, 15819, 10918, 15821, 10916, 15823, 10914, 15825, 10912, 15827, 10910, 15829, 10908, 15831, 10906, 15833, 10904, 15835, 10902, 15837, 10900, 15839, 10898, 15841, 10896, 15843, 10894, 15845, 10892, 15847, 10890, 15849, 10888, 15851, 10886, 15853, 10884, 15855, 10882, 15857, 10880, 15859, 10878, 15861, 10876, 15863, 10874, 15865, 10872, 15867, 10870, 15869, 10868, 15871, 10866, 15873, 10864, 15875, 10862, 15877, 10860, 15879, 10858, 15881, 10856, 15883, 10854, 15885, 10852, 15887, 10850, 15889, 10848, 15891, 10846, 15893, 10844, 15895, 10842, 15897, 10840, 15899, 10838, 15901, 10836, 15903, 10834, 15905, 10832, 15907, 10830, 15909, 10828, 15911, 10826, 15913, 10824, 15915, 10822, 15917, 10820, 15919, 10818, 15921, 10816, 15923, 10814, 15925, 10812, 15927, 10810, 15929, 10808, 15931, 10806, 15933, 10804, 15935, 10802, 15937, 10800, 15939, 10798, 15941, 10796, 15943, 10794, 15945, 10792, 15947, 10790, 15949, 10788, 15951, 10786, 15953, 10784, 15955, 10782, 15957, 10780, 15959, 10778, 15961, 10776, 15963, 10774, 15965, 10772, 15967, 10770, 15969, 10768, 15971, 10766, 15973, 10764, 15975, 10762, 15977, 10760, 15979, 10758, 15981, 10756, 15983, 10754, 15985, 10752, 15987, 10750, 15989, 10748, 15991, 10746, 15993, 10744, 15995, 10742, 15997, 10740, 15999, 10738, 16001, 10736, 16003, 10734, 16005, 10732, 16007, 10730, 16009, 10728, 16011, 10726, 16013, 10724, 16015, 10722, 16017, 10720, 16019, 10718, 16021, 10716, 16023, 10714, 16025, 10712, 16027, 10710, 16029, 10708, 16031, 10706, 16033, 10704, 16035, 10702, 16037, 10700, 16039, 10698, 16041, 10696, 16043, 10694, 16045, 10692, 16047, 10690, 16049, 10688, 16051, 10686, 16053, 10684, 16055, 10682, 16057, 10680, 16059, 10678, 16061, 10676, 16063, 10674, 16065, 10672, 16067, 10670, 16069, 10668, 16071, 10666, 16073, 10664, 16075, 10662, 16077, 10660, 16079, 10658, 16081, 10656, 16083, 10654, 16085, 10652, 16087, 10650, 16089, 10648, 16091, 10646, 16093, 10644, 16095, 10642, 16097, 10640, 16099, 10638, 16101, 10636, 16103, 10634, 16105, 10632, 16107, 10630, 16109, 10628, 16111, 10626, 16113, 10624, 16115, 10622, 16117, 10620, 16119, 10618, 16121, 10616, 16123, 10614, 16125, 10612, 16127, 10610, 16129, 10608, 16131, 10606, 16133, 10604, 16135, 10602, 16137, 10600, 16139, 10598, 16141, 10596, 16143, 10594, 16145, 10592, 16147, 10590, 16149, 10588, 16151, 10586, 16153, 10584, 16155, 10582, 16157, 10580, 16159, 10578, 16161, 10576, 16163, 10574, 16165, 10572, 16167, 10570, 16169, 10568, 16171, 10566, 16173, 10564, 16175, 10562, 16177, 10560, 16179, 10558, 16181, 10556, 16183, 10554, 16185, 10552, 16187, 10550, 16189, 10548, 16191, 10546, 16193, 10544, 16195, 10542, 16197, 10540, 16199, 10538, 16201, 10536, 16203, 10534, 16205, 10532, 16207, 10530, 16209, 10528, 16211, 10526, 16213, 10524, 16215, 10522, 16217, 10520, 16219, 10518, 16221, 10516, 16223, 10514, 16225, 10512, 16227, 10510, 16229, 10508, 16231, 10506, 16233, 10504, 16235, 10502, 16237, 10500, 16239, 10498, 16241, 10496, 16243, 10494, 16245, 10492, 16247, 10490, 16249, 10488, 16251, 10486, 16253, 10484, 16255, 10482, 16257, 10480, 16259, 10478, 16261, 10476, 16263, 10474, 16265, 10472, 16267, 10470, 16269, 10468, 16271, 10466, 16273, 10464, 16275, 10462, 16277, 10460, 16279, 10458, 16281, 10456, 16283, 10454, 16285, 10452, 16287, 10450, 16289, 10448, 16291, 10446, 16293, 10444, 16295, 10442, 16297, 10440, 16299, 10438, 16301, 10436, 16303, 10434, 16305, 10432, 16307, 10430, 16309, 10428, 16311, 10426, 16313, 10424, 16315, 10422, 16317, 10420, 16319, 10418, 16321, 10416, 16323, 10414, 16325, 10412, 16327, 10410, 16329, 10408, 16331, 10406, 16333, 10404, 16335, 10402, 16337, 10400, 16339, 10398, 16341, 10396, 16343, 10394, 16345, 10392, 16347, 10390, 16349, 10388, 16351, 10386, 16353, 10384, 16355, 10382, 16357, 10380, 16359, 10378, 16361, 10376, 16363, 10374, 16365, 10372, 16367, 10370, 16369, 10368, 16371, 10366, 16373, 10364, 16375, 10362, 16377, 10360, 16379, 10358, 16381, 10356, 16383, 10354, 16385, 10352, 16387, 10350, 16389, 10348, 16391, 10346, 16393, 10344, 16395, 10342, 16397, 10340, 16399, 10338, 16401, 10336, 16403, 10334, 16405, 10332, 16407, 10330, 16409, 10328, 16411, 10326, 16413, 10324, 16415, 10322, 16417, 10320, 16419, 10318, 16421, 10316, 16423, 10314, 16425, 10312, 16427, 10310, 16429, 10308, 16431, 10306, 16433, 10304, 16435, 10302, 16437, 10300, 16439, 10298, 16441, 10296, 16443, 10294, 16445, 10292, 16447, 10290, 16449, 10288, 16451, 10286, 16453, 10284, 16455, 10282, 16457, 10280, 16459, 10278, 16461, 10276, 16463, 10274, 16465, 10272, 16467, 10270, 16469, 10268, 16471, 10266, 16473, 10264, 16475, 10262, 16477, 10260, 16479, 10258, 16481, 10256, 16483, 10254, 16485, 10252, 16487, 10250, 16489, 10248, 16491, 10246, 16493, 10244, 16495, 10242, 16497, 10240, 16499, 10238, 16501, 10236, 16503, 10234, 16505, 10232, 16507, 10230, 16509, 10228, 16511, 10226, 16513, 10224, 16515, 10222, 16517, 10220, 16519, 10218, 16521, 10216, 16523, 10214, 16525, 10212, 16527, 10210, 16529, 10208, 16531, 10206, 16533, 10204, 16535, 10202, 16537, 10200, 16539, 10198, 16541, 10196, 16543, 10194, 16545, 10192, 16547, 10190, 16549, 10188, 16551, 10186, 16553, 10184, 16555, 10182, 16557, 10180, 16559, 10178, 16561, 10176, 16563, 10174, 16565, 10172, 16567, 10170, 16569, 10168, 16571, 10166, 16573, 10164, 16575, 10162, 16577, 10160, 16579, 10158, 16581, 10156, 16583, 10154, 16585, 10152, 16587, 10150, 16589, 10148, 16591, 10146, 16593, 10144, 16595, 10142, 16597, 10140, 16599, 10138, 16601, 10136, 16603, 10134, 16605, 10132, 16607, 10130, 16609, 10128, 16611, 10126, 16613, 10124, 16615, 10122, 16617, 10120, 16619, 10118, 16621, 10116, 16623, 10114, 16625, 10112, 16627, 10110, 16629, 10108, 16631, 10106, 16633, 10104, 16635, 10102, 16637, 10100, 16639, 10098, 16641, 10096, 16643, 10094, 16645, 10092, 16647, 10090, 16649, 10088, 16651, 10086, 16653, 10084, 16655, 10082, 16657, 10080, 16659, 10078, 16661, 10076, 16663, 10074, 16665, 10072, 16667, 10070, 16669, 10068, 16671, 10066, 16673, 10064, 16675, 10062, 16677, 10060, 16679, 10058, 16681, 10056, 16683, 10054, 16685, 10052, 16687, 10050, 16689, 10048, 16691, 10046, 16693, 10044, 16695, 10042, 16697, 10040, 16699, 10038, 16701, 10036, 16703, 10034, 16705, 10032, 16707, 10030, 16709, 10028, 16711, 10026, 16713, 10024, 16715, 10022, 16717, 10020, 16719, 10018, 16721, 10016, 16723, 10014, 16725, 10012, 16727, 10010, 16729, 10008, 16731, 10006, 16733, 10004, 16735, 10002, 16737, 10000, 16739, 9998, 16741, 9996, 16743, 9994, 16745, 9992, 16747, 9990, 16749, 9988, 16751, 9986, 16753, 9984, 16755, 9982, 16757, 9980, 16759, 9978, 16761, 9976, 16763, 9974, 16765, 9972, 16767, 9970, 16769, 9968, 16771, 9966, 16773, 9964, 16775, 9962, 16777, 9960, 16779, 9958, 16781, 9956, 16783, 9954, 16785, 9952, 16787, 9950, 16789, 9948, 16791, 9946, 16793, 9944, 16795, 9942, 16797, 9940, 16799, 9938, 16801, 9936, 16803, 9934, 16805, 9932, 16807, 9930, 16809, 9928, 16811, 9926, 16813, 9924, 16815, 9922, 16817, 9920, 16819, 9918, 16821, 9916, 16823, 9914, 16825, 9912, 16827, 9910, 16829, 9908, 16831, 9906, 16833, 9904, 16835, 9902, 16837, 9900, 16839, 9898, 16841, 9896, 16843, 9894, 16845, 9892, 16847, 9890, 16849, 9888, 16851, 9886, 16853, 9884, 16855, 9882, 16857, 9880, 16859, 9878, 16861, 9876, 16863, 9874, 16865, 9872, 16867, 9870, 16869, 9868, 16871, 9866, 16873, 9864, 16875, 9862, 16877, 9860, 16879, 9858, 16881, 9856, 16883, 9854, 16885, 9852, 16887, 9850, 16889, 9848, 16891, 9846, 16893, 9844, 16895, 9842, 16897, 9840, 16899, 9838, 16901, 9836, 16903, 9834, 16905, 9832, 16907, 9830, 16909, 9828, 16911, 9826, 16913, 9824, 16915, 9822, 16917, 9820, 16919, 9818, 16921, 9816, 16923, 9814, 16925, 9812, 16927, 9810, 16929, 9808, 16931, 9806, 16933, 9804, 16935, 9802, 16937, 9800, 16939, 9798, 16941, 9796, 16943, 9794, 16945, 9792, 16947, 9790, 16949, 9788, 16951, 9786, 16953, 9784, 16955, 9782, 16957, 9780, 16959, 9778, 16961, 9776, 16963, 9774, 16965, 9772, 16967, 9770, 16969, 9768, 16971, 9766, 16973, 9764, 16975, 9762, 16977, 9760, 16979, 9758, 16981, 9756, 16983, 9754, 16985, 9752, 16987, 9750, 16989, 9748, 16991, 9746, 16993, 9744, 16995, 9742, 16997, 9740, 16999, 9738, 17001, 9736, 17003, 9734, 17005, 9732, 17007, 9730, 17009, 9728, 17011, 9726, 17013, 9724, 17015, 9722, 17017, 9720, 17019, 9718, 17021, 9716, 17023, 9714, 17025, 9712, 17027, 9710, 17029, 9708, 17031, 9706, 17033, 9704, 17035, 9702, 17037, 9700, 17039, 9698, 17041, 9696, 17043, 9694, 17045, 9692, 17047, 9690, 17049, 9688, 17051, 9686, 17053, 9684, 17055, 9682, 17057, 9680, 17059, 9678, 17061, 9676, 17063, 9674, 17065, 9672, 17067, 9670, 17069, 9668, 17071, 9666, 17073, 9664, 17075, 9662, 17077, 9660, 17079, 9658, 17081, 9656, 17083, 9654, 17085, 9652, 17087, 9650, 17089, 9648, 17091, 9646, 17093, 9644, 17095, 9642, 17097, 9640, 17099, 9638, 17101, 9636, 17103, 9634, 17105, 9632, 17107, 9630, 17109, 9628, 17111, 9626, 17113, 9624, 17115, 9622, 17117, 9620, 17119, 9618, 17121, 9616, 17123, 9614, 17125, 9612, 17127, 9610, 17129, 9608, 17131, 9606, 17133, 9604, 17135, 9602, 17137, 9600, 17139, 9598, 17141, 9596, 17143, 9594, 17145, 9592, 17147, 9590, 17149, 9588, 17151, 9586, 17153, 9584, 17155, 9582, 17157, 9580, 17159, 9578, 17161, 9576, 17163, 9574, 17165, 9572, 17167, 9570, 17169, 9568, 17171, 9566, 17173, 9564, 17175, 9562, 17177, 9560, 17179, 9558, 17181, 9556, 17183, 9554, 17185, 9552, 17187, 9550, 17189, 9548, 17191, 9546, 17193, 9544, 17195, 9542, 17197, 9540, 17199, 9538, 17201, 9536, 17203, 9534, 17205, 9532, 17207, 9530, 17209, 9528, 17211, 9526, 17213, 9524, 17215, 9522, 17217, 9520, 17219, 9518, 17221, 9516, 17223, 9514, 17225, 9512, 17227, 9510, 17229, 9508, 17231, 9506, 17233, 9504, 17235, 9502, 17237, 9500, 17239, 9498, 17241, 9496, 17243, 9494, 17245, 9492, 17247, 9490, 17249, 9488, 17251, 9486, 17253, 9484, 17255, 9482, 17257, 9480, 17259, 9478, 17261, 9476, 17263, 9474, 17265, 9472, 17267, 9470, 17269, 9468, 17271, 9466, 17273, 9464, 17275, 9462, 17277, 9460, 17279, 9458, 17281, 9456, 17283, 9454, 17285, 9452, 17287, 9450, 17289, 9448, 17291, 9446, 17293, 9444, 17295, 9442, 17297, 9440, 17299, 9438, 17301, 9436, 17303, 9434, 17305, 9432, 17307, 9430, 17309, 9428, 17311, 9426, 17313, 9424, 17315, 9422, 17317, 9420, 17319, 9418, 17321, 9416, 17323, 9414, 17325, 9412, 17327, 9410, 17329, 9408, 17331, 9406, 17333, 9404, 17335, 9402, 17337, 9400, 17339, 9398, 17341, 9396, 17343, 9394, 17345, 9392, 17347, 9390, 17349, 9388, 17351, 9386, 17353, 9384, 17355, 9382, 17357, 9380, 17359, 9378, 17361, 9376, 17363, 9374, 17365, 9372, 17367, 9370, 17369, 9368, 17371, 9366, 17373, 9364, 17375, 9362, 17377, 9360, 17379, 9358, 17381, 9356, 17383, 9354, 17385, 9352, 17387, 9350, 17389, 9348, 17391, 9346, 17393, 9344, 17395, 9342, 17397, 9340, 17399, 9338, 17401, 9336, 17403, 9334, 17405, 9332, 17407, 9330, 17409, 9328, 17411, 9326, 17413, 9324, 17415, 9322, 17417, 9320, 17419, 9318, 17421, 9316, 17423, 9314, 17425, 9312, 17427, 9310, 17429, 9308, 17431, 9306, 17433, 9304, 17435, 9302, 17437, 9300, 17439, 9298, 17441, 9296, 17443, 9294, 17445, 9292, 17447, 9290, 17449, 9288, 17451, 9286, 17453, 9284, 17455, 9282, 17457, 9280, 17459, 9278, 17461, 9276, 17463, 9274, 17465, 9272, 17467, 9270, 17469, 9268, 17471, 9266, 17473, 9264, 17475, 9262, 17477, 9260, 17479, 9258, 17481, 9256, 17483, 9254, 17485, 9252, 17487, 9250, 17489, 9248, 17491, 9246, 17493, 9244, 17495, 9242, 17497, 9240, 17499, 9238, 17501, 9236, 17503, 9234, 17505, 9232, 17507, 9230, 17509, 9228, 17511, 9226, 17513, 9224, 17515, 9222, 17517, 9220, 17519, 9218, 17521, 9216, 17523, 9214, 17525, 9212, 17527, 9210, 17529, 9208, 17531, 9206, 17533, 9204, 17535, 9202, 17537, 9200, 17539, 9198, 17541, 9196, 17543, 9194, 17545, 9192, 17547, 9190, 17549, 9188, 17551, 9186, 17553, 9184, 17555, 9182, 17557, 9180, 17559, 9178, 17561, 9176, 17563, 9174, 17565, 9172, 17567, 9170, 17569, 9168, 17571, 9166, 17573, 9164, 17575, 9162, 17577, 9160, 17579, 9158, 17581, 9156, 17583, 9154, 17585, 9152, 17587, 9150, 17589, 9148, 17591, 9146, 17593, 9144, 17595, 9142, 17597, 9140, 17599, 9138, 17601, 9136, 17603, 9134, 17605, 9132, 17607, 9130, 17609, 9128, 17611, 9126, 17613, 9124, 17615, 9122, 17617, 9120, 17619, 9118, 17621, 9116, 17623, 9114, 17625, 9112, 17627, 9110, 17629, 9108, 17631, 9106, 17633, 9104, 17635, 9102, 17637, 9100, 17639, 9098, 17641, 9096, 17643, 9094, 17645, 9092, 17647, 9090, 17649, 9088, 17651, 9086, 17653, 9084, 17655, 9082, 17657, 9080, 17659, 9078, 17661, 9076, 17663, 9074, 17665, 9072, 17667, 9070, 17669, 9068, 17671, 9066, 17673, 9064, 17675, 9062, 17677, 9060, 17679, 9058, 17681, 9056, 17683, 9054, 17685, 9052, 17687, 9050, 17689, 9048, 17691, 9046, 17693, 9044, 17695, 9042, 17697, 9040, 17699, 9038, 17701, 9036, 17703, 9034, 17705, 9032, 17707, 9030, 17709, 9028, 17711, 9026, 17713, 9024, 17715, 9022, 17717, 9020, 17719, 9018, 17721, 9016, 17723, 9014, 17725, 9012, 17727, 9010, 17729, 9008, 17731, 9006, 17733, 9004, 17735, 9002, 17737, 9000, 17739, 8998, 17741, 8996, 17743, 8994, 17745, 8992, 17747, 8990, 17749, 8988, 17751, 8986, 17753, 8984, 17755, 8982, 17757, 8980, 17759, 8978, 17761, 8976, 17763, 8974, 17765, 8972, 17767, 8970, 17769, 8968, 17771, 8966, 17773, 8964, 17775, 8962, 17777, 8960, 17779, 8958, 17781, 8956, 17783, 8954, 17785, 8952, 17787, 8950, 17789, 8948, 17791, 8946, 17793, 8944, 17795, 8942, 17797, 8940, 17799, 8938, 17801, 8936, 17803, 8934, 17805, 8932, 17807, 8930, 17809, 8928, 17811, 8926, 17813, 8924, 17815, 8922, 17817, 8920, 17819, 8918, 17821, 8916, 17823, 8914, 17825, 8912, 17827, 8910, 17829, 8908, 17831, 8906, 17833, 8904, 17835, 8902, 17837, 8900, 17839, 8898, 17841, 8896, 17843, 8894, 17845, 8892, 17847, 8890, 17849, 8888, 17851, 8886, 17853, 8884, 17855, 8882, 17857, 8880, 17859, 8878, 17861, 8876, 17863, 8874, 17865, 8872, 17867, 8870, 17869, 8868, 17871, 8866, 17873, 8864, 17875, 8862, 17877, 8860, 17879, 8858, 17881, 8856, 17883, 8854, 17885, 8852, 17887, 8850, 17889, 8848, 17891, 8846, 17893, 8844, 17895, 8842, 17897, 8840, 17899, 8838, 17901, 8836, 17903, 8834, 17905, 8832, 17907, 8830, 17909, 8828, 17911, 8826, 17913, 8824, 17915, 8822, 17917, 8820, 17919, 8818, 17921, 8816, 17923, 8814, 17925, 8812, 17927, 8810, 17929, 8808, 17931, 8806, 17933, 8804, 17935, 8802, 17937, 8800, 17939, 8798, 17941, 8796, 17943, 8794, 17945, 8792, 17947, 8790, 17949, 8788, 17951, 8786, 17953, 8784, 17955, 8782, 17957, 8780, 17959, 8778, 17961, 8776, 17963, 8774, 17965, 8772, 17967, 8770, 17969, 8768, 17971, 8766, 17973, 8764, 17975, 8762, 17977, 8760, 17979, 8758, 17981, 8756, 17983, 8754, 17985, 8752, 17987, 8750, 17989, 8748, 17991, 8746, 17993, 8744, 17995, 8742, 17997, 8740, 17999, 8738, 18001, 8736, 18003, 8734, 18005, 8732, 18007, 8730, 18009, 8728, 18011, 8726, 18013, 8724, 18015, 8722, 18017, 8720, 18019, 8718, 18021, 8716, 18023, 8714, 18025, 8712, 18027, 8710, 18029, 8708, 18031, 8706, 18033, 8704, 18035, 8702, 18037, 8700, 18039, 8698, 18041, 8696, 18043, 8694, 18045, 8692, 18047, 8690, 18049, 8688, 18051, 8686, 18053, 8684, 18055, 8682, 18057, 8680, 18059, 8678, 18061, 8676, 18063, 8674, 18065, 8672, 18067, 8670, 18069, 8668, 18071, 8666, 18073, 8664, 18075, 8662, 18077, 8660, 18079, 8658, 18081, 8656, 18083, 8654, 18085, 8652, 18087, 8650, 18089, 8648, 18091, 8646, 18093, 8644, 18095, 8642, 18097, 8640, 18099, 8638, 18101, 8636, 18103, 8634, 18105, 8632, 18107, 8630, 18109, 8628, 18111, 8626, 18113, 8624, 18115, 8622, 18117, 8620, 18119, 8618, 18121, 8616, 18123, 8614, 18125, 8612, 18127, 8610, 18129, 8608, 18131, 8606, 18133, 8604, 18135, 8602, 18137, 8600, 18139, 8598, 18141, 8596, 18143, 8594, 18145, 8592, 18147, 8590, 18149, 8588, 18151, 8586, 18153, 8584, 18155, 8582, 18157, 8580, 18159, 8578, 18161, 8576, 18163, 8574, 18165, 8572, 18167, 8570, 18169, 8568, 18171, 8566, 18173, 8564, 18175, 8562, 18177, 8560, 18179, 8558, 18181, 8556, 18183, 8554, 18185, 8552, 18187, 8550, 18189, 8548, 18191, 8546, 18193, 8544, 18195, 8542, 18197, 8540, 18199, 8538, 18201, 8536, 18203, 8534, 18205, 8532, 18207, 8530, 18209, 8528, 18211, 8526, 18213, 8524, 18215, 8522, 18217, 8520, 18219, 8518, 18221, 8516, 18223, 8514, 18225, 8512, 18227, 8510, 18229, 8508, 18231, 8506, 18233, 8504, 18235, 8502, 18237, 8500, 18239, 8498, 18241, 8496, 18243, 8494, 18245, 8492, 18247, 8490, 18249, 8488, 18251, 8486, 18253, 8484, 18255, 8482, 18257, 8480, 18259, 8478, 18261, 8476, 18263, 8474, 18265, 8472, 18267, 8470, 18269, 8468, 18271, 8466, 18273, 8464, 18275, 8462, 18277, 8460, 18279, 8458, 18281, 8456, 18283, 8454, 18285, 8452, 18287, 8450, 18289, 8448, 18291, 8446, 18293, 8444, 18295, 8442, 18297, 8440, 18299, 8438, 18301, 8436, 18303, 8434, 18305, 8432, 18307, 8430, 18309, 8428, 18311, 8426, 18313, 8424, 18315, 8422, 18317, 8420, 18319, 8418, 18321, 8416, 18323, 8414, 18325, 8412, 18327, 8410, 18329, 8408, 18331, 8406, 18333, 8404, 18335, 8402, 18337, 8400, 18339, 8398, 18341, 8396, 18343, 8394, 18345, 8392, 18347, 8390, 18349, 8388, 18351, 8386, 18353, 8384, 18355, 8382, 18357, 8380, 18359, 8378, 18361, 8376, 18363, 8374, 18365, 8372, 18367, 8370, 18369, 8368, 18371, 8366, 18373, 8364, 18375, 8362, 18377, 8360, 18379, 8358, 18381, 8356, 18383, 8354, 18385, 8352, 18387, 8350, 18389, 8348, 18391, 8346, 18393, 8344, 18395, 8342, 18397, 8340, 18399, 8338, 18401, 8336, 18403, 8334, 18405, 8332, 18407, 8330, 18409, 8328, 18411, 8326, 18413, 8324, 18415, 8322, 18417, 8320, 18419, 8318, 18421, 8316, 18423, 8314, 18425, 8312, 18427, 8310, 18429, 8308, 18431, 8306, 18433, 8304, 18435, 8302, 18437, 8300, 18439, 8298, 18441, 8296, 18443, 8294, 18445, 8292, 18447, 8290, 18449, 8288, 18451, 8286, 18453, 8284, 18455, 8282, 18457, 8280, 18459, 8278, 18461, 8276, 18463, 8274, 18465, 8272, 18467, 8270, 18469, 8268, 18471, 8266, 18473, 8264, 18475, 8262, 18477, 8260, 18479, 8258, 18481, 8256, 18483, 8254, 18485, 8252, 18487, 8250, 18489, 8248, 18491, 8246, 18493, 8244, 18495, 8242, 18497, 8240, 18499, 8238, 18501, 8236, 18503, 8234, 18505, 8232, 18507, 8230, 18509, 8228, 18511, 8226, 18513, 8224, 18515, 8222, 18517, 8220, 18519, 8218, 18521, 8216, 18523, 8214, 18525, 8212, 18527, 8210, 18529, 8208, 18531, 8206, 18533, 8204, 18535, 8202, 18537, 8200, 18539, 8198, 18541, 8196, 18543, 8194, 18545, 8192, 18547, 8190, 18549, 8188, 18551, 8186, 18553, 8184, 18555, 8182, 18557, 8180, 18559, 8178, 18561, 8176, 18563, 8174, 18565, 8172, 18567, 8170, 18569, 8168, 18571, 8166, 18573, 8164, 18575, 8162, 18577, 8160, 18579, 8158, 18581, 8156, 18583, 8154, 18585, 8152, 18587, 8150, 18589, 8148, 18591, 8146, 18593, 8144, 18595, 8142, 18597, 8140, 18599, 8138, 18601, 8136, 18603, 8134, 18605, 8132, 18607, 8130, 18609, 8128, 18611, 8126, 18613, 8124, 18615, 8122, 18617, 8120, 18619, 8118, 18621, 8116, 18623, 8114, 18625, 8112, 18627, 8110, 18629, 8108, 18631, 8106, 18633, 8104, 18635, 8102, 18637, 8100, 18639, 8098, 18641, 8096, 18643, 8094, 18645, 8092, 18647, 8090, 18649, 8088, 18651, 8086, 18653, 8084, 18655, 8082, 18657, 8080, 18659, 8078, 18661, 8076, 18663, 8074, 18665, 8072, 18667, 8070, 18669, 8068, 18671, 8066, 18673, 8064, 18675, 8062, 18677, 8060, 18679, 8058, 18681, 8056, 18683, 8054, 18685, 8052, 18687, 8050, 18689, 8048, 18691, 8046, 18693, 8044, 18695, 8042, 18697, 8040, 18699, 8038, 18701, 8036, 18703, 8034, 18705, 8032, 18707, 8030, 18709, 8028, 18711, 8026, 18713, 8024, 18715, 8022, 18717, 8020, 18719, 8018, 18721, 8016, 18723, 8014, 18725, 8012, 18727, 8010, 18729, 8008, 18731, 8006, 18733, 8004, 18735, 8002, 18737, 8000, 18739, 7998, 18741, 7996, 18743, 7994, 18745, 7992, 18747, 7990, 18749, 7988, 18751, 7986, 18753, 7984, 18755, 7982, 18757, 7980, 18759, 7978, 18761, 7976, 18763, 7974, 18765, 7972, 18767, 7970, 18769, 7968, 18771, 7966, 18773, 7964, 18775, 7962, 18777, 7960, 18779, 7958, 18781, 7956, 18783, 7954, 18785, 7952, 18787, 7950, 18789, 7948, 18791, 7946, 18793, 7944, 18795, 7942, 18797, 7940, 18799, 7938, 18801, 7936, 18803, 7934, 18805, 7932, 18807, 7930, 18809, 7928, 18811, 7926, 18813, 7924, 18815, 7922, 18817, 7920, 18819, 7918, 18821, 7916, 18823, 7914, 18825, 7912, 18827, 7910, 18829, 7908, 18831, 7906, 18833, 7904, 18835, 7902, 18837, 7900, 18839, 7898, 18841, 7896, 18843, 7894, 18845, 7892, 18847, 7890, 18849, 7888, 18851, 7886, 18853, 7884, 18855, 7882, 18857, 7880, 18859, 7878, 18861, 7876, 18863, 7874, 18865, 7872, 18867, 7870, 18869, 7868, 18871, 7866, 18873, 7864, 18875, 7862, 18877, 7860, 18879, 7858, 18881, 7856, 18883, 7854, 18885, 7852, 18887, 7850, 18889, 7848, 18891, 7846, 18893, 7844, 18895, 7842, 18897, 7840, 18899, 7838, 18901, 7836, 18903, 7834, 18905, 7832, 18907, 7830, 18909, 7828, 18911, 7826, 18913, 7824, 18915, 7822, 18917, 7820, 18919, 7818, 18921, 7816, 18923, 7814, 18925, 7812, 18927, 7810, 18929, 7808, 18931, 7806, 18933, 7804, 18935, 7802, 18937, 7800, 18939, 7798, 18941, 7796, 18943, 7794, 18945, 7792, 18947, 7790, 18949, 7788, 18951, 7786, 18953, 7784, 18955, 7782, 18957, 7780, 18959, 7778, 18961, 7776, 18963, 7774, 18965, 7772, 18967, 7770, 18969, 7768, 18971, 7766, 18973, 7764, 18975, 7762, 18977, 7760, 18979, 7758, 18981, 7756, 18983, 7754, 18985, 7752, 18987, 7750, 18989, 7748, 18991, 7746, 18993, 7744, 18995, 7742, 18997, 7740, 18999, 7738, 19001, 7736, 19003, 7734, 19005, 7732, 19007, 7730, 19009, 7728, 19011, 7726, 19013, 7724, 19015, 7722, 19017, 7720, 19019, 7718, 19021, 7716, 19023, 7714, 19025, 7712, 19027, 7710, 19029, 7708, 19031, 7706, 19033, 7704, 19035, 7702, 19037, 7700, 19039, 7698, 19041, 7696, 19043, 7694, 19045, 7692, 19047, 7690, 19049, 7688, 19051, 7686, 19053, 7684, 19055, 7682, 19057, 7680, 19059, 7678, 19061, 7676, 19063, 7674, 19065, 7672, 19067, 7670, 19069, 7668, 19071, 7666, 19073, 7664, 19075, 7662, 19077, 7660, 19079, 7658, 19081, 7656, 19083, 7654, 19085, 7652, 19087, 7650, 19089, 7648, 19091, 7646, 19093, 7644, 19095, 7642, 19097, 7640, 19099, 7638, 19101, 7636, 19103, 7634, 19105, 7632, 19107, 7630, 19109, 7628, 19111, 7626, 19113, 7624, 19115, 7622, 19117, 7620, 19119, 7618, 19121, 7616, 19123, 7614, 19125, 7612, 19127, 7610, 19129, 7608, 19131, 7606, 19133, 7604, 19135, 7602, 19137, 7600, 19139, 7598, 19141, 7596, 19143, 7594, 19145, 7592, 19147, 7590, 19149, 7588, 19151, 7586, 19153, 7584, 19155, 7582, 19157, 7580, 19159, 7578, 19161, 7576, 19163, 7574, 19165, 7572, 19167, 7570, 19169, 7568, 19171, 7566, 19173, 7564, 19175, 7562, 19177, 7560, 19179, 7558, 19181, 7556, 19183, 7554, 19185, 7552, 19187, 7550, 19189, 7548, 19191, 7546, 19193, 7544, 19195, 7542, 19197, 7540, 19199, 7538, 19201, 7536, 19203, 7534, 19205, 7532, 19207, 7530, 19209, 7528, 19211, 7526, 19213, 7524, 19215, 7522, 19217, 7520, 19219, 7518, 19221, 7516, 19223, 7514, 19225, 7512, 19227, 7510, 19229, 7508, 19231, 7506, 19233, 7504, 19235, 7502, 19237, 7500, 19239, 7498, 19241, 7496, 19243, 7494, 19245, 7492, 19247, 7490, 19249, 7488, 19251, 7486, 19253, 7484, 19255, 7482, 19257, 7480, 19259, 7478, 19261, 7476, 19263, 7474, 19265, 7472, 19267, 7470, 19269, 7468, 19271, 7466, 19273, 7464, 19275, 7462, 19277, 7460, 19279, 7458, 19281, 7456, 19283, 7454, 19285, 7452, 19287, 7450, 19289, 7448, 19291, 7446, 19293, 7444, 19295, 7442, 19297, 7440, 19299, 7438, 19301, 7436, 19303, 7434, 19305, 7432, 19307, 7430, 19309, 7428, 19311, 7426, 19313, 7424, 19315, 7422, 19317, 7420, 19319, 7418, 19321, 7416, 19323, 7414, 19325, 7412, 19327, 7410, 19329, 7408, 19331, 7406, 19333, 7404, 19335, 7402, 19337, 7400, 19339, 7398, 19341, 7396, 19343, 7394, 19345, 7392, 19347, 7390, 19349, 7388, 19351, 7386, 19353, 7384, 19355, 7382, 19357, 7380, 19359, 7378, 19361, 7376, 19363, 7374, 19365, 7372, 19367, 7370, 19369, 7368, 19371, 7366, 19373, 7364, 19375, 7362, 19377, 7360, 19379, 7358, 19381, 7356, 19383, 7354, 19385, 7352, 19387, 7350, 19389, 7348, 19391, 7346, 19393, 7344, 19395, 7342, 19397, 7340, 19399, 7338, 19401, 7336, 19403, 7334, 19405, 7332, 19407, 7330, 19409, 7328, 19411, 7326, 19413, 7324, 19415, 7322, 19417, 7320, 19419, 7318, 19421, 7316, 19423, 7314, 19425, 7312, 19427, 7310, 19429, 7308, 19431, 7306, 19433, 7304, 19435, 7302, 19437, 7300, 19439, 7298, 19441, 7296, 19443, 7294, 19445, 7292, 19447, 7290, 19449, 7288, 19451, 7286, 19453, 7284, 19455, 7282, 19457, 7280, 19459, 7278, 19461, 7276, 19463, 7274, 19465, 7272, 19467, 7270, 19469, 7268, 19471, 7266, 19473, 7264, 19475, 7262, 19477, 7260, 19479, 7258, 19481, 7256, 19483, 7254, 19485, 7252, 19487, 7250, 19489, 7248, 19491, 7246, 19493, 7244, 19495, 7242, 19497, 7240, 19499, 7238, 19501, 7236, 19503, 7234, 19505, 7232, 19507, 7230, 19509, 7228, 19511, 7226, 19513, 7224, 19515, 7222, 19517, 7220, 19519, 7218, 19521, 7216, 19523, 7214, 19525, 7212, 19527, 7210, 19529, 7208, 19531, 7206, 19533, 7204, 19535, 7202, 19537, 7200, 19539, 7198, 19541, 7196, 19543, 7194, 19545, 7192, 19547, 7190, 19549, 7188, 19551, 7186, 19553, 7184, 19555, 7182, 19557, 7180, 19559, 7178, 19561, 7176, 19563, 7174, 19565, 7172, 19567, 7170, 19569, 7168, 19571, 7166, 19573, 7164, 19575, 7162, 19577, 7160, 19579, 7158, 19581, 7156, 19583, 7154, 19585, 7152, 19587, 7150, 19589, 7148, 19591, 7146, 19593, 7144, 19595, 7142, 19597, 7140, 19599, 7138, 19601, 7136, 19603, 7134, 19605, 7132, 19607, 7130, 19609, 7128, 19611, 7126, 19613, 7124, 19615, 7122, 19617, 7120, 19619, 7118, 19621, 7116, 19623, 7114, 19625, 7112, 19627, 7110, 19629, 7108, 19631, 7106, 19633, 7104, 19635, 7102, 19637, 7100, 19639, 7098, 19641, 7096, 19643, 7094, 19645, 7092, 19647, 7090, 19649, 7088, 19651, 7086, 19653, 7084, 19655, 7082, 19657, 7080, 19659, 7078, 19661, 7076, 19663, 7074, 19665, 7072, 19667, 7070, 19669, 7068, 19671, 7066, 19673, 7064, 19675, 7062, 19677, 7060, 19679, 7058, 19681, 7056, 19683, 7054, 19685, 7052, 19687, 7050, 19689, 7048, 19691, 7046, 19693, 7044, 19695, 7042, 19697, 7040, 19699, 7038, 19701, 7036, 19703, 7034, 19705, 7032, 19707, 7030, 19709, 7028, 19711, 7026, 19713, 7024, 19715, 7022, 19717, 7020, 19719, 7018, 19721, 7016, 19723, 7014, 19725, 7012, 19727, 7010, 19729, 7008, 19731, 7006, 19733, 7004, 19735, 7002, 19737, 7000, 19739, 6998, 19741, 6996, 19743, 6994, 19745, 6992, 19747, 6990, 19749, 6988, 19751, 6986, 19753, 6984, 19755, 6982, 19757, 6980, 19759, 6978, 19761, 6976, 19763, 6974, 19765, 6972, 19767, 6970, 19769, 6968, 19771, 6966, 19773, 6964, 19775, 6962, 19777, 6960, 19779, 6958, 19781, 6956, 19783, 6954, 19785, 6952, 19787, 6950, 19789, 6948, 19791, 6946, 19793, 6944, 19795, 6942, 19797, 6940, 19799, 6938, 19801, 6936, 19803, 6934, 19805, 6932, 19807, 6930, 19809, 6928, 19811, 6926, 19813, 6924, 19815, 6922, 19817, 6920, 19819, 6918, 19821, 6916, 19823, 6914, 19825, 6912, 19827, 6910, 19829, 6908, 19831, 6906, 19833, 6904, 19835, 6902, 19837, 6900, 19839, 6898, 19841, 6896, 19843, 6894, 19845, 6892, 19847, 6890, 19849, 6888, 19851, 6886, 19853, 6884, 19855, 6882, 19857, 6880, 19859, 6878, 19861, 6876, 19863, 6874, 19865, 6872, 19867, 6870, 19869, 6868, 19871, 6866, 19873, 6864, 19875, 6862, 19877, 6860, 19879, 6858, 19881, 6856, 19883, 6854, 19885, 6852, 19887, 6850, 19889, 6848, 19891, 6846, 19893, 6844, 19895, 6842, 19897, 6840, 19899, 6838, 19901, 6836, 19903, 6834, 19905, 6832, 19907, 6830, 19909, 6828, 19911, 6826, 19913, 6824, 19915, 6822, 19917, 6820, 19919, 6818, 19921, 6816, 19923, 6814, 19925, 6812, 19927, 6810, 19929, 6808, 19931, 6806, 19933, 6804, 19935, 6802, 19937, 6800, 19939, 6798, 19941, 6796, 19943, 6794, 19945, 6792, 19947, 6790, 19949, 6788, 19951, 6786, 19953, 6784, 19955, 6782, 19957, 6780, 19959, 6778, 19961, 6776, 19963, 6774, 19965, 6772, 19967, 6770, 19969, 6768, 19971, 6766, 19973, 6764, 19975, 6762, 19977, 6760, 19979, 6758, 19981, 6756, 19983, 6754, 19985, 6752, 19987, 6750, 19989, 6748, 19991, 6746, 19993, 6744, 19995, 6742, 19997, 6740, 19999, 6738, 20001, 6736, 20003, 6734, 20005, 6732, 20007, 6730, 20009, 6728, 20011, 6726, 20013, 6724, 20015, 6722, 20017, 6720, 20019, 6718, 20021, 6716, 20023, 6714, 20025, 6712, 20027, 6710, 20029, 6708, 20031, 6706, 20033, 6704, 20035, 6702, 20037, 6700, 20039, 6698, 20041, 6696, 20043, 6694, 20045, 6692, 20047, 6690, 20049, 6688, 20051, 6686, 20053, 6684, 20055, 6682, 20057, 6680, 20059, 6678, 20061, 6676, 20063, 6674, 20065, 6672, 20067, 6670, 20069, 6668, 20071, 6666, 20073, 6664, 20075, 6662, 20077, 6660, 20079, 6658, 20081, 6656, 20083, 6654, 20085, 6652, 20087, 6650, 20089, 6648, 20091, 6646, 20093, 6644, 20095, 6642, 20097, 6640, 20099, 6638, 20101, 6636, 20103, 6634, 20105, 6632, 20107, 6630, 20109, 6628, 20111, 6626, 20113, 6624, 20115, 6622, 20117, 6620, 20119, 6618, 20121, 6616, 20123, 6614, 20125, 6612, 20127, 6610, 20129, 6608, 20131, 6606, 20133, 6604, 20135, 6602, 20137, 6600, 20139, 6598, 20141, 6596, 20143, 6594, 20145, 6592, 20147, 6590, 20149, 6588, 20151, 6586, 20153, 6584, 20155, 6582, 20157, 6580, 20159, 6578, 20161, 6576, 20163, 6574, 20165, 6572, 20167, 6570, 20169, 6568, 20171, 6566, 20173, 6564, 20175, 6562, 20177, 6560, 20179, 6558, 20181, 6556, 20183, 6554, 20185, 6552, 20187, 6550, 20189, 6548, 20191, 6546, 20193, 6544, 20195, 6542, 20197, 6540, 20199, 6538, 20201, 6536, 20203, 6534, 20205, 6532, 20207, 6530, 20209, 6528, 20211, 6526, 20213, 6524, 20215, 6522, 20217, 6520, 20219, 6518, 20221, 6516, 20223, 6514, 20225, 6512, 20227, 6510, 20229, 6508, 20231, 6506, 20233, 6504, 20235, 6502, 20237, 6500, 20239, 6498, 20241, 6496, 20243, 6494, 20245, 6492, 20247, 6490, 20249, 6488, 20251, 6486, 20253, 6484, 20255, 6482, 20257, 6480, 20259, 6478, 20261, 6476, 20263, 6474, 20265, 6472, 20267, 6470, 20269, 6468, 20271, 6466, 20273, 6464, 20275, 6462, 20277, 6460, 20279, 6458, 20281, 6456, 20283, 6454, 20285, 6452, 20287, 6450, 20289, 6448, 20291, 6446, 20293, 6444, 20295, 6442, 20297, 6440, 20299, 6438, 20301, 6436, 20303, 6434, 20305, 6432, 20307, 6430, 20309, 6428, 20311, 6426, 20313, 6424, 20315, 6422, 20317, 6420, 20319, 6418, 20321, 6416, 20323, 6414, 20325, 6412, 20327, 6410, 20329, 6408, 20331, 6406, 20333, 6404, 20335, 6402, 20337, 6400, 20339, 6398, 20341, 6396, 20343, 6394, 20345, 6392, 20347, 6390, 20349, 6388, 20351, 6386, 20353, 6384, 20355, 6382, 20357, 6380, 20359, 6378, 20361, 6376, 20363, 6374, 20365, 6372, 20367, 6370, 20369, 6368, 20371, 6366, 20373, 6364, 20375, 6362, 20377, 6360, 20379, 6358, 20381, 6356, 20383, 6354, 20385, 6352, 20387, 6350, 20389, 6348, 20391, 6346, 20393, 6344, 20395, 6342, 20397, 6340, 20399, 6338, 20401, 6336, 20403, 6334, 20405, 6332, 20407, 6330, 20409, 6328, 20411, 6326, 20413, 6324, 20415, 6322, 20417, 6320, 20419, 6318, 20421, 6316, 20423, 6314, 20425, 6312, 20427, 6310, 20429, 6308, 20431, 6306, 20433, 6304, 20435, 6302, 20437, 6300, 20439, 6298, 20441, 6296, 20443, 6294, 20445, 6292, 20447, 6290, 20449, 6288, 20451, 6286, 20453, 6284, 20455, 6282, 20457, 6280, 20459, 6278, 20461, 6276, 20463, 6274, 20465, 6272, 20467, 6270, 20469, 6268, 20471, 6266, 20473, 6264, 20475, 6262, 20477, 6260, 20479, 6258, 20481, 6256, 20483, 6254, 20485, 6252, 20487, 6250, 20489, 6248, 20491, 6246, 20493, 6244, 20495, 6242, 20497, 6240, 20499, 6238, 20501, 6236, 20503, 6234, 20505, 6232, 20507, 6230, 20509, 6228, 20511, 6226, 20513, 6224, 20515, 6222, 20517, 6220, 20519, 6218, 20521, 6216, 20523, 6214, 20525, 6212, 20527, 6210, 20529, 6208, 20531, 6206, 20533, 6204, 20535, 6202, 20537, 6200, 20539, 6198, 20541, 6196, 20543, 6194, 20545, 6192, 20547, 6190, 20549, 6188, 20551, 6186, 20553, 6184, 20555, 6182, 20557, 6180, 20559, 6178, 20561, 6176, 20563, 6174, 20565, 6172, 20567, 6170, 20569, 6168, 20571, 6166, 20573, 6164, 20575, 6162, 20577, 6160, 20579, 6158, 20581, 6156, 20583, 6154, 20585, 6152, 20587, 6150, 20589, 6148, 20591, 6146, 20593, 6144, 20595, 6142, 20597, 6140, 20599, 6138, 20601, 6136, 20603, 6134, 20605, 6132, 20607, 6130, 20609, 6128, 20611, 6126, 20613, 6124, 20615, 6122, 20617, 6120, 20619, 6118, 20621, 6116, 20623, 6114, 20625, 6112, 20627, 6110, 20629, 6108, 20631, 6106, 20633, 6104, 20635, 6102, 20637, 6100, 20639, 6098, 20641, 6096, 20643, 6094, 20645, 6092, 20647, 6090, 20649, 6088, 20651, 6086, 20653, 6084, 20655, 6082, 20657, 6080, 20659, 6078, 20661, 6076, 20663, 6074, 20665, 6072, 20667, 6070, 20669, 6068, 20671, 6066, 20673, 6064, 20675, 6062, 20677, 6060, 20679, 6058, 20681, 6056, 20683, 6054, 20685, 6052, 20687, 6050, 20689, 6048, 20691, 6046, 20693, 6044, 20695, 6042, 20697, 6040, 20699, 6038, 20701, 6036, 20703, 6034, 20705, 6032, 20707, 6030, 20709, 6028, 20711, 6026, 20713, 6024, 20715, 6022, 20717, 6020, 20719, 6018, 20721, 6016, 20723, 6014, 20725, 6012, 20727, 6010, 20729, 6008, 20731, 6006, 20733, 6004, 20735, 6002, 20737, 6000, 20739, 5998, 20741, 5996, 20743, 5994, 20745, 5992, 20747, 5990, 20749, 5988, 20751, 5986, 20753, 5984, 20755, 5982, 20757, 5980, 20759, 5978, 20761, 5976, 20763, 5974, 20765, 5972, 20767, 5970, 20769, 5968, 20771, 5966, 20773, 5964, 20775, 5962, 20777, 5960, 20779, 5958, 20781, 5956, 20783, 5954, 20785, 5952, 20787, 5950, 20789, 5948, 20791, 5946, 20793, 5944, 20795, 5942, 20797, 5940, 20799, 5938, 20801, 5936, 20803, 5934, 20805, 5932, 20807, 5930, 20809, 5928, 20811, 5926, 20813, 5924, 20815, 5922, 20817, 5920, 20819, 5918, 20821, 5916, 20823, 5914, 20825, 5912, 20827, 5910, 20829, 5908, 20831, 5906, 20833, 5904, 20835, 5902, 20837, 5900, 20839, 5898, 20841, 5896, 20843, 5894, 20845, 5892, 20847, 5890, 20849, 5888, 20851, 5886, 20853, 5884, 20855, 5882, 20857, 5880, 20859, 5878, 20861, 5876, 20863, 5874, 20865, 5872, 20867, 5870, 20869, 5868, 20871, 5866, 20873, 5864, 20875, 5862, 20877, 5860, 20879, 5858, 20881, 5856, 20883, 5854, 20885, 5852, 20887, 5850, 20889, 5848, 20891, 5846, 20893, 5844, 20895, 5842, 20897, 5840, 20899, 5838, 20901, 5836, 20903, 5834, 20905, 5832, 20907, 5830, 20909, 5828, 20911, 5826, 20913, 5824, 20915, 5822, 20917, 5820, 20919, 5818, 20921, 5816, 20923, 5814, 20925, 5812, 20927, 5810, 20929, 5808, 20931, 5806, 20933, 5804, 20935, 5802, 20937, 5800, 20939, 5798, 20941, 5796, 20943, 5794, 20945, 5792, 20947, 5790, 20949, 5788, 20951, 5786, 20953, 5784, 20955, 5782, 20957, 5780, 20959, 5778, 20961, 5776, 20963, 5774, 20965, 5772, 20967, 5770, 20969, 5768, 20971, 5766, 20973, 5764, 20975, 5762, 20977, 5760, 20979, 5758, 20981, 5756, 20983, 5754, 20985, 5752, 20987, 5750, 20989, 5748, 20991, 5746, 20993, 5744, 20995, 5742, 20997, 5740, 20999, 5738, 21001, 5736, 21003, 5734, 21005, 5732, 21007, 5730, 21009, 5728, 21011, 5726, 21013, 5724, 21015, 5722, 21017, 5720, 21019, 5718, 21021, 5716, 21023, 5714, 21025, 5712, 21027, 5710, 21029, 5708, 21031, 5706, 21033, 5704, 21035, 5702, 21037, 5700, 21039, 5698, 21041, 5696, 21043, 5694, 21045, 5692, 21047, 5690, 21049, 5688, 21051, 5686, 21053, 5684, 21055, 5682, 21057, 5680, 21059, 5678, 21061, 5676, 21063, 5674, 21065, 5672, 21067, 5670, 21069, 5668, 21071, 5666, 21073, 5664, 21075, 5662, 21077, 5660, 21079, 5658, 21081, 5656, 21083, 5654, 21085, 5652, 21087, 5650, 21089, 5648, 21091, 5646, 21093, 5644, 21095, 5642, 21097, 5640, 21099, 5638, 21101, 5636, 21103, 5634, 21105, 5632, 21107, 5630, 21109, 5628, 21111, 5626, 21113, 5624, 21115, 5622, 21117, 5620, 21119, 5618, 21121, 5616, 21123, 5614, 21125, 5612, 21127, 5610, 21129, 5608, 21131, 5606, 21133, 5604, 21135, 5602, 21137, 5600, 21139, 5598, 21141, 5596, 21143, 5594, 21145, 5592, 21147, 5590, 21149, 5588, 21151, 5586, 21153, 5584, 21155, 5582, 21157, 5580, 21159, 5578, 21161, 5576, 21163, 5574, 21165, 5572, 21167, 5570, 21169, 5568, 21171, 5566, 21173, 5564, 21175, 5562, 21177, 5560, 21179, 5558, 21181, 5556, 21183, 5554, 21185, 5552, 21187, 5550, 21189, 5548, 21191, 5546, 21193, 5544, 21195, 5542, 21197, 5540, 21199, 5538, 21201, 5536, 21203, 5534, 21205, 5532, 21207, 5530, 21209, 5528, 21211, 5526, 21213, 5524, 21215, 5522, 21217, 5520, 21219, 5518, 21221, 5516, 21223, 5514, 21225, 5512, 21227, 5510, 21229, 5508, 21231, 5506, 21233, 5504, 21235, 5502, 21237, 5500, 21239, 5498, 21241, 5496, 21243, 5494, 21245, 5492, 21247, 5490, 21249, 5488, 21251, 5486, 21253, 5484, 21255, 5482, 21257, 5480, 21259, 5478, 21261, 5476, 21263, 5474, 21265, 5472, 21267, 5470, 21269, 5468, 21271, 5466, 21273, 5464, 21275, 5462, 21277, 5460, 21279, 5458, 21281, 5456, 21283, 5454, 21285, 5452, 21287, 5450, 21289, 5448, 21291, 5446, 21293, 5444, 21295, 5442, 21297, 5440, 21299, 5438, 21301, 5436, 21303, 5434, 21305, 5432, 21307, 5430, 21309, 5428, 21311, 5426, 21313, 5424, 21315, 5422, 21317, 5420, 21319, 5418, 21321, 5416, 21323, 5414, 21325, 5412, 21327, 5410, 21329, 5408, 21331, 5406, 21333, 5404, 21335, 5402, 21337, 5400, 21339, 5398, 21341, 5396, 21343, 5394, 21345, 5392, 21347, 5390, 21349, 5388, 21351, 5386, 21353, 5384, 21355, 5382, 21357, 5380, 21359, 5378, 21361, 5376, 21363, 5374, 21365, 5372, 21367, 5370, 21369, 5368, 21371, 5366, 21373, 5364, 21375, 5362, 21377, 5360, 21379, 5358, 21381, 5356, 21383, 5354, 21385, 5352, 21387, 5350, 21389, 5348, 21391, 5346, 21393, 5344, 21395, 5342, 21397, 5340, 21399, 5338, 21401, 5336, 21403, 5334, 21405, 5332, 21407, 5330, 21409, 5328, 21411, 5326, 21413, 5324, 21415, 5322, 21417, 5320, 21419, 5318, 21421, 5316, 21423, 5314, 21425, 5312, 21427, 5310, 21429, 5308, 21431, 5306, 21433, 5304, 21435, 5302, 21437, 5300, 21439, 5298, 21441, 5296, 21443, 5294, 21445, 5292, 21447, 5290, 21449, 5288, 21451, 5286, 21453, 5284, 21455, 5282, 21457, 5280, 21459, 5278, 21461, 5276, 21463, 5274, 21465, 5272, 21467, 5270, 21469, 5268, 21471, 5266, 21473, 5264, 21475, 5262, 21477, 5260, 21479, 5258, 21481, 5256, 21483, 5254, 21485, 5252, 21487, 5250, 21489, 5248, 21491, 5246, 21493, 5244, 21495, 5242, 21497, 5240, 21499, 5238, 21501, 5236, 21503, 5234, 21505, 5232, 21507, 5230, 21509, 5228, 21511, 5226, 21513, 5224, 21515, 5222, 21517, 5220, 21519, 5218, 21521, 5216, 21523, 5214, 21525, 5212, 21527, 5210, 21529, 5208, 21531, 5206, 21533, 5204, 21535, 5202, 21537, 5200, 21539, 5198, 21541, 5196, 21543, 5194, 21545, 5192, 21547, 5190, 21549, 5188, 21551, 5186, 21553, 5184, 21555, 5182, 21557, 5180, 21559, 5178, 21561, 5176, 21563, 5174, 21565, 5172, 21567, 5170, 21569, 5168, 21571, 5166, 21573, 5164, 21575, 5162, 21577, 5160, 21579, 5158, 21581, 5156, 21583, 5154, 21585, 5152, 21587, 5150, 21589, 5148, 21591, 5146, 21593, 5144, 21595, 5142, 21597, 5140, 21599, 5138, 21601, 5136, 21603, 5134, 21605, 5132, 21607, 5130, 21609, 5128, 21611, 5126, 21613, 5124, 21615, 5122, 21617, 5120, 21619, 5118, 21621, 5116, 21623, 5114, 21625, 5112, 21627, 5110, 21629, 5108, 21631, 5106, 21633, 5104, 21635, 5102, 21637, 5100, 21639, 5098, 21641, 5096, 21643, 5094, 21645, 5092, 21647, 5090, 21649, 5088, 21651, 5086, 21653, 5084, 21655, 5082, 21657, 5080, 21659, 5078, 21661, 5076, 21663, 5074, 21665, 5072, 21667, 5070, 21669, 5068, 21671, 5066, 21673, 5064, 21675, 5062, 21677, 5060, 21679, 5058, 21681, 5056, 21683, 5054, 21685, 5052, 21687, 5050, 21689, 5048, 21691, 5046, 21693, 5044, 21695, 5042, 21697, 5040, 21699, 5038, 21701, 5036, 21703, 5034, 21705, 5032, 21707, 5030, 21709, 5028, 21711, 5026, 21713, 5024, 21715, 5022, 21717, 5020, 21719, 5018, 21721, 5016, 21723, 5014, 21725, 5012, 21727, 5010, 21729, 5008, 21731, 5006, 21733, 5004, 21735, 5002, 21737, 5000, 21739, 4998, 21741, 4996, 21743, 4994, 21745, 4992, 21747, 4990, 21749, 4988, 21751, 4986, 21753, 4984, 21755, 4982, 21757, 4980, 21759, 4978, 21761, 4976, 21763, 4974, 21765, 4972, 21767, 4970, 21769, 4968, 21771, 4966, 21773, 4964, 21775, 4962, 21777, 4960, 21779, 4958, 21781, 4956, 21783, 4954, 21785, 4952, 21787, 4950, 21789, 4948, 21791, 4946, 21793, 4944, 21795, 4942, 21797, 4940, 21799, 4938, 21801, 4936, 21803, 4934, 21805, 4932, 21807, 4930, 21809, 4928, 21811, 4926, 21813, 4924, 21815, 4922, 21817, 4920, 21819, 4918, 21821, 4916, 21823, 4914, 21825, 4912, 21827, 4910, 21829, 4908, 21831, 4906, 21833, 4904, 21835, 4902, 21837, 4900, 21839, 4898, 21841, 4896, 21843, 4894, 21845, 4892, 21847, 4890, 21849, 4888, 21851, 4886, 21853, 4884, 21855, 4882, 21857, 4880, 21859, 4878, 21861, 4876, 21863, 4874, 21865, 4872, 21867, 4870, 21869, 4868, 21871, 4866, 21873, 4864, 21875, 4862, 21877, 4860, 21879, 4858, 21881, 4856, 21883, 4854, 21885, 4852, 21887, 4850, 21889, 4848, 21891, 4846, 21893, 4844, 21895, 4842, 21897, 4840, 21899, 4838, 21901, 4836, 21903, 4834, 21905, 4832, 21907, 4830, 21909, 4828, 21911, 4826, 21913, 4824, 21915, 4822, 21917, 4820, 21919, 4818, 21921, 4816, 21923, 4814, 21925, 4812, 21927, 4810, 21929, 4808, 21931, 4806, 21933, 4804, 21935, 4802, 21937, 4800, 21939, 4798, 21941, 4796, 21943, 4794, 21945, 4792, 21947, 4790, 21949, 4788, 21951, 4786, 21953, 4784, 21955, 4782, 21957, 4780, 21959, 4778, 21961, 4776, 21963, 4774, 21965, 4772, 21967, 4770, 21969, 4768, 21971, 4766, 21973, 4764, 21975, 4762, 21977, 4760, 21979, 4758, 21981, 4756, 21983, 4754, 21985, 4752, 21987, 4750, 21989, 4748, 21991, 4746, 21993, 4744, 21995, 4742, 21997, 4740, 21999, 4738, 22001, 4736, 22003, 4734, 22005, 4732, 22007, 4730, 22009, 4728, 22011, 4726, 22013, 4724, 22015, 4722, 22017, 4720, 22019, 4718, 22021, 4716, 22023, 4714, 22025, 4712, 22027, 4710, 22029, 4708, 22031, 4706, 22033, 4704, 22035, 4702, 22037, 4700, 22039, 4698, 22041, 4696, 22043, 4694, 22045, 4692, 22047, 4690, 22049, 4688, 22051, 4686, 22053, 4684, 22055, 4682, 22057, 4680, 22059, 4678, 22061, 4676, 22063, 4674, 22065, 4672, 22067, 4670, 22069, 4668, 22071, 4666, 22073, 4664, 22075, 4662, 22077, 4660, 22079, 4658, 22081, 4656, 22083, 4654, 22085, 4652, 22087, 4650, 22089, 4648, 22091, 4646, 22093, 4644, 22095, 4642, 22097, 4640, 22099, 4638, 22101, 4636, 22103, 4634, 22105, 4632, 22107, 4630, 22109, 4628, 22111, 4626, 22113, 4624, 22115, 4622, 22117, 4620, 22119, 4618, 22121, 4616, 22123, 4614, 22125, 4612, 22127, 4610, 22129, 4608, 22131, 4606, 22133, 4604, 22135, 4602, 22137, 4600, 22139, 4598, 22141, 4596, 22143, 4594, 22145, 4592, 22147, 4590, 22149, 4588, 22151, 4586, 22153, 4584, 22155, 4582, 22157, 4580, 22159, 4578, 22161, 4576, 22163, 4574, 22165, 4572, 22167, 4570, 22169, 4568, 22171, 4566, 22173, 4564, 22175, 4562, 22177, 4560, 22179, 4558, 22181, 4556, 22183, 4554, 22185, 4552, 22187, 4550, 22189, 4548, 22191, 4546, 22193, 4544, 22195, 4542, 22197, 4540, 22199, 4538, 22201, 4536, 22203, 4534, 22205, 4532, 22207, 4530, 22209, 4528, 22211, 4526, 22213, 4524, 22215, 4522, 22217, 4520, 22219, 4518, 22221, 4516, 22223, 4514, 22225, 4512, 22227, 4510, 22229, 4508, 22231, 4506, 22233, 4504, 22235, 4502, 22237, 4500, 22239, 4498, 22241, 4496, 22243, 4494, 22245, 4492, 22247, 4490, 22249, 4488, 22251, 4486, 22253, 4484, 22255, 4482, 22257, 4480, 22259, 4478, 22261, 4476, 22263, 4474, 22265, 4472, 22267, 4470, 22269, 4468, 22271, 4466, 22273, 4464, 22275, 4462, 22277, 4460, 22279, 4458, 22281, 4456, 22283, 4454, 22285, 4452, 22287, 4450, 22289, 4448, 22291, 4446, 22293, 4444, 22295, 4442, 22297, 4440, 22299, 4438, 22301, 4436, 22303, 4434, 22305, 4432, 22307, 4430, 22309, 4428, 22311, 4426, 22313, 4424, 22315, 4422, 22317, 4420, 22319, 4418, 22321, 4416, 22323, 4414, 22325, 4412, 22327, 4410, 22329, 4408, 22331, 4406, 22333, 4404, 22335, 4402, 22337, 4400, 22339, 4398, 22341, 4396, 22343, 4394, 22345, 4392, 22347, 4390, 22349, 4388, 22351, 4386, 22353, 4384, 22355, 4382, 22357, 4380, 22359, 4378, 22361, 4376, 22363, 4374, 22365, 4372, 22367, 4370, 22369, 4368, 22371, 4366, 22373, 4364, 22375, 4362, 22377, 4360, 22379, 4358, 22381, 4356, 22383, 4354, 22385, 4352, 22387, 4350, 22389, 4348, 22391, 4346, 22393, 4344, 22395, 4342, 22397, 4340, 22399, 4338, 22401, 4336, 22403, 4334, 22405, 4332, 22407, 4330, 22409, 4328, 22411, 4326, 22413, 4324, 22415, 4322, 22417, 4320, 22419, 4318, 22421, 4316, 22423, 4314, 22425, 4312, 22427, 4310, 22429, 4308, 22431, 4306, 22433, 4304, 22435, 4302, 22437, 4300, 22439, 4298, 22441, 4296, 22443, 4294, 22445, 4292, 22447, 4290, 22449, 4288, 22451, 4286, 22453, 4284, 22455, 4282, 22457, 4280, 22459, 4278, 22461, 4276, 22463, 4274, 22465, 4272, 22467, 4270, 22469, 4268, 22471, 4266, 22473, 4264, 22475, 4262, 22477, 4260, 22479, 4258, 22481, 4256, 22483, 4254, 22485, 4252, 22487, 4250, 22489, 4248, 22491, 4246, 22493, 4244, 22495, 4242, 22497, 4240, 22499, 4238, 22501, 4236, 22503, 4234, 22505, 4232, 22507, 4230, 22509, 4228, 22511, 4226, 22513, 4224, 22515, 4222, 22517, 4220, 22519, 4218, 22521, 4216, 22523, 4214, 22525, 4212, 22527, 4210, 22529, 4208, 22531, 4206, 22533, 4204, 22535, 4202, 22537, 4200, 22539, 4198, 22541, 4196, 22543, 4194, 22545, 4192, 22547, 4190, 22549, 4188, 22551, 4186, 22553, 4184, 22555, 4182, 22557, 4180, 22559, 4178, 22561, 4176, 22563, 4174, 22565, 4172, 22567, 4170, 22569, 4168, 22571, 4166, 22573, 4164, 22575, 4162, 22577, 4160, 22579, 4158, 22581, 4156, 22583, 4154, 22585, 4152, 22587, 4150, 22589, 4148, 22591, 4146, 22593, 4144, 22595, 4142, 22597, 4140, 22599, 4138, 22601, 4136, 22603, 4134, 22605, 4132, 22607, 4130, 22609, 4128, 22611, 4126, 22613, 4124, 22615, 4122, 22617, 4120, 22619, 4118, 22621, 4116, 22623, 4114, 22625, 4112, 22627, 4110, 22629, 4108, 22631, 4106, 22633, 4104, 22635, 4102, 22637, 4100, 22639, 4098, 22641, 4096, 22643, 4094, 22645, 4092, 22647, 4090, 22649, 4088, 22651, 4086, 22653, 4084, 22655, 4082, 22657, 4080, 22659, 4078, 22661, 4076, 22663, 4074, 22665, 4072, 22667, 4070, 22669, 4068, 22671, 4066, 22673, 4064, 22675, 4062, 22677, 4060, 22679, 4058, 22681, 4056, 22683, 4054, 22685, 4052, 22687, 4050, 22689, 4048, 22691, 4046, 22693, 4044, 22695, 4042, 22697, 4040, 22699, 4038, 22701, 4036, 22703, 4034, 22705, 4032, 22707, 4030, 22709, 4028, 22711, 4026, 22713, 4024, 22715, 4022, 22717, 4020, 22719, 4018, 22721, 4016, 22723, 4014, 22725, 4012, 22727, 4010, 22729, 4008, 22731, 4006, 22733, 4004, 22735, 4002, 22737, 4000, 22739, 3998, 22741, 3996, 22743, 3994, 22745, 3992, 22747, 3990, 22749, 3988, 22751, 3986, 22753, 3984, 22755, 3982, 22757, 3980, 22759, 3978, 22761, 3976, 22763, 3974, 22765, 3972, 22767, 3970, 22769, 3968, 22771, 3966, 22773, 3964, 22775, 3962, 22777, 3960, 22779, 3958, 22781, 3956, 22783, 3954, 22785, 3952, 22787, 3950, 22789, 3948, 22791, 3946, 22793, 3944, 22795, 3942, 22797, 3940, 22799, 3938, 22801, 3936, 22803, 3934, 22805, 3932, 22807, 3930, 22809, 3928, 22811, 3926, 22813, 3924, 22815, 3922, 22817, 3920, 22819, 3918, 22821, 3916, 22823, 3914, 22825, 3912, 22827, 3910, 22829, 3908, 22831, 3906, 22833, 3904, 22835, 3902, 22837, 3900, 22839, 3898, 22841, 3896, 22843, 3894, 22845, 3892, 22847, 3890, 22849, 3888, 22851, 3886, 22853, 3884, 22855, 3882, 22857, 3880, 22859, 3878, 22861, 3876, 22863, 3874, 22865, 3872, 22867, 3870, 22869, 3868, 22871, 3866, 22873, 3864, 22875, 3862, 22877, 3860, 22879, 3858, 22881, 3856, 22883, 3854, 22885, 3852, 22887, 3850, 22889, 3848, 22891, 3846, 22893, 3844, 22895, 3842, 22897, 3840, 22899, 3838, 22901, 3836, 22903, 3834, 22905, 3832, 22907, 3830, 22909, 3828, 22911, 3826, 22913, 3824, 22915, 3822, 22917, 3820, 22919, 3818, 22921, 3816, 22923, 3814, 22925, 3812, 22927, 3810, 22929, 3808, 22931, 3806, 22933, 3804, 22935, 3802, 22937, 3800, 22939, 3798, 22941, 3796, 22943, 3794, 22945, 3792, 22947, 3790, 22949, 3788, 22951, 3786, 22953, 3784, 22955, 3782, 22957, 3780, 22959, 3778, 22961, 3776, 22963, 3774, 22965, 3772, 22967, 3770, 22969, 3768, 22971, 3766, 22973, 3764, 22975, 3762, 22977, 3760, 22979, 3758, 22981, 3756, 22983, 3754, 22985, 3752, 22987, 3750, 22989, 3748, 22991, 3746, 22993, 3744, 22995, 3742, 22997, 3740, 22999, 3738, 23001, 3736, 23003, 3734, 23005, 3732, 23007, 3730, 23009, 3728, 23011, 3726, 23013, 3724, 23015, 3722, 23017, 3720, 23019, 3718, 23021, 3716, 23023, 3714, 23025, 3712, 23027, 3710, 23029, 3708, 23031, 3706, 23033, 3704, 23035, 3702, 23037, 3700, 23039, 3698, 23041, 3696, 23043, 3694, 23045, 3692, 23047, 3690, 23049, 3688, 23051, 3686, 23053, 3684, 23055, 3682, 23057, 3680, 23059, 3678, 23061, 3676, 23063, 3674, 23065, 3672, 23067, 3670, 23069, 3668, 23071, 3666, 23073, 3664, 23075, 3662, 23077, 3660, 23079, 3658, 23081, 3656, 23083, 3654, 23085, 3652, 23087, 3650, 23089, 3648, 23091, 3646, 23093, 3644, 23095, 3642, 23097, 3640, 23099, 3638, 23101, 3636, 23103, 3634, 23105, 3632, 23107, 3630, 23109, 3628, 23111, 3626, 23113, 3624, 23115, 3622, 23117, 3620, 23119, 3618, 23121, 3616, 23123, 3614, 23125, 3612, 23127, 3610, 23129, 3608, 23131, 3606, 23133, 3604, 23135, 3602, 23137, 3600, 23139, 3598, 23141, 3596, 23143, 3594, 23145, 3592, 23147, 3590, 23149, 3588, 23151, 3586, 23153, 3584, 23155, 3582, 23157, 3580, 23159, 3578, 23161, 3576, 23163, 3574, 23165, 3572, 23167, 3570, 23169, 3568, 23171, 3566, 23173, 3564, 23175, 3562, 23177, 3560, 23179, 3558, 23181, 3556, 23183, 3554, 23185, 3552, 23187, 3550, 23189, 3548, 23191, 3546, 23193, 3544, 23195, 3542, 23197, 3540, 23199, 3538, 23201, 3536, 23203, 3534, 23205, 3532, 23207, 3530, 23209, 3528, 23211, 3526, 23213, 3524, 23215, 3522, 23217, 3520, 23219, 3518, 23221, 3516, 23223, 3514, 23225, 3512, 23227, 3510, 23229, 3508, 23231, 3506, 23233, 3504, 23235, 3502, 23237, 3500, 23239, 3498, 23241, 3496, 23243, 3494, 23245, 3492, 23247, 3490, 23249, 3488, 23251, 3486, 23253, 3484, 23255, 3482, 23257, 3480, 23259, 3478, 23261, 3476, 23263, 3474, 23265, 3472, 23267, 3470, 23269, 3468, 23271, 3466, 23273, 3464, 23275, 3462, 23277, 3460, 23279, 3458, 23281, 3456, 23283, 3454, 23285, 3452, 23287, 3450, 23289, 3448, 23291, 3446, 23293, 3444, 23295, 3442, 23297, 3440, 23299, 3438, 23301, 3436, 23303, 3434, 23305, 3432, 23307, 3430, 23309, 3428, 23311, 3426, 23313, 3424, 23315, 3422, 23317, 3420, 23319, 3418, 23321, 3416, 23323, 3414, 23325, 3412, 23327, 3410, 23329, 3408, 23331, 3406, 23333, 3404, 23335, 3402, 23337, 3400, 23339, 3398, 23341, 3396, 23343, 3394, 23345, 3392, 23347, 3390, 23349, 3388, 23351, 3386, 23353, 3384, 23355, 3382, 23357, 3380, 23359, 3378, 23361, 3376, 23363, 3374, 23365, 3372, 23367, 3370, 23369, 3368, 23371, 3366, 23373, 3364, 23375, 3362, 23377, 3360, 23379, 3358, 23381, 3356, 23383, 3354, 23385, 3352, 23387, 3350, 23389, 3348, 23391, 3346, 23393, 3344, 23395, 3342, 23397, 3340, 23399, 3338, 23401, 3336, 23403, 3334, 23405, 3332, 23407, 3330, 23409, 3328, 23411, 3326, 23413, 3324, 23415, 3322, 23417, 3320, 23419, 3318, 23421, 3316, 23423, 3314, 23425, 3312, 23427, 3310, 23429, 3308, 23431, 3306, 23433, 3304, 23435, 3302, 23437, 3300, 23439, 3298, 23441, 3296, 23443, 3294, 23445, 3292, 23447, 3290, 23449, 3288, 23451, 3286, 23453, 3284, 23455, 3282, 23457, 3280, 23459, 3278, 23461, 3276, 23463, 3274, 23465, 3272, 23467, 3270, 23469, 3268, 23471, 3266, 23473, 3264, 23475, 3262, 23477, 3260, 23479, 3258, 23481, 3256, 23483, 3254, 23485, 3252, 23487, 3250, 23489, 3248, 23491, 3246, 23493, 3244, 23495, 3242, 23497, 3240, 23499, 3238, 23501, 3236, 23503, 3234, 23505, 3232, 23507, 3230, 23509, 3228, 23511, 3226, 23513, 3224, 23515, 3222, 23517, 3220, 23519, 3218, 23521, 3216, 23523, 3214, 23525, 3212, 23527, 3210, 23529, 3208, 23531, 3206, 23533, 3204, 23535, 3202, 23537, 3200, 23539, 3198, 23541, 3196, 23543, 3194, 23545, 3192, 23547, 3190, 23549, 3188, 23551, 3186, 23553, 3184, 23555, 3182, 23557, 3180, 23559, 3178, 23561, 3176, 23563, 3174, 23565, 3172, 23567, 3170, 23569, 3168, 23571, 3166, 23573, 3164, 23575, 3162, 23577, 3160, 23579, 3158, 23581, 3156, 23583, 3154, 23585, 3152, 23587, 3150, 23589, 3148, 23591, 3146, 23593, 3144, 23595, 3142, 23597, 3140, 23599, 3138, 23601, 3136, 23603, 3134, 23605, 3132, 23607, 3130, 23609, 3128, 23611, 3126, 23613, 3124, 23615, 3122, 23617, 3120, 23619, 3118, 23621, 3116, 23623, 3114, 23625, 3112, 23627, 3110, 23629, 3108, 23631, 3106, 23633, 3104, 23635, 3102, 23637, 3100, 23639, 3098, 23641, 3096, 23643, 3094, 23645, 3092, 23647, 3090, 23649, 3088, 23651, 3086, 23653, 3084, 23655, 3082, 23657, 3080, 23659, 3078, 23661, 3076, 23663, 3074, 23665, 3072, 23667, 3070, 23669, 3068, 23671, 3066, 23673, 3064, 23675, 3062, 23677, 3060, 23679, 3058, 23681, 3056, 23683, 3054, 23685, 3052, 23687, 3050, 23689, 3048, 23691, 3046, 23693, 3044, 23695, 3042, 23697, 3040, 23699, 3038, 23701, 3036, 23703, 3034, 23705, 3032, 23707, 3030, 23709, 3028, 23711, 3026, 23713, 3024, 23715, 3022, 23717, 3020, 23719, 3018, 23721, 3016, 23723, 3014, 23725, 3012, 23727, 3010, 23729, 3008, 23731, 3006, 23733, 3004, 23735, 3002, 23737, 3000, 23739, 2998, 23741, 2996, 23743, 2994, 23745, 2992, 23747, 2990, 23749, 2988, 23751, 2986, 23753, 2984, 23755, 2982, 23757, 2980, 23759, 2978, 23761, 2976, 23763, 2974, 23765, 2972, 23767, 2970, 23769, 2968, 23771, 2966, 23773, 2964, 23775, 2962, 23777, 2960, 23779, 2958, 23781, 2956, 23783, 2954, 23785, 2952, 23787, 2950, 23789, 2948, 23791, 2946, 23793, 2944, 23795, 2942, 23797, 2940, 23799, 2938, 23801, 2936, 23803, 2934, 23805, 2932, 23807, 2930, 23809, 2928, 23811, 2926, 23813, 2924, 23815, 2922, 23817, 2920, 23819, 2918, 23821, 2916, 23823, 2914, 23825, 2912, 23827, 2910, 23829, 2908, 23831, 2906, 23833, 2904, 23835, 2902, 23837, 2900, 23839, 2898, 23841, 2896, 23843, 2894, 23845, 2892, 23847, 2890, 23849, 2888, 23851, 2886, 23853, 2884, 23855, 2882, 23857, 2880, 23859, 2878, 23861, 2876, 23863, 2874, 23865, 2872, 23867, 2870, 23869, 2868, 23871, 2866, 23873, 2864, 23875, 2862, 23877, 2860, 23879, 2858, 23881, 2856, 23883, 2854, 23885, 2852, 23887, 2850, 23889, 2848, 23891, 2846, 23893, 2844, 23895, 2842, 23897, 2840, 23899, 2838, 23901, 2836, 23903, 2834, 23905, 2832, 23907, 2830, 23909, 2828, 23911, 2826, 23913, 2824, 23915, 2822, 23917, 2820, 23919, 2818, 23921, 2816, 23923, 2814, 23925, 2812, 23927, 2810, 23929, 2808, 23931, 2806, 23933, 2804, 23935, 2802, 23937, 2800, 23939, 2798, 23941, 2796, 23943, 2794, 23945, 2792, 23947, 2790, 23949, 2788, 23951, 2786, 23953, 2784, 23955, 2782, 23957, 2780, 23959, 2778, 23961, 2776, 23963, 2774, 23965, 2772, 23967, 2770, 23969, 2768, 23971, 2766, 23973, 2764, 23975, 2762, 23977, 2760, 23979, 2758, 23981, 2756, 23983, 2754, 23985, 2752, 23987, 2750, 23989, 2748, 23991, 2746, 23993, 2744, 23995, 2742, 23997, 2740, 23999, 2738, 24001, 2736, 24003, 2734, 24005, 2732, 24007, 2730, 24009, 2728, 24011, 2726, 24013, 2724, 24015, 2722, 24017, 2720, 24019, 2718, 24021, 2716, 24023, 2714, 24025, 2712, 24027, 2710, 24029, 2708, 24031, 2706, 24033, 2704, 24035, 2702, 24037, 2700, 24039, 2698, 24041, 2696, 24043, 2694, 24045, 2692, 24047, 2690, 24049, 2688, 24051, 2686, 24053, 2684, 24055, 2682, 24057, 2680, 24059, 2678, 24061, 2676, 24063, 2674, 24065, 2672, 24067, 2670, 24069, 2668, 24071, 2666, 24073, 2664, 24075, 2662, 24077, 2660, 24079, 2658, 24081, 2656, 24083, 2654, 24085, 2652, 24087, 2650, 24089, 2648, 24091, 2646, 24093, 2644, 24095, 2642, 24097, 2640, 24099, 2638, 24101, 2636, 24103, 2634, 24105, 2632, 24107, 2630, 24109, 2628, 24111, 2626, 24113, 2624, 24115, 2622, 24117, 2620, 24119, 2618, 24121, 2616, 24123, 2614, 24125, 2612, 24127, 2610, 24129, 2608, 24131, 2606, 24133, 2604, 24135, 2602, 24137, 2600, 24139, 2598, 24141, 2596, 24143, 2594, 24145, 2592, 24147, 2590, 24149, 2588, 24151, 2586, 24153, 2584, 24155, 2582, 24157, 2580, 24159, 2578, 24161, 2576, 24163, 2574, 24165, 2572, 24167, 2570, 24169, 2568, 24171, 2566, 24173, 2564, 24175, 2562, 24177, 2560, 24179, 2558, 24181, 2556, 24183, 2554, 24185, 2552, 24187, 2550, 24189, 2548, 24191, 2546, 24193, 2544, 24195, 2542, 24197, 2540, 24199, 2538, 24201, 2536, 24203, 2534, 24205, 2532, 24207, 2530, 24209, 2528, 24211, 2526, 24213, 2524, 24215, 2522, 24217, 2520, 24219, 2518, 24221, 2516, 24223, 2514, 24225, 2512, 24227, 2510, 24229, 2508, 24231, 2506, 24233, 2504, 24235, 2502, 24237, 2500, 24239, 2498, 24241, 2496, 24243, 2494, 24245, 2492, 24247, 2490, 24249, 2488, 24251, 2486, 24253, 2484, 24255, 2482, 24257, 2480, 24259, 2478, 24261, 2476, 24263, 2474, 24265, 2472, 24267, 2470, 24269, 2468, 24271, 2466, 24273, 2464, 24275, 2462, 24277, 2460, 24279, 2458, 24281, 2456, 24283, 2454, 24285, 2452, 24287, 2450, 24289, 2448, 24291, 2446, 24293, 2444, 24295, 2442, 24297, 2440, 24299, 2438, 24301, 2436, 24303, 2434, 24305, 2432, 24307, 2430, 24309, 2428, 24311, 2426, 24313, 2424, 24315, 2422, 24317, 2420, 24319, 2418, 24321, 2416, 24323, 2414, 24325, 2412, 24327, 2410, 24329, 2408, 24331, 2406, 24333, 2404, 24335, 2402, 24337, 2400, 24339, 2398, 24341, 2396, 24343, 2394, 24345, 2392, 24347, 2390, 24349, 2388, 24351, 2386, 24353, 2384, 24355, 2382, 24357, 2380, 24359, 2378, 24361, 2376, 24363, 2374, 24365, 2372, 24367, 2370, 24369, 2368, 24371, 2366, 24373, 2364, 24375, 2362, 24377, 2360, 24379, 2358, 24381, 2356, 24383, 2354, 24385, 2352, 24387, 2350, 24389, 2348, 24391, 2346, 24393, 2344, 24395, 2342, 24397, 2340, 24399, 2338, 24401, 2336, 24403, 2334, 24405, 2332, 24407, 2330, 24409, 2328, 24411, 2326, 24413, 2324, 24415, 2322, 24417, 2320, 24419, 2318, 24421, 2316, 24423, 2314, 24425, 2312, 24427, 2310, 24429, 2308, 24431, 2306, 24433, 2304, 24435, 2302, 24437, 2300, 24439, 2298, 24441, 2296, 24443, 2294, 24445, 2292, 24447, 2290, 24449, 2288, 24451, 2286, 24453, 2284, 24455, 2282, 24457, 2280, 24459, 2278, 24461, 2276, 24463, 2274, 24465, 2272, 24467, 2270, 24469, 2268, 24471, 2266, 24473, 2264, 24475, 2262, 24477, 2260, 24479, 2258, 24481, 2256, 24483, 2254, 24485, 2252, 24487, 2250, 24489, 2248, 24491, 2246, 24493, 2244, 24495, 2242, 24497, 2240, 24499, 2238, 24501, 2236, 24503, 2234, 24505, 2232, 24507, 2230, 24509, 2228, 24511, 2226, 24513, 2224, 24515, 2222, 24517, 2220, 24519, 2218, 24521, 2216, 24523, 2214, 24525, 2212, 24527, 2210, 24529, 2208, 24531, 2206, 24533, 2204, 24535, 2202, 24537, 2200, 24539, 2198, 24541, 2196, 24543, 2194, 24545, 2192, 24547, 2190, 24549, 2188, 24551, 2186, 24553, 2184, 24555, 2182, 24557, 2180, 24559, 2178, 24561, 2176, 24563, 2174, 24565, 2172, 24567, 2170, 24569, 2168, 24571, 2166, 24573, 2164, 24575, 2162, 24577, 2160, 24579, 2158, 24581, 2156, 24583, 2154, 24585, 2152, 24587, 2150, 24589, 2148, 24591, 2146, 24593, 2144, 24595, 2142, 24597, 2140, 24599, 2138, 24601, 2136, 24603, 2134, 24605, 2132, 24607, 2130, 24609, 2128, 24611, 2126, 24613, 2124, 24615, 2122, 24617, 2120, 24619, 2118, 24621, 2116, 24623, 2114, 24625, 2112, 24627, 2110, 24629, 2108, 24631, 2106, 24633, 2104, 24635, 2102, 24637, 2100, 24639, 2098, 24641, 2096, 24643, 2094, 24645, 2092, 24647, 2090, 24649, 2088, 24651, 2086, 24653, 2084, 24655, 2082, 24657, 2080, 24659, 2078, 24661, 2076, 24663, 2074, 24665, 2072, 24667, 2070, 24669, 2068, 24671, 2066, 24673, 2064, 24675, 2062, 24677, 2060, 24679, 2058, 24681, 2056, 24683, 2054, 24685, 2052, 24687, 2050, 24689, 2048, 24691, 2046, 24693, 2044, 24695, 2042, 24697, 2040, 24699, 2038, 24701, 2036, 24703, 2034, 24705, 2032, 24707, 2030, 24709, 2028, 24711, 2026, 24713, 2024, 24715, 2022, 24717, 2020, 24719, 2018, 24721, 2016, 24723, 2014, 24725, 2012, 24727, 2010, 24729, 2008, 24731, 2006, 24733, 2004, 24735, 2002, 24737, 2000, 24739, 1998, 24741, 1996, 24743, 1994, 24745, 1992, 24747, 1990, 24749, 1988, 24751, 1986, 24753, 1984, 24755, 1982, 24757, 1980, 24759, 1978, 24761, 1976, 24763, 1974, 24765, 1972, 24767, 1970, 24769, 1968, 24771, 1966, 24773, 1964, 24775, 1962, 24777, 1960, 24779, 1958, 24781, 1956, 24783, 1954, 24785, 1952, 24787, 1950, 24789, 1948, 24791, 1946, 24793, 1944, 24795, 1942, 24797, 1940, 24799, 1938, 24801, 1936, 24803, 1934, 24805, 1932, 24807, 1930, 24809, 1928, 24811, 1926, 24813, 1924, 24815, 1922, 24817, 1920, 24819, 1918, 24821, 1916, 24823, 1914, 24825, 1912, 24827, 1910, 24829, 1908, 24831, 1906, 24833, 1904, 24835, 1902, 24837, 1900, 24839, 1898, 24841, 1896, 24843, 1894, 24845, 1892, 24847, 1890, 24849, 1888, 24851, 1886, 24853, 1884, 24855, 1882, 24857, 1880, 24859, 1878, 24861, 1876, 24863, 1874, 24865, 1872, 24867, 1870, 24869, 1868, 24871, 1866, 24873, 1864, 24875, 1862, 24877, 1860, 24879, 1858, 24881, 1856, 24883, 1854, 24885, 1852, 24887, 1850, 24889, 1848, 24891, 1846, 24893, 1844, 24895, 1842, 24897, 1840, 24899, 1838, 24901, 1836, 24903, 1834, 24905, 1832, 24907, 1830, 24909, 1828, 24911, 1826, 24913, 1824, 24915, 1822, 24917, 1820, 24919, 1818, 24921, 1816, 24923, 1814, 24925, 1812, 24927, 1810, 24929, 1808, 24931, 1806, 24933, 1804, 24935, 1802, 24937, 1800, 24939, 1798, 24941, 1796, 24943, 1794, 24945, 1792, 24947, 1790, 24949, 1788, 24951, 1786, 24953, 1784, 24955, 1782, 24957, 1780, 24959, 1778, 24961, 1776, 24963, 1774, 24965, 1772, 24967, 1770, 24969, 1768, 24971, 1766, 24973, 1764, 24975, 1762, 24977, 1760, 24979, 1758, 24981, 1756, 24983, 1754, 24985, 1752, 24987, 1750, 24989, 1748, 24991, 1746, 24993, 1744, 24995, 1742, 24997, 1740, 24999, 1738, 25001, 1736, 25003, 1734, 25005, 1732, 25007, 1730, 25009, 1728, 25011, 1726, 25013, 1724, 25015, 1722, 25017, 1720, 25019, 1718, 25021, 1716, 25023, 1714, 25025, 1712, 25027, 1710, 25029, 1708, 25031, 1706, 25033, 1704, 25035, 1702, 25037, 1700, 25039, 1698, 25041, 1696, 25043, 1694, 25045, 1692, 25047, 1690, 25049, 1688, 25051, 1686, 25053, 1684, 25055, 1682, 25057, 1680, 25059, 1678, 25061, 1676, 25063, 1674, 25065, 1672, 25067, 1670, 25069, 1668, 25071, 1666, 25073, 1664, 25075, 1662, 25077, 1660, 25079, 1658, 25081, 1656, 25083, 1654, 25085, 1652, 25087, 1650, 25089, 1648, 25091, 1646, 25093, 1644, 25095, 1642, 25097, 1640, 25099, 1638, 25101, 1636, 25103, 1634, 25105, 1632, 25107, 1630, 25109, 1628, 25111, 1626, 25113, 1624, 25115, 1622, 25117, 1620, 25119, 1618, 25121, 1616, 25123, 1614, 25125, 1612, 25127, 1610, 25129, 1608, 25131, 1606, 25133, 1604, 25135, 1602, 25137, 1600, 25139, 1598, 25141, 1596, 25143, 1594, 25145, 1592, 25147, 1590, 25149, 1588, 25151, 1586, 25153, 1584, 25155, 1582, 25157, 1580, 25159, 1578, 25161, 1576, 25163, 1574, 25165, 1572, 25167, 1570, 25169, 1568, 25171, 1566, 25173, 1564, 25175, 1562, 25177, 1560, 25179, 1558, 25181, 1556, 25183, 1554, 25185, 1552, 25187, 1550, 25189, 1548, 25191, 1546, 25193, 1544, 25195, 1542, 25197, 1540, 25199, 1538, 25201, 1536, 25203, 1534, 25205, 1532, 25207, 1530, 25209, 1528, 25211, 1526, 25213, 1524, 25215, 1522, 25217, 1520, 25219, 1518, 25221, 1516, 25223, 1514, 25225, 1512, 25227, 1510, 25229, 1508, 25231, 1506, 25233, 1504, 25235, 1502, 25237, 1500, 25239, 1498, 25241, 1496, 25243, 1494, 25245, 1492, 25247, 1490, 25249, 1488, 25251, 1486, 25253, 1484, 25255, 1482, 25257, 1480, 25259, 1478, 25261, 1476, 25263, 1474, 25265, 1472, 25267, 1470, 25269, 1468, 25271, 1466, 25273, 1464, 25275, 1462, 25277, 1460, 25279, 1458, 25281, 1456, 25283, 1454, 25285, 1452, 25287, 1450, 25289, 1448, 25291, 1446, 25293, 1444, 25295, 1442, 25297, 1440, 25299, 1438, 25301, 1436, 25303, 1434, 25305, 1432, 25307, 1430, 25309, 1428, 25311, 1426, 25313, 1424, 25315, 1422, 25317, 1420, 25319, 1418, 25321, 1416, 25323, 1414, 25325, 1412, 25327, 1410, 25329, 1408, 25331, 1406, 25333, 1404, 25335, 1402, 25337, 1400, 25339, 1398, 25341, 1396, 25343, 1394, 25345, 1392, 25347, 1390, 25349, 1388, 25351, 1386, 25353, 1384, 25355, 1382, 25357, 1380, 25359, 1378, 25361, 1376, 25363, 1374, 25365, 1372, 25367, 1370, 25369, 1368, 25371, 1366, 25373, 1364, 25375, 1362, 25377, 1360, 25379, 1358, 25381, 1356, 25383, 1354, 25385, 1352, 25387, 1350, 25389, 1348, 25391, 1346, 25393, 1344, 25395, 1342, 25397, 1340, 25399, 1338, 25401, 1336, 25403, 1334, 25405, 1332, 25407, 1330, 25409, 1328, 25411, 1326, 25413, 1324, 25415, 1322, 25417, 1320, 25419, 1318, 25421, 1316, 25423, 1314, 25425, 1312, 25427, 1310, 25429, 1308, 25431, 1306, 25433, 1304, 25435, 1302, 25437, 1300, 25439, 1298, 25441, 1296, 25443, 1294, 25445, 1292, 25447, 1290, 25449, 1288, 25451, 1286, 25453, 1284, 25455, 1282, 25457, 1280, 25459, 1278, 25461, 1276, 25463, 1274, 25465, 1272, 25467, 1270, 25469, 1268, 25471, 1266, 25473, 1264, 25475, 1262, 25477, 1260, 25479, 1258, 25481, 1256, 25483, 1254, 25485, 1252, 25487, 1250, 25489, 1248, 25491, 1246, 25493, 1244, 25495, 1242, 25497, 1240, 25499, 1238, 25501, 1236, 25503, 1234, 25505, 1232, 25507, 1230, 25509, 1228, 25511, 1226, 25513, 1224, 25515, 1222, 25517, 1220, 25519, 1218, 25521, 1216, 25523, 1214, 25525, 1212, 25527, 1210, 25529, 1208, 25531, 1206, 25533, 1204, 25535, 1202, 25537, 1200, 25539, 1198, 25541, 1196, 25543, 1194, 25545, 1192, 25547, 1190, 25549, 1188, 25551, 1186, 25553, 1184, 25555, 1182, 25557, 1180, 25559, 1178, 25561, 1176, 25563, 1174, 25565, 1172, 25567, 1170, 25569, 1168, 25571, 1166, 25573, 1164, 25575, 1162, 25577, 1160, 25579, 1158, 25581, 1156, 25583, 1154, 25585, 1152, 25587, 1150, 25589, 1148, 25591, 1146, 25593, 1144, 25595, 1142, 25597, 1140, 25599, 1138, 25601, 1136, 25603, 1134, 25605, 1132, 25607, 1130, 25609, 1128, 25611, 1126, 25613, 1124, 25615, 1122, 25617, 1120, 25619, 1118, 25621, 1116, 25623, 1114, 25625, 1112, 25627, 1110, 25629, 1108, 25631, 1106, 25633, 1104, 25635, 1102, 25637, 1100, 25639, 1098, 25641, 1096, 25643, 1094, 25645, 1092, 25647, 1090, 25649, 1088, 25651, 1086, 25653, 1084, 25655, 1082, 25657, 1080, 25659, 1078, 25661, 1076, 25663, 1074, 25665, 1072, 25667, 1070, 25669, 1068, 25671, 1066, 25673, 1064, 25675, 1062, 25677, 1060, 25679, 1058, 25681, 1056, 25683, 1054, 25685, 1052, 25687, 1050, 25689, 1048, 25691, 1046, 25693, 1044, 25695, 1042, 25697, 1040, 25699, 1038, 25701, 1036, 25703, 1034, 25705, 1032, 25707, 1030, 25709, 1028, 25711, 1026, 25713, 1024, 25715, 1022, 25717, 1020, 25719, 1018, 25721, 1016, 25723, 1014, 25725, 1012, 25727, 1010, 25729, 1008, 25731, 1006, 25733, 1004, 25735, 1002, 25737, 1000, 25739, 998, 25741, 996, 25743, 994, 25745, 992, 25747, 990, 25749, 988, 25751, 986, 25753, 984, 25755, 982, 25757, 980, 25759, 978, 25761, 976, 25763, 974, 25765, 972, 25767, 970, 25769, 968, 25771, 966, 25773, 964, 25775, 962, 25777, 960, 25779, 958, 25781, 956, 25783, 954, 25785, 952, 25787, 950, 25789, 948, 25791, 946, 25793, 944, 25795, 942, 25797, 940, 25799, 938, 25801, 936, 25803, 934, 25805, 932, 25807, 930, 25809, 928, 25811, 926, 25813, 924, 25815, 922, 25817, 920, 25819, 918, 25821, 916, 25823, 914, 25825, 912, 25827, 910, 25829, 908, 25831, 906, 25833, 904, 25835, 902, 25837, 900, 25839, 898, 25841, 896, 25843, 894, 25845, 892, 25847, 890, 25849, 888, 25851, 886, 25853, 884, 25855, 882, 25857, 880, 25859, 878, 25861, 876, 25863, 874, 25865, 872, 25867, 870, 25869, 868, 25871, 866, 25873, 864, 25875, 862, 25877, 860, 25879, 858, 25881, 856, 25883, 854, 25885, 852, 25887, 850, 25889, 848, 25891, 846, 25893, 844, 25895, 842, 25897, 840, 25899, 838, 25901, 836, 25903, 834, 25905, 832, 25907, 830, 25909, 828, 25911, 826, 25913, 824, 25915, 822, 25917, 820, 25919, 818, 25921, 816, 25923, 814, 25925, 812, 25927, 810, 25929, 808, 25931, 806, 25933, 804, 25935, 802, 25937, 800, 25939, 798, 25941, 796, 25943, 794, 25945, 792, 25947, 790, 25949, 788, 25951, 786, 25953, 784, 25955, 782, 25957, 780, 25959, 778, 25961, 776, 25963, 774, 25965, 772, 25967, 770, 25969, 768, 25971, 766, 25973, 764, 25975, 762, 25977, 760, 25979, 758, 25981, 756, 25983, 754, 25985, 752, 25987, 750, 25989, 748, 25991, 746, 25993, 744, 25995, 742, 25997, 740, 25999, 738, 26001, 736, 26003, 734, 26005, 732, 26007, 730, 26009, 728, 26011, 726, 26013, 724, 26015, 722, 26017, 720, 26019, 718, 26021, 716, 26023, 714, 26025, 712, 26027, 710, 26029, 708, 26031, 706, 26033, 704, 26035, 702, 26037, 700, 26039, 698, 26041, 696, 26043, 694, 26045, 692, 26047, 690, 26049, 688, 26051, 686, 26053, 684, 26055, 682, 26057, 680, 26059, 678, 26061, 676, 26063, 674, 26065, 672, 26067, 670, 26069, 668, 26071, 666, 26073, 664, 26075, 662, 26077, 660, 26079, 658, 26081, 656, 26083, 654, 26085, 652, 26087, 650, 26089, 648, 26091, 646, 26093, 644, 26095, 642, 26097, 640, 26099, 638, 26101, 636, 26103, 634, 26105, 632, 26107, 630, 26109, 628, 26111, 626, 26113, 624, 26115, 622, 26117, 620, 26119, 618, 26121, 616, 26123, 614, 26125, 612, 26127, 610, 26129, 608, 26131, 606, 26133, 604, 26135, 602, 26137, 600, 26139, 598, 26141, 596, 26143, 594, 26145, 592, 26147, 590, 26149, 588, 26151, 586, 26153, 584, 26155, 582, 26157, 580, 26159, 578, 26161, 576, 26163, 574, 26165, 572, 26167, 570, 26169, 568, 26171, 566, 26173, 564, 26175, 562, 26177, 560, 26179, 558, 26181, 556, 26183, 554, 26185, 552, 26187, 550, 26189, 548, 26191, 546, 26193, 544, 26195, 542, 26197, 540, 26199, 538, 26201, 536, 26203, 534, 26205, 532, 26207, 530, 26209, 528, 26211, 526, 26213, 524, 26215, 522, 26217, 520, 26219, 518, 26221, 516, 26223, 514, 26225, 512, 26227, 510, 26229, 508, 26231, 506, 26233, 504, 26235, 502, 26237, 500, 26239, 498, 26241, 496, 26243, 494, 26245, 492, 26247, 490, 26249, 488, 26251, 486, 26253, 484, 26255, 482, 26257, 480, 26259, 478, 26261, 476, 26263, 474, 26265, 472, 26267, 470, 26269, 468, 26271, 466, 26273, 464, 26275, 462, 26277, 460, 26279, 458, 26281, 456, 26283, 454, 26285, 452, 26287, 450, 26289, 448, 26291, 446, 26293, 444, 26295, 442, 26297, 440, 26299, 438, 26301, 436, 26303, 434, 26305, 432, 26307, 430, 26309, 428, 26311, 426, 26313, 424, 26315, 422, 26317, 420, 26319, 418, 26321, 416, 26323, 414, 26325, 412, 26327, 410, 26329, 408, 26331, 406, 26333, 404, 26335, 402, 26337, 400, 26339, 398, 26341, 396, 26343, 394, 26345, 392, 26347, 390, 26349, 388, 26351, 386, 26353, 384, 26355, 382, 26357, 380, 26359, 378, 26361, 376, 26363, 374, 26365, 372, 26367, 370, 26369, 368, 26371, 366, 26373, 364, 26375, 362, 26377, 360, 26379, 358, 26381, 356, 26383, 354, 26385, 352, 26387, 350, 26389, 348, 26391, 346, 26393, 344, 26395, 342, 26397, 340, 26399, 338, 26401, 336, 26403, 334, 26405, 332, 26407, 330, 26409, 328, 26411, 326, 26413, 324, 26415, 322, 26417, 320, 26419, 318, 26421, 316, 26423, 314, 26425, 312, 26427, 310, 26429, 308, 26431, 306, 26433, 304, 26435, 302, 26437, 300, 26439, 298, 26441, 296, 26443, 294, 26445, 292, 26447, 290, 26449, 288, 26451, 286, 26453, 284, 26455, 282, 26457, 280, 26459, 278, 26461, 276, 26463, 274, 26465, 272, 26467, 270, 26469, 268, 26471, 266, 26473, 264, 26475, 262, 26477, 260, 26479, 258, 26481, 256, 26483, 254, 26485, 252, 26487, 250, 26489, 248, 26491, 246, 26493, 244, 26495, 242, 26497, 240, 26499, 238, 26501, 236, 26503, 234, 26505, 232, 26507, 230, 26509, 228, 26511, 226, 26513, 224, 26515, 222, 26517, 220, 26519, 218, 26521, 216, 26523, 214, 26525, 212, 26527, 210, 26529, 208, 26531, 206, 26533, 204, 26535, 202, 26537, 200, 26539, 198, 26541, 196, 26543, 194, 26545, 192, 26547, 190, 26549, 188, 26551, 186, 26553, 184, 26555, 182, 26557, 180, 26559, 178, 26561, 176, 26563, 174, 26565, 172, 26567, 170, 26569, 168, 26571, 166, 26573, 164, 26575, 162, 26577, 160, 26579, 158, 26581, 156, 26583, 154, 26585, 152, 26587, 150, 26589, 148, 26591, 146, 26593, 144, 26595, 142, 26597, 140, 26599, 138, 26601, 136, 26603, 134, 26605, 132, 26607, 130, 26609, 128, 26611, 126, 26613, 124, 26615, 122, 26617, 120, 26619, 118, 26621, 116, 26623, 114, 26625, 112, 26627, 110, 26629, 108, 26631, 106, 26633, 104, 26635, 102, 26637, 100, 26639, 98, 26641, 96, 26643, 94, 26645, 92, 26647, 90, 26649, 88, 26651, 86, 26653, 84, 26655, 82, 26657, 80, 26659, 78, 26661, 76, 26663, 74, 26665, 72, 26667, 70, 26669, 68, 26671, 66, 26673, 64, 26675, 62, 26677, 60, 26679, 58, 26681, 56, 26683, 54, 26685, 52, 26687, 50, 26689, 48, 26691, 46, 26693, 44, 26695, 42, 26697, 40, 26699, 38, 26701, 36, 26703, 34, 26705, 32, 26707, 30, 26709, 28, 26711, 26, 26713, 24, 26715, 22, 26717, 20, 26719, 18, 26721, 16, 26723, 14, 26725, 12, 26727, 10, 26729, 8, 26731, 6, 26733, 4, 26735, 2, 26737]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s3/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l6-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s3/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 0 + for v in p: + acc = (acc + v) % n + if acc in seen: + raise Invalid(f"prefix sum residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s3/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l6-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..ef5492b01b3be47bb8205d31471b980125937b24 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s3/tests/instance.json @@ -0,0 +1 @@ +{"n": 26738, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s3/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l6-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l6-s3/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l6-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l6-s4/environment/Dockerfile b/tasks/construct-rlve-prefix-sum-permutation-l6-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l6-s4/environment/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l6-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bd059b35b257dbf8b39cfe17a97015d7ba68f3d6 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s4/environment/instance.json @@ -0,0 +1 @@ +{"n": 16686, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s4/solution/solve.sh b/tasks/construct-rlve-prefix-sum-permutation-l6-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3c55b36e6d6eeb3703e48a77b1e814fa515ed9da --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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' +{"perm": [16686, 1, 16684, 3, 16682, 5, 16680, 7, 16678, 9, 16676, 11, 16674, 13, 16672, 15, 16670, 17, 16668, 19, 16666, 21, 16664, 23, 16662, 25, 16660, 27, 16658, 29, 16656, 31, 16654, 33, 16652, 35, 16650, 37, 16648, 39, 16646, 41, 16644, 43, 16642, 45, 16640, 47, 16638, 49, 16636, 51, 16634, 53, 16632, 55, 16630, 57, 16628, 59, 16626, 61, 16624, 63, 16622, 65, 16620, 67, 16618, 69, 16616, 71, 16614, 73, 16612, 75, 16610, 77, 16608, 79, 16606, 81, 16604, 83, 16602, 85, 16600, 87, 16598, 89, 16596, 91, 16594, 93, 16592, 95, 16590, 97, 16588, 99, 16586, 101, 16584, 103, 16582, 105, 16580, 107, 16578, 109, 16576, 111, 16574, 113, 16572, 115, 16570, 117, 16568, 119, 16566, 121, 16564, 123, 16562, 125, 16560, 127, 16558, 129, 16556, 131, 16554, 133, 16552, 135, 16550, 137, 16548, 139, 16546, 141, 16544, 143, 16542, 145, 16540, 147, 16538, 149, 16536, 151, 16534, 153, 16532, 155, 16530, 157, 16528, 159, 16526, 161, 16524, 163, 16522, 165, 16520, 167, 16518, 169, 16516, 171, 16514, 173, 16512, 175, 16510, 177, 16508, 179, 16506, 181, 16504, 183, 16502, 185, 16500, 187, 16498, 189, 16496, 191, 16494, 193, 16492, 195, 16490, 197, 16488, 199, 16486, 201, 16484, 203, 16482, 205, 16480, 207, 16478, 209, 16476, 211, 16474, 213, 16472, 215, 16470, 217, 16468, 219, 16466, 221, 16464, 223, 16462, 225, 16460, 227, 16458, 229, 16456, 231, 16454, 233, 16452, 235, 16450, 237, 16448, 239, 16446, 241, 16444, 243, 16442, 245, 16440, 247, 16438, 249, 16436, 251, 16434, 253, 16432, 255, 16430, 257, 16428, 259, 16426, 261, 16424, 263, 16422, 265, 16420, 267, 16418, 269, 16416, 271, 16414, 273, 16412, 275, 16410, 277, 16408, 279, 16406, 281, 16404, 283, 16402, 285, 16400, 287, 16398, 289, 16396, 291, 16394, 293, 16392, 295, 16390, 297, 16388, 299, 16386, 301, 16384, 303, 16382, 305, 16380, 307, 16378, 309, 16376, 311, 16374, 313, 16372, 315, 16370, 317, 16368, 319, 16366, 321, 16364, 323, 16362, 325, 16360, 327, 16358, 329, 16356, 331, 16354, 333, 16352, 335, 16350, 337, 16348, 339, 16346, 341, 16344, 343, 16342, 345, 16340, 347, 16338, 349, 16336, 351, 16334, 353, 16332, 355, 16330, 357, 16328, 359, 16326, 361, 16324, 363, 16322, 365, 16320, 367, 16318, 369, 16316, 371, 16314, 373, 16312, 375, 16310, 377, 16308, 379, 16306, 381, 16304, 383, 16302, 385, 16300, 387, 16298, 389, 16296, 391, 16294, 393, 16292, 395, 16290, 397, 16288, 399, 16286, 401, 16284, 403, 16282, 405, 16280, 407, 16278, 409, 16276, 411, 16274, 413, 16272, 415, 16270, 417, 16268, 419, 16266, 421, 16264, 423, 16262, 425, 16260, 427, 16258, 429, 16256, 431, 16254, 433, 16252, 435, 16250, 437, 16248, 439, 16246, 441, 16244, 443, 16242, 445, 16240, 447, 16238, 449, 16236, 451, 16234, 453, 16232, 455, 16230, 457, 16228, 459, 16226, 461, 16224, 463, 16222, 465, 16220, 467, 16218, 469, 16216, 471, 16214, 473, 16212, 475, 16210, 477, 16208, 479, 16206, 481, 16204, 483, 16202, 485, 16200, 487, 16198, 489, 16196, 491, 16194, 493, 16192, 495, 16190, 497, 16188, 499, 16186, 501, 16184, 503, 16182, 505, 16180, 507, 16178, 509, 16176, 511, 16174, 513, 16172, 515, 16170, 517, 16168, 519, 16166, 521, 16164, 523, 16162, 525, 16160, 527, 16158, 529, 16156, 531, 16154, 533, 16152, 535, 16150, 537, 16148, 539, 16146, 541, 16144, 543, 16142, 545, 16140, 547, 16138, 549, 16136, 551, 16134, 553, 16132, 555, 16130, 557, 16128, 559, 16126, 561, 16124, 563, 16122, 565, 16120, 567, 16118, 569, 16116, 571, 16114, 573, 16112, 575, 16110, 577, 16108, 579, 16106, 581, 16104, 583, 16102, 585, 16100, 587, 16098, 589, 16096, 591, 16094, 593, 16092, 595, 16090, 597, 16088, 599, 16086, 601, 16084, 603, 16082, 605, 16080, 607, 16078, 609, 16076, 611, 16074, 613, 16072, 615, 16070, 617, 16068, 619, 16066, 621, 16064, 623, 16062, 625, 16060, 627, 16058, 629, 16056, 631, 16054, 633, 16052, 635, 16050, 637, 16048, 639, 16046, 641, 16044, 643, 16042, 645, 16040, 647, 16038, 649, 16036, 651, 16034, 653, 16032, 655, 16030, 657, 16028, 659, 16026, 661, 16024, 663, 16022, 665, 16020, 667, 16018, 669, 16016, 671, 16014, 673, 16012, 675, 16010, 677, 16008, 679, 16006, 681, 16004, 683, 16002, 685, 16000, 687, 15998, 689, 15996, 691, 15994, 693, 15992, 695, 15990, 697, 15988, 699, 15986, 701, 15984, 703, 15982, 705, 15980, 707, 15978, 709, 15976, 711, 15974, 713, 15972, 715, 15970, 717, 15968, 719, 15966, 721, 15964, 723, 15962, 725, 15960, 727, 15958, 729, 15956, 731, 15954, 733, 15952, 735, 15950, 737, 15948, 739, 15946, 741, 15944, 743, 15942, 745, 15940, 747, 15938, 749, 15936, 751, 15934, 753, 15932, 755, 15930, 757, 15928, 759, 15926, 761, 15924, 763, 15922, 765, 15920, 767, 15918, 769, 15916, 771, 15914, 773, 15912, 775, 15910, 777, 15908, 779, 15906, 781, 15904, 783, 15902, 785, 15900, 787, 15898, 789, 15896, 791, 15894, 793, 15892, 795, 15890, 797, 15888, 799, 15886, 801, 15884, 803, 15882, 805, 15880, 807, 15878, 809, 15876, 811, 15874, 813, 15872, 815, 15870, 817, 15868, 819, 15866, 821, 15864, 823, 15862, 825, 15860, 827, 15858, 829, 15856, 831, 15854, 833, 15852, 835, 15850, 837, 15848, 839, 15846, 841, 15844, 843, 15842, 845, 15840, 847, 15838, 849, 15836, 851, 15834, 853, 15832, 855, 15830, 857, 15828, 859, 15826, 861, 15824, 863, 15822, 865, 15820, 867, 15818, 869, 15816, 871, 15814, 873, 15812, 875, 15810, 877, 15808, 879, 15806, 881, 15804, 883, 15802, 885, 15800, 887, 15798, 889, 15796, 891, 15794, 893, 15792, 895, 15790, 897, 15788, 899, 15786, 901, 15784, 903, 15782, 905, 15780, 907, 15778, 909, 15776, 911, 15774, 913, 15772, 915, 15770, 917, 15768, 919, 15766, 921, 15764, 923, 15762, 925, 15760, 927, 15758, 929, 15756, 931, 15754, 933, 15752, 935, 15750, 937, 15748, 939, 15746, 941, 15744, 943, 15742, 945, 15740, 947, 15738, 949, 15736, 951, 15734, 953, 15732, 955, 15730, 957, 15728, 959, 15726, 961, 15724, 963, 15722, 965, 15720, 967, 15718, 969, 15716, 971, 15714, 973, 15712, 975, 15710, 977, 15708, 979, 15706, 981, 15704, 983, 15702, 985, 15700, 987, 15698, 989, 15696, 991, 15694, 993, 15692, 995, 15690, 997, 15688, 999, 15686, 1001, 15684, 1003, 15682, 1005, 15680, 1007, 15678, 1009, 15676, 1011, 15674, 1013, 15672, 1015, 15670, 1017, 15668, 1019, 15666, 1021, 15664, 1023, 15662, 1025, 15660, 1027, 15658, 1029, 15656, 1031, 15654, 1033, 15652, 1035, 15650, 1037, 15648, 1039, 15646, 1041, 15644, 1043, 15642, 1045, 15640, 1047, 15638, 1049, 15636, 1051, 15634, 1053, 15632, 1055, 15630, 1057, 15628, 1059, 15626, 1061, 15624, 1063, 15622, 1065, 15620, 1067, 15618, 1069, 15616, 1071, 15614, 1073, 15612, 1075, 15610, 1077, 15608, 1079, 15606, 1081, 15604, 1083, 15602, 1085, 15600, 1087, 15598, 1089, 15596, 1091, 15594, 1093, 15592, 1095, 15590, 1097, 15588, 1099, 15586, 1101, 15584, 1103, 15582, 1105, 15580, 1107, 15578, 1109, 15576, 1111, 15574, 1113, 15572, 1115, 15570, 1117, 15568, 1119, 15566, 1121, 15564, 1123, 15562, 1125, 15560, 1127, 15558, 1129, 15556, 1131, 15554, 1133, 15552, 1135, 15550, 1137, 15548, 1139, 15546, 1141, 15544, 1143, 15542, 1145, 15540, 1147, 15538, 1149, 15536, 1151, 15534, 1153, 15532, 1155, 15530, 1157, 15528, 1159, 15526, 1161, 15524, 1163, 15522, 1165, 15520, 1167, 15518, 1169, 15516, 1171, 15514, 1173, 15512, 1175, 15510, 1177, 15508, 1179, 15506, 1181, 15504, 1183, 15502, 1185, 15500, 1187, 15498, 1189, 15496, 1191, 15494, 1193, 15492, 1195, 15490, 1197, 15488, 1199, 15486, 1201, 15484, 1203, 15482, 1205, 15480, 1207, 15478, 1209, 15476, 1211, 15474, 1213, 15472, 1215, 15470, 1217, 15468, 1219, 15466, 1221, 15464, 1223, 15462, 1225, 15460, 1227, 15458, 1229, 15456, 1231, 15454, 1233, 15452, 1235, 15450, 1237, 15448, 1239, 15446, 1241, 15444, 1243, 15442, 1245, 15440, 1247, 15438, 1249, 15436, 1251, 15434, 1253, 15432, 1255, 15430, 1257, 15428, 1259, 15426, 1261, 15424, 1263, 15422, 1265, 15420, 1267, 15418, 1269, 15416, 1271, 15414, 1273, 15412, 1275, 15410, 1277, 15408, 1279, 15406, 1281, 15404, 1283, 15402, 1285, 15400, 1287, 15398, 1289, 15396, 1291, 15394, 1293, 15392, 1295, 15390, 1297, 15388, 1299, 15386, 1301, 15384, 1303, 15382, 1305, 15380, 1307, 15378, 1309, 15376, 1311, 15374, 1313, 15372, 1315, 15370, 1317, 15368, 1319, 15366, 1321, 15364, 1323, 15362, 1325, 15360, 1327, 15358, 1329, 15356, 1331, 15354, 1333, 15352, 1335, 15350, 1337, 15348, 1339, 15346, 1341, 15344, 1343, 15342, 1345, 15340, 1347, 15338, 1349, 15336, 1351, 15334, 1353, 15332, 1355, 15330, 1357, 15328, 1359, 15326, 1361, 15324, 1363, 15322, 1365, 15320, 1367, 15318, 1369, 15316, 1371, 15314, 1373, 15312, 1375, 15310, 1377, 15308, 1379, 15306, 1381, 15304, 1383, 15302, 1385, 15300, 1387, 15298, 1389, 15296, 1391, 15294, 1393, 15292, 1395, 15290, 1397, 15288, 1399, 15286, 1401, 15284, 1403, 15282, 1405, 15280, 1407, 15278, 1409, 15276, 1411, 15274, 1413, 15272, 1415, 15270, 1417, 15268, 1419, 15266, 1421, 15264, 1423, 15262, 1425, 15260, 1427, 15258, 1429, 15256, 1431, 15254, 1433, 15252, 1435, 15250, 1437, 15248, 1439, 15246, 1441, 15244, 1443, 15242, 1445, 15240, 1447, 15238, 1449, 15236, 1451, 15234, 1453, 15232, 1455, 15230, 1457, 15228, 1459, 15226, 1461, 15224, 1463, 15222, 1465, 15220, 1467, 15218, 1469, 15216, 1471, 15214, 1473, 15212, 1475, 15210, 1477, 15208, 1479, 15206, 1481, 15204, 1483, 15202, 1485, 15200, 1487, 15198, 1489, 15196, 1491, 15194, 1493, 15192, 1495, 15190, 1497, 15188, 1499, 15186, 1501, 15184, 1503, 15182, 1505, 15180, 1507, 15178, 1509, 15176, 1511, 15174, 1513, 15172, 1515, 15170, 1517, 15168, 1519, 15166, 1521, 15164, 1523, 15162, 1525, 15160, 1527, 15158, 1529, 15156, 1531, 15154, 1533, 15152, 1535, 15150, 1537, 15148, 1539, 15146, 1541, 15144, 1543, 15142, 1545, 15140, 1547, 15138, 1549, 15136, 1551, 15134, 1553, 15132, 1555, 15130, 1557, 15128, 1559, 15126, 1561, 15124, 1563, 15122, 1565, 15120, 1567, 15118, 1569, 15116, 1571, 15114, 1573, 15112, 1575, 15110, 1577, 15108, 1579, 15106, 1581, 15104, 1583, 15102, 1585, 15100, 1587, 15098, 1589, 15096, 1591, 15094, 1593, 15092, 1595, 15090, 1597, 15088, 1599, 15086, 1601, 15084, 1603, 15082, 1605, 15080, 1607, 15078, 1609, 15076, 1611, 15074, 1613, 15072, 1615, 15070, 1617, 15068, 1619, 15066, 1621, 15064, 1623, 15062, 1625, 15060, 1627, 15058, 1629, 15056, 1631, 15054, 1633, 15052, 1635, 15050, 1637, 15048, 1639, 15046, 1641, 15044, 1643, 15042, 1645, 15040, 1647, 15038, 1649, 15036, 1651, 15034, 1653, 15032, 1655, 15030, 1657, 15028, 1659, 15026, 1661, 15024, 1663, 15022, 1665, 15020, 1667, 15018, 1669, 15016, 1671, 15014, 1673, 15012, 1675, 15010, 1677, 15008, 1679, 15006, 1681, 15004, 1683, 15002, 1685, 15000, 1687, 14998, 1689, 14996, 1691, 14994, 1693, 14992, 1695, 14990, 1697, 14988, 1699, 14986, 1701, 14984, 1703, 14982, 1705, 14980, 1707, 14978, 1709, 14976, 1711, 14974, 1713, 14972, 1715, 14970, 1717, 14968, 1719, 14966, 1721, 14964, 1723, 14962, 1725, 14960, 1727, 14958, 1729, 14956, 1731, 14954, 1733, 14952, 1735, 14950, 1737, 14948, 1739, 14946, 1741, 14944, 1743, 14942, 1745, 14940, 1747, 14938, 1749, 14936, 1751, 14934, 1753, 14932, 1755, 14930, 1757, 14928, 1759, 14926, 1761, 14924, 1763, 14922, 1765, 14920, 1767, 14918, 1769, 14916, 1771, 14914, 1773, 14912, 1775, 14910, 1777, 14908, 1779, 14906, 1781, 14904, 1783, 14902, 1785, 14900, 1787, 14898, 1789, 14896, 1791, 14894, 1793, 14892, 1795, 14890, 1797, 14888, 1799, 14886, 1801, 14884, 1803, 14882, 1805, 14880, 1807, 14878, 1809, 14876, 1811, 14874, 1813, 14872, 1815, 14870, 1817, 14868, 1819, 14866, 1821, 14864, 1823, 14862, 1825, 14860, 1827, 14858, 1829, 14856, 1831, 14854, 1833, 14852, 1835, 14850, 1837, 14848, 1839, 14846, 1841, 14844, 1843, 14842, 1845, 14840, 1847, 14838, 1849, 14836, 1851, 14834, 1853, 14832, 1855, 14830, 1857, 14828, 1859, 14826, 1861, 14824, 1863, 14822, 1865, 14820, 1867, 14818, 1869, 14816, 1871, 14814, 1873, 14812, 1875, 14810, 1877, 14808, 1879, 14806, 1881, 14804, 1883, 14802, 1885, 14800, 1887, 14798, 1889, 14796, 1891, 14794, 1893, 14792, 1895, 14790, 1897, 14788, 1899, 14786, 1901, 14784, 1903, 14782, 1905, 14780, 1907, 14778, 1909, 14776, 1911, 14774, 1913, 14772, 1915, 14770, 1917, 14768, 1919, 14766, 1921, 14764, 1923, 14762, 1925, 14760, 1927, 14758, 1929, 14756, 1931, 14754, 1933, 14752, 1935, 14750, 1937, 14748, 1939, 14746, 1941, 14744, 1943, 14742, 1945, 14740, 1947, 14738, 1949, 14736, 1951, 14734, 1953, 14732, 1955, 14730, 1957, 14728, 1959, 14726, 1961, 14724, 1963, 14722, 1965, 14720, 1967, 14718, 1969, 14716, 1971, 14714, 1973, 14712, 1975, 14710, 1977, 14708, 1979, 14706, 1981, 14704, 1983, 14702, 1985, 14700, 1987, 14698, 1989, 14696, 1991, 14694, 1993, 14692, 1995, 14690, 1997, 14688, 1999, 14686, 2001, 14684, 2003, 14682, 2005, 14680, 2007, 14678, 2009, 14676, 2011, 14674, 2013, 14672, 2015, 14670, 2017, 14668, 2019, 14666, 2021, 14664, 2023, 14662, 2025, 14660, 2027, 14658, 2029, 14656, 2031, 14654, 2033, 14652, 2035, 14650, 2037, 14648, 2039, 14646, 2041, 14644, 2043, 14642, 2045, 14640, 2047, 14638, 2049, 14636, 2051, 14634, 2053, 14632, 2055, 14630, 2057, 14628, 2059, 14626, 2061, 14624, 2063, 14622, 2065, 14620, 2067, 14618, 2069, 14616, 2071, 14614, 2073, 14612, 2075, 14610, 2077, 14608, 2079, 14606, 2081, 14604, 2083, 14602, 2085, 14600, 2087, 14598, 2089, 14596, 2091, 14594, 2093, 14592, 2095, 14590, 2097, 14588, 2099, 14586, 2101, 14584, 2103, 14582, 2105, 14580, 2107, 14578, 2109, 14576, 2111, 14574, 2113, 14572, 2115, 14570, 2117, 14568, 2119, 14566, 2121, 14564, 2123, 14562, 2125, 14560, 2127, 14558, 2129, 14556, 2131, 14554, 2133, 14552, 2135, 14550, 2137, 14548, 2139, 14546, 2141, 14544, 2143, 14542, 2145, 14540, 2147, 14538, 2149, 14536, 2151, 14534, 2153, 14532, 2155, 14530, 2157, 14528, 2159, 14526, 2161, 14524, 2163, 14522, 2165, 14520, 2167, 14518, 2169, 14516, 2171, 14514, 2173, 14512, 2175, 14510, 2177, 14508, 2179, 14506, 2181, 14504, 2183, 14502, 2185, 14500, 2187, 14498, 2189, 14496, 2191, 14494, 2193, 14492, 2195, 14490, 2197, 14488, 2199, 14486, 2201, 14484, 2203, 14482, 2205, 14480, 2207, 14478, 2209, 14476, 2211, 14474, 2213, 14472, 2215, 14470, 2217, 14468, 2219, 14466, 2221, 14464, 2223, 14462, 2225, 14460, 2227, 14458, 2229, 14456, 2231, 14454, 2233, 14452, 2235, 14450, 2237, 14448, 2239, 14446, 2241, 14444, 2243, 14442, 2245, 14440, 2247, 14438, 2249, 14436, 2251, 14434, 2253, 14432, 2255, 14430, 2257, 14428, 2259, 14426, 2261, 14424, 2263, 14422, 2265, 14420, 2267, 14418, 2269, 14416, 2271, 14414, 2273, 14412, 2275, 14410, 2277, 14408, 2279, 14406, 2281, 14404, 2283, 14402, 2285, 14400, 2287, 14398, 2289, 14396, 2291, 14394, 2293, 14392, 2295, 14390, 2297, 14388, 2299, 14386, 2301, 14384, 2303, 14382, 2305, 14380, 2307, 14378, 2309, 14376, 2311, 14374, 2313, 14372, 2315, 14370, 2317, 14368, 2319, 14366, 2321, 14364, 2323, 14362, 2325, 14360, 2327, 14358, 2329, 14356, 2331, 14354, 2333, 14352, 2335, 14350, 2337, 14348, 2339, 14346, 2341, 14344, 2343, 14342, 2345, 14340, 2347, 14338, 2349, 14336, 2351, 14334, 2353, 14332, 2355, 14330, 2357, 14328, 2359, 14326, 2361, 14324, 2363, 14322, 2365, 14320, 2367, 14318, 2369, 14316, 2371, 14314, 2373, 14312, 2375, 14310, 2377, 14308, 2379, 14306, 2381, 14304, 2383, 14302, 2385, 14300, 2387, 14298, 2389, 14296, 2391, 14294, 2393, 14292, 2395, 14290, 2397, 14288, 2399, 14286, 2401, 14284, 2403, 14282, 2405, 14280, 2407, 14278, 2409, 14276, 2411, 14274, 2413, 14272, 2415, 14270, 2417, 14268, 2419, 14266, 2421, 14264, 2423, 14262, 2425, 14260, 2427, 14258, 2429, 14256, 2431, 14254, 2433, 14252, 2435, 14250, 2437, 14248, 2439, 14246, 2441, 14244, 2443, 14242, 2445, 14240, 2447, 14238, 2449, 14236, 2451, 14234, 2453, 14232, 2455, 14230, 2457, 14228, 2459, 14226, 2461, 14224, 2463, 14222, 2465, 14220, 2467, 14218, 2469, 14216, 2471, 14214, 2473, 14212, 2475, 14210, 2477, 14208, 2479, 14206, 2481, 14204, 2483, 14202, 2485, 14200, 2487, 14198, 2489, 14196, 2491, 14194, 2493, 14192, 2495, 14190, 2497, 14188, 2499, 14186, 2501, 14184, 2503, 14182, 2505, 14180, 2507, 14178, 2509, 14176, 2511, 14174, 2513, 14172, 2515, 14170, 2517, 14168, 2519, 14166, 2521, 14164, 2523, 14162, 2525, 14160, 2527, 14158, 2529, 14156, 2531, 14154, 2533, 14152, 2535, 14150, 2537, 14148, 2539, 14146, 2541, 14144, 2543, 14142, 2545, 14140, 2547, 14138, 2549, 14136, 2551, 14134, 2553, 14132, 2555, 14130, 2557, 14128, 2559, 14126, 2561, 14124, 2563, 14122, 2565, 14120, 2567, 14118, 2569, 14116, 2571, 14114, 2573, 14112, 2575, 14110, 2577, 14108, 2579, 14106, 2581, 14104, 2583, 14102, 2585, 14100, 2587, 14098, 2589, 14096, 2591, 14094, 2593, 14092, 2595, 14090, 2597, 14088, 2599, 14086, 2601, 14084, 2603, 14082, 2605, 14080, 2607, 14078, 2609, 14076, 2611, 14074, 2613, 14072, 2615, 14070, 2617, 14068, 2619, 14066, 2621, 14064, 2623, 14062, 2625, 14060, 2627, 14058, 2629, 14056, 2631, 14054, 2633, 14052, 2635, 14050, 2637, 14048, 2639, 14046, 2641, 14044, 2643, 14042, 2645, 14040, 2647, 14038, 2649, 14036, 2651, 14034, 2653, 14032, 2655, 14030, 2657, 14028, 2659, 14026, 2661, 14024, 2663, 14022, 2665, 14020, 2667, 14018, 2669, 14016, 2671, 14014, 2673, 14012, 2675, 14010, 2677, 14008, 2679, 14006, 2681, 14004, 2683, 14002, 2685, 14000, 2687, 13998, 2689, 13996, 2691, 13994, 2693, 13992, 2695, 13990, 2697, 13988, 2699, 13986, 2701, 13984, 2703, 13982, 2705, 13980, 2707, 13978, 2709, 13976, 2711, 13974, 2713, 13972, 2715, 13970, 2717, 13968, 2719, 13966, 2721, 13964, 2723, 13962, 2725, 13960, 2727, 13958, 2729, 13956, 2731, 13954, 2733, 13952, 2735, 13950, 2737, 13948, 2739, 13946, 2741, 13944, 2743, 13942, 2745, 13940, 2747, 13938, 2749, 13936, 2751, 13934, 2753, 13932, 2755, 13930, 2757, 13928, 2759, 13926, 2761, 13924, 2763, 13922, 2765, 13920, 2767, 13918, 2769, 13916, 2771, 13914, 2773, 13912, 2775, 13910, 2777, 13908, 2779, 13906, 2781, 13904, 2783, 13902, 2785, 13900, 2787, 13898, 2789, 13896, 2791, 13894, 2793, 13892, 2795, 13890, 2797, 13888, 2799, 13886, 2801, 13884, 2803, 13882, 2805, 13880, 2807, 13878, 2809, 13876, 2811, 13874, 2813, 13872, 2815, 13870, 2817, 13868, 2819, 13866, 2821, 13864, 2823, 13862, 2825, 13860, 2827, 13858, 2829, 13856, 2831, 13854, 2833, 13852, 2835, 13850, 2837, 13848, 2839, 13846, 2841, 13844, 2843, 13842, 2845, 13840, 2847, 13838, 2849, 13836, 2851, 13834, 2853, 13832, 2855, 13830, 2857, 13828, 2859, 13826, 2861, 13824, 2863, 13822, 2865, 13820, 2867, 13818, 2869, 13816, 2871, 13814, 2873, 13812, 2875, 13810, 2877, 13808, 2879, 13806, 2881, 13804, 2883, 13802, 2885, 13800, 2887, 13798, 2889, 13796, 2891, 13794, 2893, 13792, 2895, 13790, 2897, 13788, 2899, 13786, 2901, 13784, 2903, 13782, 2905, 13780, 2907, 13778, 2909, 13776, 2911, 13774, 2913, 13772, 2915, 13770, 2917, 13768, 2919, 13766, 2921, 13764, 2923, 13762, 2925, 13760, 2927, 13758, 2929, 13756, 2931, 13754, 2933, 13752, 2935, 13750, 2937, 13748, 2939, 13746, 2941, 13744, 2943, 13742, 2945, 13740, 2947, 13738, 2949, 13736, 2951, 13734, 2953, 13732, 2955, 13730, 2957, 13728, 2959, 13726, 2961, 13724, 2963, 13722, 2965, 13720, 2967, 13718, 2969, 13716, 2971, 13714, 2973, 13712, 2975, 13710, 2977, 13708, 2979, 13706, 2981, 13704, 2983, 13702, 2985, 13700, 2987, 13698, 2989, 13696, 2991, 13694, 2993, 13692, 2995, 13690, 2997, 13688, 2999, 13686, 3001, 13684, 3003, 13682, 3005, 13680, 3007, 13678, 3009, 13676, 3011, 13674, 3013, 13672, 3015, 13670, 3017, 13668, 3019, 13666, 3021, 13664, 3023, 13662, 3025, 13660, 3027, 13658, 3029, 13656, 3031, 13654, 3033, 13652, 3035, 13650, 3037, 13648, 3039, 13646, 3041, 13644, 3043, 13642, 3045, 13640, 3047, 13638, 3049, 13636, 3051, 13634, 3053, 13632, 3055, 13630, 3057, 13628, 3059, 13626, 3061, 13624, 3063, 13622, 3065, 13620, 3067, 13618, 3069, 13616, 3071, 13614, 3073, 13612, 3075, 13610, 3077, 13608, 3079, 13606, 3081, 13604, 3083, 13602, 3085, 13600, 3087, 13598, 3089, 13596, 3091, 13594, 3093, 13592, 3095, 13590, 3097, 13588, 3099, 13586, 3101, 13584, 3103, 13582, 3105, 13580, 3107, 13578, 3109, 13576, 3111, 13574, 3113, 13572, 3115, 13570, 3117, 13568, 3119, 13566, 3121, 13564, 3123, 13562, 3125, 13560, 3127, 13558, 3129, 13556, 3131, 13554, 3133, 13552, 3135, 13550, 3137, 13548, 3139, 13546, 3141, 13544, 3143, 13542, 3145, 13540, 3147, 13538, 3149, 13536, 3151, 13534, 3153, 13532, 3155, 13530, 3157, 13528, 3159, 13526, 3161, 13524, 3163, 13522, 3165, 13520, 3167, 13518, 3169, 13516, 3171, 13514, 3173, 13512, 3175, 13510, 3177, 13508, 3179, 13506, 3181, 13504, 3183, 13502, 3185, 13500, 3187, 13498, 3189, 13496, 3191, 13494, 3193, 13492, 3195, 13490, 3197, 13488, 3199, 13486, 3201, 13484, 3203, 13482, 3205, 13480, 3207, 13478, 3209, 13476, 3211, 13474, 3213, 13472, 3215, 13470, 3217, 13468, 3219, 13466, 3221, 13464, 3223, 13462, 3225, 13460, 3227, 13458, 3229, 13456, 3231, 13454, 3233, 13452, 3235, 13450, 3237, 13448, 3239, 13446, 3241, 13444, 3243, 13442, 3245, 13440, 3247, 13438, 3249, 13436, 3251, 13434, 3253, 13432, 3255, 13430, 3257, 13428, 3259, 13426, 3261, 13424, 3263, 13422, 3265, 13420, 3267, 13418, 3269, 13416, 3271, 13414, 3273, 13412, 3275, 13410, 3277, 13408, 3279, 13406, 3281, 13404, 3283, 13402, 3285, 13400, 3287, 13398, 3289, 13396, 3291, 13394, 3293, 13392, 3295, 13390, 3297, 13388, 3299, 13386, 3301, 13384, 3303, 13382, 3305, 13380, 3307, 13378, 3309, 13376, 3311, 13374, 3313, 13372, 3315, 13370, 3317, 13368, 3319, 13366, 3321, 13364, 3323, 13362, 3325, 13360, 3327, 13358, 3329, 13356, 3331, 13354, 3333, 13352, 3335, 13350, 3337, 13348, 3339, 13346, 3341, 13344, 3343, 13342, 3345, 13340, 3347, 13338, 3349, 13336, 3351, 13334, 3353, 13332, 3355, 13330, 3357, 13328, 3359, 13326, 3361, 13324, 3363, 13322, 3365, 13320, 3367, 13318, 3369, 13316, 3371, 13314, 3373, 13312, 3375, 13310, 3377, 13308, 3379, 13306, 3381, 13304, 3383, 13302, 3385, 13300, 3387, 13298, 3389, 13296, 3391, 13294, 3393, 13292, 3395, 13290, 3397, 13288, 3399, 13286, 3401, 13284, 3403, 13282, 3405, 13280, 3407, 13278, 3409, 13276, 3411, 13274, 3413, 13272, 3415, 13270, 3417, 13268, 3419, 13266, 3421, 13264, 3423, 13262, 3425, 13260, 3427, 13258, 3429, 13256, 3431, 13254, 3433, 13252, 3435, 13250, 3437, 13248, 3439, 13246, 3441, 13244, 3443, 13242, 3445, 13240, 3447, 13238, 3449, 13236, 3451, 13234, 3453, 13232, 3455, 13230, 3457, 13228, 3459, 13226, 3461, 13224, 3463, 13222, 3465, 13220, 3467, 13218, 3469, 13216, 3471, 13214, 3473, 13212, 3475, 13210, 3477, 13208, 3479, 13206, 3481, 13204, 3483, 13202, 3485, 13200, 3487, 13198, 3489, 13196, 3491, 13194, 3493, 13192, 3495, 13190, 3497, 13188, 3499, 13186, 3501, 13184, 3503, 13182, 3505, 13180, 3507, 13178, 3509, 13176, 3511, 13174, 3513, 13172, 3515, 13170, 3517, 13168, 3519, 13166, 3521, 13164, 3523, 13162, 3525, 13160, 3527, 13158, 3529, 13156, 3531, 13154, 3533, 13152, 3535, 13150, 3537, 13148, 3539, 13146, 3541, 13144, 3543, 13142, 3545, 13140, 3547, 13138, 3549, 13136, 3551, 13134, 3553, 13132, 3555, 13130, 3557, 13128, 3559, 13126, 3561, 13124, 3563, 13122, 3565, 13120, 3567, 13118, 3569, 13116, 3571, 13114, 3573, 13112, 3575, 13110, 3577, 13108, 3579, 13106, 3581, 13104, 3583, 13102, 3585, 13100, 3587, 13098, 3589, 13096, 3591, 13094, 3593, 13092, 3595, 13090, 3597, 13088, 3599, 13086, 3601, 13084, 3603, 13082, 3605, 13080, 3607, 13078, 3609, 13076, 3611, 13074, 3613, 13072, 3615, 13070, 3617, 13068, 3619, 13066, 3621, 13064, 3623, 13062, 3625, 13060, 3627, 13058, 3629, 13056, 3631, 13054, 3633, 13052, 3635, 13050, 3637, 13048, 3639, 13046, 3641, 13044, 3643, 13042, 3645, 13040, 3647, 13038, 3649, 13036, 3651, 13034, 3653, 13032, 3655, 13030, 3657, 13028, 3659, 13026, 3661, 13024, 3663, 13022, 3665, 13020, 3667, 13018, 3669, 13016, 3671, 13014, 3673, 13012, 3675, 13010, 3677, 13008, 3679, 13006, 3681, 13004, 3683, 13002, 3685, 13000, 3687, 12998, 3689, 12996, 3691, 12994, 3693, 12992, 3695, 12990, 3697, 12988, 3699, 12986, 3701, 12984, 3703, 12982, 3705, 12980, 3707, 12978, 3709, 12976, 3711, 12974, 3713, 12972, 3715, 12970, 3717, 12968, 3719, 12966, 3721, 12964, 3723, 12962, 3725, 12960, 3727, 12958, 3729, 12956, 3731, 12954, 3733, 12952, 3735, 12950, 3737, 12948, 3739, 12946, 3741, 12944, 3743, 12942, 3745, 12940, 3747, 12938, 3749, 12936, 3751, 12934, 3753, 12932, 3755, 12930, 3757, 12928, 3759, 12926, 3761, 12924, 3763, 12922, 3765, 12920, 3767, 12918, 3769, 12916, 3771, 12914, 3773, 12912, 3775, 12910, 3777, 12908, 3779, 12906, 3781, 12904, 3783, 12902, 3785, 12900, 3787, 12898, 3789, 12896, 3791, 12894, 3793, 12892, 3795, 12890, 3797, 12888, 3799, 12886, 3801, 12884, 3803, 12882, 3805, 12880, 3807, 12878, 3809, 12876, 3811, 12874, 3813, 12872, 3815, 12870, 3817, 12868, 3819, 12866, 3821, 12864, 3823, 12862, 3825, 12860, 3827, 12858, 3829, 12856, 3831, 12854, 3833, 12852, 3835, 12850, 3837, 12848, 3839, 12846, 3841, 12844, 3843, 12842, 3845, 12840, 3847, 12838, 3849, 12836, 3851, 12834, 3853, 12832, 3855, 12830, 3857, 12828, 3859, 12826, 3861, 12824, 3863, 12822, 3865, 12820, 3867, 12818, 3869, 12816, 3871, 12814, 3873, 12812, 3875, 12810, 3877, 12808, 3879, 12806, 3881, 12804, 3883, 12802, 3885, 12800, 3887, 12798, 3889, 12796, 3891, 12794, 3893, 12792, 3895, 12790, 3897, 12788, 3899, 12786, 3901, 12784, 3903, 12782, 3905, 12780, 3907, 12778, 3909, 12776, 3911, 12774, 3913, 12772, 3915, 12770, 3917, 12768, 3919, 12766, 3921, 12764, 3923, 12762, 3925, 12760, 3927, 12758, 3929, 12756, 3931, 12754, 3933, 12752, 3935, 12750, 3937, 12748, 3939, 12746, 3941, 12744, 3943, 12742, 3945, 12740, 3947, 12738, 3949, 12736, 3951, 12734, 3953, 12732, 3955, 12730, 3957, 12728, 3959, 12726, 3961, 12724, 3963, 12722, 3965, 12720, 3967, 12718, 3969, 12716, 3971, 12714, 3973, 12712, 3975, 12710, 3977, 12708, 3979, 12706, 3981, 12704, 3983, 12702, 3985, 12700, 3987, 12698, 3989, 12696, 3991, 12694, 3993, 12692, 3995, 12690, 3997, 12688, 3999, 12686, 4001, 12684, 4003, 12682, 4005, 12680, 4007, 12678, 4009, 12676, 4011, 12674, 4013, 12672, 4015, 12670, 4017, 12668, 4019, 12666, 4021, 12664, 4023, 12662, 4025, 12660, 4027, 12658, 4029, 12656, 4031, 12654, 4033, 12652, 4035, 12650, 4037, 12648, 4039, 12646, 4041, 12644, 4043, 12642, 4045, 12640, 4047, 12638, 4049, 12636, 4051, 12634, 4053, 12632, 4055, 12630, 4057, 12628, 4059, 12626, 4061, 12624, 4063, 12622, 4065, 12620, 4067, 12618, 4069, 12616, 4071, 12614, 4073, 12612, 4075, 12610, 4077, 12608, 4079, 12606, 4081, 12604, 4083, 12602, 4085, 12600, 4087, 12598, 4089, 12596, 4091, 12594, 4093, 12592, 4095, 12590, 4097, 12588, 4099, 12586, 4101, 12584, 4103, 12582, 4105, 12580, 4107, 12578, 4109, 12576, 4111, 12574, 4113, 12572, 4115, 12570, 4117, 12568, 4119, 12566, 4121, 12564, 4123, 12562, 4125, 12560, 4127, 12558, 4129, 12556, 4131, 12554, 4133, 12552, 4135, 12550, 4137, 12548, 4139, 12546, 4141, 12544, 4143, 12542, 4145, 12540, 4147, 12538, 4149, 12536, 4151, 12534, 4153, 12532, 4155, 12530, 4157, 12528, 4159, 12526, 4161, 12524, 4163, 12522, 4165, 12520, 4167, 12518, 4169, 12516, 4171, 12514, 4173, 12512, 4175, 12510, 4177, 12508, 4179, 12506, 4181, 12504, 4183, 12502, 4185, 12500, 4187, 12498, 4189, 12496, 4191, 12494, 4193, 12492, 4195, 12490, 4197, 12488, 4199, 12486, 4201, 12484, 4203, 12482, 4205, 12480, 4207, 12478, 4209, 12476, 4211, 12474, 4213, 12472, 4215, 12470, 4217, 12468, 4219, 12466, 4221, 12464, 4223, 12462, 4225, 12460, 4227, 12458, 4229, 12456, 4231, 12454, 4233, 12452, 4235, 12450, 4237, 12448, 4239, 12446, 4241, 12444, 4243, 12442, 4245, 12440, 4247, 12438, 4249, 12436, 4251, 12434, 4253, 12432, 4255, 12430, 4257, 12428, 4259, 12426, 4261, 12424, 4263, 12422, 4265, 12420, 4267, 12418, 4269, 12416, 4271, 12414, 4273, 12412, 4275, 12410, 4277, 12408, 4279, 12406, 4281, 12404, 4283, 12402, 4285, 12400, 4287, 12398, 4289, 12396, 4291, 12394, 4293, 12392, 4295, 12390, 4297, 12388, 4299, 12386, 4301, 12384, 4303, 12382, 4305, 12380, 4307, 12378, 4309, 12376, 4311, 12374, 4313, 12372, 4315, 12370, 4317, 12368, 4319, 12366, 4321, 12364, 4323, 12362, 4325, 12360, 4327, 12358, 4329, 12356, 4331, 12354, 4333, 12352, 4335, 12350, 4337, 12348, 4339, 12346, 4341, 12344, 4343, 12342, 4345, 12340, 4347, 12338, 4349, 12336, 4351, 12334, 4353, 12332, 4355, 12330, 4357, 12328, 4359, 12326, 4361, 12324, 4363, 12322, 4365, 12320, 4367, 12318, 4369, 12316, 4371, 12314, 4373, 12312, 4375, 12310, 4377, 12308, 4379, 12306, 4381, 12304, 4383, 12302, 4385, 12300, 4387, 12298, 4389, 12296, 4391, 12294, 4393, 12292, 4395, 12290, 4397, 12288, 4399, 12286, 4401, 12284, 4403, 12282, 4405, 12280, 4407, 12278, 4409, 12276, 4411, 12274, 4413, 12272, 4415, 12270, 4417, 12268, 4419, 12266, 4421, 12264, 4423, 12262, 4425, 12260, 4427, 12258, 4429, 12256, 4431, 12254, 4433, 12252, 4435, 12250, 4437, 12248, 4439, 12246, 4441, 12244, 4443, 12242, 4445, 12240, 4447, 12238, 4449, 12236, 4451, 12234, 4453, 12232, 4455, 12230, 4457, 12228, 4459, 12226, 4461, 12224, 4463, 12222, 4465, 12220, 4467, 12218, 4469, 12216, 4471, 12214, 4473, 12212, 4475, 12210, 4477, 12208, 4479, 12206, 4481, 12204, 4483, 12202, 4485, 12200, 4487, 12198, 4489, 12196, 4491, 12194, 4493, 12192, 4495, 12190, 4497, 12188, 4499, 12186, 4501, 12184, 4503, 12182, 4505, 12180, 4507, 12178, 4509, 12176, 4511, 12174, 4513, 12172, 4515, 12170, 4517, 12168, 4519, 12166, 4521, 12164, 4523, 12162, 4525, 12160, 4527, 12158, 4529, 12156, 4531, 12154, 4533, 12152, 4535, 12150, 4537, 12148, 4539, 12146, 4541, 12144, 4543, 12142, 4545, 12140, 4547, 12138, 4549, 12136, 4551, 12134, 4553, 12132, 4555, 12130, 4557, 12128, 4559, 12126, 4561, 12124, 4563, 12122, 4565, 12120, 4567, 12118, 4569, 12116, 4571, 12114, 4573, 12112, 4575, 12110, 4577, 12108, 4579, 12106, 4581, 12104, 4583, 12102, 4585, 12100, 4587, 12098, 4589, 12096, 4591, 12094, 4593, 12092, 4595, 12090, 4597, 12088, 4599, 12086, 4601, 12084, 4603, 12082, 4605, 12080, 4607, 12078, 4609, 12076, 4611, 12074, 4613, 12072, 4615, 12070, 4617, 12068, 4619, 12066, 4621, 12064, 4623, 12062, 4625, 12060, 4627, 12058, 4629, 12056, 4631, 12054, 4633, 12052, 4635, 12050, 4637, 12048, 4639, 12046, 4641, 12044, 4643, 12042, 4645, 12040, 4647, 12038, 4649, 12036, 4651, 12034, 4653, 12032, 4655, 12030, 4657, 12028, 4659, 12026, 4661, 12024, 4663, 12022, 4665, 12020, 4667, 12018, 4669, 12016, 4671, 12014, 4673, 12012, 4675, 12010, 4677, 12008, 4679, 12006, 4681, 12004, 4683, 12002, 4685, 12000, 4687, 11998, 4689, 11996, 4691, 11994, 4693, 11992, 4695, 11990, 4697, 11988, 4699, 11986, 4701, 11984, 4703, 11982, 4705, 11980, 4707, 11978, 4709, 11976, 4711, 11974, 4713, 11972, 4715, 11970, 4717, 11968, 4719, 11966, 4721, 11964, 4723, 11962, 4725, 11960, 4727, 11958, 4729, 11956, 4731, 11954, 4733, 11952, 4735, 11950, 4737, 11948, 4739, 11946, 4741, 11944, 4743, 11942, 4745, 11940, 4747, 11938, 4749, 11936, 4751, 11934, 4753, 11932, 4755, 11930, 4757, 11928, 4759, 11926, 4761, 11924, 4763, 11922, 4765, 11920, 4767, 11918, 4769, 11916, 4771, 11914, 4773, 11912, 4775, 11910, 4777, 11908, 4779, 11906, 4781, 11904, 4783, 11902, 4785, 11900, 4787, 11898, 4789, 11896, 4791, 11894, 4793, 11892, 4795, 11890, 4797, 11888, 4799, 11886, 4801, 11884, 4803, 11882, 4805, 11880, 4807, 11878, 4809, 11876, 4811, 11874, 4813, 11872, 4815, 11870, 4817, 11868, 4819, 11866, 4821, 11864, 4823, 11862, 4825, 11860, 4827, 11858, 4829, 11856, 4831, 11854, 4833, 11852, 4835, 11850, 4837, 11848, 4839, 11846, 4841, 11844, 4843, 11842, 4845, 11840, 4847, 11838, 4849, 11836, 4851, 11834, 4853, 11832, 4855, 11830, 4857, 11828, 4859, 11826, 4861, 11824, 4863, 11822, 4865, 11820, 4867, 11818, 4869, 11816, 4871, 11814, 4873, 11812, 4875, 11810, 4877, 11808, 4879, 11806, 4881, 11804, 4883, 11802, 4885, 11800, 4887, 11798, 4889, 11796, 4891, 11794, 4893, 11792, 4895, 11790, 4897, 11788, 4899, 11786, 4901, 11784, 4903, 11782, 4905, 11780, 4907, 11778, 4909, 11776, 4911, 11774, 4913, 11772, 4915, 11770, 4917, 11768, 4919, 11766, 4921, 11764, 4923, 11762, 4925, 11760, 4927, 11758, 4929, 11756, 4931, 11754, 4933, 11752, 4935, 11750, 4937, 11748, 4939, 11746, 4941, 11744, 4943, 11742, 4945, 11740, 4947, 11738, 4949, 11736, 4951, 11734, 4953, 11732, 4955, 11730, 4957, 11728, 4959, 11726, 4961, 11724, 4963, 11722, 4965, 11720, 4967, 11718, 4969, 11716, 4971, 11714, 4973, 11712, 4975, 11710, 4977, 11708, 4979, 11706, 4981, 11704, 4983, 11702, 4985, 11700, 4987, 11698, 4989, 11696, 4991, 11694, 4993, 11692, 4995, 11690, 4997, 11688, 4999, 11686, 5001, 11684, 5003, 11682, 5005, 11680, 5007, 11678, 5009, 11676, 5011, 11674, 5013, 11672, 5015, 11670, 5017, 11668, 5019, 11666, 5021, 11664, 5023, 11662, 5025, 11660, 5027, 11658, 5029, 11656, 5031, 11654, 5033, 11652, 5035, 11650, 5037, 11648, 5039, 11646, 5041, 11644, 5043, 11642, 5045, 11640, 5047, 11638, 5049, 11636, 5051, 11634, 5053, 11632, 5055, 11630, 5057, 11628, 5059, 11626, 5061, 11624, 5063, 11622, 5065, 11620, 5067, 11618, 5069, 11616, 5071, 11614, 5073, 11612, 5075, 11610, 5077, 11608, 5079, 11606, 5081, 11604, 5083, 11602, 5085, 11600, 5087, 11598, 5089, 11596, 5091, 11594, 5093, 11592, 5095, 11590, 5097, 11588, 5099, 11586, 5101, 11584, 5103, 11582, 5105, 11580, 5107, 11578, 5109, 11576, 5111, 11574, 5113, 11572, 5115, 11570, 5117, 11568, 5119, 11566, 5121, 11564, 5123, 11562, 5125, 11560, 5127, 11558, 5129, 11556, 5131, 11554, 5133, 11552, 5135, 11550, 5137, 11548, 5139, 11546, 5141, 11544, 5143, 11542, 5145, 11540, 5147, 11538, 5149, 11536, 5151, 11534, 5153, 11532, 5155, 11530, 5157, 11528, 5159, 11526, 5161, 11524, 5163, 11522, 5165, 11520, 5167, 11518, 5169, 11516, 5171, 11514, 5173, 11512, 5175, 11510, 5177, 11508, 5179, 11506, 5181, 11504, 5183, 11502, 5185, 11500, 5187, 11498, 5189, 11496, 5191, 11494, 5193, 11492, 5195, 11490, 5197, 11488, 5199, 11486, 5201, 11484, 5203, 11482, 5205, 11480, 5207, 11478, 5209, 11476, 5211, 11474, 5213, 11472, 5215, 11470, 5217, 11468, 5219, 11466, 5221, 11464, 5223, 11462, 5225, 11460, 5227, 11458, 5229, 11456, 5231, 11454, 5233, 11452, 5235, 11450, 5237, 11448, 5239, 11446, 5241, 11444, 5243, 11442, 5245, 11440, 5247, 11438, 5249, 11436, 5251, 11434, 5253, 11432, 5255, 11430, 5257, 11428, 5259, 11426, 5261, 11424, 5263, 11422, 5265, 11420, 5267, 11418, 5269, 11416, 5271, 11414, 5273, 11412, 5275, 11410, 5277, 11408, 5279, 11406, 5281, 11404, 5283, 11402, 5285, 11400, 5287, 11398, 5289, 11396, 5291, 11394, 5293, 11392, 5295, 11390, 5297, 11388, 5299, 11386, 5301, 11384, 5303, 11382, 5305, 11380, 5307, 11378, 5309, 11376, 5311, 11374, 5313, 11372, 5315, 11370, 5317, 11368, 5319, 11366, 5321, 11364, 5323, 11362, 5325, 11360, 5327, 11358, 5329, 11356, 5331, 11354, 5333, 11352, 5335, 11350, 5337, 11348, 5339, 11346, 5341, 11344, 5343, 11342, 5345, 11340, 5347, 11338, 5349, 11336, 5351, 11334, 5353, 11332, 5355, 11330, 5357, 11328, 5359, 11326, 5361, 11324, 5363, 11322, 5365, 11320, 5367, 11318, 5369, 11316, 5371, 11314, 5373, 11312, 5375, 11310, 5377, 11308, 5379, 11306, 5381, 11304, 5383, 11302, 5385, 11300, 5387, 11298, 5389, 11296, 5391, 11294, 5393, 11292, 5395, 11290, 5397, 11288, 5399, 11286, 5401, 11284, 5403, 11282, 5405, 11280, 5407, 11278, 5409, 11276, 5411, 11274, 5413, 11272, 5415, 11270, 5417, 11268, 5419, 11266, 5421, 11264, 5423, 11262, 5425, 11260, 5427, 11258, 5429, 11256, 5431, 11254, 5433, 11252, 5435, 11250, 5437, 11248, 5439, 11246, 5441, 11244, 5443, 11242, 5445, 11240, 5447, 11238, 5449, 11236, 5451, 11234, 5453, 11232, 5455, 11230, 5457, 11228, 5459, 11226, 5461, 11224, 5463, 11222, 5465, 11220, 5467, 11218, 5469, 11216, 5471, 11214, 5473, 11212, 5475, 11210, 5477, 11208, 5479, 11206, 5481, 11204, 5483, 11202, 5485, 11200, 5487, 11198, 5489, 11196, 5491, 11194, 5493, 11192, 5495, 11190, 5497, 11188, 5499, 11186, 5501, 11184, 5503, 11182, 5505, 11180, 5507, 11178, 5509, 11176, 5511, 11174, 5513, 11172, 5515, 11170, 5517, 11168, 5519, 11166, 5521, 11164, 5523, 11162, 5525, 11160, 5527, 11158, 5529, 11156, 5531, 11154, 5533, 11152, 5535, 11150, 5537, 11148, 5539, 11146, 5541, 11144, 5543, 11142, 5545, 11140, 5547, 11138, 5549, 11136, 5551, 11134, 5553, 11132, 5555, 11130, 5557, 11128, 5559, 11126, 5561, 11124, 5563, 11122, 5565, 11120, 5567, 11118, 5569, 11116, 5571, 11114, 5573, 11112, 5575, 11110, 5577, 11108, 5579, 11106, 5581, 11104, 5583, 11102, 5585, 11100, 5587, 11098, 5589, 11096, 5591, 11094, 5593, 11092, 5595, 11090, 5597, 11088, 5599, 11086, 5601, 11084, 5603, 11082, 5605, 11080, 5607, 11078, 5609, 11076, 5611, 11074, 5613, 11072, 5615, 11070, 5617, 11068, 5619, 11066, 5621, 11064, 5623, 11062, 5625, 11060, 5627, 11058, 5629, 11056, 5631, 11054, 5633, 11052, 5635, 11050, 5637, 11048, 5639, 11046, 5641, 11044, 5643, 11042, 5645, 11040, 5647, 11038, 5649, 11036, 5651, 11034, 5653, 11032, 5655, 11030, 5657, 11028, 5659, 11026, 5661, 11024, 5663, 11022, 5665, 11020, 5667, 11018, 5669, 11016, 5671, 11014, 5673, 11012, 5675, 11010, 5677, 11008, 5679, 11006, 5681, 11004, 5683, 11002, 5685, 11000, 5687, 10998, 5689, 10996, 5691, 10994, 5693, 10992, 5695, 10990, 5697, 10988, 5699, 10986, 5701, 10984, 5703, 10982, 5705, 10980, 5707, 10978, 5709, 10976, 5711, 10974, 5713, 10972, 5715, 10970, 5717, 10968, 5719, 10966, 5721, 10964, 5723, 10962, 5725, 10960, 5727, 10958, 5729, 10956, 5731, 10954, 5733, 10952, 5735, 10950, 5737, 10948, 5739, 10946, 5741, 10944, 5743, 10942, 5745, 10940, 5747, 10938, 5749, 10936, 5751, 10934, 5753, 10932, 5755, 10930, 5757, 10928, 5759, 10926, 5761, 10924, 5763, 10922, 5765, 10920, 5767, 10918, 5769, 10916, 5771, 10914, 5773, 10912, 5775, 10910, 5777, 10908, 5779, 10906, 5781, 10904, 5783, 10902, 5785, 10900, 5787, 10898, 5789, 10896, 5791, 10894, 5793, 10892, 5795, 10890, 5797, 10888, 5799, 10886, 5801, 10884, 5803, 10882, 5805, 10880, 5807, 10878, 5809, 10876, 5811, 10874, 5813, 10872, 5815, 10870, 5817, 10868, 5819, 10866, 5821, 10864, 5823, 10862, 5825, 10860, 5827, 10858, 5829, 10856, 5831, 10854, 5833, 10852, 5835, 10850, 5837, 10848, 5839, 10846, 5841, 10844, 5843, 10842, 5845, 10840, 5847, 10838, 5849, 10836, 5851, 10834, 5853, 10832, 5855, 10830, 5857, 10828, 5859, 10826, 5861, 10824, 5863, 10822, 5865, 10820, 5867, 10818, 5869, 10816, 5871, 10814, 5873, 10812, 5875, 10810, 5877, 10808, 5879, 10806, 5881, 10804, 5883, 10802, 5885, 10800, 5887, 10798, 5889, 10796, 5891, 10794, 5893, 10792, 5895, 10790, 5897, 10788, 5899, 10786, 5901, 10784, 5903, 10782, 5905, 10780, 5907, 10778, 5909, 10776, 5911, 10774, 5913, 10772, 5915, 10770, 5917, 10768, 5919, 10766, 5921, 10764, 5923, 10762, 5925, 10760, 5927, 10758, 5929, 10756, 5931, 10754, 5933, 10752, 5935, 10750, 5937, 10748, 5939, 10746, 5941, 10744, 5943, 10742, 5945, 10740, 5947, 10738, 5949, 10736, 5951, 10734, 5953, 10732, 5955, 10730, 5957, 10728, 5959, 10726, 5961, 10724, 5963, 10722, 5965, 10720, 5967, 10718, 5969, 10716, 5971, 10714, 5973, 10712, 5975, 10710, 5977, 10708, 5979, 10706, 5981, 10704, 5983, 10702, 5985, 10700, 5987, 10698, 5989, 10696, 5991, 10694, 5993, 10692, 5995, 10690, 5997, 10688, 5999, 10686, 6001, 10684, 6003, 10682, 6005, 10680, 6007, 10678, 6009, 10676, 6011, 10674, 6013, 10672, 6015, 10670, 6017, 10668, 6019, 10666, 6021, 10664, 6023, 10662, 6025, 10660, 6027, 10658, 6029, 10656, 6031, 10654, 6033, 10652, 6035, 10650, 6037, 10648, 6039, 10646, 6041, 10644, 6043, 10642, 6045, 10640, 6047, 10638, 6049, 10636, 6051, 10634, 6053, 10632, 6055, 10630, 6057, 10628, 6059, 10626, 6061, 10624, 6063, 10622, 6065, 10620, 6067, 10618, 6069, 10616, 6071, 10614, 6073, 10612, 6075, 10610, 6077, 10608, 6079, 10606, 6081, 10604, 6083, 10602, 6085, 10600, 6087, 10598, 6089, 10596, 6091, 10594, 6093, 10592, 6095, 10590, 6097, 10588, 6099, 10586, 6101, 10584, 6103, 10582, 6105, 10580, 6107, 10578, 6109, 10576, 6111, 10574, 6113, 10572, 6115, 10570, 6117, 10568, 6119, 10566, 6121, 10564, 6123, 10562, 6125, 10560, 6127, 10558, 6129, 10556, 6131, 10554, 6133, 10552, 6135, 10550, 6137, 10548, 6139, 10546, 6141, 10544, 6143, 10542, 6145, 10540, 6147, 10538, 6149, 10536, 6151, 10534, 6153, 10532, 6155, 10530, 6157, 10528, 6159, 10526, 6161, 10524, 6163, 10522, 6165, 10520, 6167, 10518, 6169, 10516, 6171, 10514, 6173, 10512, 6175, 10510, 6177, 10508, 6179, 10506, 6181, 10504, 6183, 10502, 6185, 10500, 6187, 10498, 6189, 10496, 6191, 10494, 6193, 10492, 6195, 10490, 6197, 10488, 6199, 10486, 6201, 10484, 6203, 10482, 6205, 10480, 6207, 10478, 6209, 10476, 6211, 10474, 6213, 10472, 6215, 10470, 6217, 10468, 6219, 10466, 6221, 10464, 6223, 10462, 6225, 10460, 6227, 10458, 6229, 10456, 6231, 10454, 6233, 10452, 6235, 10450, 6237, 10448, 6239, 10446, 6241, 10444, 6243, 10442, 6245, 10440, 6247, 10438, 6249, 10436, 6251, 10434, 6253, 10432, 6255, 10430, 6257, 10428, 6259, 10426, 6261, 10424, 6263, 10422, 6265, 10420, 6267, 10418, 6269, 10416, 6271, 10414, 6273, 10412, 6275, 10410, 6277, 10408, 6279, 10406, 6281, 10404, 6283, 10402, 6285, 10400, 6287, 10398, 6289, 10396, 6291, 10394, 6293, 10392, 6295, 10390, 6297, 10388, 6299, 10386, 6301, 10384, 6303, 10382, 6305, 10380, 6307, 10378, 6309, 10376, 6311, 10374, 6313, 10372, 6315, 10370, 6317, 10368, 6319, 10366, 6321, 10364, 6323, 10362, 6325, 10360, 6327, 10358, 6329, 10356, 6331, 10354, 6333, 10352, 6335, 10350, 6337, 10348, 6339, 10346, 6341, 10344, 6343, 10342, 6345, 10340, 6347, 10338, 6349, 10336, 6351, 10334, 6353, 10332, 6355, 10330, 6357, 10328, 6359, 10326, 6361, 10324, 6363, 10322, 6365, 10320, 6367, 10318, 6369, 10316, 6371, 10314, 6373, 10312, 6375, 10310, 6377, 10308, 6379, 10306, 6381, 10304, 6383, 10302, 6385, 10300, 6387, 10298, 6389, 10296, 6391, 10294, 6393, 10292, 6395, 10290, 6397, 10288, 6399, 10286, 6401, 10284, 6403, 10282, 6405, 10280, 6407, 10278, 6409, 10276, 6411, 10274, 6413, 10272, 6415, 10270, 6417, 10268, 6419, 10266, 6421, 10264, 6423, 10262, 6425, 10260, 6427, 10258, 6429, 10256, 6431, 10254, 6433, 10252, 6435, 10250, 6437, 10248, 6439, 10246, 6441, 10244, 6443, 10242, 6445, 10240, 6447, 10238, 6449, 10236, 6451, 10234, 6453, 10232, 6455, 10230, 6457, 10228, 6459, 10226, 6461, 10224, 6463, 10222, 6465, 10220, 6467, 10218, 6469, 10216, 6471, 10214, 6473, 10212, 6475, 10210, 6477, 10208, 6479, 10206, 6481, 10204, 6483, 10202, 6485, 10200, 6487, 10198, 6489, 10196, 6491, 10194, 6493, 10192, 6495, 10190, 6497, 10188, 6499, 10186, 6501, 10184, 6503, 10182, 6505, 10180, 6507, 10178, 6509, 10176, 6511, 10174, 6513, 10172, 6515, 10170, 6517, 10168, 6519, 10166, 6521, 10164, 6523, 10162, 6525, 10160, 6527, 10158, 6529, 10156, 6531, 10154, 6533, 10152, 6535, 10150, 6537, 10148, 6539, 10146, 6541, 10144, 6543, 10142, 6545, 10140, 6547, 10138, 6549, 10136, 6551, 10134, 6553, 10132, 6555, 10130, 6557, 10128, 6559, 10126, 6561, 10124, 6563, 10122, 6565, 10120, 6567, 10118, 6569, 10116, 6571, 10114, 6573, 10112, 6575, 10110, 6577, 10108, 6579, 10106, 6581, 10104, 6583, 10102, 6585, 10100, 6587, 10098, 6589, 10096, 6591, 10094, 6593, 10092, 6595, 10090, 6597, 10088, 6599, 10086, 6601, 10084, 6603, 10082, 6605, 10080, 6607, 10078, 6609, 10076, 6611, 10074, 6613, 10072, 6615, 10070, 6617, 10068, 6619, 10066, 6621, 10064, 6623, 10062, 6625, 10060, 6627, 10058, 6629, 10056, 6631, 10054, 6633, 10052, 6635, 10050, 6637, 10048, 6639, 10046, 6641, 10044, 6643, 10042, 6645, 10040, 6647, 10038, 6649, 10036, 6651, 10034, 6653, 10032, 6655, 10030, 6657, 10028, 6659, 10026, 6661, 10024, 6663, 10022, 6665, 10020, 6667, 10018, 6669, 10016, 6671, 10014, 6673, 10012, 6675, 10010, 6677, 10008, 6679, 10006, 6681, 10004, 6683, 10002, 6685, 10000, 6687, 9998, 6689, 9996, 6691, 9994, 6693, 9992, 6695, 9990, 6697, 9988, 6699, 9986, 6701, 9984, 6703, 9982, 6705, 9980, 6707, 9978, 6709, 9976, 6711, 9974, 6713, 9972, 6715, 9970, 6717, 9968, 6719, 9966, 6721, 9964, 6723, 9962, 6725, 9960, 6727, 9958, 6729, 9956, 6731, 9954, 6733, 9952, 6735, 9950, 6737, 9948, 6739, 9946, 6741, 9944, 6743, 9942, 6745, 9940, 6747, 9938, 6749, 9936, 6751, 9934, 6753, 9932, 6755, 9930, 6757, 9928, 6759, 9926, 6761, 9924, 6763, 9922, 6765, 9920, 6767, 9918, 6769, 9916, 6771, 9914, 6773, 9912, 6775, 9910, 6777, 9908, 6779, 9906, 6781, 9904, 6783, 9902, 6785, 9900, 6787, 9898, 6789, 9896, 6791, 9894, 6793, 9892, 6795, 9890, 6797, 9888, 6799, 9886, 6801, 9884, 6803, 9882, 6805, 9880, 6807, 9878, 6809, 9876, 6811, 9874, 6813, 9872, 6815, 9870, 6817, 9868, 6819, 9866, 6821, 9864, 6823, 9862, 6825, 9860, 6827, 9858, 6829, 9856, 6831, 9854, 6833, 9852, 6835, 9850, 6837, 9848, 6839, 9846, 6841, 9844, 6843, 9842, 6845, 9840, 6847, 9838, 6849, 9836, 6851, 9834, 6853, 9832, 6855, 9830, 6857, 9828, 6859, 9826, 6861, 9824, 6863, 9822, 6865, 9820, 6867, 9818, 6869, 9816, 6871, 9814, 6873, 9812, 6875, 9810, 6877, 9808, 6879, 9806, 6881, 9804, 6883, 9802, 6885, 9800, 6887, 9798, 6889, 9796, 6891, 9794, 6893, 9792, 6895, 9790, 6897, 9788, 6899, 9786, 6901, 9784, 6903, 9782, 6905, 9780, 6907, 9778, 6909, 9776, 6911, 9774, 6913, 9772, 6915, 9770, 6917, 9768, 6919, 9766, 6921, 9764, 6923, 9762, 6925, 9760, 6927, 9758, 6929, 9756, 6931, 9754, 6933, 9752, 6935, 9750, 6937, 9748, 6939, 9746, 6941, 9744, 6943, 9742, 6945, 9740, 6947, 9738, 6949, 9736, 6951, 9734, 6953, 9732, 6955, 9730, 6957, 9728, 6959, 9726, 6961, 9724, 6963, 9722, 6965, 9720, 6967, 9718, 6969, 9716, 6971, 9714, 6973, 9712, 6975, 9710, 6977, 9708, 6979, 9706, 6981, 9704, 6983, 9702, 6985, 9700, 6987, 9698, 6989, 9696, 6991, 9694, 6993, 9692, 6995, 9690, 6997, 9688, 6999, 9686, 7001, 9684, 7003, 9682, 7005, 9680, 7007, 9678, 7009, 9676, 7011, 9674, 7013, 9672, 7015, 9670, 7017, 9668, 7019, 9666, 7021, 9664, 7023, 9662, 7025, 9660, 7027, 9658, 7029, 9656, 7031, 9654, 7033, 9652, 7035, 9650, 7037, 9648, 7039, 9646, 7041, 9644, 7043, 9642, 7045, 9640, 7047, 9638, 7049, 9636, 7051, 9634, 7053, 9632, 7055, 9630, 7057, 9628, 7059, 9626, 7061, 9624, 7063, 9622, 7065, 9620, 7067, 9618, 7069, 9616, 7071, 9614, 7073, 9612, 7075, 9610, 7077, 9608, 7079, 9606, 7081, 9604, 7083, 9602, 7085, 9600, 7087, 9598, 7089, 9596, 7091, 9594, 7093, 9592, 7095, 9590, 7097, 9588, 7099, 9586, 7101, 9584, 7103, 9582, 7105, 9580, 7107, 9578, 7109, 9576, 7111, 9574, 7113, 9572, 7115, 9570, 7117, 9568, 7119, 9566, 7121, 9564, 7123, 9562, 7125, 9560, 7127, 9558, 7129, 9556, 7131, 9554, 7133, 9552, 7135, 9550, 7137, 9548, 7139, 9546, 7141, 9544, 7143, 9542, 7145, 9540, 7147, 9538, 7149, 9536, 7151, 9534, 7153, 9532, 7155, 9530, 7157, 9528, 7159, 9526, 7161, 9524, 7163, 9522, 7165, 9520, 7167, 9518, 7169, 9516, 7171, 9514, 7173, 9512, 7175, 9510, 7177, 9508, 7179, 9506, 7181, 9504, 7183, 9502, 7185, 9500, 7187, 9498, 7189, 9496, 7191, 9494, 7193, 9492, 7195, 9490, 7197, 9488, 7199, 9486, 7201, 9484, 7203, 9482, 7205, 9480, 7207, 9478, 7209, 9476, 7211, 9474, 7213, 9472, 7215, 9470, 7217, 9468, 7219, 9466, 7221, 9464, 7223, 9462, 7225, 9460, 7227, 9458, 7229, 9456, 7231, 9454, 7233, 9452, 7235, 9450, 7237, 9448, 7239, 9446, 7241, 9444, 7243, 9442, 7245, 9440, 7247, 9438, 7249, 9436, 7251, 9434, 7253, 9432, 7255, 9430, 7257, 9428, 7259, 9426, 7261, 9424, 7263, 9422, 7265, 9420, 7267, 9418, 7269, 9416, 7271, 9414, 7273, 9412, 7275, 9410, 7277, 9408, 7279, 9406, 7281, 9404, 7283, 9402, 7285, 9400, 7287, 9398, 7289, 9396, 7291, 9394, 7293, 9392, 7295, 9390, 7297, 9388, 7299, 9386, 7301, 9384, 7303, 9382, 7305, 9380, 7307, 9378, 7309, 9376, 7311, 9374, 7313, 9372, 7315, 9370, 7317, 9368, 7319, 9366, 7321, 9364, 7323, 9362, 7325, 9360, 7327, 9358, 7329, 9356, 7331, 9354, 7333, 9352, 7335, 9350, 7337, 9348, 7339, 9346, 7341, 9344, 7343, 9342, 7345, 9340, 7347, 9338, 7349, 9336, 7351, 9334, 7353, 9332, 7355, 9330, 7357, 9328, 7359, 9326, 7361, 9324, 7363, 9322, 7365, 9320, 7367, 9318, 7369, 9316, 7371, 9314, 7373, 9312, 7375, 9310, 7377, 9308, 7379, 9306, 7381, 9304, 7383, 9302, 7385, 9300, 7387, 9298, 7389, 9296, 7391, 9294, 7393, 9292, 7395, 9290, 7397, 9288, 7399, 9286, 7401, 9284, 7403, 9282, 7405, 9280, 7407, 9278, 7409, 9276, 7411, 9274, 7413, 9272, 7415, 9270, 7417, 9268, 7419, 9266, 7421, 9264, 7423, 9262, 7425, 9260, 7427, 9258, 7429, 9256, 7431, 9254, 7433, 9252, 7435, 9250, 7437, 9248, 7439, 9246, 7441, 9244, 7443, 9242, 7445, 9240, 7447, 9238, 7449, 9236, 7451, 9234, 7453, 9232, 7455, 9230, 7457, 9228, 7459, 9226, 7461, 9224, 7463, 9222, 7465, 9220, 7467, 9218, 7469, 9216, 7471, 9214, 7473, 9212, 7475, 9210, 7477, 9208, 7479, 9206, 7481, 9204, 7483, 9202, 7485, 9200, 7487, 9198, 7489, 9196, 7491, 9194, 7493, 9192, 7495, 9190, 7497, 9188, 7499, 9186, 7501, 9184, 7503, 9182, 7505, 9180, 7507, 9178, 7509, 9176, 7511, 9174, 7513, 9172, 7515, 9170, 7517, 9168, 7519, 9166, 7521, 9164, 7523, 9162, 7525, 9160, 7527, 9158, 7529, 9156, 7531, 9154, 7533, 9152, 7535, 9150, 7537, 9148, 7539, 9146, 7541, 9144, 7543, 9142, 7545, 9140, 7547, 9138, 7549, 9136, 7551, 9134, 7553, 9132, 7555, 9130, 7557, 9128, 7559, 9126, 7561, 9124, 7563, 9122, 7565, 9120, 7567, 9118, 7569, 9116, 7571, 9114, 7573, 9112, 7575, 9110, 7577, 9108, 7579, 9106, 7581, 9104, 7583, 9102, 7585, 9100, 7587, 9098, 7589, 9096, 7591, 9094, 7593, 9092, 7595, 9090, 7597, 9088, 7599, 9086, 7601, 9084, 7603, 9082, 7605, 9080, 7607, 9078, 7609, 9076, 7611, 9074, 7613, 9072, 7615, 9070, 7617, 9068, 7619, 9066, 7621, 9064, 7623, 9062, 7625, 9060, 7627, 9058, 7629, 9056, 7631, 9054, 7633, 9052, 7635, 9050, 7637, 9048, 7639, 9046, 7641, 9044, 7643, 9042, 7645, 9040, 7647, 9038, 7649, 9036, 7651, 9034, 7653, 9032, 7655, 9030, 7657, 9028, 7659, 9026, 7661, 9024, 7663, 9022, 7665, 9020, 7667, 9018, 7669, 9016, 7671, 9014, 7673, 9012, 7675, 9010, 7677, 9008, 7679, 9006, 7681, 9004, 7683, 9002, 7685, 9000, 7687, 8998, 7689, 8996, 7691, 8994, 7693, 8992, 7695, 8990, 7697, 8988, 7699, 8986, 7701, 8984, 7703, 8982, 7705, 8980, 7707, 8978, 7709, 8976, 7711, 8974, 7713, 8972, 7715, 8970, 7717, 8968, 7719, 8966, 7721, 8964, 7723, 8962, 7725, 8960, 7727, 8958, 7729, 8956, 7731, 8954, 7733, 8952, 7735, 8950, 7737, 8948, 7739, 8946, 7741, 8944, 7743, 8942, 7745, 8940, 7747, 8938, 7749, 8936, 7751, 8934, 7753, 8932, 7755, 8930, 7757, 8928, 7759, 8926, 7761, 8924, 7763, 8922, 7765, 8920, 7767, 8918, 7769, 8916, 7771, 8914, 7773, 8912, 7775, 8910, 7777, 8908, 7779, 8906, 7781, 8904, 7783, 8902, 7785, 8900, 7787, 8898, 7789, 8896, 7791, 8894, 7793, 8892, 7795, 8890, 7797, 8888, 7799, 8886, 7801, 8884, 7803, 8882, 7805, 8880, 7807, 8878, 7809, 8876, 7811, 8874, 7813, 8872, 7815, 8870, 7817, 8868, 7819, 8866, 7821, 8864, 7823, 8862, 7825, 8860, 7827, 8858, 7829, 8856, 7831, 8854, 7833, 8852, 7835, 8850, 7837, 8848, 7839, 8846, 7841, 8844, 7843, 8842, 7845, 8840, 7847, 8838, 7849, 8836, 7851, 8834, 7853, 8832, 7855, 8830, 7857, 8828, 7859, 8826, 7861, 8824, 7863, 8822, 7865, 8820, 7867, 8818, 7869, 8816, 7871, 8814, 7873, 8812, 7875, 8810, 7877, 8808, 7879, 8806, 7881, 8804, 7883, 8802, 7885, 8800, 7887, 8798, 7889, 8796, 7891, 8794, 7893, 8792, 7895, 8790, 7897, 8788, 7899, 8786, 7901, 8784, 7903, 8782, 7905, 8780, 7907, 8778, 7909, 8776, 7911, 8774, 7913, 8772, 7915, 8770, 7917, 8768, 7919, 8766, 7921, 8764, 7923, 8762, 7925, 8760, 7927, 8758, 7929, 8756, 7931, 8754, 7933, 8752, 7935, 8750, 7937, 8748, 7939, 8746, 7941, 8744, 7943, 8742, 7945, 8740, 7947, 8738, 7949, 8736, 7951, 8734, 7953, 8732, 7955, 8730, 7957, 8728, 7959, 8726, 7961, 8724, 7963, 8722, 7965, 8720, 7967, 8718, 7969, 8716, 7971, 8714, 7973, 8712, 7975, 8710, 7977, 8708, 7979, 8706, 7981, 8704, 7983, 8702, 7985, 8700, 7987, 8698, 7989, 8696, 7991, 8694, 7993, 8692, 7995, 8690, 7997, 8688, 7999, 8686, 8001, 8684, 8003, 8682, 8005, 8680, 8007, 8678, 8009, 8676, 8011, 8674, 8013, 8672, 8015, 8670, 8017, 8668, 8019, 8666, 8021, 8664, 8023, 8662, 8025, 8660, 8027, 8658, 8029, 8656, 8031, 8654, 8033, 8652, 8035, 8650, 8037, 8648, 8039, 8646, 8041, 8644, 8043, 8642, 8045, 8640, 8047, 8638, 8049, 8636, 8051, 8634, 8053, 8632, 8055, 8630, 8057, 8628, 8059, 8626, 8061, 8624, 8063, 8622, 8065, 8620, 8067, 8618, 8069, 8616, 8071, 8614, 8073, 8612, 8075, 8610, 8077, 8608, 8079, 8606, 8081, 8604, 8083, 8602, 8085, 8600, 8087, 8598, 8089, 8596, 8091, 8594, 8093, 8592, 8095, 8590, 8097, 8588, 8099, 8586, 8101, 8584, 8103, 8582, 8105, 8580, 8107, 8578, 8109, 8576, 8111, 8574, 8113, 8572, 8115, 8570, 8117, 8568, 8119, 8566, 8121, 8564, 8123, 8562, 8125, 8560, 8127, 8558, 8129, 8556, 8131, 8554, 8133, 8552, 8135, 8550, 8137, 8548, 8139, 8546, 8141, 8544, 8143, 8542, 8145, 8540, 8147, 8538, 8149, 8536, 8151, 8534, 8153, 8532, 8155, 8530, 8157, 8528, 8159, 8526, 8161, 8524, 8163, 8522, 8165, 8520, 8167, 8518, 8169, 8516, 8171, 8514, 8173, 8512, 8175, 8510, 8177, 8508, 8179, 8506, 8181, 8504, 8183, 8502, 8185, 8500, 8187, 8498, 8189, 8496, 8191, 8494, 8193, 8492, 8195, 8490, 8197, 8488, 8199, 8486, 8201, 8484, 8203, 8482, 8205, 8480, 8207, 8478, 8209, 8476, 8211, 8474, 8213, 8472, 8215, 8470, 8217, 8468, 8219, 8466, 8221, 8464, 8223, 8462, 8225, 8460, 8227, 8458, 8229, 8456, 8231, 8454, 8233, 8452, 8235, 8450, 8237, 8448, 8239, 8446, 8241, 8444, 8243, 8442, 8245, 8440, 8247, 8438, 8249, 8436, 8251, 8434, 8253, 8432, 8255, 8430, 8257, 8428, 8259, 8426, 8261, 8424, 8263, 8422, 8265, 8420, 8267, 8418, 8269, 8416, 8271, 8414, 8273, 8412, 8275, 8410, 8277, 8408, 8279, 8406, 8281, 8404, 8283, 8402, 8285, 8400, 8287, 8398, 8289, 8396, 8291, 8394, 8293, 8392, 8295, 8390, 8297, 8388, 8299, 8386, 8301, 8384, 8303, 8382, 8305, 8380, 8307, 8378, 8309, 8376, 8311, 8374, 8313, 8372, 8315, 8370, 8317, 8368, 8319, 8366, 8321, 8364, 8323, 8362, 8325, 8360, 8327, 8358, 8329, 8356, 8331, 8354, 8333, 8352, 8335, 8350, 8337, 8348, 8339, 8346, 8341, 8344, 8343, 8342, 8345, 8340, 8347, 8338, 8349, 8336, 8351, 8334, 8353, 8332, 8355, 8330, 8357, 8328, 8359, 8326, 8361, 8324, 8363, 8322, 8365, 8320, 8367, 8318, 8369, 8316, 8371, 8314, 8373, 8312, 8375, 8310, 8377, 8308, 8379, 8306, 8381, 8304, 8383, 8302, 8385, 8300, 8387, 8298, 8389, 8296, 8391, 8294, 8393, 8292, 8395, 8290, 8397, 8288, 8399, 8286, 8401, 8284, 8403, 8282, 8405, 8280, 8407, 8278, 8409, 8276, 8411, 8274, 8413, 8272, 8415, 8270, 8417, 8268, 8419, 8266, 8421, 8264, 8423, 8262, 8425, 8260, 8427, 8258, 8429, 8256, 8431, 8254, 8433, 8252, 8435, 8250, 8437, 8248, 8439, 8246, 8441, 8244, 8443, 8242, 8445, 8240, 8447, 8238, 8449, 8236, 8451, 8234, 8453, 8232, 8455, 8230, 8457, 8228, 8459, 8226, 8461, 8224, 8463, 8222, 8465, 8220, 8467, 8218, 8469, 8216, 8471, 8214, 8473, 8212, 8475, 8210, 8477, 8208, 8479, 8206, 8481, 8204, 8483, 8202, 8485, 8200, 8487, 8198, 8489, 8196, 8491, 8194, 8493, 8192, 8495, 8190, 8497, 8188, 8499, 8186, 8501, 8184, 8503, 8182, 8505, 8180, 8507, 8178, 8509, 8176, 8511, 8174, 8513, 8172, 8515, 8170, 8517, 8168, 8519, 8166, 8521, 8164, 8523, 8162, 8525, 8160, 8527, 8158, 8529, 8156, 8531, 8154, 8533, 8152, 8535, 8150, 8537, 8148, 8539, 8146, 8541, 8144, 8543, 8142, 8545, 8140, 8547, 8138, 8549, 8136, 8551, 8134, 8553, 8132, 8555, 8130, 8557, 8128, 8559, 8126, 8561, 8124, 8563, 8122, 8565, 8120, 8567, 8118, 8569, 8116, 8571, 8114, 8573, 8112, 8575, 8110, 8577, 8108, 8579, 8106, 8581, 8104, 8583, 8102, 8585, 8100, 8587, 8098, 8589, 8096, 8591, 8094, 8593, 8092, 8595, 8090, 8597, 8088, 8599, 8086, 8601, 8084, 8603, 8082, 8605, 8080, 8607, 8078, 8609, 8076, 8611, 8074, 8613, 8072, 8615, 8070, 8617, 8068, 8619, 8066, 8621, 8064, 8623, 8062, 8625, 8060, 8627, 8058, 8629, 8056, 8631, 8054, 8633, 8052, 8635, 8050, 8637, 8048, 8639, 8046, 8641, 8044, 8643, 8042, 8645, 8040, 8647, 8038, 8649, 8036, 8651, 8034, 8653, 8032, 8655, 8030, 8657, 8028, 8659, 8026, 8661, 8024, 8663, 8022, 8665, 8020, 8667, 8018, 8669, 8016, 8671, 8014, 8673, 8012, 8675, 8010, 8677, 8008, 8679, 8006, 8681, 8004, 8683, 8002, 8685, 8000, 8687, 7998, 8689, 7996, 8691, 7994, 8693, 7992, 8695, 7990, 8697, 7988, 8699, 7986, 8701, 7984, 8703, 7982, 8705, 7980, 8707, 7978, 8709, 7976, 8711, 7974, 8713, 7972, 8715, 7970, 8717, 7968, 8719, 7966, 8721, 7964, 8723, 7962, 8725, 7960, 8727, 7958, 8729, 7956, 8731, 7954, 8733, 7952, 8735, 7950, 8737, 7948, 8739, 7946, 8741, 7944, 8743, 7942, 8745, 7940, 8747, 7938, 8749, 7936, 8751, 7934, 8753, 7932, 8755, 7930, 8757, 7928, 8759, 7926, 8761, 7924, 8763, 7922, 8765, 7920, 8767, 7918, 8769, 7916, 8771, 7914, 8773, 7912, 8775, 7910, 8777, 7908, 8779, 7906, 8781, 7904, 8783, 7902, 8785, 7900, 8787, 7898, 8789, 7896, 8791, 7894, 8793, 7892, 8795, 7890, 8797, 7888, 8799, 7886, 8801, 7884, 8803, 7882, 8805, 7880, 8807, 7878, 8809, 7876, 8811, 7874, 8813, 7872, 8815, 7870, 8817, 7868, 8819, 7866, 8821, 7864, 8823, 7862, 8825, 7860, 8827, 7858, 8829, 7856, 8831, 7854, 8833, 7852, 8835, 7850, 8837, 7848, 8839, 7846, 8841, 7844, 8843, 7842, 8845, 7840, 8847, 7838, 8849, 7836, 8851, 7834, 8853, 7832, 8855, 7830, 8857, 7828, 8859, 7826, 8861, 7824, 8863, 7822, 8865, 7820, 8867, 7818, 8869, 7816, 8871, 7814, 8873, 7812, 8875, 7810, 8877, 7808, 8879, 7806, 8881, 7804, 8883, 7802, 8885, 7800, 8887, 7798, 8889, 7796, 8891, 7794, 8893, 7792, 8895, 7790, 8897, 7788, 8899, 7786, 8901, 7784, 8903, 7782, 8905, 7780, 8907, 7778, 8909, 7776, 8911, 7774, 8913, 7772, 8915, 7770, 8917, 7768, 8919, 7766, 8921, 7764, 8923, 7762, 8925, 7760, 8927, 7758, 8929, 7756, 8931, 7754, 8933, 7752, 8935, 7750, 8937, 7748, 8939, 7746, 8941, 7744, 8943, 7742, 8945, 7740, 8947, 7738, 8949, 7736, 8951, 7734, 8953, 7732, 8955, 7730, 8957, 7728, 8959, 7726, 8961, 7724, 8963, 7722, 8965, 7720, 8967, 7718, 8969, 7716, 8971, 7714, 8973, 7712, 8975, 7710, 8977, 7708, 8979, 7706, 8981, 7704, 8983, 7702, 8985, 7700, 8987, 7698, 8989, 7696, 8991, 7694, 8993, 7692, 8995, 7690, 8997, 7688, 8999, 7686, 9001, 7684, 9003, 7682, 9005, 7680, 9007, 7678, 9009, 7676, 9011, 7674, 9013, 7672, 9015, 7670, 9017, 7668, 9019, 7666, 9021, 7664, 9023, 7662, 9025, 7660, 9027, 7658, 9029, 7656, 9031, 7654, 9033, 7652, 9035, 7650, 9037, 7648, 9039, 7646, 9041, 7644, 9043, 7642, 9045, 7640, 9047, 7638, 9049, 7636, 9051, 7634, 9053, 7632, 9055, 7630, 9057, 7628, 9059, 7626, 9061, 7624, 9063, 7622, 9065, 7620, 9067, 7618, 9069, 7616, 9071, 7614, 9073, 7612, 9075, 7610, 9077, 7608, 9079, 7606, 9081, 7604, 9083, 7602, 9085, 7600, 9087, 7598, 9089, 7596, 9091, 7594, 9093, 7592, 9095, 7590, 9097, 7588, 9099, 7586, 9101, 7584, 9103, 7582, 9105, 7580, 9107, 7578, 9109, 7576, 9111, 7574, 9113, 7572, 9115, 7570, 9117, 7568, 9119, 7566, 9121, 7564, 9123, 7562, 9125, 7560, 9127, 7558, 9129, 7556, 9131, 7554, 9133, 7552, 9135, 7550, 9137, 7548, 9139, 7546, 9141, 7544, 9143, 7542, 9145, 7540, 9147, 7538, 9149, 7536, 9151, 7534, 9153, 7532, 9155, 7530, 9157, 7528, 9159, 7526, 9161, 7524, 9163, 7522, 9165, 7520, 9167, 7518, 9169, 7516, 9171, 7514, 9173, 7512, 9175, 7510, 9177, 7508, 9179, 7506, 9181, 7504, 9183, 7502, 9185, 7500, 9187, 7498, 9189, 7496, 9191, 7494, 9193, 7492, 9195, 7490, 9197, 7488, 9199, 7486, 9201, 7484, 9203, 7482, 9205, 7480, 9207, 7478, 9209, 7476, 9211, 7474, 9213, 7472, 9215, 7470, 9217, 7468, 9219, 7466, 9221, 7464, 9223, 7462, 9225, 7460, 9227, 7458, 9229, 7456, 9231, 7454, 9233, 7452, 9235, 7450, 9237, 7448, 9239, 7446, 9241, 7444, 9243, 7442, 9245, 7440, 9247, 7438, 9249, 7436, 9251, 7434, 9253, 7432, 9255, 7430, 9257, 7428, 9259, 7426, 9261, 7424, 9263, 7422, 9265, 7420, 9267, 7418, 9269, 7416, 9271, 7414, 9273, 7412, 9275, 7410, 9277, 7408, 9279, 7406, 9281, 7404, 9283, 7402, 9285, 7400, 9287, 7398, 9289, 7396, 9291, 7394, 9293, 7392, 9295, 7390, 9297, 7388, 9299, 7386, 9301, 7384, 9303, 7382, 9305, 7380, 9307, 7378, 9309, 7376, 9311, 7374, 9313, 7372, 9315, 7370, 9317, 7368, 9319, 7366, 9321, 7364, 9323, 7362, 9325, 7360, 9327, 7358, 9329, 7356, 9331, 7354, 9333, 7352, 9335, 7350, 9337, 7348, 9339, 7346, 9341, 7344, 9343, 7342, 9345, 7340, 9347, 7338, 9349, 7336, 9351, 7334, 9353, 7332, 9355, 7330, 9357, 7328, 9359, 7326, 9361, 7324, 9363, 7322, 9365, 7320, 9367, 7318, 9369, 7316, 9371, 7314, 9373, 7312, 9375, 7310, 9377, 7308, 9379, 7306, 9381, 7304, 9383, 7302, 9385, 7300, 9387, 7298, 9389, 7296, 9391, 7294, 9393, 7292, 9395, 7290, 9397, 7288, 9399, 7286, 9401, 7284, 9403, 7282, 9405, 7280, 9407, 7278, 9409, 7276, 9411, 7274, 9413, 7272, 9415, 7270, 9417, 7268, 9419, 7266, 9421, 7264, 9423, 7262, 9425, 7260, 9427, 7258, 9429, 7256, 9431, 7254, 9433, 7252, 9435, 7250, 9437, 7248, 9439, 7246, 9441, 7244, 9443, 7242, 9445, 7240, 9447, 7238, 9449, 7236, 9451, 7234, 9453, 7232, 9455, 7230, 9457, 7228, 9459, 7226, 9461, 7224, 9463, 7222, 9465, 7220, 9467, 7218, 9469, 7216, 9471, 7214, 9473, 7212, 9475, 7210, 9477, 7208, 9479, 7206, 9481, 7204, 9483, 7202, 9485, 7200, 9487, 7198, 9489, 7196, 9491, 7194, 9493, 7192, 9495, 7190, 9497, 7188, 9499, 7186, 9501, 7184, 9503, 7182, 9505, 7180, 9507, 7178, 9509, 7176, 9511, 7174, 9513, 7172, 9515, 7170, 9517, 7168, 9519, 7166, 9521, 7164, 9523, 7162, 9525, 7160, 9527, 7158, 9529, 7156, 9531, 7154, 9533, 7152, 9535, 7150, 9537, 7148, 9539, 7146, 9541, 7144, 9543, 7142, 9545, 7140, 9547, 7138, 9549, 7136, 9551, 7134, 9553, 7132, 9555, 7130, 9557, 7128, 9559, 7126, 9561, 7124, 9563, 7122, 9565, 7120, 9567, 7118, 9569, 7116, 9571, 7114, 9573, 7112, 9575, 7110, 9577, 7108, 9579, 7106, 9581, 7104, 9583, 7102, 9585, 7100, 9587, 7098, 9589, 7096, 9591, 7094, 9593, 7092, 9595, 7090, 9597, 7088, 9599, 7086, 9601, 7084, 9603, 7082, 9605, 7080, 9607, 7078, 9609, 7076, 9611, 7074, 9613, 7072, 9615, 7070, 9617, 7068, 9619, 7066, 9621, 7064, 9623, 7062, 9625, 7060, 9627, 7058, 9629, 7056, 9631, 7054, 9633, 7052, 9635, 7050, 9637, 7048, 9639, 7046, 9641, 7044, 9643, 7042, 9645, 7040, 9647, 7038, 9649, 7036, 9651, 7034, 9653, 7032, 9655, 7030, 9657, 7028, 9659, 7026, 9661, 7024, 9663, 7022, 9665, 7020, 9667, 7018, 9669, 7016, 9671, 7014, 9673, 7012, 9675, 7010, 9677, 7008, 9679, 7006, 9681, 7004, 9683, 7002, 9685, 7000, 9687, 6998, 9689, 6996, 9691, 6994, 9693, 6992, 9695, 6990, 9697, 6988, 9699, 6986, 9701, 6984, 9703, 6982, 9705, 6980, 9707, 6978, 9709, 6976, 9711, 6974, 9713, 6972, 9715, 6970, 9717, 6968, 9719, 6966, 9721, 6964, 9723, 6962, 9725, 6960, 9727, 6958, 9729, 6956, 9731, 6954, 9733, 6952, 9735, 6950, 9737, 6948, 9739, 6946, 9741, 6944, 9743, 6942, 9745, 6940, 9747, 6938, 9749, 6936, 9751, 6934, 9753, 6932, 9755, 6930, 9757, 6928, 9759, 6926, 9761, 6924, 9763, 6922, 9765, 6920, 9767, 6918, 9769, 6916, 9771, 6914, 9773, 6912, 9775, 6910, 9777, 6908, 9779, 6906, 9781, 6904, 9783, 6902, 9785, 6900, 9787, 6898, 9789, 6896, 9791, 6894, 9793, 6892, 9795, 6890, 9797, 6888, 9799, 6886, 9801, 6884, 9803, 6882, 9805, 6880, 9807, 6878, 9809, 6876, 9811, 6874, 9813, 6872, 9815, 6870, 9817, 6868, 9819, 6866, 9821, 6864, 9823, 6862, 9825, 6860, 9827, 6858, 9829, 6856, 9831, 6854, 9833, 6852, 9835, 6850, 9837, 6848, 9839, 6846, 9841, 6844, 9843, 6842, 9845, 6840, 9847, 6838, 9849, 6836, 9851, 6834, 9853, 6832, 9855, 6830, 9857, 6828, 9859, 6826, 9861, 6824, 9863, 6822, 9865, 6820, 9867, 6818, 9869, 6816, 9871, 6814, 9873, 6812, 9875, 6810, 9877, 6808, 9879, 6806, 9881, 6804, 9883, 6802, 9885, 6800, 9887, 6798, 9889, 6796, 9891, 6794, 9893, 6792, 9895, 6790, 9897, 6788, 9899, 6786, 9901, 6784, 9903, 6782, 9905, 6780, 9907, 6778, 9909, 6776, 9911, 6774, 9913, 6772, 9915, 6770, 9917, 6768, 9919, 6766, 9921, 6764, 9923, 6762, 9925, 6760, 9927, 6758, 9929, 6756, 9931, 6754, 9933, 6752, 9935, 6750, 9937, 6748, 9939, 6746, 9941, 6744, 9943, 6742, 9945, 6740, 9947, 6738, 9949, 6736, 9951, 6734, 9953, 6732, 9955, 6730, 9957, 6728, 9959, 6726, 9961, 6724, 9963, 6722, 9965, 6720, 9967, 6718, 9969, 6716, 9971, 6714, 9973, 6712, 9975, 6710, 9977, 6708, 9979, 6706, 9981, 6704, 9983, 6702, 9985, 6700, 9987, 6698, 9989, 6696, 9991, 6694, 9993, 6692, 9995, 6690, 9997, 6688, 9999, 6686, 10001, 6684, 10003, 6682, 10005, 6680, 10007, 6678, 10009, 6676, 10011, 6674, 10013, 6672, 10015, 6670, 10017, 6668, 10019, 6666, 10021, 6664, 10023, 6662, 10025, 6660, 10027, 6658, 10029, 6656, 10031, 6654, 10033, 6652, 10035, 6650, 10037, 6648, 10039, 6646, 10041, 6644, 10043, 6642, 10045, 6640, 10047, 6638, 10049, 6636, 10051, 6634, 10053, 6632, 10055, 6630, 10057, 6628, 10059, 6626, 10061, 6624, 10063, 6622, 10065, 6620, 10067, 6618, 10069, 6616, 10071, 6614, 10073, 6612, 10075, 6610, 10077, 6608, 10079, 6606, 10081, 6604, 10083, 6602, 10085, 6600, 10087, 6598, 10089, 6596, 10091, 6594, 10093, 6592, 10095, 6590, 10097, 6588, 10099, 6586, 10101, 6584, 10103, 6582, 10105, 6580, 10107, 6578, 10109, 6576, 10111, 6574, 10113, 6572, 10115, 6570, 10117, 6568, 10119, 6566, 10121, 6564, 10123, 6562, 10125, 6560, 10127, 6558, 10129, 6556, 10131, 6554, 10133, 6552, 10135, 6550, 10137, 6548, 10139, 6546, 10141, 6544, 10143, 6542, 10145, 6540, 10147, 6538, 10149, 6536, 10151, 6534, 10153, 6532, 10155, 6530, 10157, 6528, 10159, 6526, 10161, 6524, 10163, 6522, 10165, 6520, 10167, 6518, 10169, 6516, 10171, 6514, 10173, 6512, 10175, 6510, 10177, 6508, 10179, 6506, 10181, 6504, 10183, 6502, 10185, 6500, 10187, 6498, 10189, 6496, 10191, 6494, 10193, 6492, 10195, 6490, 10197, 6488, 10199, 6486, 10201, 6484, 10203, 6482, 10205, 6480, 10207, 6478, 10209, 6476, 10211, 6474, 10213, 6472, 10215, 6470, 10217, 6468, 10219, 6466, 10221, 6464, 10223, 6462, 10225, 6460, 10227, 6458, 10229, 6456, 10231, 6454, 10233, 6452, 10235, 6450, 10237, 6448, 10239, 6446, 10241, 6444, 10243, 6442, 10245, 6440, 10247, 6438, 10249, 6436, 10251, 6434, 10253, 6432, 10255, 6430, 10257, 6428, 10259, 6426, 10261, 6424, 10263, 6422, 10265, 6420, 10267, 6418, 10269, 6416, 10271, 6414, 10273, 6412, 10275, 6410, 10277, 6408, 10279, 6406, 10281, 6404, 10283, 6402, 10285, 6400, 10287, 6398, 10289, 6396, 10291, 6394, 10293, 6392, 10295, 6390, 10297, 6388, 10299, 6386, 10301, 6384, 10303, 6382, 10305, 6380, 10307, 6378, 10309, 6376, 10311, 6374, 10313, 6372, 10315, 6370, 10317, 6368, 10319, 6366, 10321, 6364, 10323, 6362, 10325, 6360, 10327, 6358, 10329, 6356, 10331, 6354, 10333, 6352, 10335, 6350, 10337, 6348, 10339, 6346, 10341, 6344, 10343, 6342, 10345, 6340, 10347, 6338, 10349, 6336, 10351, 6334, 10353, 6332, 10355, 6330, 10357, 6328, 10359, 6326, 10361, 6324, 10363, 6322, 10365, 6320, 10367, 6318, 10369, 6316, 10371, 6314, 10373, 6312, 10375, 6310, 10377, 6308, 10379, 6306, 10381, 6304, 10383, 6302, 10385, 6300, 10387, 6298, 10389, 6296, 10391, 6294, 10393, 6292, 10395, 6290, 10397, 6288, 10399, 6286, 10401, 6284, 10403, 6282, 10405, 6280, 10407, 6278, 10409, 6276, 10411, 6274, 10413, 6272, 10415, 6270, 10417, 6268, 10419, 6266, 10421, 6264, 10423, 6262, 10425, 6260, 10427, 6258, 10429, 6256, 10431, 6254, 10433, 6252, 10435, 6250, 10437, 6248, 10439, 6246, 10441, 6244, 10443, 6242, 10445, 6240, 10447, 6238, 10449, 6236, 10451, 6234, 10453, 6232, 10455, 6230, 10457, 6228, 10459, 6226, 10461, 6224, 10463, 6222, 10465, 6220, 10467, 6218, 10469, 6216, 10471, 6214, 10473, 6212, 10475, 6210, 10477, 6208, 10479, 6206, 10481, 6204, 10483, 6202, 10485, 6200, 10487, 6198, 10489, 6196, 10491, 6194, 10493, 6192, 10495, 6190, 10497, 6188, 10499, 6186, 10501, 6184, 10503, 6182, 10505, 6180, 10507, 6178, 10509, 6176, 10511, 6174, 10513, 6172, 10515, 6170, 10517, 6168, 10519, 6166, 10521, 6164, 10523, 6162, 10525, 6160, 10527, 6158, 10529, 6156, 10531, 6154, 10533, 6152, 10535, 6150, 10537, 6148, 10539, 6146, 10541, 6144, 10543, 6142, 10545, 6140, 10547, 6138, 10549, 6136, 10551, 6134, 10553, 6132, 10555, 6130, 10557, 6128, 10559, 6126, 10561, 6124, 10563, 6122, 10565, 6120, 10567, 6118, 10569, 6116, 10571, 6114, 10573, 6112, 10575, 6110, 10577, 6108, 10579, 6106, 10581, 6104, 10583, 6102, 10585, 6100, 10587, 6098, 10589, 6096, 10591, 6094, 10593, 6092, 10595, 6090, 10597, 6088, 10599, 6086, 10601, 6084, 10603, 6082, 10605, 6080, 10607, 6078, 10609, 6076, 10611, 6074, 10613, 6072, 10615, 6070, 10617, 6068, 10619, 6066, 10621, 6064, 10623, 6062, 10625, 6060, 10627, 6058, 10629, 6056, 10631, 6054, 10633, 6052, 10635, 6050, 10637, 6048, 10639, 6046, 10641, 6044, 10643, 6042, 10645, 6040, 10647, 6038, 10649, 6036, 10651, 6034, 10653, 6032, 10655, 6030, 10657, 6028, 10659, 6026, 10661, 6024, 10663, 6022, 10665, 6020, 10667, 6018, 10669, 6016, 10671, 6014, 10673, 6012, 10675, 6010, 10677, 6008, 10679, 6006, 10681, 6004, 10683, 6002, 10685, 6000, 10687, 5998, 10689, 5996, 10691, 5994, 10693, 5992, 10695, 5990, 10697, 5988, 10699, 5986, 10701, 5984, 10703, 5982, 10705, 5980, 10707, 5978, 10709, 5976, 10711, 5974, 10713, 5972, 10715, 5970, 10717, 5968, 10719, 5966, 10721, 5964, 10723, 5962, 10725, 5960, 10727, 5958, 10729, 5956, 10731, 5954, 10733, 5952, 10735, 5950, 10737, 5948, 10739, 5946, 10741, 5944, 10743, 5942, 10745, 5940, 10747, 5938, 10749, 5936, 10751, 5934, 10753, 5932, 10755, 5930, 10757, 5928, 10759, 5926, 10761, 5924, 10763, 5922, 10765, 5920, 10767, 5918, 10769, 5916, 10771, 5914, 10773, 5912, 10775, 5910, 10777, 5908, 10779, 5906, 10781, 5904, 10783, 5902, 10785, 5900, 10787, 5898, 10789, 5896, 10791, 5894, 10793, 5892, 10795, 5890, 10797, 5888, 10799, 5886, 10801, 5884, 10803, 5882, 10805, 5880, 10807, 5878, 10809, 5876, 10811, 5874, 10813, 5872, 10815, 5870, 10817, 5868, 10819, 5866, 10821, 5864, 10823, 5862, 10825, 5860, 10827, 5858, 10829, 5856, 10831, 5854, 10833, 5852, 10835, 5850, 10837, 5848, 10839, 5846, 10841, 5844, 10843, 5842, 10845, 5840, 10847, 5838, 10849, 5836, 10851, 5834, 10853, 5832, 10855, 5830, 10857, 5828, 10859, 5826, 10861, 5824, 10863, 5822, 10865, 5820, 10867, 5818, 10869, 5816, 10871, 5814, 10873, 5812, 10875, 5810, 10877, 5808, 10879, 5806, 10881, 5804, 10883, 5802, 10885, 5800, 10887, 5798, 10889, 5796, 10891, 5794, 10893, 5792, 10895, 5790, 10897, 5788, 10899, 5786, 10901, 5784, 10903, 5782, 10905, 5780, 10907, 5778, 10909, 5776, 10911, 5774, 10913, 5772, 10915, 5770, 10917, 5768, 10919, 5766, 10921, 5764, 10923, 5762, 10925, 5760, 10927, 5758, 10929, 5756, 10931, 5754, 10933, 5752, 10935, 5750, 10937, 5748, 10939, 5746, 10941, 5744, 10943, 5742, 10945, 5740, 10947, 5738, 10949, 5736, 10951, 5734, 10953, 5732, 10955, 5730, 10957, 5728, 10959, 5726, 10961, 5724, 10963, 5722, 10965, 5720, 10967, 5718, 10969, 5716, 10971, 5714, 10973, 5712, 10975, 5710, 10977, 5708, 10979, 5706, 10981, 5704, 10983, 5702, 10985, 5700, 10987, 5698, 10989, 5696, 10991, 5694, 10993, 5692, 10995, 5690, 10997, 5688, 10999, 5686, 11001, 5684, 11003, 5682, 11005, 5680, 11007, 5678, 11009, 5676, 11011, 5674, 11013, 5672, 11015, 5670, 11017, 5668, 11019, 5666, 11021, 5664, 11023, 5662, 11025, 5660, 11027, 5658, 11029, 5656, 11031, 5654, 11033, 5652, 11035, 5650, 11037, 5648, 11039, 5646, 11041, 5644, 11043, 5642, 11045, 5640, 11047, 5638, 11049, 5636, 11051, 5634, 11053, 5632, 11055, 5630, 11057, 5628, 11059, 5626, 11061, 5624, 11063, 5622, 11065, 5620, 11067, 5618, 11069, 5616, 11071, 5614, 11073, 5612, 11075, 5610, 11077, 5608, 11079, 5606, 11081, 5604, 11083, 5602, 11085, 5600, 11087, 5598, 11089, 5596, 11091, 5594, 11093, 5592, 11095, 5590, 11097, 5588, 11099, 5586, 11101, 5584, 11103, 5582, 11105, 5580, 11107, 5578, 11109, 5576, 11111, 5574, 11113, 5572, 11115, 5570, 11117, 5568, 11119, 5566, 11121, 5564, 11123, 5562, 11125, 5560, 11127, 5558, 11129, 5556, 11131, 5554, 11133, 5552, 11135, 5550, 11137, 5548, 11139, 5546, 11141, 5544, 11143, 5542, 11145, 5540, 11147, 5538, 11149, 5536, 11151, 5534, 11153, 5532, 11155, 5530, 11157, 5528, 11159, 5526, 11161, 5524, 11163, 5522, 11165, 5520, 11167, 5518, 11169, 5516, 11171, 5514, 11173, 5512, 11175, 5510, 11177, 5508, 11179, 5506, 11181, 5504, 11183, 5502, 11185, 5500, 11187, 5498, 11189, 5496, 11191, 5494, 11193, 5492, 11195, 5490, 11197, 5488, 11199, 5486, 11201, 5484, 11203, 5482, 11205, 5480, 11207, 5478, 11209, 5476, 11211, 5474, 11213, 5472, 11215, 5470, 11217, 5468, 11219, 5466, 11221, 5464, 11223, 5462, 11225, 5460, 11227, 5458, 11229, 5456, 11231, 5454, 11233, 5452, 11235, 5450, 11237, 5448, 11239, 5446, 11241, 5444, 11243, 5442, 11245, 5440, 11247, 5438, 11249, 5436, 11251, 5434, 11253, 5432, 11255, 5430, 11257, 5428, 11259, 5426, 11261, 5424, 11263, 5422, 11265, 5420, 11267, 5418, 11269, 5416, 11271, 5414, 11273, 5412, 11275, 5410, 11277, 5408, 11279, 5406, 11281, 5404, 11283, 5402, 11285, 5400, 11287, 5398, 11289, 5396, 11291, 5394, 11293, 5392, 11295, 5390, 11297, 5388, 11299, 5386, 11301, 5384, 11303, 5382, 11305, 5380, 11307, 5378, 11309, 5376, 11311, 5374, 11313, 5372, 11315, 5370, 11317, 5368, 11319, 5366, 11321, 5364, 11323, 5362, 11325, 5360, 11327, 5358, 11329, 5356, 11331, 5354, 11333, 5352, 11335, 5350, 11337, 5348, 11339, 5346, 11341, 5344, 11343, 5342, 11345, 5340, 11347, 5338, 11349, 5336, 11351, 5334, 11353, 5332, 11355, 5330, 11357, 5328, 11359, 5326, 11361, 5324, 11363, 5322, 11365, 5320, 11367, 5318, 11369, 5316, 11371, 5314, 11373, 5312, 11375, 5310, 11377, 5308, 11379, 5306, 11381, 5304, 11383, 5302, 11385, 5300, 11387, 5298, 11389, 5296, 11391, 5294, 11393, 5292, 11395, 5290, 11397, 5288, 11399, 5286, 11401, 5284, 11403, 5282, 11405, 5280, 11407, 5278, 11409, 5276, 11411, 5274, 11413, 5272, 11415, 5270, 11417, 5268, 11419, 5266, 11421, 5264, 11423, 5262, 11425, 5260, 11427, 5258, 11429, 5256, 11431, 5254, 11433, 5252, 11435, 5250, 11437, 5248, 11439, 5246, 11441, 5244, 11443, 5242, 11445, 5240, 11447, 5238, 11449, 5236, 11451, 5234, 11453, 5232, 11455, 5230, 11457, 5228, 11459, 5226, 11461, 5224, 11463, 5222, 11465, 5220, 11467, 5218, 11469, 5216, 11471, 5214, 11473, 5212, 11475, 5210, 11477, 5208, 11479, 5206, 11481, 5204, 11483, 5202, 11485, 5200, 11487, 5198, 11489, 5196, 11491, 5194, 11493, 5192, 11495, 5190, 11497, 5188, 11499, 5186, 11501, 5184, 11503, 5182, 11505, 5180, 11507, 5178, 11509, 5176, 11511, 5174, 11513, 5172, 11515, 5170, 11517, 5168, 11519, 5166, 11521, 5164, 11523, 5162, 11525, 5160, 11527, 5158, 11529, 5156, 11531, 5154, 11533, 5152, 11535, 5150, 11537, 5148, 11539, 5146, 11541, 5144, 11543, 5142, 11545, 5140, 11547, 5138, 11549, 5136, 11551, 5134, 11553, 5132, 11555, 5130, 11557, 5128, 11559, 5126, 11561, 5124, 11563, 5122, 11565, 5120, 11567, 5118, 11569, 5116, 11571, 5114, 11573, 5112, 11575, 5110, 11577, 5108, 11579, 5106, 11581, 5104, 11583, 5102, 11585, 5100, 11587, 5098, 11589, 5096, 11591, 5094, 11593, 5092, 11595, 5090, 11597, 5088, 11599, 5086, 11601, 5084, 11603, 5082, 11605, 5080, 11607, 5078, 11609, 5076, 11611, 5074, 11613, 5072, 11615, 5070, 11617, 5068, 11619, 5066, 11621, 5064, 11623, 5062, 11625, 5060, 11627, 5058, 11629, 5056, 11631, 5054, 11633, 5052, 11635, 5050, 11637, 5048, 11639, 5046, 11641, 5044, 11643, 5042, 11645, 5040, 11647, 5038, 11649, 5036, 11651, 5034, 11653, 5032, 11655, 5030, 11657, 5028, 11659, 5026, 11661, 5024, 11663, 5022, 11665, 5020, 11667, 5018, 11669, 5016, 11671, 5014, 11673, 5012, 11675, 5010, 11677, 5008, 11679, 5006, 11681, 5004, 11683, 5002, 11685, 5000, 11687, 4998, 11689, 4996, 11691, 4994, 11693, 4992, 11695, 4990, 11697, 4988, 11699, 4986, 11701, 4984, 11703, 4982, 11705, 4980, 11707, 4978, 11709, 4976, 11711, 4974, 11713, 4972, 11715, 4970, 11717, 4968, 11719, 4966, 11721, 4964, 11723, 4962, 11725, 4960, 11727, 4958, 11729, 4956, 11731, 4954, 11733, 4952, 11735, 4950, 11737, 4948, 11739, 4946, 11741, 4944, 11743, 4942, 11745, 4940, 11747, 4938, 11749, 4936, 11751, 4934, 11753, 4932, 11755, 4930, 11757, 4928, 11759, 4926, 11761, 4924, 11763, 4922, 11765, 4920, 11767, 4918, 11769, 4916, 11771, 4914, 11773, 4912, 11775, 4910, 11777, 4908, 11779, 4906, 11781, 4904, 11783, 4902, 11785, 4900, 11787, 4898, 11789, 4896, 11791, 4894, 11793, 4892, 11795, 4890, 11797, 4888, 11799, 4886, 11801, 4884, 11803, 4882, 11805, 4880, 11807, 4878, 11809, 4876, 11811, 4874, 11813, 4872, 11815, 4870, 11817, 4868, 11819, 4866, 11821, 4864, 11823, 4862, 11825, 4860, 11827, 4858, 11829, 4856, 11831, 4854, 11833, 4852, 11835, 4850, 11837, 4848, 11839, 4846, 11841, 4844, 11843, 4842, 11845, 4840, 11847, 4838, 11849, 4836, 11851, 4834, 11853, 4832, 11855, 4830, 11857, 4828, 11859, 4826, 11861, 4824, 11863, 4822, 11865, 4820, 11867, 4818, 11869, 4816, 11871, 4814, 11873, 4812, 11875, 4810, 11877, 4808, 11879, 4806, 11881, 4804, 11883, 4802, 11885, 4800, 11887, 4798, 11889, 4796, 11891, 4794, 11893, 4792, 11895, 4790, 11897, 4788, 11899, 4786, 11901, 4784, 11903, 4782, 11905, 4780, 11907, 4778, 11909, 4776, 11911, 4774, 11913, 4772, 11915, 4770, 11917, 4768, 11919, 4766, 11921, 4764, 11923, 4762, 11925, 4760, 11927, 4758, 11929, 4756, 11931, 4754, 11933, 4752, 11935, 4750, 11937, 4748, 11939, 4746, 11941, 4744, 11943, 4742, 11945, 4740, 11947, 4738, 11949, 4736, 11951, 4734, 11953, 4732, 11955, 4730, 11957, 4728, 11959, 4726, 11961, 4724, 11963, 4722, 11965, 4720, 11967, 4718, 11969, 4716, 11971, 4714, 11973, 4712, 11975, 4710, 11977, 4708, 11979, 4706, 11981, 4704, 11983, 4702, 11985, 4700, 11987, 4698, 11989, 4696, 11991, 4694, 11993, 4692, 11995, 4690, 11997, 4688, 11999, 4686, 12001, 4684, 12003, 4682, 12005, 4680, 12007, 4678, 12009, 4676, 12011, 4674, 12013, 4672, 12015, 4670, 12017, 4668, 12019, 4666, 12021, 4664, 12023, 4662, 12025, 4660, 12027, 4658, 12029, 4656, 12031, 4654, 12033, 4652, 12035, 4650, 12037, 4648, 12039, 4646, 12041, 4644, 12043, 4642, 12045, 4640, 12047, 4638, 12049, 4636, 12051, 4634, 12053, 4632, 12055, 4630, 12057, 4628, 12059, 4626, 12061, 4624, 12063, 4622, 12065, 4620, 12067, 4618, 12069, 4616, 12071, 4614, 12073, 4612, 12075, 4610, 12077, 4608, 12079, 4606, 12081, 4604, 12083, 4602, 12085, 4600, 12087, 4598, 12089, 4596, 12091, 4594, 12093, 4592, 12095, 4590, 12097, 4588, 12099, 4586, 12101, 4584, 12103, 4582, 12105, 4580, 12107, 4578, 12109, 4576, 12111, 4574, 12113, 4572, 12115, 4570, 12117, 4568, 12119, 4566, 12121, 4564, 12123, 4562, 12125, 4560, 12127, 4558, 12129, 4556, 12131, 4554, 12133, 4552, 12135, 4550, 12137, 4548, 12139, 4546, 12141, 4544, 12143, 4542, 12145, 4540, 12147, 4538, 12149, 4536, 12151, 4534, 12153, 4532, 12155, 4530, 12157, 4528, 12159, 4526, 12161, 4524, 12163, 4522, 12165, 4520, 12167, 4518, 12169, 4516, 12171, 4514, 12173, 4512, 12175, 4510, 12177, 4508, 12179, 4506, 12181, 4504, 12183, 4502, 12185, 4500, 12187, 4498, 12189, 4496, 12191, 4494, 12193, 4492, 12195, 4490, 12197, 4488, 12199, 4486, 12201, 4484, 12203, 4482, 12205, 4480, 12207, 4478, 12209, 4476, 12211, 4474, 12213, 4472, 12215, 4470, 12217, 4468, 12219, 4466, 12221, 4464, 12223, 4462, 12225, 4460, 12227, 4458, 12229, 4456, 12231, 4454, 12233, 4452, 12235, 4450, 12237, 4448, 12239, 4446, 12241, 4444, 12243, 4442, 12245, 4440, 12247, 4438, 12249, 4436, 12251, 4434, 12253, 4432, 12255, 4430, 12257, 4428, 12259, 4426, 12261, 4424, 12263, 4422, 12265, 4420, 12267, 4418, 12269, 4416, 12271, 4414, 12273, 4412, 12275, 4410, 12277, 4408, 12279, 4406, 12281, 4404, 12283, 4402, 12285, 4400, 12287, 4398, 12289, 4396, 12291, 4394, 12293, 4392, 12295, 4390, 12297, 4388, 12299, 4386, 12301, 4384, 12303, 4382, 12305, 4380, 12307, 4378, 12309, 4376, 12311, 4374, 12313, 4372, 12315, 4370, 12317, 4368, 12319, 4366, 12321, 4364, 12323, 4362, 12325, 4360, 12327, 4358, 12329, 4356, 12331, 4354, 12333, 4352, 12335, 4350, 12337, 4348, 12339, 4346, 12341, 4344, 12343, 4342, 12345, 4340, 12347, 4338, 12349, 4336, 12351, 4334, 12353, 4332, 12355, 4330, 12357, 4328, 12359, 4326, 12361, 4324, 12363, 4322, 12365, 4320, 12367, 4318, 12369, 4316, 12371, 4314, 12373, 4312, 12375, 4310, 12377, 4308, 12379, 4306, 12381, 4304, 12383, 4302, 12385, 4300, 12387, 4298, 12389, 4296, 12391, 4294, 12393, 4292, 12395, 4290, 12397, 4288, 12399, 4286, 12401, 4284, 12403, 4282, 12405, 4280, 12407, 4278, 12409, 4276, 12411, 4274, 12413, 4272, 12415, 4270, 12417, 4268, 12419, 4266, 12421, 4264, 12423, 4262, 12425, 4260, 12427, 4258, 12429, 4256, 12431, 4254, 12433, 4252, 12435, 4250, 12437, 4248, 12439, 4246, 12441, 4244, 12443, 4242, 12445, 4240, 12447, 4238, 12449, 4236, 12451, 4234, 12453, 4232, 12455, 4230, 12457, 4228, 12459, 4226, 12461, 4224, 12463, 4222, 12465, 4220, 12467, 4218, 12469, 4216, 12471, 4214, 12473, 4212, 12475, 4210, 12477, 4208, 12479, 4206, 12481, 4204, 12483, 4202, 12485, 4200, 12487, 4198, 12489, 4196, 12491, 4194, 12493, 4192, 12495, 4190, 12497, 4188, 12499, 4186, 12501, 4184, 12503, 4182, 12505, 4180, 12507, 4178, 12509, 4176, 12511, 4174, 12513, 4172, 12515, 4170, 12517, 4168, 12519, 4166, 12521, 4164, 12523, 4162, 12525, 4160, 12527, 4158, 12529, 4156, 12531, 4154, 12533, 4152, 12535, 4150, 12537, 4148, 12539, 4146, 12541, 4144, 12543, 4142, 12545, 4140, 12547, 4138, 12549, 4136, 12551, 4134, 12553, 4132, 12555, 4130, 12557, 4128, 12559, 4126, 12561, 4124, 12563, 4122, 12565, 4120, 12567, 4118, 12569, 4116, 12571, 4114, 12573, 4112, 12575, 4110, 12577, 4108, 12579, 4106, 12581, 4104, 12583, 4102, 12585, 4100, 12587, 4098, 12589, 4096, 12591, 4094, 12593, 4092, 12595, 4090, 12597, 4088, 12599, 4086, 12601, 4084, 12603, 4082, 12605, 4080, 12607, 4078, 12609, 4076, 12611, 4074, 12613, 4072, 12615, 4070, 12617, 4068, 12619, 4066, 12621, 4064, 12623, 4062, 12625, 4060, 12627, 4058, 12629, 4056, 12631, 4054, 12633, 4052, 12635, 4050, 12637, 4048, 12639, 4046, 12641, 4044, 12643, 4042, 12645, 4040, 12647, 4038, 12649, 4036, 12651, 4034, 12653, 4032, 12655, 4030, 12657, 4028, 12659, 4026, 12661, 4024, 12663, 4022, 12665, 4020, 12667, 4018, 12669, 4016, 12671, 4014, 12673, 4012, 12675, 4010, 12677, 4008, 12679, 4006, 12681, 4004, 12683, 4002, 12685, 4000, 12687, 3998, 12689, 3996, 12691, 3994, 12693, 3992, 12695, 3990, 12697, 3988, 12699, 3986, 12701, 3984, 12703, 3982, 12705, 3980, 12707, 3978, 12709, 3976, 12711, 3974, 12713, 3972, 12715, 3970, 12717, 3968, 12719, 3966, 12721, 3964, 12723, 3962, 12725, 3960, 12727, 3958, 12729, 3956, 12731, 3954, 12733, 3952, 12735, 3950, 12737, 3948, 12739, 3946, 12741, 3944, 12743, 3942, 12745, 3940, 12747, 3938, 12749, 3936, 12751, 3934, 12753, 3932, 12755, 3930, 12757, 3928, 12759, 3926, 12761, 3924, 12763, 3922, 12765, 3920, 12767, 3918, 12769, 3916, 12771, 3914, 12773, 3912, 12775, 3910, 12777, 3908, 12779, 3906, 12781, 3904, 12783, 3902, 12785, 3900, 12787, 3898, 12789, 3896, 12791, 3894, 12793, 3892, 12795, 3890, 12797, 3888, 12799, 3886, 12801, 3884, 12803, 3882, 12805, 3880, 12807, 3878, 12809, 3876, 12811, 3874, 12813, 3872, 12815, 3870, 12817, 3868, 12819, 3866, 12821, 3864, 12823, 3862, 12825, 3860, 12827, 3858, 12829, 3856, 12831, 3854, 12833, 3852, 12835, 3850, 12837, 3848, 12839, 3846, 12841, 3844, 12843, 3842, 12845, 3840, 12847, 3838, 12849, 3836, 12851, 3834, 12853, 3832, 12855, 3830, 12857, 3828, 12859, 3826, 12861, 3824, 12863, 3822, 12865, 3820, 12867, 3818, 12869, 3816, 12871, 3814, 12873, 3812, 12875, 3810, 12877, 3808, 12879, 3806, 12881, 3804, 12883, 3802, 12885, 3800, 12887, 3798, 12889, 3796, 12891, 3794, 12893, 3792, 12895, 3790, 12897, 3788, 12899, 3786, 12901, 3784, 12903, 3782, 12905, 3780, 12907, 3778, 12909, 3776, 12911, 3774, 12913, 3772, 12915, 3770, 12917, 3768, 12919, 3766, 12921, 3764, 12923, 3762, 12925, 3760, 12927, 3758, 12929, 3756, 12931, 3754, 12933, 3752, 12935, 3750, 12937, 3748, 12939, 3746, 12941, 3744, 12943, 3742, 12945, 3740, 12947, 3738, 12949, 3736, 12951, 3734, 12953, 3732, 12955, 3730, 12957, 3728, 12959, 3726, 12961, 3724, 12963, 3722, 12965, 3720, 12967, 3718, 12969, 3716, 12971, 3714, 12973, 3712, 12975, 3710, 12977, 3708, 12979, 3706, 12981, 3704, 12983, 3702, 12985, 3700, 12987, 3698, 12989, 3696, 12991, 3694, 12993, 3692, 12995, 3690, 12997, 3688, 12999, 3686, 13001, 3684, 13003, 3682, 13005, 3680, 13007, 3678, 13009, 3676, 13011, 3674, 13013, 3672, 13015, 3670, 13017, 3668, 13019, 3666, 13021, 3664, 13023, 3662, 13025, 3660, 13027, 3658, 13029, 3656, 13031, 3654, 13033, 3652, 13035, 3650, 13037, 3648, 13039, 3646, 13041, 3644, 13043, 3642, 13045, 3640, 13047, 3638, 13049, 3636, 13051, 3634, 13053, 3632, 13055, 3630, 13057, 3628, 13059, 3626, 13061, 3624, 13063, 3622, 13065, 3620, 13067, 3618, 13069, 3616, 13071, 3614, 13073, 3612, 13075, 3610, 13077, 3608, 13079, 3606, 13081, 3604, 13083, 3602, 13085, 3600, 13087, 3598, 13089, 3596, 13091, 3594, 13093, 3592, 13095, 3590, 13097, 3588, 13099, 3586, 13101, 3584, 13103, 3582, 13105, 3580, 13107, 3578, 13109, 3576, 13111, 3574, 13113, 3572, 13115, 3570, 13117, 3568, 13119, 3566, 13121, 3564, 13123, 3562, 13125, 3560, 13127, 3558, 13129, 3556, 13131, 3554, 13133, 3552, 13135, 3550, 13137, 3548, 13139, 3546, 13141, 3544, 13143, 3542, 13145, 3540, 13147, 3538, 13149, 3536, 13151, 3534, 13153, 3532, 13155, 3530, 13157, 3528, 13159, 3526, 13161, 3524, 13163, 3522, 13165, 3520, 13167, 3518, 13169, 3516, 13171, 3514, 13173, 3512, 13175, 3510, 13177, 3508, 13179, 3506, 13181, 3504, 13183, 3502, 13185, 3500, 13187, 3498, 13189, 3496, 13191, 3494, 13193, 3492, 13195, 3490, 13197, 3488, 13199, 3486, 13201, 3484, 13203, 3482, 13205, 3480, 13207, 3478, 13209, 3476, 13211, 3474, 13213, 3472, 13215, 3470, 13217, 3468, 13219, 3466, 13221, 3464, 13223, 3462, 13225, 3460, 13227, 3458, 13229, 3456, 13231, 3454, 13233, 3452, 13235, 3450, 13237, 3448, 13239, 3446, 13241, 3444, 13243, 3442, 13245, 3440, 13247, 3438, 13249, 3436, 13251, 3434, 13253, 3432, 13255, 3430, 13257, 3428, 13259, 3426, 13261, 3424, 13263, 3422, 13265, 3420, 13267, 3418, 13269, 3416, 13271, 3414, 13273, 3412, 13275, 3410, 13277, 3408, 13279, 3406, 13281, 3404, 13283, 3402, 13285, 3400, 13287, 3398, 13289, 3396, 13291, 3394, 13293, 3392, 13295, 3390, 13297, 3388, 13299, 3386, 13301, 3384, 13303, 3382, 13305, 3380, 13307, 3378, 13309, 3376, 13311, 3374, 13313, 3372, 13315, 3370, 13317, 3368, 13319, 3366, 13321, 3364, 13323, 3362, 13325, 3360, 13327, 3358, 13329, 3356, 13331, 3354, 13333, 3352, 13335, 3350, 13337, 3348, 13339, 3346, 13341, 3344, 13343, 3342, 13345, 3340, 13347, 3338, 13349, 3336, 13351, 3334, 13353, 3332, 13355, 3330, 13357, 3328, 13359, 3326, 13361, 3324, 13363, 3322, 13365, 3320, 13367, 3318, 13369, 3316, 13371, 3314, 13373, 3312, 13375, 3310, 13377, 3308, 13379, 3306, 13381, 3304, 13383, 3302, 13385, 3300, 13387, 3298, 13389, 3296, 13391, 3294, 13393, 3292, 13395, 3290, 13397, 3288, 13399, 3286, 13401, 3284, 13403, 3282, 13405, 3280, 13407, 3278, 13409, 3276, 13411, 3274, 13413, 3272, 13415, 3270, 13417, 3268, 13419, 3266, 13421, 3264, 13423, 3262, 13425, 3260, 13427, 3258, 13429, 3256, 13431, 3254, 13433, 3252, 13435, 3250, 13437, 3248, 13439, 3246, 13441, 3244, 13443, 3242, 13445, 3240, 13447, 3238, 13449, 3236, 13451, 3234, 13453, 3232, 13455, 3230, 13457, 3228, 13459, 3226, 13461, 3224, 13463, 3222, 13465, 3220, 13467, 3218, 13469, 3216, 13471, 3214, 13473, 3212, 13475, 3210, 13477, 3208, 13479, 3206, 13481, 3204, 13483, 3202, 13485, 3200, 13487, 3198, 13489, 3196, 13491, 3194, 13493, 3192, 13495, 3190, 13497, 3188, 13499, 3186, 13501, 3184, 13503, 3182, 13505, 3180, 13507, 3178, 13509, 3176, 13511, 3174, 13513, 3172, 13515, 3170, 13517, 3168, 13519, 3166, 13521, 3164, 13523, 3162, 13525, 3160, 13527, 3158, 13529, 3156, 13531, 3154, 13533, 3152, 13535, 3150, 13537, 3148, 13539, 3146, 13541, 3144, 13543, 3142, 13545, 3140, 13547, 3138, 13549, 3136, 13551, 3134, 13553, 3132, 13555, 3130, 13557, 3128, 13559, 3126, 13561, 3124, 13563, 3122, 13565, 3120, 13567, 3118, 13569, 3116, 13571, 3114, 13573, 3112, 13575, 3110, 13577, 3108, 13579, 3106, 13581, 3104, 13583, 3102, 13585, 3100, 13587, 3098, 13589, 3096, 13591, 3094, 13593, 3092, 13595, 3090, 13597, 3088, 13599, 3086, 13601, 3084, 13603, 3082, 13605, 3080, 13607, 3078, 13609, 3076, 13611, 3074, 13613, 3072, 13615, 3070, 13617, 3068, 13619, 3066, 13621, 3064, 13623, 3062, 13625, 3060, 13627, 3058, 13629, 3056, 13631, 3054, 13633, 3052, 13635, 3050, 13637, 3048, 13639, 3046, 13641, 3044, 13643, 3042, 13645, 3040, 13647, 3038, 13649, 3036, 13651, 3034, 13653, 3032, 13655, 3030, 13657, 3028, 13659, 3026, 13661, 3024, 13663, 3022, 13665, 3020, 13667, 3018, 13669, 3016, 13671, 3014, 13673, 3012, 13675, 3010, 13677, 3008, 13679, 3006, 13681, 3004, 13683, 3002, 13685, 3000, 13687, 2998, 13689, 2996, 13691, 2994, 13693, 2992, 13695, 2990, 13697, 2988, 13699, 2986, 13701, 2984, 13703, 2982, 13705, 2980, 13707, 2978, 13709, 2976, 13711, 2974, 13713, 2972, 13715, 2970, 13717, 2968, 13719, 2966, 13721, 2964, 13723, 2962, 13725, 2960, 13727, 2958, 13729, 2956, 13731, 2954, 13733, 2952, 13735, 2950, 13737, 2948, 13739, 2946, 13741, 2944, 13743, 2942, 13745, 2940, 13747, 2938, 13749, 2936, 13751, 2934, 13753, 2932, 13755, 2930, 13757, 2928, 13759, 2926, 13761, 2924, 13763, 2922, 13765, 2920, 13767, 2918, 13769, 2916, 13771, 2914, 13773, 2912, 13775, 2910, 13777, 2908, 13779, 2906, 13781, 2904, 13783, 2902, 13785, 2900, 13787, 2898, 13789, 2896, 13791, 2894, 13793, 2892, 13795, 2890, 13797, 2888, 13799, 2886, 13801, 2884, 13803, 2882, 13805, 2880, 13807, 2878, 13809, 2876, 13811, 2874, 13813, 2872, 13815, 2870, 13817, 2868, 13819, 2866, 13821, 2864, 13823, 2862, 13825, 2860, 13827, 2858, 13829, 2856, 13831, 2854, 13833, 2852, 13835, 2850, 13837, 2848, 13839, 2846, 13841, 2844, 13843, 2842, 13845, 2840, 13847, 2838, 13849, 2836, 13851, 2834, 13853, 2832, 13855, 2830, 13857, 2828, 13859, 2826, 13861, 2824, 13863, 2822, 13865, 2820, 13867, 2818, 13869, 2816, 13871, 2814, 13873, 2812, 13875, 2810, 13877, 2808, 13879, 2806, 13881, 2804, 13883, 2802, 13885, 2800, 13887, 2798, 13889, 2796, 13891, 2794, 13893, 2792, 13895, 2790, 13897, 2788, 13899, 2786, 13901, 2784, 13903, 2782, 13905, 2780, 13907, 2778, 13909, 2776, 13911, 2774, 13913, 2772, 13915, 2770, 13917, 2768, 13919, 2766, 13921, 2764, 13923, 2762, 13925, 2760, 13927, 2758, 13929, 2756, 13931, 2754, 13933, 2752, 13935, 2750, 13937, 2748, 13939, 2746, 13941, 2744, 13943, 2742, 13945, 2740, 13947, 2738, 13949, 2736, 13951, 2734, 13953, 2732, 13955, 2730, 13957, 2728, 13959, 2726, 13961, 2724, 13963, 2722, 13965, 2720, 13967, 2718, 13969, 2716, 13971, 2714, 13973, 2712, 13975, 2710, 13977, 2708, 13979, 2706, 13981, 2704, 13983, 2702, 13985, 2700, 13987, 2698, 13989, 2696, 13991, 2694, 13993, 2692, 13995, 2690, 13997, 2688, 13999, 2686, 14001, 2684, 14003, 2682, 14005, 2680, 14007, 2678, 14009, 2676, 14011, 2674, 14013, 2672, 14015, 2670, 14017, 2668, 14019, 2666, 14021, 2664, 14023, 2662, 14025, 2660, 14027, 2658, 14029, 2656, 14031, 2654, 14033, 2652, 14035, 2650, 14037, 2648, 14039, 2646, 14041, 2644, 14043, 2642, 14045, 2640, 14047, 2638, 14049, 2636, 14051, 2634, 14053, 2632, 14055, 2630, 14057, 2628, 14059, 2626, 14061, 2624, 14063, 2622, 14065, 2620, 14067, 2618, 14069, 2616, 14071, 2614, 14073, 2612, 14075, 2610, 14077, 2608, 14079, 2606, 14081, 2604, 14083, 2602, 14085, 2600, 14087, 2598, 14089, 2596, 14091, 2594, 14093, 2592, 14095, 2590, 14097, 2588, 14099, 2586, 14101, 2584, 14103, 2582, 14105, 2580, 14107, 2578, 14109, 2576, 14111, 2574, 14113, 2572, 14115, 2570, 14117, 2568, 14119, 2566, 14121, 2564, 14123, 2562, 14125, 2560, 14127, 2558, 14129, 2556, 14131, 2554, 14133, 2552, 14135, 2550, 14137, 2548, 14139, 2546, 14141, 2544, 14143, 2542, 14145, 2540, 14147, 2538, 14149, 2536, 14151, 2534, 14153, 2532, 14155, 2530, 14157, 2528, 14159, 2526, 14161, 2524, 14163, 2522, 14165, 2520, 14167, 2518, 14169, 2516, 14171, 2514, 14173, 2512, 14175, 2510, 14177, 2508, 14179, 2506, 14181, 2504, 14183, 2502, 14185, 2500, 14187, 2498, 14189, 2496, 14191, 2494, 14193, 2492, 14195, 2490, 14197, 2488, 14199, 2486, 14201, 2484, 14203, 2482, 14205, 2480, 14207, 2478, 14209, 2476, 14211, 2474, 14213, 2472, 14215, 2470, 14217, 2468, 14219, 2466, 14221, 2464, 14223, 2462, 14225, 2460, 14227, 2458, 14229, 2456, 14231, 2454, 14233, 2452, 14235, 2450, 14237, 2448, 14239, 2446, 14241, 2444, 14243, 2442, 14245, 2440, 14247, 2438, 14249, 2436, 14251, 2434, 14253, 2432, 14255, 2430, 14257, 2428, 14259, 2426, 14261, 2424, 14263, 2422, 14265, 2420, 14267, 2418, 14269, 2416, 14271, 2414, 14273, 2412, 14275, 2410, 14277, 2408, 14279, 2406, 14281, 2404, 14283, 2402, 14285, 2400, 14287, 2398, 14289, 2396, 14291, 2394, 14293, 2392, 14295, 2390, 14297, 2388, 14299, 2386, 14301, 2384, 14303, 2382, 14305, 2380, 14307, 2378, 14309, 2376, 14311, 2374, 14313, 2372, 14315, 2370, 14317, 2368, 14319, 2366, 14321, 2364, 14323, 2362, 14325, 2360, 14327, 2358, 14329, 2356, 14331, 2354, 14333, 2352, 14335, 2350, 14337, 2348, 14339, 2346, 14341, 2344, 14343, 2342, 14345, 2340, 14347, 2338, 14349, 2336, 14351, 2334, 14353, 2332, 14355, 2330, 14357, 2328, 14359, 2326, 14361, 2324, 14363, 2322, 14365, 2320, 14367, 2318, 14369, 2316, 14371, 2314, 14373, 2312, 14375, 2310, 14377, 2308, 14379, 2306, 14381, 2304, 14383, 2302, 14385, 2300, 14387, 2298, 14389, 2296, 14391, 2294, 14393, 2292, 14395, 2290, 14397, 2288, 14399, 2286, 14401, 2284, 14403, 2282, 14405, 2280, 14407, 2278, 14409, 2276, 14411, 2274, 14413, 2272, 14415, 2270, 14417, 2268, 14419, 2266, 14421, 2264, 14423, 2262, 14425, 2260, 14427, 2258, 14429, 2256, 14431, 2254, 14433, 2252, 14435, 2250, 14437, 2248, 14439, 2246, 14441, 2244, 14443, 2242, 14445, 2240, 14447, 2238, 14449, 2236, 14451, 2234, 14453, 2232, 14455, 2230, 14457, 2228, 14459, 2226, 14461, 2224, 14463, 2222, 14465, 2220, 14467, 2218, 14469, 2216, 14471, 2214, 14473, 2212, 14475, 2210, 14477, 2208, 14479, 2206, 14481, 2204, 14483, 2202, 14485, 2200, 14487, 2198, 14489, 2196, 14491, 2194, 14493, 2192, 14495, 2190, 14497, 2188, 14499, 2186, 14501, 2184, 14503, 2182, 14505, 2180, 14507, 2178, 14509, 2176, 14511, 2174, 14513, 2172, 14515, 2170, 14517, 2168, 14519, 2166, 14521, 2164, 14523, 2162, 14525, 2160, 14527, 2158, 14529, 2156, 14531, 2154, 14533, 2152, 14535, 2150, 14537, 2148, 14539, 2146, 14541, 2144, 14543, 2142, 14545, 2140, 14547, 2138, 14549, 2136, 14551, 2134, 14553, 2132, 14555, 2130, 14557, 2128, 14559, 2126, 14561, 2124, 14563, 2122, 14565, 2120, 14567, 2118, 14569, 2116, 14571, 2114, 14573, 2112, 14575, 2110, 14577, 2108, 14579, 2106, 14581, 2104, 14583, 2102, 14585, 2100, 14587, 2098, 14589, 2096, 14591, 2094, 14593, 2092, 14595, 2090, 14597, 2088, 14599, 2086, 14601, 2084, 14603, 2082, 14605, 2080, 14607, 2078, 14609, 2076, 14611, 2074, 14613, 2072, 14615, 2070, 14617, 2068, 14619, 2066, 14621, 2064, 14623, 2062, 14625, 2060, 14627, 2058, 14629, 2056, 14631, 2054, 14633, 2052, 14635, 2050, 14637, 2048, 14639, 2046, 14641, 2044, 14643, 2042, 14645, 2040, 14647, 2038, 14649, 2036, 14651, 2034, 14653, 2032, 14655, 2030, 14657, 2028, 14659, 2026, 14661, 2024, 14663, 2022, 14665, 2020, 14667, 2018, 14669, 2016, 14671, 2014, 14673, 2012, 14675, 2010, 14677, 2008, 14679, 2006, 14681, 2004, 14683, 2002, 14685, 2000, 14687, 1998, 14689, 1996, 14691, 1994, 14693, 1992, 14695, 1990, 14697, 1988, 14699, 1986, 14701, 1984, 14703, 1982, 14705, 1980, 14707, 1978, 14709, 1976, 14711, 1974, 14713, 1972, 14715, 1970, 14717, 1968, 14719, 1966, 14721, 1964, 14723, 1962, 14725, 1960, 14727, 1958, 14729, 1956, 14731, 1954, 14733, 1952, 14735, 1950, 14737, 1948, 14739, 1946, 14741, 1944, 14743, 1942, 14745, 1940, 14747, 1938, 14749, 1936, 14751, 1934, 14753, 1932, 14755, 1930, 14757, 1928, 14759, 1926, 14761, 1924, 14763, 1922, 14765, 1920, 14767, 1918, 14769, 1916, 14771, 1914, 14773, 1912, 14775, 1910, 14777, 1908, 14779, 1906, 14781, 1904, 14783, 1902, 14785, 1900, 14787, 1898, 14789, 1896, 14791, 1894, 14793, 1892, 14795, 1890, 14797, 1888, 14799, 1886, 14801, 1884, 14803, 1882, 14805, 1880, 14807, 1878, 14809, 1876, 14811, 1874, 14813, 1872, 14815, 1870, 14817, 1868, 14819, 1866, 14821, 1864, 14823, 1862, 14825, 1860, 14827, 1858, 14829, 1856, 14831, 1854, 14833, 1852, 14835, 1850, 14837, 1848, 14839, 1846, 14841, 1844, 14843, 1842, 14845, 1840, 14847, 1838, 14849, 1836, 14851, 1834, 14853, 1832, 14855, 1830, 14857, 1828, 14859, 1826, 14861, 1824, 14863, 1822, 14865, 1820, 14867, 1818, 14869, 1816, 14871, 1814, 14873, 1812, 14875, 1810, 14877, 1808, 14879, 1806, 14881, 1804, 14883, 1802, 14885, 1800, 14887, 1798, 14889, 1796, 14891, 1794, 14893, 1792, 14895, 1790, 14897, 1788, 14899, 1786, 14901, 1784, 14903, 1782, 14905, 1780, 14907, 1778, 14909, 1776, 14911, 1774, 14913, 1772, 14915, 1770, 14917, 1768, 14919, 1766, 14921, 1764, 14923, 1762, 14925, 1760, 14927, 1758, 14929, 1756, 14931, 1754, 14933, 1752, 14935, 1750, 14937, 1748, 14939, 1746, 14941, 1744, 14943, 1742, 14945, 1740, 14947, 1738, 14949, 1736, 14951, 1734, 14953, 1732, 14955, 1730, 14957, 1728, 14959, 1726, 14961, 1724, 14963, 1722, 14965, 1720, 14967, 1718, 14969, 1716, 14971, 1714, 14973, 1712, 14975, 1710, 14977, 1708, 14979, 1706, 14981, 1704, 14983, 1702, 14985, 1700, 14987, 1698, 14989, 1696, 14991, 1694, 14993, 1692, 14995, 1690, 14997, 1688, 14999, 1686, 15001, 1684, 15003, 1682, 15005, 1680, 15007, 1678, 15009, 1676, 15011, 1674, 15013, 1672, 15015, 1670, 15017, 1668, 15019, 1666, 15021, 1664, 15023, 1662, 15025, 1660, 15027, 1658, 15029, 1656, 15031, 1654, 15033, 1652, 15035, 1650, 15037, 1648, 15039, 1646, 15041, 1644, 15043, 1642, 15045, 1640, 15047, 1638, 15049, 1636, 15051, 1634, 15053, 1632, 15055, 1630, 15057, 1628, 15059, 1626, 15061, 1624, 15063, 1622, 15065, 1620, 15067, 1618, 15069, 1616, 15071, 1614, 15073, 1612, 15075, 1610, 15077, 1608, 15079, 1606, 15081, 1604, 15083, 1602, 15085, 1600, 15087, 1598, 15089, 1596, 15091, 1594, 15093, 1592, 15095, 1590, 15097, 1588, 15099, 1586, 15101, 1584, 15103, 1582, 15105, 1580, 15107, 1578, 15109, 1576, 15111, 1574, 15113, 1572, 15115, 1570, 15117, 1568, 15119, 1566, 15121, 1564, 15123, 1562, 15125, 1560, 15127, 1558, 15129, 1556, 15131, 1554, 15133, 1552, 15135, 1550, 15137, 1548, 15139, 1546, 15141, 1544, 15143, 1542, 15145, 1540, 15147, 1538, 15149, 1536, 15151, 1534, 15153, 1532, 15155, 1530, 15157, 1528, 15159, 1526, 15161, 1524, 15163, 1522, 15165, 1520, 15167, 1518, 15169, 1516, 15171, 1514, 15173, 1512, 15175, 1510, 15177, 1508, 15179, 1506, 15181, 1504, 15183, 1502, 15185, 1500, 15187, 1498, 15189, 1496, 15191, 1494, 15193, 1492, 15195, 1490, 15197, 1488, 15199, 1486, 15201, 1484, 15203, 1482, 15205, 1480, 15207, 1478, 15209, 1476, 15211, 1474, 15213, 1472, 15215, 1470, 15217, 1468, 15219, 1466, 15221, 1464, 15223, 1462, 15225, 1460, 15227, 1458, 15229, 1456, 15231, 1454, 15233, 1452, 15235, 1450, 15237, 1448, 15239, 1446, 15241, 1444, 15243, 1442, 15245, 1440, 15247, 1438, 15249, 1436, 15251, 1434, 15253, 1432, 15255, 1430, 15257, 1428, 15259, 1426, 15261, 1424, 15263, 1422, 15265, 1420, 15267, 1418, 15269, 1416, 15271, 1414, 15273, 1412, 15275, 1410, 15277, 1408, 15279, 1406, 15281, 1404, 15283, 1402, 15285, 1400, 15287, 1398, 15289, 1396, 15291, 1394, 15293, 1392, 15295, 1390, 15297, 1388, 15299, 1386, 15301, 1384, 15303, 1382, 15305, 1380, 15307, 1378, 15309, 1376, 15311, 1374, 15313, 1372, 15315, 1370, 15317, 1368, 15319, 1366, 15321, 1364, 15323, 1362, 15325, 1360, 15327, 1358, 15329, 1356, 15331, 1354, 15333, 1352, 15335, 1350, 15337, 1348, 15339, 1346, 15341, 1344, 15343, 1342, 15345, 1340, 15347, 1338, 15349, 1336, 15351, 1334, 15353, 1332, 15355, 1330, 15357, 1328, 15359, 1326, 15361, 1324, 15363, 1322, 15365, 1320, 15367, 1318, 15369, 1316, 15371, 1314, 15373, 1312, 15375, 1310, 15377, 1308, 15379, 1306, 15381, 1304, 15383, 1302, 15385, 1300, 15387, 1298, 15389, 1296, 15391, 1294, 15393, 1292, 15395, 1290, 15397, 1288, 15399, 1286, 15401, 1284, 15403, 1282, 15405, 1280, 15407, 1278, 15409, 1276, 15411, 1274, 15413, 1272, 15415, 1270, 15417, 1268, 15419, 1266, 15421, 1264, 15423, 1262, 15425, 1260, 15427, 1258, 15429, 1256, 15431, 1254, 15433, 1252, 15435, 1250, 15437, 1248, 15439, 1246, 15441, 1244, 15443, 1242, 15445, 1240, 15447, 1238, 15449, 1236, 15451, 1234, 15453, 1232, 15455, 1230, 15457, 1228, 15459, 1226, 15461, 1224, 15463, 1222, 15465, 1220, 15467, 1218, 15469, 1216, 15471, 1214, 15473, 1212, 15475, 1210, 15477, 1208, 15479, 1206, 15481, 1204, 15483, 1202, 15485, 1200, 15487, 1198, 15489, 1196, 15491, 1194, 15493, 1192, 15495, 1190, 15497, 1188, 15499, 1186, 15501, 1184, 15503, 1182, 15505, 1180, 15507, 1178, 15509, 1176, 15511, 1174, 15513, 1172, 15515, 1170, 15517, 1168, 15519, 1166, 15521, 1164, 15523, 1162, 15525, 1160, 15527, 1158, 15529, 1156, 15531, 1154, 15533, 1152, 15535, 1150, 15537, 1148, 15539, 1146, 15541, 1144, 15543, 1142, 15545, 1140, 15547, 1138, 15549, 1136, 15551, 1134, 15553, 1132, 15555, 1130, 15557, 1128, 15559, 1126, 15561, 1124, 15563, 1122, 15565, 1120, 15567, 1118, 15569, 1116, 15571, 1114, 15573, 1112, 15575, 1110, 15577, 1108, 15579, 1106, 15581, 1104, 15583, 1102, 15585, 1100, 15587, 1098, 15589, 1096, 15591, 1094, 15593, 1092, 15595, 1090, 15597, 1088, 15599, 1086, 15601, 1084, 15603, 1082, 15605, 1080, 15607, 1078, 15609, 1076, 15611, 1074, 15613, 1072, 15615, 1070, 15617, 1068, 15619, 1066, 15621, 1064, 15623, 1062, 15625, 1060, 15627, 1058, 15629, 1056, 15631, 1054, 15633, 1052, 15635, 1050, 15637, 1048, 15639, 1046, 15641, 1044, 15643, 1042, 15645, 1040, 15647, 1038, 15649, 1036, 15651, 1034, 15653, 1032, 15655, 1030, 15657, 1028, 15659, 1026, 15661, 1024, 15663, 1022, 15665, 1020, 15667, 1018, 15669, 1016, 15671, 1014, 15673, 1012, 15675, 1010, 15677, 1008, 15679, 1006, 15681, 1004, 15683, 1002, 15685, 1000, 15687, 998, 15689, 996, 15691, 994, 15693, 992, 15695, 990, 15697, 988, 15699, 986, 15701, 984, 15703, 982, 15705, 980, 15707, 978, 15709, 976, 15711, 974, 15713, 972, 15715, 970, 15717, 968, 15719, 966, 15721, 964, 15723, 962, 15725, 960, 15727, 958, 15729, 956, 15731, 954, 15733, 952, 15735, 950, 15737, 948, 15739, 946, 15741, 944, 15743, 942, 15745, 940, 15747, 938, 15749, 936, 15751, 934, 15753, 932, 15755, 930, 15757, 928, 15759, 926, 15761, 924, 15763, 922, 15765, 920, 15767, 918, 15769, 916, 15771, 914, 15773, 912, 15775, 910, 15777, 908, 15779, 906, 15781, 904, 15783, 902, 15785, 900, 15787, 898, 15789, 896, 15791, 894, 15793, 892, 15795, 890, 15797, 888, 15799, 886, 15801, 884, 15803, 882, 15805, 880, 15807, 878, 15809, 876, 15811, 874, 15813, 872, 15815, 870, 15817, 868, 15819, 866, 15821, 864, 15823, 862, 15825, 860, 15827, 858, 15829, 856, 15831, 854, 15833, 852, 15835, 850, 15837, 848, 15839, 846, 15841, 844, 15843, 842, 15845, 840, 15847, 838, 15849, 836, 15851, 834, 15853, 832, 15855, 830, 15857, 828, 15859, 826, 15861, 824, 15863, 822, 15865, 820, 15867, 818, 15869, 816, 15871, 814, 15873, 812, 15875, 810, 15877, 808, 15879, 806, 15881, 804, 15883, 802, 15885, 800, 15887, 798, 15889, 796, 15891, 794, 15893, 792, 15895, 790, 15897, 788, 15899, 786, 15901, 784, 15903, 782, 15905, 780, 15907, 778, 15909, 776, 15911, 774, 15913, 772, 15915, 770, 15917, 768, 15919, 766, 15921, 764, 15923, 762, 15925, 760, 15927, 758, 15929, 756, 15931, 754, 15933, 752, 15935, 750, 15937, 748, 15939, 746, 15941, 744, 15943, 742, 15945, 740, 15947, 738, 15949, 736, 15951, 734, 15953, 732, 15955, 730, 15957, 728, 15959, 726, 15961, 724, 15963, 722, 15965, 720, 15967, 718, 15969, 716, 15971, 714, 15973, 712, 15975, 710, 15977, 708, 15979, 706, 15981, 704, 15983, 702, 15985, 700, 15987, 698, 15989, 696, 15991, 694, 15993, 692, 15995, 690, 15997, 688, 15999, 686, 16001, 684, 16003, 682, 16005, 680, 16007, 678, 16009, 676, 16011, 674, 16013, 672, 16015, 670, 16017, 668, 16019, 666, 16021, 664, 16023, 662, 16025, 660, 16027, 658, 16029, 656, 16031, 654, 16033, 652, 16035, 650, 16037, 648, 16039, 646, 16041, 644, 16043, 642, 16045, 640, 16047, 638, 16049, 636, 16051, 634, 16053, 632, 16055, 630, 16057, 628, 16059, 626, 16061, 624, 16063, 622, 16065, 620, 16067, 618, 16069, 616, 16071, 614, 16073, 612, 16075, 610, 16077, 608, 16079, 606, 16081, 604, 16083, 602, 16085, 600, 16087, 598, 16089, 596, 16091, 594, 16093, 592, 16095, 590, 16097, 588, 16099, 586, 16101, 584, 16103, 582, 16105, 580, 16107, 578, 16109, 576, 16111, 574, 16113, 572, 16115, 570, 16117, 568, 16119, 566, 16121, 564, 16123, 562, 16125, 560, 16127, 558, 16129, 556, 16131, 554, 16133, 552, 16135, 550, 16137, 548, 16139, 546, 16141, 544, 16143, 542, 16145, 540, 16147, 538, 16149, 536, 16151, 534, 16153, 532, 16155, 530, 16157, 528, 16159, 526, 16161, 524, 16163, 522, 16165, 520, 16167, 518, 16169, 516, 16171, 514, 16173, 512, 16175, 510, 16177, 508, 16179, 506, 16181, 504, 16183, 502, 16185, 500, 16187, 498, 16189, 496, 16191, 494, 16193, 492, 16195, 490, 16197, 488, 16199, 486, 16201, 484, 16203, 482, 16205, 480, 16207, 478, 16209, 476, 16211, 474, 16213, 472, 16215, 470, 16217, 468, 16219, 466, 16221, 464, 16223, 462, 16225, 460, 16227, 458, 16229, 456, 16231, 454, 16233, 452, 16235, 450, 16237, 448, 16239, 446, 16241, 444, 16243, 442, 16245, 440, 16247, 438, 16249, 436, 16251, 434, 16253, 432, 16255, 430, 16257, 428, 16259, 426, 16261, 424, 16263, 422, 16265, 420, 16267, 418, 16269, 416, 16271, 414, 16273, 412, 16275, 410, 16277, 408, 16279, 406, 16281, 404, 16283, 402, 16285, 400, 16287, 398, 16289, 396, 16291, 394, 16293, 392, 16295, 390, 16297, 388, 16299, 386, 16301, 384, 16303, 382, 16305, 380, 16307, 378, 16309, 376, 16311, 374, 16313, 372, 16315, 370, 16317, 368, 16319, 366, 16321, 364, 16323, 362, 16325, 360, 16327, 358, 16329, 356, 16331, 354, 16333, 352, 16335, 350, 16337, 348, 16339, 346, 16341, 344, 16343, 342, 16345, 340, 16347, 338, 16349, 336, 16351, 334, 16353, 332, 16355, 330, 16357, 328, 16359, 326, 16361, 324, 16363, 322, 16365, 320, 16367, 318, 16369, 316, 16371, 314, 16373, 312, 16375, 310, 16377, 308, 16379, 306, 16381, 304, 16383, 302, 16385, 300, 16387, 298, 16389, 296, 16391, 294, 16393, 292, 16395, 290, 16397, 288, 16399, 286, 16401, 284, 16403, 282, 16405, 280, 16407, 278, 16409, 276, 16411, 274, 16413, 272, 16415, 270, 16417, 268, 16419, 266, 16421, 264, 16423, 262, 16425, 260, 16427, 258, 16429, 256, 16431, 254, 16433, 252, 16435, 250, 16437, 248, 16439, 246, 16441, 244, 16443, 242, 16445, 240, 16447, 238, 16449, 236, 16451, 234, 16453, 232, 16455, 230, 16457, 228, 16459, 226, 16461, 224, 16463, 222, 16465, 220, 16467, 218, 16469, 216, 16471, 214, 16473, 212, 16475, 210, 16477, 208, 16479, 206, 16481, 204, 16483, 202, 16485, 200, 16487, 198, 16489, 196, 16491, 194, 16493, 192, 16495, 190, 16497, 188, 16499, 186, 16501, 184, 16503, 182, 16505, 180, 16507, 178, 16509, 176, 16511, 174, 16513, 172, 16515, 170, 16517, 168, 16519, 166, 16521, 164, 16523, 162, 16525, 160, 16527, 158, 16529, 156, 16531, 154, 16533, 152, 16535, 150, 16537, 148, 16539, 146, 16541, 144, 16543, 142, 16545, 140, 16547, 138, 16549, 136, 16551, 134, 16553, 132, 16555, 130, 16557, 128, 16559, 126, 16561, 124, 16563, 122, 16565, 120, 16567, 118, 16569, 116, 16571, 114, 16573, 112, 16575, 110, 16577, 108, 16579, 106, 16581, 104, 16583, 102, 16585, 100, 16587, 98, 16589, 96, 16591, 94, 16593, 92, 16595, 90, 16597, 88, 16599, 86, 16601, 84, 16603, 82, 16605, 80, 16607, 78, 16609, 76, 16611, 74, 16613, 72, 16615, 70, 16617, 68, 16619, 66, 16621, 64, 16623, 62, 16625, 60, 16627, 58, 16629, 56, 16631, 54, 16633, 52, 16635, 50, 16637, 48, 16639, 46, 16641, 44, 16643, 42, 16645, 40, 16647, 38, 16649, 36, 16651, 34, 16653, 32, 16655, 30, 16657, 28, 16659, 26, 16661, 24, 16663, 22, 16665, 20, 16667, 18, 16669, 16, 16671, 14, 16673, 12, 16675, 10, 16677, 8, 16679, 6, 16681, 4, 16683, 2, 16685]} +RLMATH_EOF diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s4/tests/check.py b/tasks/construct-rlve-prefix-sum-permutation-l6-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..60c3e0996cdfa8673fd7f34ad70cccb789b17654 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s4/tests/check.py @@ -0,0 +1,15 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n = inst["n"] + p = int_list(ans.get("perm"), n, 1, n, "perm") + if len(set(p)) != n: + raise Invalid("not a permutation") + seen, acc = set(), 0 + for v in p: + acc = (acc + v) % n + if acc in seen: + raise Invalid(f"prefix sum residue {acc} repeats") + seen.add(acc) + return None, {} diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s4/tests/instance.json b/tasks/construct-rlve-prefix-sum-permutation-l6-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bd059b35b257dbf8b39cfe17a97015d7ba68f3d6 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s4/tests/instance.json @@ -0,0 +1 @@ +{"n": 16686, "family": "rlve_prefix_sum_permutation", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-prefix-sum-permutation-l6-s4/tests/run.py b/tasks/construct-rlve-prefix-sum-permutation-l6-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-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-prefix-sum-permutation-l6-s4/tests/test.sh b/tasks/construct-rlve-prefix-sum-permutation-l6-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-prefix-sum-permutation-l6-s4/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s0/environment/Dockerfile b/tasks/construct-rlve-recursive-sequence-sum-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s0/environment/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..90ec08a68a41155ca93f869dcc1e6dc2363cd2bd --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"F0": 81, "A": 1, "B": 15807, "S": 126699, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s0/solution/solve.sh b/tasks/construct-rlve-recursive-sequence-sum-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..d774f739ee786d2ad272f9c4c4d9f30628f00343 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"indices": [1, 3, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s0/tests/check.py b/tasks/construct-rlve-recursive-sequence-sum-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..feda076c3f95e5e12198151dee30e1b8223924bc --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s0/tests/check.py @@ -0,0 +1,29 @@ +from run import Invalid, int_list + + +def F(inst, n): + F0, A, B = inst["F0"], inst["A"], inst["B"] + if A == 1: + return F0 + n * B + An = A ** n + return An * F0 + B * (An - 1) // (A - 1) + + +def check(inst, ans): + S = inst["S"] + idx = int_list(ans.get("indices"), None, 1, None, "indices") + if not idx: + raise Invalid("need at least one index") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + total = 0 + for n in idx: + # F is strictly increasing with F(n) >= n and, when A >= 2, F(n) >= 2^(n-1); bail out before big powers + if n > S or (inst["A"] >= 2 and n - 1 > S.bit_length()): + raise Invalid(f"F({n}) exceeds S") + total += F(inst, n) + if total > S: + raise Invalid("sum exceeds S") + if total != S: + raise Invalid(f"sum is {total}, need {S}") + return None, {} diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s0/tests/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..90ec08a68a41155ca93f869dcc1e6dc2363cd2bd --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"F0": 81, "A": 1, "B": 15807, "S": 126699, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s0/tests/run.py b/tasks/construct-rlve-recursive-sequence-sum-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s0/tests/test.sh b/tasks/construct-rlve-recursive-sequence-sum-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s7/environment/Dockerfile b/tasks/construct-rlve-recursive-sequence-sum-l1-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s7/environment/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l1-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7be029c828216823f4d96bd891064753c32711e2 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s7/environment/instance.json @@ -0,0 +1 @@ +{"F0": 12, "A": 16, "B": 16232, "S": 279016, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s7/solution/solve.sh b/tasks/construct-rlve-recursive-sequence-sum-l1-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0522b8ac283d8e01f9b68293254f761e6b7bc69c --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"indices": [2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s7/tests/check.py b/tasks/construct-rlve-recursive-sequence-sum-l1-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..feda076c3f95e5e12198151dee30e1b8223924bc --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s7/tests/check.py @@ -0,0 +1,29 @@ +from run import Invalid, int_list + + +def F(inst, n): + F0, A, B = inst["F0"], inst["A"], inst["B"] + if A == 1: + return F0 + n * B + An = A ** n + return An * F0 + B * (An - 1) // (A - 1) + + +def check(inst, ans): + S = inst["S"] + idx = int_list(ans.get("indices"), None, 1, None, "indices") + if not idx: + raise Invalid("need at least one index") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + total = 0 + for n in idx: + # F is strictly increasing with F(n) >= n and, when A >= 2, F(n) >= 2^(n-1); bail out before big powers + if n > S or (inst["A"] >= 2 and n - 1 > S.bit_length()): + raise Invalid(f"F({n}) exceeds S") + total += F(inst, n) + if total > S: + raise Invalid("sum exceeds S") + if total != S: + raise Invalid(f"sum is {total}, need {S}") + return None, {} diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s7/tests/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l1-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..7be029c828216823f4d96bd891064753c32711e2 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s7/tests/instance.json @@ -0,0 +1 @@ +{"F0": 12, "A": 16, "B": 16232, "S": 279016, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s7/tests/run.py b/tasks/construct-rlve-recursive-sequence-sum-l1-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s7/tests/test.sh b/tasks/construct-rlve-recursive-sequence-sum-l1-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s9/environment/Dockerfile b/tasks/construct-rlve-recursive-sequence-sum-l1-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s9/environment/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l1-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cd071c19eca607d38dec2d00b53735e9203453b4 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s9/environment/instance.json @@ -0,0 +1 @@ +{"F0": 36, "A": 12, "B": 959, "S": 17651, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s9/solution/solve.sh b/tasks/construct-rlve-recursive-sequence-sum-l1-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0522b8ac283d8e01f9b68293254f761e6b7bc69c --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"indices": [2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s9/tests/check.py b/tasks/construct-rlve-recursive-sequence-sum-l1-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..feda076c3f95e5e12198151dee30e1b8223924bc --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s9/tests/check.py @@ -0,0 +1,29 @@ +from run import Invalid, int_list + + +def F(inst, n): + F0, A, B = inst["F0"], inst["A"], inst["B"] + if A == 1: + return F0 + n * B + An = A ** n + return An * F0 + B * (An - 1) // (A - 1) + + +def check(inst, ans): + S = inst["S"] + idx = int_list(ans.get("indices"), None, 1, None, "indices") + if not idx: + raise Invalid("need at least one index") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + total = 0 + for n in idx: + # F is strictly increasing with F(n) >= n and, when A >= 2, F(n) >= 2^(n-1); bail out before big powers + if n > S or (inst["A"] >= 2 and n - 1 > S.bit_length()): + raise Invalid(f"F({n}) exceeds S") + total += F(inst, n) + if total > S: + raise Invalid("sum exceeds S") + if total != S: + raise Invalid(f"sum is {total}, need {S}") + return None, {} diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s9/tests/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l1-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..cd071c19eca607d38dec2d00b53735e9203453b4 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s9/tests/instance.json @@ -0,0 +1 @@ +{"F0": 36, "A": 12, "B": 959, "S": 17651, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s9/tests/run.py b/tasks/construct-rlve-recursive-sequence-sum-l1-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-recursive-sequence-sum-l1-s9/tests/test.sh b/tasks/construct-rlve-recursive-sequence-sum-l1-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l1-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s1/environment/Dockerfile b/tasks/construct-rlve-recursive-sequence-sum-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s1/environment/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3a6fa8e82acfb0abbc6915623de5b45b86985299 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"F0": 62, "A": 1, "B": 4197, "S": 1823172, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s1/solution/solve.sh b/tasks/construct-rlve-recursive-sequence-sum-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3c63d7f655b72a4a83ef1e883277e9960ae2067b --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-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' +{"indices": [1, 2, 3, 4, 5, 6, 7, 9, 10, 12, 13, 14, 15, 16, 17, 19, 20, 21, 22, 23, 24, 26, 27, 28, 29, 30, 31]} +RLMATH_EOF diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s1/tests/check.py b/tasks/construct-rlve-recursive-sequence-sum-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..feda076c3f95e5e12198151dee30e1b8223924bc --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s1/tests/check.py @@ -0,0 +1,29 @@ +from run import Invalid, int_list + + +def F(inst, n): + F0, A, B = inst["F0"], inst["A"], inst["B"] + if A == 1: + return F0 + n * B + An = A ** n + return An * F0 + B * (An - 1) // (A - 1) + + +def check(inst, ans): + S = inst["S"] + idx = int_list(ans.get("indices"), None, 1, None, "indices") + if not idx: + raise Invalid("need at least one index") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + total = 0 + for n in idx: + # F is strictly increasing with F(n) >= n and, when A >= 2, F(n) >= 2^(n-1); bail out before big powers + if n > S or (inst["A"] >= 2 and n - 1 > S.bit_length()): + raise Invalid(f"F({n}) exceeds S") + total += F(inst, n) + if total > S: + raise Invalid("sum exceeds S") + if total != S: + raise Invalid(f"sum is {total}, need {S}") + return None, {} diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s1/tests/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..3a6fa8e82acfb0abbc6915623de5b45b86985299 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"F0": 62, "A": 1, "B": 4197, "S": 1823172, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s1/tests/run.py b/tasks/construct-rlve-recursive-sequence-sum-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s1/tests/test.sh b/tasks/construct-rlve-recursive-sequence-sum-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s6/environment/Dockerfile b/tasks/construct-rlve-recursive-sequence-sum-l5-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s6/environment/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l5-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2a0ef397d1be05f7ee67b4968840ea1c7db6e1d8 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s6/environment/instance.json @@ -0,0 +1 @@ +{"F0": 47, "A": 1, "B": 10647, "S": 3833907, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s6/solution/solve.sh b/tasks/construct-rlve-recursive-sequence-sum-l5-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0d837c24d6bbdabced54467692ffd89cfb4e1383 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"indices": [1, 2, 4, 8, 9, 10, 12, 14, 15, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 31, 32]} +RLMATH_EOF diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s6/tests/check.py b/tasks/construct-rlve-recursive-sequence-sum-l5-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..feda076c3f95e5e12198151dee30e1b8223924bc --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s6/tests/check.py @@ -0,0 +1,29 @@ +from run import Invalid, int_list + + +def F(inst, n): + F0, A, B = inst["F0"], inst["A"], inst["B"] + if A == 1: + return F0 + n * B + An = A ** n + return An * F0 + B * (An - 1) // (A - 1) + + +def check(inst, ans): + S = inst["S"] + idx = int_list(ans.get("indices"), None, 1, None, "indices") + if not idx: + raise Invalid("need at least one index") + if len(set(idx)) != len(idx): + raise Invalid("indices must be distinct") + total = 0 + for n in idx: + # F is strictly increasing with F(n) >= n and, when A >= 2, F(n) >= 2^(n-1); bail out before big powers + if n > S or (inst["A"] >= 2 and n - 1 > S.bit_length()): + raise Invalid(f"F({n}) exceeds S") + total += F(inst, n) + if total > S: + raise Invalid("sum exceeds S") + if total != S: + raise Invalid(f"sum is {total}, need {S}") + return None, {} diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s6/tests/instance.json b/tasks/construct-rlve-recursive-sequence-sum-l5-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2a0ef397d1be05f7ee67b4968840ea1c7db6e1d8 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s6/tests/instance.json @@ -0,0 +1 @@ +{"F0": 47, "A": 1, "B": 10647, "S": 3833907, "family": "rlve_recursive_sequence_sum", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s6/tests/run.py b/tasks/construct-rlve-recursive-sequence-sum-l5-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-recursive-sequence-sum-l5-s6/tests/test.sh b/tasks/construct-rlve-recursive-sequence-sum-l5-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-recursive-sequence-sum-l5-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-round-robin-scores-l5-s2/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l5-s2/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s2/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-round-robin-scores-l5-s2/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l5-s2/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8aff8b938bf786c998515c0aa8520dfdf205dbc4 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s2/environment/instance.json @@ -0,0 +1 @@ +{"W": [16, 16, 21, 18, 18, 22, 17, 23, 27, 14, 24, 14, 12, 20, 21, 22, 19, 24], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l5-s2/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l5-s2/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..533b77a4da185261ba56d64d0a8acc4d662c0e4d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s2/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"A": ["011011101111111021", "101111111111101111", "110120111111212011", "211001200112111010", "110200011111211111", "112120111111121011", "111021010111111111", "211211101111111211", "111211210121111122", "111111111001101110", "111111110201221211", "111011111110200100", "110101111100010111", "121110111202100111", "110111111112220101", "212212101101111010", "011111110112112101", "111211110212111210"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l5-s2/tests/check.py b/tasks/construct-rlve-round-robin-scores-l5-s2/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s2/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid + + +def check(inst, ans): + W = inst["W"] + n = len(W) + A = ans.get("A") + if not isinstance(A, list) or len(A) != n: + raise Invalid(f"A must be a list of {n} strings") + for r in A: + if not isinstance(r, str) or len(r) != n or set(r) - {"0", "1", "2"}: + raise Invalid(f"each row must be a string of {n} digits 0/1/2") + for i in range(n): + if A[i][i] != "0": + raise Invalid("diagonal must be 0") + w = 0 + for j in range(n): + if i != j: + if int(A[i][j]) + int(A[j][i]) != 2: + raise Invalid(f"A[{i}][{j}] + A[{j}][{i}] != 2") + w += 3 * (A[i][j] == "2") + (A[i][j] == "1") + if w != W[i]: + raise Invalid(f"W[{i}] = {w}, need {W[i]}") + return None, {} diff --git a/tasks/construct-rlve-round-robin-scores-l5-s2/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l5-s2/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8aff8b938bf786c998515c0aa8520dfdf205dbc4 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s2/tests/instance.json @@ -0,0 +1 @@ +{"W": [16, 16, 21, 18, 18, 22, 17, 23, 27, 14, 24, 14, 12, 20, 21, 22, 19, 24], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l5-s2/tests/run.py b/tasks/construct-rlve-round-robin-scores-l5-s2/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s2/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-round-robin-scores-l5-s2/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l5-s2/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s2/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-round-robin-scores-l5-s5/environment/Dockerfile b/tasks/construct-rlve-round-robin-scores-l5-s5/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s5/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-round-robin-scores-l5-s5/environment/instance.json b/tasks/construct-rlve-round-robin-scores-l5-s5/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9f8076f704c8350121cd4e1c794a0c22f7f0be2d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s5/environment/instance.json @@ -0,0 +1 @@ +{"W": [16, 12, 30, 28, 26, 20, 13, 24, 32, 17, 28, 26, 18, 21, 33, 20, 20, 30], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l5-s5/solution/solve.sh b/tasks/construct-rlve-round-robin-scores-l5-s5/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..330f5b21a18816a7b46d2c44530f01030ddd0088 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s5/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"A": ["020100100210200201", "000101000210100112", "220021200100222221", "112022220000022211", "220002202202210010", "211000000222111020", "120002020100000110", "222022001001112110", "222202210021210112", "001200122001120001", "112220220202111110", "222200211100120021", "010201210111000220", "220011211010201200", "220021202212210202", "010022111212000020", "210110111210022001", "101122220121220210"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-round-robin-scores-l5-s5/tests/check.py b/tasks/construct-rlve-round-robin-scores-l5-s5/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..214446acaa90ce170daad3989b42317353060f9d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s5/tests/check.py @@ -0,0 +1,24 @@ +from run import Invalid + + +def check(inst, ans): + W = inst["W"] + n = len(W) + A = ans.get("A") + if not isinstance(A, list) or len(A) != n: + raise Invalid(f"A must be a list of {n} strings") + for r in A: + if not isinstance(r, str) or len(r) != n or set(r) - {"0", "1", "2"}: + raise Invalid(f"each row must be a string of {n} digits 0/1/2") + for i in range(n): + if A[i][i] != "0": + raise Invalid("diagonal must be 0") + w = 0 + for j in range(n): + if i != j: + if int(A[i][j]) + int(A[j][i]) != 2: + raise Invalid(f"A[{i}][{j}] + A[{j}][{i}] != 2") + w += 3 * (A[i][j] == "2") + (A[i][j] == "1") + if w != W[i]: + raise Invalid(f"W[{i}] = {w}, need {W[i]}") + return None, {} diff --git a/tasks/construct-rlve-round-robin-scores-l5-s5/tests/instance.json b/tasks/construct-rlve-round-robin-scores-l5-s5/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..9f8076f704c8350121cd4e1c794a0c22f7f0be2d --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s5/tests/instance.json @@ -0,0 +1 @@ +{"W": [16, 12, 30, 28, 26, 20, 13, 24, 32, 17, 28, 26, 18, 21, 33, 20, 20, 30], "family": "rlve_round_robin_scores", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-round-robin-scores-l5-s5/tests/run.py b/tasks/construct-rlve-round-robin-scores-l5-s5/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s5/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-round-robin-scores-l5-s5/tests/test.sh b/tasks/construct-rlve-round-robin-scores-l5-s5/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-round-robin-scores-l5-s5/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-shortest-path-count-l2-s0/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l2-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l2-s0/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l2-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8e6a5b27a03c54014270bd0476efe687cf00d2c6 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s0/environment/instance.json @@ -0,0 +1 @@ +{"K": 381, "n_max": 57, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l2-s0/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l2-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0614e5ca269f34901d78631c2dd28aa81c3bb18c --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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' +{"n": 27, "adj": ["NNYYNNNNNNNNNNNNNNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNYNNNNNN", "NNYYNNYYNNNNNNNNNNNNYNNNNNN", "NNNNYYNNYYNNNNNNNNNNNYNNNNN", "NNNNYYNNYYNNNNNNNNNNNYNNNNN", "NNNNNNYYNNYYNNNNNNNNNNYNNNN", "NNNNNNYYNNYYNNNNNNNNNNYNNNN", "NNNNNNNNYYNNYYNNNNNNNNNYNNN", "NNNNNNNNYYNNYYNNNNNNNNNYNNN", "NNNNNNNNNNYYNNYYNNNNNNNNYNN", "NNNNNNNNNNYYNNYYNNNNNNNNYNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNN", "NNNNNNNNNNNNNNYYNNNNNNNNNNY", "NNNNNNNNNNNNNNYYNNNNNNNNNNY", "YNNNNNNNNNNNNNNNNNNYNNNNNNN", "NNNNNNNNNNNNNNNNNNYNYNNNNNN", "NNNNYYNNNNNNNNNNNNNYNYNNNNN", "NNNNNNYYNNNNNNNNNNNNYNYNNNN", "NNNNNNNNYYNNNNNNNNNNNYNYNNN", "NNNNNNNNNNYYNNNNNNNNNNYNYNN", "NNNNNNNNNNNNYYNNNNNNNNNYNYN", "NNNNNNNNNNNNNNNNNNNNNNNNYNY", "NYNNNNNNNNNNNNNNYYNNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l2-s0/tests/check.py b/tasks/construct-rlve-shortest-path-count-l2-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s0/tests/check.py @@ -0,0 +1,34 @@ +from run import Invalid, as_int + + +def check(inst, ans): + n = as_int(ans.get("n"), "n", lo=2, hi=inst["n_max"]) + adj = ans.get("adj") + if not isinstance(adj, list) or len(adj) != n: + raise Invalid(f"adj must be a list of {n} strings") + for r in adj: + if not isinstance(r, str) or len(r) != n or set(r) - {"Y", "N"}: + raise Invalid("each row must be a string of length n over {'Y','N'}") + for i in range(n): + if adj[i][i] != "N": + raise Invalid("self-loop") + for j in range(i + 1, n): + if adj[i][j] != adj[j][i]: + raise Invalid("matrix not symmetric") + nb = [[j for j in range(n) if adj[i][j] == "Y"] for i in range(n)] + dist = [-1] * n + cnt = [0] * n + dist[0], cnt[0] = 0, 1 + q = [0] + for u in q: # BFS with exact (Python int) path counts + for v in nb[u]: + if dist[v] < 0: + dist[v] = dist[u] + 1 + q.append(v) + if dist[v] == dist[u] + 1: + cnt[v] += cnt[u] + if dist[1] < 0: + raise Invalid("vertex 2 is unreachable from vertex 1") + if cnt[1] != inst["K"]: + raise Invalid(f"{cnt[1]} shortest paths, need {inst['K']}") + return None, {} diff --git a/tasks/construct-rlve-shortest-path-count-l2-s0/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l2-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8e6a5b27a03c54014270bd0476efe687cf00d2c6 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s0/tests/instance.json @@ -0,0 +1 @@ +{"K": 381, "n_max": 57, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l2-s0/tests/run.py b/tasks/construct-rlve-shortest-path-count-l2-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l2-s0/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l2-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l2-s7/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l2-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l2-s7/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l2-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f2472c917629e589a574e1ab36b125a7afc24ae4 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s7/environment/instance.json @@ -0,0 +1 @@ +{"K": 228, "n_max": 51, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l2-s7/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l2-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f28ed4cf9ab76d963a1c15c2e8aa2596fbb860ec --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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' +{"n": 24, "adj": ["NNYYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNYNNNNN", "NNYYNNYYNNNNNNNNNNYNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNYNN", "NNNNNNNNYYNNYYNNNNNNNYNN", "NNNNNNNNNNYYNNYYNNNNNNYN", "NNNNNNNNNNYYNNYYNNNNNNYN", "NNNNNNNNNNNNYYNNNNNNNNNY", "NNNNNNNNNNNNYYNNNNNNNNNY", "NNNNNNNNNNNNNNNNNYNNNNNN", "NNNNNNNNNNNNNNNNYNYNNNNN", "NNNNYYNNNNNNNNNNNYNYNNNN", "NNNNNNNNNNNNNNNNNNYNYNNN", "NNNNNNNNNNNNNNNNNNNYNYNN", "NNNNNNNNNNYYNNNNNNNNYNYN", "NNNNNNNNNNNNYYNNNNNNNYNY", "NYNNNNNNNNNNNNYYNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l2-s7/tests/check.py b/tasks/construct-rlve-shortest-path-count-l2-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s7/tests/check.py @@ -0,0 +1,34 @@ +from run import Invalid, as_int + + +def check(inst, ans): + n = as_int(ans.get("n"), "n", lo=2, hi=inst["n_max"]) + adj = ans.get("adj") + if not isinstance(adj, list) or len(adj) != n: + raise Invalid(f"adj must be a list of {n} strings") + for r in adj: + if not isinstance(r, str) or len(r) != n or set(r) - {"Y", "N"}: + raise Invalid("each row must be a string of length n over {'Y','N'}") + for i in range(n): + if adj[i][i] != "N": + raise Invalid("self-loop") + for j in range(i + 1, n): + if adj[i][j] != adj[j][i]: + raise Invalid("matrix not symmetric") + nb = [[j for j in range(n) if adj[i][j] == "Y"] for i in range(n)] + dist = [-1] * n + cnt = [0] * n + dist[0], cnt[0] = 0, 1 + q = [0] + for u in q: # BFS with exact (Python int) path counts + for v in nb[u]: + if dist[v] < 0: + dist[v] = dist[u] + 1 + q.append(v) + if dist[v] == dist[u] + 1: + cnt[v] += cnt[u] + if dist[1] < 0: + raise Invalid("vertex 2 is unreachable from vertex 1") + if cnt[1] != inst["K"]: + raise Invalid(f"{cnt[1]} shortest paths, need {inst['K']}") + return None, {} diff --git a/tasks/construct-rlve-shortest-path-count-l2-s7/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l2-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..f2472c917629e589a574e1ab36b125a7afc24ae4 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l2-s7/tests/instance.json @@ -0,0 +1 @@ +{"K": 228, "n_max": 51, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l2-s7/tests/run.py b/tasks/construct-rlve-shortest-path-count-l2-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l2-s7/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l2-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l6-s8/environment/Dockerfile b/tasks/construct-rlve-shortest-path-count-l6-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l6-s8/environment/instance.json b/tasks/construct-rlve-shortest-path-count-l6-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b0bb6b4bdf5517e8ae99c77c098ad8fed3bf71e3 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s8/environment/instance.json @@ -0,0 +1 @@ +{"K": 346367314648891555, "n_max": 357, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l6-s8/solution/solve.sh b/tasks/construct-rlve-shortest-path-count-l6-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..dfc95d0c61c437cb5aa5a3fb0ff2101fa887f815 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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' +{"n": 177, "adj": ["NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "YNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNY", "YNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYNN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNYN", "NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYNY", "NYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYYNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNYN"]} +RLMATH_EOF diff --git a/tasks/construct-rlve-shortest-path-count-l6-s8/tests/check.py b/tasks/construct-rlve-shortest-path-count-l6-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..c59d4c4f4bb4e824a2019380643a5b3ade0ca974 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s8/tests/check.py @@ -0,0 +1,34 @@ +from run import Invalid, as_int + + +def check(inst, ans): + n = as_int(ans.get("n"), "n", lo=2, hi=inst["n_max"]) + adj = ans.get("adj") + if not isinstance(adj, list) or len(adj) != n: + raise Invalid(f"adj must be a list of {n} strings") + for r in adj: + if not isinstance(r, str) or len(r) != n or set(r) - {"Y", "N"}: + raise Invalid("each row must be a string of length n over {'Y','N'}") + for i in range(n): + if adj[i][i] != "N": + raise Invalid("self-loop") + for j in range(i + 1, n): + if adj[i][j] != adj[j][i]: + raise Invalid("matrix not symmetric") + nb = [[j for j in range(n) if adj[i][j] == "Y"] for i in range(n)] + dist = [-1] * n + cnt = [0] * n + dist[0], cnt[0] = 0, 1 + q = [0] + for u in q: # BFS with exact (Python int) path counts + for v in nb[u]: + if dist[v] < 0: + dist[v] = dist[u] + 1 + q.append(v) + if dist[v] == dist[u] + 1: + cnt[v] += cnt[u] + if dist[1] < 0: + raise Invalid("vertex 2 is unreachable from vertex 1") + if cnt[1] != inst["K"]: + raise Invalid(f"{cnt[1]} shortest paths, need {inst['K']}") + return None, {} diff --git a/tasks/construct-rlve-shortest-path-count-l6-s8/tests/instance.json b/tasks/construct-rlve-shortest-path-count-l6-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..b0bb6b4bdf5517e8ae99c77c098ad8fed3bf71e3 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-l6-s8/tests/instance.json @@ -0,0 +1 @@ +{"K": 346367314648891555, "n_max": 357, "family": "rlve_shortest_path_count", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-shortest-path-count-l6-s8/tests/run.py b/tasks/construct-rlve-shortest-path-count-l6-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-shortest-path-count-l6-s8/tests/test.sh b/tasks/construct-rlve-shortest-path-count-l6-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-shortest-path-count-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-smallest-enclosing-circle-l5-s3/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l5-s3/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l5-s3/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l5-s3/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a9ddfd29289182b870875b2c7cca7515aec6f929 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s3/environment/instance.json @@ -0,0 +1 @@ +{"points": [[1, 40], [6, 24], [6, 61], [11, 19], [17, 79], [19, 14], [20, 23], [20, 97], [22, 102], [23, 70], [24, 3], [25, 31], [26, 14], [26, 73], [29, 109], [33, 67], [34, 84], [37, 2], [38, 96], [41, 110], [44, 36], [46, 61], [48, 56], [51, 18], [51, 29], [54, 21], [59, 64], [62, 26], [62, 106], [64, 11], [65, 42], [67, 116], [68, 78], [71, 82], [72, 11], [75, 99], [76, 2], [76, 48], [78, 44], [85, 53], [86, 12], [92, 1], [93, 52], [93, 72], [95, 96], [99, 94], [103, 22], [103, 83], [104, 58], [106, 100], [110, 52], [111, 79], [113, 1], [115, 69], [115, 78], [117, 0], [118, 73], [119, 12], [120, 23], [120, 54]], "r_opt": 70.14474467232513, "r2_num": 102400208125, "r2_den": 20811844, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s3/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l5-s3/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..af539a0acd518270558651e8acb2efe9836b023b --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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": 70.085050416484, "y": 52.14664620780359, "r": 70.14474467332514} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s3/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l5-s3/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s3/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s3/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l5-s3/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a9ddfd29289182b870875b2c7cca7515aec6f929 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s3/tests/instance.json @@ -0,0 +1 @@ +{"points": [[1, 40], [6, 24], [6, 61], [11, 19], [17, 79], [19, 14], [20, 23], [20, 97], [22, 102], [23, 70], [24, 3], [25, 31], [26, 14], [26, 73], [29, 109], [33, 67], [34, 84], [37, 2], [38, 96], [41, 110], [44, 36], [46, 61], [48, 56], [51, 18], [51, 29], [54, 21], [59, 64], [62, 26], [62, 106], [64, 11], [65, 42], [67, 116], [68, 78], [71, 82], [72, 11], [75, 99], [76, 2], [76, 48], [78, 44], [85, 53], [86, 12], [92, 1], [93, 52], [93, 72], [95, 96], [99, 94], [103, 22], [103, 83], [104, 58], [106, 100], [110, 52], [111, 79], [113, 1], [115, 69], [115, 78], [117, 0], [118, 73], [119, 12], [120, 23], [120, 54]], "r_opt": 70.14474467232513, "r2_num": 102400208125, "r2_den": 20811844, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s3/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l5-s3/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l5-s3/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l5-s3/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l5-s4/environment/Dockerfile b/tasks/construct-rlve-smallest-enclosing-circle-l5-s4/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l5-s4/environment/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l5-s4/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bfd14cc305970fce2cfcba429a3d340a9ab013a9 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s4/environment/instance.json @@ -0,0 +1 @@ +{"points": [[1, 58], [2, 36], [2, 59], [3, 58], [7, 9], [10, 54], [12, 19], [12, 42], [13, 14], [15, 91], [21, 55], [21, 95], [23, 52], [24, 34], [25, 114], [26, 43], [29, 116], [30, 115], [33, 78], [35, 29], [35, 36], [36, 52], [36, 98], [38, 16], [39, 93], [41, 95], [44, 9], [44, 110], [47, 46], [48, 54], [52, 18], [52, 78], [55, 88], [55, 92], [57, 98], [58, 5], [63, 11], [68, 4], [70, 11], [76, 17], [76, 96], [78, 65], [79, 92], [82, 16], [83, 53], [84, 67], [85, 29], [85, 43], [87, 4], [89, 57], [92, 41], [95, 117], [98, 49], [102, 44], [103, 57], [107, 20], [111, 104], [114, 90], [116, 65], [119, 116]], "r_opt": 77.4483698989204, "r2_num": 23993, "r2_den": 4, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s4/solution/solve.sh b/tasks/construct-rlve-smallest-enclosing-circle-l5-s4/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..7443dea61ab159ed26667d1e9482b8cfe2609673 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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": 63.0, "y": 62.5, "r": 77.44836989992041} +RLMATH_EOF diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s4/tests/check.py b/tasks/construct-rlve-smallest-enclosing-circle-l5-s4/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..0eabf3219588f98db42bf5fd305dc24ce21ca495 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s4/tests/check.py @@ -0,0 +1,17 @@ +import math + +from run import Invalid, num + +TOL = 1e-6 + + +def check(inst, ans): + x, y, r = num(ans.get("x"), "x"), num(ans.get("y"), "y"), num(ans.get("r"), "r") + if r <= 0: + raise Invalid("r must be positive") + if r > inst["r_opt"] + TOL: + raise Invalid(f"r = {r} exceeds the minimum radius {inst['r_opt']} by more than {TOL}") + for px, py in inst["points"]: + if math.hypot(px - x, py - y) > r + TOL: + raise Invalid(f"point ({px}, {py}) is outside the circle") + return None, {"r": r} diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s4/tests/instance.json b/tasks/construct-rlve-smallest-enclosing-circle-l5-s4/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bfd14cc305970fce2cfcba429a3d340a9ab013a9 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-l5-s4/tests/instance.json @@ -0,0 +1 @@ +{"points": [[1, 58], [2, 36], [2, 59], [3, 58], [7, 9], [10, 54], [12, 19], [12, 42], [13, 14], [15, 91], [21, 55], [21, 95], [23, 52], [24, 34], [25, 114], [26, 43], [29, 116], [30, 115], [33, 78], [35, 29], [35, 36], [36, 52], [36, 98], [38, 16], [39, 93], [41, 95], [44, 9], [44, 110], [47, 46], [48, 54], [52, 18], [52, 78], [55, 88], [55, 92], [57, 98], [58, 5], [63, 11], [68, 4], [70, 11], [76, 17], [76, 96], [78, 65], [79, 92], [82, 16], [83, 53], [84, 67], [85, 29], [85, 43], [87, 4], [89, 57], [92, 41], [95, 117], [98, 49], [102, 44], [103, 57], [107, 20], [111, 104], [114, 90], [116, 65], [119, 116]], "r_opt": 77.4483698989204, "r2_num": 23993, "r2_den": 4, "family": "rlve_smallest_enclosing_circle", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-smallest-enclosing-circle-l5-s4/tests/run.py b/tasks/construct-rlve-smallest-enclosing-circle-l5-s4/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-smallest-enclosing-circle-l5-s4/tests/test.sh b/tasks/construct-rlve-smallest-enclosing-circle-l5-s4/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-smallest-enclosing-circle-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-subgraph-isomorphism-l1-s0/environment/Dockerfile b/tasks/construct-rlve-subgraph-isomorphism-l1-s0/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s0/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s0/environment/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l1-s0/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..372a5b09d90c319cbeb98cca33488abfb4ff3e71 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s0/environment/instance.json @@ -0,0 +1 @@ +{"n1": 3, "n2": 5, "edges1": [[0, 2], [1, 2]], "edges2": [[1, 4], [3, 4], [0, 3], [0, 4], [0, 1], [2, 4]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s0/solution/solve.sh b/tasks/construct-rlve-subgraph-isomorphism-l1-s0/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..083ae58f1f040c03654707c7c6af812526c70503 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s0/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"p": [2, 3, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s0/tests/check.py b/tasks/construct-rlve-subgraph-isomorphism-l1-s0/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b8467dd00c27c8902c06206c376ff7a11ac78ae0 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s0/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n1, n2 = inst["n1"], inst["n2"] + p = int_list(ans.get("p"), n1, 0, n2 - 1, "p") + if len(set(p)) != n1: + raise Invalid("p is not injective") + e1 = {(min(u, v), max(u, v)) for u, v in inst["edges1"]} + e2 = {(min(u, v), max(u, v)) for u, v in inst["edges2"]} + for u in range(n1): + for v in range(u + 1, n1): + a, b = min(p[u], p[v]), max(p[u], p[v]) + if ((u, v) in e1) != ((a, b) in e2): + raise Invalid(f"pair ({u}, {v}) is not preserved") + return None, {} diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s0/tests/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l1-s0/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..372a5b09d90c319cbeb98cca33488abfb4ff3e71 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s0/tests/instance.json @@ -0,0 +1 @@ +{"n1": 3, "n2": 5, "edges1": [[0, 2], [1, 2]], "edges2": [[1, 4], [3, 4], [0, 3], [0, 4], [0, 1], [2, 4]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s0/tests/run.py b/tasks/construct-rlve-subgraph-isomorphism-l1-s0/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s0/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s0/tests/test.sh b/tasks/construct-rlve-subgraph-isomorphism-l1-s0/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s0/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s7/environment/Dockerfile b/tasks/construct-rlve-subgraph-isomorphism-l1-s7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s7/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s7/environment/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l1-s7/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bf87cae18c34c66624ad88f8bd2cee1b6661a3eb --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s7/environment/instance.json @@ -0,0 +1 @@ +{"n1": 5, "n2": 5, "edges1": [[0, 3], [0, 1], [2, 3]], "edges2": [[2, 3], [0, 1], [1, 2]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s7/solution/solve.sh b/tasks/construct-rlve-subgraph-isomorphism-l1-s7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..fd30ec6a8f01ffac9170f7d1a0fd1c0d247b8cd2 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s7/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"p": [1, 0, 3, 2, 4]} +RLMATH_EOF diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s7/tests/check.py b/tasks/construct-rlve-subgraph-isomorphism-l1-s7/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b8467dd00c27c8902c06206c376ff7a11ac78ae0 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s7/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n1, n2 = inst["n1"], inst["n2"] + p = int_list(ans.get("p"), n1, 0, n2 - 1, "p") + if len(set(p)) != n1: + raise Invalid("p is not injective") + e1 = {(min(u, v), max(u, v)) for u, v in inst["edges1"]} + e2 = {(min(u, v), max(u, v)) for u, v in inst["edges2"]} + for u in range(n1): + for v in range(u + 1, n1): + a, b = min(p[u], p[v]), max(p[u], p[v]) + if ((u, v) in e1) != ((a, b) in e2): + raise Invalid(f"pair ({u}, {v}) is not preserved") + return None, {} diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s7/tests/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l1-s7/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..bf87cae18c34c66624ad88f8bd2cee1b6661a3eb --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s7/tests/instance.json @@ -0,0 +1 @@ +{"n1": 5, "n2": 5, "edges1": [[0, 3], [0, 1], [2, 3]], "edges2": [[2, 3], [0, 1], [1, 2]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s7/tests/run.py b/tasks/construct-rlve-subgraph-isomorphism-l1-s7/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s7/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s7/tests/test.sh b/tasks/construct-rlve-subgraph-isomorphism-l1-s7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s7/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s9/environment/Dockerfile b/tasks/construct-rlve-subgraph-isomorphism-l1-s9/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s9/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s9/environment/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l1-s9/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6536d398cbbba5ddd56612933e82b8bf77064bd5 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s9/environment/instance.json @@ -0,0 +1 @@ +{"n1": 3, "n2": 5, "edges1": [[1, 2]], "edges2": [[2, 4], [0, 2], [1, 2], [0, 1]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s9/solution/solve.sh b/tasks/construct-rlve-subgraph-isomorphism-l1-s9/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..56dc465226bf2dcdcfcacd600ec04dacfe81eae5 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s9/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"p": [3, 0, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s9/tests/check.py b/tasks/construct-rlve-subgraph-isomorphism-l1-s9/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b8467dd00c27c8902c06206c376ff7a11ac78ae0 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s9/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n1, n2 = inst["n1"], inst["n2"] + p = int_list(ans.get("p"), n1, 0, n2 - 1, "p") + if len(set(p)) != n1: + raise Invalid("p is not injective") + e1 = {(min(u, v), max(u, v)) for u, v in inst["edges1"]} + e2 = {(min(u, v), max(u, v)) for u, v in inst["edges2"]} + for u in range(n1): + for v in range(u + 1, n1): + a, b = min(p[u], p[v]), max(p[u], p[v]) + if ((u, v) in e1) != ((a, b) in e2): + raise Invalid(f"pair ({u}, {v}) is not preserved") + return None, {} diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s9/tests/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l1-s9/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..6536d398cbbba5ddd56612933e82b8bf77064bd5 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s9/tests/instance.json @@ -0,0 +1 @@ +{"n1": 3, "n2": 5, "edges1": [[1, 2]], "edges2": [[2, 4], [0, 2], [1, 2], [0, 1]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s9/tests/run.py b/tasks/construct-rlve-subgraph-isomorphism-l1-s9/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s9/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-subgraph-isomorphism-l1-s9/tests/test.sh b/tasks/construct-rlve-subgraph-isomorphism-l1-s9/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l1-s9/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s1/environment/Dockerfile b/tasks/construct-rlve-subgraph-isomorphism-l5-s1/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s1/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s1/environment/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l5-s1/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2086e6da14c662a64d6991f8b24d85a1b2afe4be --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s1/environment/instance.json @@ -0,0 +1 @@ +{"n1": 26, "n2": 26, "edges1": [[10, 19], [9, 14], [10, 13], [16, 17], [22, 24], [9, 16], [6, 14], [13, 16], [10, 23], [14, 15], [0, 17], [6, 19], [2, 16], [16, 25], [7, 22], [23, 25], [11, 16], [1, 20], [13, 17], [5, 10], [12, 13], [16, 21], [7, 23], [11, 19], [2, 23], [7, 16], [3, 12], [12, 19], [15, 16], [7, 13], [21, 25], [12, 22], [6, 11], [5, 25], [9, 23], [8, 11], [0, 2], [8, 14], [12, 14], [2, 24], [0, 25], [22, 23], [5, 24], [7, 11], [7, 15], [6, 12], [10, 14], [12, 18], [1, 9], [12, 16], [17, 18], [7, 12], [2, 5], [4, 9], [2, 13], [20, 21], [7, 17], [4, 5], [15, 21], [0, 23], [15, 17], [21, 23], [0, 20], [7, 14], [22, 25], [5, 15], [10, 24], [0, 15], [10, 12], [9, 13], [9, 10], [14, 16], [17, 23], [6, 15], [5, 23], [6, 8], [0, 24], [4, 13], [1, 11], [15, 24], [9, 19]], "edges2": [[0, 19], [18, 22], [1, 3], [3, 5], [3, 21], [5, 21], [4, 24], [3, 6], [14, 20], [0, 16], [0, 11], [20, 25], [18, 21], [0, 13], [11, 21], [0, 23], [23, 24], [8, 18], [0, 2], [9, 23], [5, 25], [16, 19], [5, 24], [12, 25], [4, 19], [15, 21], [1, 16], [0, 15], [4, 11], [6, 12], [6, 19], [21, 25], [14, 18], [0, 6], [2, 13], [7, 10], [5, 13], [2, 5], [10, 20], [0, 24], [14, 25], [11, 18], [10, 21], [7, 21], [5, 18], [3, 19], [9, 13], [7, 16], [7, 15], [18, 19], [10, 18], [14, 19], [3, 24], [2, 11], [5, 15], [3, 18], [6, 10], [16, 24], [17, 20], [7, 23], [18, 20], [10, 19], [2, 23], [4, 7], [5, 7], [1, 6], [7, 13], [6, 14], [7, 20], [5, 10], [8, 15], [9, 12], [2, 16], [10, 17], [3, 15], [4, 23], [4, 16], [15, 23], [5, 6], [17, 25], [0, 21]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s1/solution/solve.sh b/tasks/construct-rlve-subgraph-isomorphism-l5-s1/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..daeb9e002b9b5fd17cf50c086439b8ecc9513f33 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-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' +{"p": [23, 12, 24, 22, 1, 16, 20, 21, 17, 6, 19, 25, 18, 3, 10, 7, 5, 15, 8, 14, 9, 13, 11, 0, 4, 2]} +RLMATH_EOF diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s1/tests/check.py b/tasks/construct-rlve-subgraph-isomorphism-l5-s1/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b8467dd00c27c8902c06206c376ff7a11ac78ae0 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s1/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n1, n2 = inst["n1"], inst["n2"] + p = int_list(ans.get("p"), n1, 0, n2 - 1, "p") + if len(set(p)) != n1: + raise Invalid("p is not injective") + e1 = {(min(u, v), max(u, v)) for u, v in inst["edges1"]} + e2 = {(min(u, v), max(u, v)) for u, v in inst["edges2"]} + for u in range(n1): + for v in range(u + 1, n1): + a, b = min(p[u], p[v]), max(p[u], p[v]) + if ((u, v) in e1) != ((a, b) in e2): + raise Invalid(f"pair ({u}, {v}) is not preserved") + return None, {} diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s1/tests/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l5-s1/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..2086e6da14c662a64d6991f8b24d85a1b2afe4be --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s1/tests/instance.json @@ -0,0 +1 @@ +{"n1": 26, "n2": 26, "edges1": [[10, 19], [9, 14], [10, 13], [16, 17], [22, 24], [9, 16], [6, 14], [13, 16], [10, 23], [14, 15], [0, 17], [6, 19], [2, 16], [16, 25], [7, 22], [23, 25], [11, 16], [1, 20], [13, 17], [5, 10], [12, 13], [16, 21], [7, 23], [11, 19], [2, 23], [7, 16], [3, 12], [12, 19], [15, 16], [7, 13], [21, 25], [12, 22], [6, 11], [5, 25], [9, 23], [8, 11], [0, 2], [8, 14], [12, 14], [2, 24], [0, 25], [22, 23], [5, 24], [7, 11], [7, 15], [6, 12], [10, 14], [12, 18], [1, 9], [12, 16], [17, 18], [7, 12], [2, 5], [4, 9], [2, 13], [20, 21], [7, 17], [4, 5], [15, 21], [0, 23], [15, 17], [21, 23], [0, 20], [7, 14], [22, 25], [5, 15], [10, 24], [0, 15], [10, 12], [9, 13], [9, 10], [14, 16], [17, 23], [6, 15], [5, 23], [6, 8], [0, 24], [4, 13], [1, 11], [15, 24], [9, 19]], "edges2": [[0, 19], [18, 22], [1, 3], [3, 5], [3, 21], [5, 21], [4, 24], [3, 6], [14, 20], [0, 16], [0, 11], [20, 25], [18, 21], [0, 13], [11, 21], [0, 23], [23, 24], [8, 18], [0, 2], [9, 23], [5, 25], [16, 19], [5, 24], [12, 25], [4, 19], [15, 21], [1, 16], [0, 15], [4, 11], [6, 12], [6, 19], [21, 25], [14, 18], [0, 6], [2, 13], [7, 10], [5, 13], [2, 5], [10, 20], [0, 24], [14, 25], [11, 18], [10, 21], [7, 21], [5, 18], [3, 19], [9, 13], [7, 16], [7, 15], [18, 19], [10, 18], [14, 19], [3, 24], [2, 11], [5, 15], [3, 18], [6, 10], [16, 24], [17, 20], [7, 23], [18, 20], [10, 19], [2, 23], [4, 7], [5, 7], [1, 6], [7, 13], [6, 14], [7, 20], [5, 10], [8, 15], [9, 12], [2, 16], [10, 17], [3, 15], [4, 23], [4, 16], [15, 23], [5, 6], [17, 25], [0, 21]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s1/tests/run.py b/tasks/construct-rlve-subgraph-isomorphism-l5-s1/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s1/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s1/tests/test.sh b/tasks/construct-rlve-subgraph-isomorphism-l5-s1/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s1/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s6/environment/Dockerfile b/tasks/construct-rlve-subgraph-isomorphism-l5-s6/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s6/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s6/environment/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l5-s6/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dffdfeb1b52d21209ffbb4541795db2ad2007845 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s6/environment/instance.json @@ -0,0 +1 @@ +{"n1": 24, "n2": 26, "edges1": [[2, 20], [1, 2], [12, 17], [6, 16], [3, 18], [2, 9], [20, 22], [3, 9], [2, 12], [7, 11], [18, 23], [9, 12], [1, 4], [0, 11], [13, 18], [14, 21], [0, 12], [13, 16], [1, 9], [8, 15], [6, 22], [5, 22], [3, 21], [2, 23], [10, 13], [9, 17], [4, 16], [6, 23], [6, 11], [14, 17], [4, 21], [0, 15], [1, 20], [0, 7], [11, 12], [6, 17], [5, 12], [4, 13], [8, 16], [16, 21], [0, 16], [4, 23], [4, 18], [3, 19], [11, 18], [0, 13], [7, 8], [10, 11], [10, 14], [11, 17], [12, 19], [10, 21], [17, 23], [4, 9], [4, 20], [12, 20], [5, 21], [13, 23], [5, 18], [0, 19], [22, 23], [1, 19], [17, 22], [3, 16], [15, 22], [4, 12], [2, 3], [2, 18]], "edges2": [[14, 21], [0, 12], [5, 22], [2, 8], [12, 18], [4, 16], [5, 10], [15, 19], [20, 21], [17, 20], [6, 12], [1, 10], [5, 16], [9, 13], [17, 18], [16, 20], [3, 12], [11, 25], [5, 15], [5, 25], [10, 21], [16, 24], [3, 6], [7, 24], [15, 21], [10, 23], [1, 4], [21, 25], [7, 8], [0, 3], [8, 17], [1, 11], [12, 19], [4, 13], [21, 22], [7, 9], [19, 21], [3, 4], [0, 22], [5, 19], [7, 15], [5, 11], [14, 17], [2, 7], [8, 19], [16, 25], [19, 25], [12, 25], [1, 9], [2, 13], [4, 14], [20, 23], [19, 24], [11, 24], [10, 16], [19, 23], [6, 21], [19, 22], [5, 6], [4, 7], [18, 20], [0, 9], [1, 23], [10, 14], [0, 23], [8, 10], [4, 21], [0, 15], [7, 14], [7, 19], [8, 12], [3, 8], [15, 17], [11, 21], [0, 6], [11, 22], [1, 7], [6, 14], [6, 10], [4, 20], [12, 15]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s6/solution/solve.sh b/tasks/construct-rlve-subgraph-isomorphism-l5-s6/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0b4dd33ed60faa72f93a1aaa70bbde47140dc082 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s6/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"p": [7, 11, 5, 16, 21, 23, 3, 2, 13, 25, 17, 8, 19, 14, 18, 9, 4, 12, 10, 24, 22, 20, 0, 6]} +RLMATH_EOF diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s6/tests/check.py b/tasks/construct-rlve-subgraph-isomorphism-l5-s6/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b8467dd00c27c8902c06206c376ff7a11ac78ae0 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s6/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n1, n2 = inst["n1"], inst["n2"] + p = int_list(ans.get("p"), n1, 0, n2 - 1, "p") + if len(set(p)) != n1: + raise Invalid("p is not injective") + e1 = {(min(u, v), max(u, v)) for u, v in inst["edges1"]} + e2 = {(min(u, v), max(u, v)) for u, v in inst["edges2"]} + for u in range(n1): + for v in range(u + 1, n1): + a, b = min(p[u], p[v]), max(p[u], p[v]) + if ((u, v) in e1) != ((a, b) in e2): + raise Invalid(f"pair ({u}, {v}) is not preserved") + return None, {} diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s6/tests/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l5-s6/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..dffdfeb1b52d21209ffbb4541795db2ad2007845 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s6/tests/instance.json @@ -0,0 +1 @@ +{"n1": 24, "n2": 26, "edges1": [[2, 20], [1, 2], [12, 17], [6, 16], [3, 18], [2, 9], [20, 22], [3, 9], [2, 12], [7, 11], [18, 23], [9, 12], [1, 4], [0, 11], [13, 18], [14, 21], [0, 12], [13, 16], [1, 9], [8, 15], [6, 22], [5, 22], [3, 21], [2, 23], [10, 13], [9, 17], [4, 16], [6, 23], [6, 11], [14, 17], [4, 21], [0, 15], [1, 20], [0, 7], [11, 12], [6, 17], [5, 12], [4, 13], [8, 16], [16, 21], [0, 16], [4, 23], [4, 18], [3, 19], [11, 18], [0, 13], [7, 8], [10, 11], [10, 14], [11, 17], [12, 19], [10, 21], [17, 23], [4, 9], [4, 20], [12, 20], [5, 21], [13, 23], [5, 18], [0, 19], [22, 23], [1, 19], [17, 22], [3, 16], [15, 22], [4, 12], [2, 3], [2, 18]], "edges2": [[14, 21], [0, 12], [5, 22], [2, 8], [12, 18], [4, 16], [5, 10], [15, 19], [20, 21], [17, 20], [6, 12], [1, 10], [5, 16], [9, 13], [17, 18], [16, 20], [3, 12], [11, 25], [5, 15], [5, 25], [10, 21], [16, 24], [3, 6], [7, 24], [15, 21], [10, 23], [1, 4], [21, 25], [7, 8], [0, 3], [8, 17], [1, 11], [12, 19], [4, 13], [21, 22], [7, 9], [19, 21], [3, 4], [0, 22], [5, 19], [7, 15], [5, 11], [14, 17], [2, 7], [8, 19], [16, 25], [19, 25], [12, 25], [1, 9], [2, 13], [4, 14], [20, 23], [19, 24], [11, 24], [10, 16], [19, 23], [6, 21], [19, 22], [5, 6], [4, 7], [18, 20], [0, 9], [1, 23], [10, 14], [0, 23], [8, 10], [4, 21], [0, 15], [7, 14], [7, 19], [8, 12], [3, 8], [15, 17], [11, 21], [0, 6], [11, 22], [1, 7], [6, 14], [6, 10], [4, 20], [12, 15]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s6/tests/run.py b/tasks/construct-rlve-subgraph-isomorphism-l5-s6/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s6/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s6/tests/test.sh b/tasks/construct-rlve-subgraph-isomorphism-l5-s6/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s6/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s8/environment/Dockerfile b/tasks/construct-rlve-subgraph-isomorphism-l5-s8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s8/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s8/environment/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l5-s8/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..41d85993baa73d4f686ea733a527a24f2b8b23de --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s8/environment/instance.json @@ -0,0 +1 @@ +{"n1": 16, "n2": 26, "edges1": [[5, 15], [1, 11], [10, 14], [3, 11], [4, 13], [2, 14], [0, 3], [6, 15], [8, 15], [1, 14], [4, 9], [9, 11], [6, 10], [8, 12], [4, 10], [7, 15], [13, 14], [0, 6], [2, 12], [3, 14], [0, 15], [0, 10], [7, 12], [11, 15], [11, 14], [3, 12], [1, 12], [9, 10], [4, 15], [7, 8], [2, 15]], "edges2": [[6, 16], [15, 24], [13, 15], [2, 15], [3, 23], [5, 23], [1, 21], [0, 21], [7, 17], [15, 16], [12, 18], [1, 4], [4, 9], [4, 7], [20, 22], [9, 21], [8, 17], [2, 20], [2, 7], [4, 5], [12, 13], [10, 18], [10, 20], [1, 19], [9, 10], [0, 23], [11, 16], [3, 20], [9, 13], [7, 8], [3, 4], [4, 24], [21, 23], [18, 22], [8, 11], [7, 24], [3, 9], [15, 23], [7, 23], [16, 19], [7, 22], [2, 22], [13, 25], [8, 9], [4, 17], [13, 24], [15, 20], [14, 21], [8, 16], [6, 12], [0, 5], [5, 14], [1, 14], [2, 11], [11, 19], [7, 11], [2, 18], [8, 20], [7, 14], [6, 7], [12, 25], [15, 19], [1, 25], [0, 7], [4, 25], [2, 12], [13, 14], [8, 18], [3, 16], [4, 16], [2, 17], [9, 11], [6, 18], [0, 12], [0, 16], [11, 25], [12, 17], [5, 24], [4, 10], [8, 24], [3, 11]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s8/solution/solve.sh b/tasks/construct-rlve-subgraph-isomorphism-l5-s8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1df227470ba57fe86ab2d62ca13df63bfba3edbc --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s8/solution/solve.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# oracle: a known valid construction (planted witness or published solution) +cat > /workdir/answer.json <<'RLMATH_EOF' +{"p": [23, 10, 8, 3, 14, 6, 0, 2, 22, 1, 21, 4, 20, 13, 9, 7]} +RLMATH_EOF diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s8/tests/check.py b/tasks/construct-rlve-subgraph-isomorphism-l5-s8/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..b8467dd00c27c8902c06206c376ff7a11ac78ae0 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s8/tests/check.py @@ -0,0 +1,16 @@ +from run import Invalid, int_list + + +def check(inst, ans): + n1, n2 = inst["n1"], inst["n2"] + p = int_list(ans.get("p"), n1, 0, n2 - 1, "p") + if len(set(p)) != n1: + raise Invalid("p is not injective") + e1 = {(min(u, v), max(u, v)) for u, v in inst["edges1"]} + e2 = {(min(u, v), max(u, v)) for u, v in inst["edges2"]} + for u in range(n1): + for v in range(u + 1, n1): + a, b = min(p[u], p[v]), max(p[u], p[v]) + if ((u, v) in e1) != ((a, b) in e2): + raise Invalid(f"pair ({u}, {v}) is not preserved") + return None, {} diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s8/tests/instance.json b/tasks/construct-rlve-subgraph-isomorphism-l5-s8/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..41d85993baa73d4f686ea733a527a24f2b8b23de --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s8/tests/instance.json @@ -0,0 +1 @@ +{"n1": 16, "n2": 26, "edges1": [[5, 15], [1, 11], [10, 14], [3, 11], [4, 13], [2, 14], [0, 3], [6, 15], [8, 15], [1, 14], [4, 9], [9, 11], [6, 10], [8, 12], [4, 10], [7, 15], [13, 14], [0, 6], [2, 12], [3, 14], [0, 15], [0, 10], [7, 12], [11, 15], [11, 14], [3, 12], [1, 12], [9, 10], [4, 15], [7, 8], [2, 15]], "edges2": [[6, 16], [15, 24], [13, 15], [2, 15], [3, 23], [5, 23], [1, 21], [0, 21], [7, 17], [15, 16], [12, 18], [1, 4], [4, 9], [4, 7], [20, 22], [9, 21], [8, 17], [2, 20], [2, 7], [4, 5], [12, 13], [10, 18], [10, 20], [1, 19], [9, 10], [0, 23], [11, 16], [3, 20], [9, 13], [7, 8], [3, 4], [4, 24], [21, 23], [18, 22], [8, 11], [7, 24], [3, 9], [15, 23], [7, 23], [16, 19], [7, 22], [2, 22], [13, 25], [8, 9], [4, 17], [13, 24], [15, 20], [14, 21], [8, 16], [6, 12], [0, 5], [5, 14], [1, 14], [2, 11], [11, 19], [7, 11], [2, 18], [8, 20], [7, 14], [6, 7], [12, 25], [15, 19], [1, 25], [0, 7], [4, 25], [2, 12], [13, 14], [8, 18], [3, 16], [4, 16], [2, 17], [9, 11], [6, 18], [0, 12], [0, 16], [11, 25], [12, 17], [5, 24], [4, 10], [8, 24], [3, 11]], "family": "rlve_subgraph_isomorphism", "subset": "construct"} \ No newline at end of file diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s8/tests/run.py b/tasks/construct-rlve-subgraph-isomorphism-l5-s8/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s8/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/construct-rlve-subgraph-isomorphism-l5-s8/tests/test.sh b/tasks/construct-rlve-subgraph-isomorphism-l5-s8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/construct-rlve-subgraph-isomorphism-l5-s8/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/optimize-ae-p1-ff-nikodym-d3-p47/environment/Dockerfile b/tasks/optimize-ae-p1-ff-nikodym-d3-p47/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-nikodym-d3-p47/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==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-p47/environment/instance.json b/tasks/optimize-ae-p1-ff-nikodym-d3-p47/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..a9fc039478c88cfed6738f627233da76e39ba6ac --- /dev/null +++ b/tasks/optimize-ae-p1-ff-nikodym-d3-p47/environment/instance.json @@ -0,0 +1 @@ +{"p": 47, "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-p47/solution/solve.sh b/tasks/optimize-ae-p1-ff-nikodym-d3-p47/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ddabeebb151a76142fc2ede124a88bd18dfb0448 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-nikodym-d3-p47/solution/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], [1, 0, 1], [1, 1, 0], [1, 1, 1], [2, 0, 2], [2, 1, 2], [2, 1, 3], [2, 1, 4], [2, 1, 6], [2, 1, 8], [2, 1, 12], [2, 1, 16], [2, 1, 24], [2, 2, 0], [2, 2, 1], [2, 2, 2], [2, 2, 4], [2, 2, 6], [2, 2, 8], [2, 2, 12], [2, 2, 16], [2, 2, 24], [2, 2, 32], [2, 3, 1], [2, 3, 6], [2, 3, 9], [2, 3, 12], [2, 3, 18], [2, 3, 24], [2, 3, 25], [2, 3, 36], [2, 4, 1], [2, 4, 2], [2, 4, 8], [2, 4, 12], [2, 4, 16], [2, 4, 17], [2, 4, 24], [2, 4, 32], [2, 6, 1], [2, 6, 2], [2, 6, 3], [2, 6, 12], [2, 6, 18], [2, 6, 24], [2, 6, 25], [2, 6, 36], [2, 7, 9], [2, 7, 14], [2, 7, 18], [2, 7, 21], [2, 7, 27], [2, 7, 28], [2, 7, 37], [2, 7, 42], [2, 8, 1], [2, 8, 2], [2, 8, 4], [2, 8, 16], [2, 8, 17], [2, 8, 24], [2, 8, 32], [2, 8, 34], [2, 9, 3], [2, 9, 7], [2, 9, 14], [2, 9, 18], [2, 9, 25], [2, 9, 27], [2, 9, 28], [2, 9, 36], [2, 12, 1], [2, 12, 2], [2, 12, 3], [2, 12, 4], [2, 12, 6], [2, 12, 24], [2, 12, 25], [2, 12, 36], [2, 14, 7], [2, 14, 9], [2, 14, 18], [2, 14, 27], [2, 14, 28], [2, 14, 36], [2, 14, 37], [2, 14, 42], [2, 16, 1], [2, 16, 2], [2, 16, 4], [2, 16, 8], [2, 16, 17], [2, 16, 21], [2, 16, 32], [2, 16, 34], [2, 17, 4], [2, 17, 8], [2, 17, 16], [2, 17, 21], [2, 17, 32], [2, 17, 34], [2, 17, 37], [2, 17, 42], [2, 18, 3], [2, 18, 6], [2, 18, 7], [2, 18, 9], [2, 18, 14], [2, 18, 25], [2, 18, 28], [2, 18, 36], [2, 21, 7], [2, 21, 16], [2, 21, 17], [2, 21, 27], [2, 21, 32], [2, 21, 34], [2, 21, 37], [2, 21, 42], [2, 24, 1], [2, 24, 2], [2, 24, 3], [2, 24, 4], [2, 24, 6], [2, 24, 8], [2, 24, 12], [2, 24, 25], [2, 25, 3], [2, 25, 6], [2, 25, 9], [2, 25, 12], [2, 25, 18], [2, 25, 24], [2, 25, 28], [2, 25, 36], [2, 27, 7], [2, 27, 9], [2, 27, 14], [2, 27, 21], [2, 27, 28], [2, 27, 34], [2, 27, 37], [2, 27, 42], [2, 28, 7], [2, 28, 9], [2, 28, 14], [2, 28, 18], [2, 28, 25], [2, 28, 27], [2, 28, 36], [2, 28, 37], [2, 32, 2], [2, 32, 4], [2, 32, 8], [2, 32, 16], [2, 32, 17], [2, 32, 21], [2, 32, 34], [2, 32, 42], [2, 34, 8], [2, 34, 16], [2, 34, 17], [2, 34, 21], [2, 34, 27], [2, 34, 32], [2, 34, 37], [2, 34, 42], [2, 36, 3], [2, 36, 6], [2, 36, 9], [2, 36, 12], [2, 36, 14], [2, 36, 18], [2, 36, 25], [2, 36, 28], [2, 37, 7], [2, 37, 14], [2, 37, 17], [2, 37, 21], [2, 37, 27], [2, 37, 28], [2, 37, 34], [2, 37, 42], [2, 42, 7], [2, 42, 14], [2, 42, 17], [2, 42, 21], [2, 42, 27], [2, 42, 32], [2, 42, 34], [2, 42, 37], [3, 0, 3], [3, 1, 3], [3, 1, 7], [3, 1, 9], [3, 1, 16], [3, 1, 18], [3, 1, 21], [3, 1, 27], [3, 1, 34], [3, 2, 6], [3, 2, 7], [3, 2, 14], [3, 2, 18], [3, 2, 21], [3, 2, 32], [3, 2, 36], [3, 2, 42], [3, 3, 0], [3, 3, 1], [3, 3, 3], [3, 3, 7], [3, 3, 8], [3, 3, 9], [3, 3, 16], [3, 3, 21], [3, 3, 27], [3, 3, 34], [3, 4, 12], [3, 4, 14], [3, 4, 17], [3, 4, 25], [3, 4, 28], [3, 4, 36], [3, 4, 37], [3, 4, 42], [3, 6, 2], [3, 6, 7], [3, 6, 14], [3, 6, 16], [3, 6, 18], [3, 6, 21], [3, 6, 32], [3, 6, 42], [3, 7, 1], [3, 7, 2], [3, 7, 3], [3, 7, 6], [3, 7, 16], [3, 7, 18], [3, 7, 21], [3, 7, 32], [3, 8, 3], [3, 8, 9], [3, 8, 24], [3, 8, 25], [3, 8, 27], [3, 8, 28], [3, 8, 34], [3, 8, 37], [3, 9, 1], [3, 9, 3], [3, 9, 8], [3, 9, 16], [3, 9, 21], [3, 9, 24], [3, 9, 27], [3, 9, 34], [3, 12, 4], [3, 12, 14], [3, 12, 17], [3, 12, 28], [3, 12, 32], [3, 12, 36], [3, 12, 37], [3, 12, 42], [3, 14, 2], [3, 14, 4], [3, 14, 6], [3, 14, 12], [3, 14, 17], [3, 14, 32], [3, 14, 36], [3, 14, 42], [3, 16, 1], [3, 16, 3], [3, 16, 6], [3, 16, 7], [3, 16, 9], [3, 16, 18], [3, 16, 21], [3, 16, 27], [3, 17, 4], [3, 17, 12], [3, 17, 14], [3, 17, 24], [3, 17, 25], [3, 17, 28], [3, 17, 36], [3, 17, 37], [3, 18, 1], [3, 18, 2], [3, 18, 6], [3, 18, 7], [3, 18, 16], [3, 18, 21], [3, 18, 32], [3, 18, 42], [3, 21, 1], [3, 21, 2], [3, 21, 3], [3, 21, 6], [3, 21, 7], [3, 21, 9], [3, 21, 16], [3, 21, 18], [3, 24, 8], [3, 24, 9], [3, 24, 17], [3, 24, 25], [3, 24, 27], [3, 24, 28], [3, 24, 34], [3, 24, 37], [3, 25, 4], [3, 25, 8], [3, 25, 17], [3, 25, 24], [3, 25, 27], [3, 25, 28], [3, 25, 34], [3, 25, 37], [3, 27, 1], [3, 27, 3], [3, 27, 8], [3, 27, 9], [3, 27, 16], [3, 27, 24], [3, 27, 25], [3, 27, 34], [3, 28, 4], [3, 28, 8], [3, 28, 12], [3, 28, 17], [3, 28, 24], [3, 28, 25], [3, 28, 34], [3, 28, 37], [3, 32, 2], [3, 32, 6], [3, 32, 7], [3, 32, 12], [3, 32, 14], [3, 32, 18], [3, 32, 36], [3, 32, 42], [3, 34, 1], [3, 34, 3], [3, 34, 8], [3, 34, 9], [3, 34, 24], [3, 34, 25], [3, 34, 27], [3, 34, 28], [3, 36, 2], [3, 36, 4], [3, 36, 12], [3, 36, 14], [3, 36, 17], [3, 36, 32], [3, 36, 37], [3, 36, 42], [3, 37, 4], [3, 37, 8], [3, 37, 12], [3, 37, 17], [3, 37, 24], [3, 37, 25], [3, 37, 28], [3, 37, 36], [3, 42, 2], [3, 42, 4], [3, 42, 6], [3, 42, 12], [3, 42, 14], [3, 42, 18], [3, 42, 32], [3, 42, 36], [4, 0, 4], [4, 1, 3], [4, 1, 4], [4, 1, 9], [4, 1, 12], [4, 1, 16], [4, 1, 17], [4, 1, 21], [4, 1, 36], [4, 2, 6], [4, 2, 8], [4, 2, 18], [4, 2, 24], [4, 2, 25], [4, 2, 32], [4, 2, 34], [4, 2, 42], [4, 3, 1], [4, 3, 4], [4, 3, 9], [4, 3, 12], [4, 3, 14], [4, 3, 16], [4, 3, 27], [4, 3, 36], [4, 4, 0], [4, 4, 1], [4, 4, 3], [4, 4, 4], [4, 4, 12], [4, 4, 16], [4, 4, 17], [4, 4, 21], [4, 4, 36], [4, 4, 37], [4, 6, 2], [4, 6, 7], [4, 6, 8], [4, 6, 18], [4, 6, 24], [4, 6, 25], [4, 6, 28], [4, 6, 32], [4, 7, 6], [4, 7, 16], [4, 7, 17], [4, 7, 18], [4, 7, 21], [4, 7, 25], [4, 7, 28], [4, 7, 37], [4, 8, 2], [4, 8, 6], [4, 8, 24], [4, 8, 25], [4, 8, 27], [4, 8, 32], [4, 8, 34], [4, 8, 42], [4, 9, 1], [4, 9, 3], [4, 9, 12], [4, 9, 14], [4, 9, 27], [4, 9, 34], [4, 9, 36], [4, 9, 42], [4, 12, 1], [4, 12, 3], [4, 12, 4], [4, 12, 9], [4, 12, 14], [4, 12, 16], [4, 12, 17], [4, 12, 36], [4, 14, 3], [4, 14, 9], [4, 14, 12], [4, 14, 27], [4, 14, 32], [4, 14, 34], [4, 14, 36], [4, 14, 42], [4, 16, 1], [4, 16, 3], [4, 16, 4], [4, 16, 7], [4, 16, 12], [4, 16, 17], [4, 16, 21], [4, 16, 37], [4, 17, 1], [4, 17, 4], [4, 17, 7], [4, 17, 12], [4, 17, 16], [4, 17, 21], [4, 17, 28], [4, 17, 37], [4, 18, 2], [4, 18, 6], [4, 18, 7], [4, 18, 21], [4, 18, 24], [4, 18, 25], [4, 18, 28], [4, 18, 37], [4, 21, 1], [4, 21, 4], [4, 21, 7], [4, 21, 16], [4, 21, 17], [4, 21, 18], [4, 21, 28], [4, 21, 37], [4, 24, 2], [4, 24, 6], [4, 24, 8], [4, 24, 18], [4, 24, 25], [4, 24, 28], [4, 24, 32], [4, 24, 34], [4, 25, 2], [4, 25, 6], [4, 25, 7], [4, 25, 8], [4, 25, 18], [4, 25, 24], [4, 25, 28], [4, 25, 37], [4, 27, 3], [4, 27, 8], [4, 27, 9], [4, 27, 14], [4, 27, 32], [4, 27, 34], [4, 27, 36], [4, 27, 42], [4, 28, 6], [4, 28, 7], [4, 28, 17], [4, 28, 18], [4, 28, 21], [4, 28, 24], [4, 28, 25], [4, 28, 37], [4, 32, 2], [4, 32, 6], [4, 32, 8], [4, 32, 14], [4, 32, 24], [4, 32, 27], [4, 32, 34], [4, 32, 42], [4, 34, 2], [4, 34, 8], [4, 34, 9], [4, 34, 14], [4, 34, 24], [4, 34, 27], [4, 34, 32], [4, 34, 42], [4, 36, 1], [4, 36, 3], [4, 36, 4], [4, 36, 9], [4, 36, 12], [4, 36, 14], [4, 36, 27], [4, 36, 42], [4, 37, 4], [4, 37, 7], [4, 37, 16], [4, 37, 17], [4, 37, 18], [4, 37, 21], [4, 37, 25], [4, 37, 28], [4, 42, 2], [4, 42, 8], [4, 42, 9], [4, 42, 14], [4, 42, 27], [4, 42, 32], [4, 42, 34], [4, 42, 36], [5, 0, 5], [5, 1, 5], [5, 1, 14], [5, 1, 19], [5, 1, 25], [5, 1, 31], [5, 1, 32], [5, 1, 37], [5, 1, 44], [5, 2, 3], [5, 2, 10], [5, 2, 15], [5, 2, 17], [5, 2, 27], [5, 2, 28], [5, 2, 38], [5, 2, 41], [5, 3, 2], [5, 3, 10], [5, 3, 15], [5, 3, 17], [5, 3, 28], [5, 3, 38], [5, 3, 42], [5, 3, 46], [5, 4, 6], [5, 4, 7], [5, 4, 9], [5, 4, 20], [5, 4, 29], [5, 4, 30], [5, 4, 34], [5, 4, 35], [5, 5, 0], [5, 5, 1], [5, 5, 5], [5, 5, 14], [5, 5, 19], [5, 5, 23], [5, 5, 25], [5, 5, 31], [5, 5, 32], [5, 5, 44], [5, 6, 4], [5, 6, 9], [5, 6, 20], [5, 6, 29], [5, 6, 30], [5, 6, 34], [5, 6, 37], [5, 6, 45], [5, 7, 4], [5, 7, 24], [5, 7, 26], [5, 7, 29], [5, 7, 34], [5, 7, 35], [5, 7, 36], [5, 7, 39], [5, 8, 11], [5, 8, 12], [5, 8, 13], [5, 8, 14], [5, 8, 18], [5, 8, 21], [5, 8, 23], [5, 8, 40], [5, 9, 4], [5, 9, 6], [5, 9, 20], [5, 9, 30], [5, 9, 32], [5, 9, 37], [5, 9, 44], [5, 9, 45], [5, 10, 2], [5, 10, 3], [5, 10, 15], [5, 10, 17], [5, 10, 28], [5, 10, 38], [5, 10, 41], [5, 10, 46], [5, 11, 8], [5, 11, 12], [5, 11, 13], [5, 11, 14], [5, 11, 21], [5, 11, 23], [5, 11, 31], [5, 11, 40], [5, 12, 8], [5, 12, 11], [5, 12, 13], [5, 12, 18], [5, 12, 21], [5, 12, 27], [5, 12, 40], [5, 12, 43], [5, 13, 8], [5, 13, 11], [5, 13, 12], [5, 13, 18], [5, 13, 27], [5, 13, 40], [5, 13, 41], [5, 13, 43], [5, 14, 1], [5, 14, 5], [5, 14, 8], [5, 14, 11], [5, 14, 21], [5, 14, 23], [5, 14, 25], [5, 14, 31], [5, 15, 2], [5, 15, 3], [5, 15, 10], [5, 15, 22], [5, 15, 28], [5, 15, 38], [5, 15, 42], [5, 15, 46], [5, 16, 22], [5, 16, 24], [5, 16, 26], [5, 16, 28], [5, 16, 33], [5, 16, 36], [5, 16, 42], [5, 16, 46], [5, 17, 2], [5, 17, 3], [5, 17, 10], [5, 17, 18], [5, 17, 27], [5, 17, 38], [5, 17, 41], [5, 17, 43], [5, 18, 8], [5, 18, 12], [5, 18, 13], [5, 18, 17], [5, 18, 27], [5, 18, 40], [5, 18, 41], [5, 18, 43], [5, 19, 1], [5, 19, 5], [5, 19, 25], [5, 19, 31], [5, 19, 32], [5, 19, 37], [5, 19, 44], [5, 19, 45], [5, 20, 4], [5, 20, 6], [5, 20, 9], [5, 20, 29], [5, 20, 30], [5, 20, 34], [5, 20, 35], [5, 20, 45], [5, 21, 8], [5, 21, 11], [5, 21, 12], [5, 21, 14], [5, 21, 23], [5, 21, 25], [5, 21, 31], [5, 21, 40], [5, 22, 15], [5, 22, 16], [5, 22, 24], [5, 22, 26], [5, 22, 28], [5, 22, 33], [5, 22, 42], [5, 22, 46], [5, 23, 5], [5, 23, 8], [5, 23, 11], [5, 23, 14], [5, 23, 21], [5, 23, 25], [5, 23, 31], [5, 23, 40], [5, 24, 7], [5, 24, 16], [5, 24, 22], [5, 24, 26], [5, 24, 33], [5, 24, 36], [5, 24, 39], [5, 24, 42], [5, 25, 1], [5, 25, 5], [5, 25, 14], [5, 25, 19], [5, 25, 21], [5, 25, 23], [5, 25, 31], [5, 25, 32], [5, 26, 7], [5, 26, 16], [5, 26, 22], [5, 26, 24], [5, 26, 33], [5, 26, 35], [5, 26, 36], [5, 26, 39], [5, 27, 2], [5, 27, 12], [5, 27, 13], [5, 27, 17], [5, 27, 18], [5, 27, 38], [5, 27, 41], [5, 27, 43], [5, 28, 2], [5, 28, 3], [5, 28, 10], [5, 28, 15], [5, 28, 16], [5, 28, 22], [5, 28, 42], [5, 28, 46], [5, 29, 4], [5, 29, 6], [5, 29, 7], [5, 29, 20], [5, 29, 30], [5, 29, 34], [5, 29, 35], [5, 29, 39], [5, 30, 4], [5, 30, 6], [5, 30, 9], [5, 30, 20], [5, 30, 29], [5, 30, 37], [5, 30, 44], [5, 30, 45], [5, 31, 1], [5, 31, 5], [5, 31, 11], [5, 31, 14], [5, 31, 19], [5, 31, 21], [5, 31, 23], [5, 31, 25], [5, 32, 1], [5, 32, 5], [5, 32, 9], [5, 32, 19], [5, 32, 25], [5, 32, 37], [5, 32, 44], [5, 32, 45], [5, 33, 16], [5, 33, 22], [5, 33, 24], [5, 33, 26], [5, 33, 36], [5, 33, 39], [5, 33, 42], [5, 33, 46], [5, 34, 4], [5, 34, 6], [5, 34, 7], [5, 34, 20], [5, 34, 29], [5, 34, 35], [5, 34, 36], [5, 34, 39], [5, 35, 4], [5, 35, 7], [5, 35, 20], [5, 35, 26], [5, 35, 29], [5, 35, 34], [5, 35, 36], [5, 35, 39], [5, 36, 7], [5, 36, 16], [5, 36, 24], [5, 36, 26], [5, 36, 33], [5, 36, 34], [5, 36, 35], [5, 36, 39], [5, 37, 1], [5, 37, 6], [5, 37, 9], [5, 37, 19], [5, 37, 30], [5, 37, 32], [5, 37, 44], [5, 37, 45], [5, 38, 2], [5, 38, 3], [5, 38, 10], [5, 38, 15], [5, 38, 17], [5, 38, 27], [5, 38, 41], [5, 38, 43], [5, 39, 7], [5, 39, 24], [5, 39, 26], [5, 39, 29], [5, 39, 33], [5, 39, 34], [5, 39, 35], [5, 39, 36], [5, 40, 8], [5, 40, 11], [5, 40, 12], [5, 40, 13], [5, 40, 18], [5, 40, 21], [5, 40, 23], [5, 40, 43], [5, 41, 2], [5, 41, 10], [5, 41, 13], [5, 41, 17], [5, 41, 18], [5, 41, 27], [5, 41, 38], [5, 41, 43], [5, 42, 3], [5, 42, 15], [5, 42, 16], [5, 42, 22], [5, 42, 24], [5, 42, 28], [5, 42, 33], [5, 42, 46], [5, 43, 12], [5, 43, 13], [5, 43, 17], [5, 43, 18], [5, 43, 27], [5, 43, 38], [5, 43, 40], [5, 43, 41], [5, 44, 1], [5, 44, 5], [5, 44, 9], [5, 44, 19], [5, 44, 30], [5, 44, 32], [5, 44, 37], [5, 44, 45], [5, 45, 6], [5, 45, 9], [5, 45, 19], [5, 45, 20], [5, 45, 30], [5, 45, 32], [5, 45, 37], [5, 45, 44], [5, 46, 3], [5, 46, 10], [5, 46, 15], [5, 46, 16], [5, 46, 22], [5, 46, 28], [5, 46, 33], [5, 46, 42], [6, 0, 6], [6, 1, 6], [6, 1, 7], [6, 1, 8], [6, 1, 17], [6, 1, 27], [6, 1, 28], [6, 1, 36], [6, 1, 42], [6, 2, 7], [6, 2, 9], [6, 2, 12], [6, 2, 14], [6, 2, 16], [6, 2, 25], [6, 2, 34], [6, 2, 37], [6, 3, 4], [6, 3, 14], [6, 3, 18], [6, 3, 21], [6, 3, 24], [6, 3, 32], [6, 3, 34], [6, 3, 37], [6, 4, 3], [6, 4, 14], [6, 4, 18], [6, 4, 21], [6, 4, 24], [6, 4, 27], [6, 4, 28], [6, 4, 32], [6, 6, 0], [6, 6, 1], [6, 6, 6], [6, 6, 8], [6, 6, 17], [6, 6, 21], [6, 6, 27], [6, 6, 28], [6, 6, 36], [6, 6, 42], [6, 7, 1], [6, 7, 2], [6, 7, 8], [6, 7, 9], [6, 7, 12], [6, 7, 17], [6, 7, 25], [6, 7, 42], [6, 8, 1], [6, 8, 6], [6, 8, 7], [6, 8, 9], [6, 8, 17], [6, 8, 28], [6, 8, 36], [6, 8, 42], [6, 9, 2], [6, 9, 7], [6, 9, 8], [6, 9, 12], [6, 9, 16], [6, 9, 17], [6, 9, 25], [6, 9, 42], [6, 12, 2], [6, 12, 7], [6, 12, 9], [6, 12, 16], [6, 12, 25], [6, 12, 34], [6, 12, 37], [6, 12, 42], [6, 14, 2], [6, 14, 3], [6, 14, 4], [6, 14, 16], [6, 14, 18], [6, 14, 24], [6, 14, 34], [6, 14, 37], [6, 16, 2], [6, 16, 9], [6, 16, 12], [6, 16, 14], [6, 16, 18], [6, 16, 25], [6, 16, 34], [6, 16, 37], [6, 17, 1], [6, 17, 6], [6, 17, 7], [6, 17, 8], [6, 17, 9], [6, 17, 25], [6, 17, 36], [6, 17, 42], [6, 18, 3], [6, 18, 4], [6, 18, 14], [6, 18, 16], [6, 18, 24], [6, 18, 32], [6, 18, 34], [6, 18, 37], [6, 21, 3], [6, 21, 4], [6, 21, 6], [6, 21, 24], [6, 21, 27], [6, 21, 28], [6, 21, 32], [6, 21, 36], [6, 24, 3], [6, 24, 4], [6, 24, 14], [6, 24, 18], [6, 24, 21], [6, 24, 27], [6, 24, 32], [6, 24, 37], [6, 25, 2], [6, 25, 7], [6, 25, 9], [6, 25, 12], [6, 25, 16], [6, 25, 17], [6, 25, 34], [6, 25, 42], [6, 27, 1], [6, 27, 4], [6, 27, 6], [6, 27, 21], [6, 27, 24], [6, 27, 28], [6, 27, 32], [6, 27, 36], [6, 28, 1], [6, 28, 4], [6, 28, 6], [6, 28, 8], [6, 28, 21], [6, 28, 27], [6, 28, 32], [6, 28, 36], [6, 32, 3], [6, 32, 4], [6, 32, 18], [6, 32, 21], [6, 32, 24], [6, 32, 27], [6, 32, 28], [6, 32, 36], [6, 34, 2], [6, 34, 3], [6, 34, 12], [6, 34, 14], [6, 34, 16], [6, 34, 18], [6, 34, 25], [6, 34, 37], [6, 36, 1], [6, 36, 6], [6, 36, 8], [6, 36, 17], [6, 36, 21], [6, 36, 27], [6, 36, 28], [6, 36, 32], [6, 37, 2], [6, 37, 3], [6, 37, 12], [6, 37, 14], [6, 37, 16], [6, 37, 18], [6, 37, 24], [6, 37, 34], [6, 42, 1], [6, 42, 6], [6, 42, 7], [6, 42, 8], [6, 42, 9], [6, 42, 12], [6, 42, 17], [6, 42, 25], [7, 0, 7], [7, 1, 2], [7, 1, 4], [7, 1, 7], [7, 1, 12], [7, 1, 14], [7, 1, 24], [7, 1, 27], [7, 1, 37], [7, 2, 1], [7, 2, 4], [7, 2, 7], [7, 2, 8], [7, 2, 14], [7, 2, 24], [7, 2, 27], [7, 2, 28], [7, 3, 6], [7, 3, 12], [7, 3, 17], [7, 3, 21], [7, 3, 25], [7, 3, 34], [7, 3, 36], [7, 3, 42], [7, 4, 1], [7, 4, 2], [7, 4, 7], [7, 4, 8], [7, 4, 9], [7, 4, 14], [7, 4, 16], [7, 4, 28], [7, 6, 3], [7, 6, 12], [7, 6, 21], [7, 6, 24], [7, 6, 25], [7, 6, 34], [7, 6, 37], [7, 6, 42], [7, 7, 0], [7, 7, 1], [7, 7, 2], [7, 7, 4], [7, 7, 7], [7, 7, 14], [7, 7, 24], [7, 7, 27], [7, 7, 28], [7, 7, 37], [7, 8, 2], [7, 8, 4], [7, 8, 9], [7, 8, 14], [7, 8, 16], [7, 8, 18], [7, 8, 28], [7, 8, 32], [7, 9, 4], [7, 9, 8], [7, 9, 14], [7, 9, 16], [7, 9, 18], [7, 9, 28], [7, 9, 32], [7, 9, 36], [7, 12, 1], [7, 12, 3], [7, 12, 6], [7, 12, 21], [7, 12, 24], [7, 12, 27], [7, 12, 37], [7, 12, 42], [7, 14, 1], [7, 14, 2], [7, 14, 4], [7, 14, 7], [7, 14, 8], [7, 14, 9], [7, 14, 27], [7, 14, 28], [7, 16, 4], [7, 16, 8], [7, 16, 9], [7, 16, 17], [7, 16, 18], [7, 16, 28], [7, 16, 32], [7, 16, 36], [7, 17, 3], [7, 17, 16], [7, 17, 18], [7, 17, 21], [7, 17, 25], [7, 17, 32], [7, 17, 34], [7, 17, 36], [7, 18, 8], [7, 18, 9], [7, 18, 16], [7, 18, 17], [7, 18, 25], [7, 18, 28], [7, 18, 32], [7, 18, 36], [7, 21, 3], [7, 21, 6], [7, 21, 12], [7, 21, 17], [7, 21, 25], [7, 21, 34], [7, 21, 37], [7, 21, 42], [7, 24, 1], [7, 24, 2], [7, 24, 6], [7, 24, 7], [7, 24, 12], [7, 24, 27], [7, 24, 37], [7, 24, 42], [7, 25, 3], [7, 25, 6], [7, 25, 17], [7, 25, 18], [7, 25, 21], [7, 25, 32], [7, 25, 34], [7, 25, 36], [7, 27, 1], [7, 27, 2], [7, 27, 7], [7, 27, 12], [7, 27, 14], [7, 27, 24], [7, 27, 37], [7, 27, 42], [7, 28, 2], [7, 28, 4], [7, 28, 7], [7, 28, 8], [7, 28, 9], [7, 28, 14], [7, 28, 16], [7, 28, 18], [7, 32, 8], [7, 32, 9], [7, 32, 16], [7, 32, 17], [7, 32, 18], [7, 32, 25], [7, 32, 34], [7, 32, 36], [7, 34, 3], [7, 34, 6], [7, 34, 17], [7, 34, 21], [7, 34, 25], [7, 34, 32], [7, 34, 36], [7, 34, 42], [7, 36, 3], [7, 36, 9], [7, 36, 16], [7, 36, 17], [7, 36, 18], [7, 36, 25], [7, 36, 32], [7, 36, 34], [7, 37, 1], [7, 37, 6], [7, 37, 7], [7, 37, 12], [7, 37, 21], [7, 37, 24], [7, 37, 27], [7, 37, 42], [7, 42, 3], [7, 42, 6], [7, 42, 12], [7, 42, 21], [7, 42, 24], [7, 42, 27], [7, 42, 34], [7, 42, 37], [8, 0, 8], [8, 1, 6], [8, 1, 7], [8, 1, 8], [8, 1, 17], [8, 1, 27], [8, 1, 28], [8, 1, 36], [8, 1, 42], [8, 2, 7], [8, 2, 9], [8, 2, 12], [8, 2, 14], [8, 2, 16], [8, 2, 25], [8, 2, 34], [8, 2, 37], [8, 3, 4], [8, 3, 14], [8, 3, 18], [8, 3, 21], [8, 3, 24], [8, 3, 32], [8, 3, 34], [8, 3, 37], [8, 4, 3], [8, 4, 14], [8, 4, 18], [8, 4, 21], [8, 4, 24], [8, 4, 27], [8, 4, 28], [8, 4, 32], [8, 6, 1], [8, 6, 8], [8, 6, 17], [8, 6, 21], [8, 6, 27], [8, 6, 28], [8, 6, 36], [8, 6, 42], [8, 7, 1], [8, 7, 2], [8, 7, 8], [8, 7, 9], [8, 7, 12], [8, 7, 17], [8, 7, 25], [8, 7, 42], [8, 8, 0], [8, 8, 1], [8, 8, 6], [8, 8, 7], [8, 8, 8], [8, 8, 9], [8, 8, 17], [8, 8, 28], [8, 8, 36], [8, 8, 42], [8, 9, 2], [8, 9, 7], [8, 9, 8], [8, 9, 12], [8, 9, 16], [8, 9, 17], [8, 9, 25], [8, 9, 42], [8, 12, 2], [8, 12, 7], [8, 12, 9], [8, 12, 16], [8, 12, 25], [8, 12, 34], [8, 12, 37], [8, 12, 42], [8, 14, 2], [8, 14, 3], [8, 14, 4], [8, 14, 16], [8, 14, 18], [8, 14, 24], [8, 14, 34], [8, 14, 37], [8, 16, 2], [8, 16, 9], [8, 16, 12], [8, 16, 14], [8, 16, 18], [8, 16, 25], [8, 16, 34], [8, 16, 37], [8, 17, 1], [8, 17, 6], [8, 17, 7], [8, 17, 8], [8, 17, 9], [8, 17, 25], [8, 17, 36], [8, 17, 42], [8, 18, 3], [8, 18, 4], [8, 18, 14], [8, 18, 16], [8, 18, 24], [8, 18, 32], [8, 18, 34], [8, 18, 37], [8, 21, 3], [8, 21, 4], [8, 21, 6], [8, 21, 24], [8, 21, 27], [8, 21, 28], [8, 21, 32], [8, 21, 36], [8, 24, 3], [8, 24, 4], [8, 24, 14], [8, 24, 18], [8, 24, 21], [8, 24, 27], [8, 24, 32], [8, 24, 37], [8, 25, 2], [8, 25, 7], [8, 25, 9], [8, 25, 12], [8, 25, 16], [8, 25, 17], [8, 25, 34], [8, 25, 42], [8, 27, 1], [8, 27, 4], [8, 27, 6], [8, 27, 21], [8, 27, 24], [8, 27, 28], [8, 27, 32], [8, 27, 36], [8, 28, 1], [8, 28, 4], [8, 28, 6], [8, 28, 8], [8, 28, 21], [8, 28, 27], [8, 28, 32], [8, 28, 36], [8, 32, 3], [8, 32, 4], [8, 32, 18], [8, 32, 21], [8, 32, 24], [8, 32, 27], [8, 32, 28], [8, 32, 36], [8, 34, 2], [8, 34, 3], [8, 34, 12], [8, 34, 14], [8, 34, 16], [8, 34, 18], [8, 34, 25], [8, 34, 37], [8, 36, 1], [8, 36, 6], [8, 36, 8], [8, 36, 17], [8, 36, 21], [8, 36, 27], [8, 36, 28], [8, 36, 32], [8, 37, 2], [8, 37, 3], [8, 37, 12], [8, 37, 14], [8, 37, 16], [8, 37, 18], [8, 37, 24], [8, 37, 34], [8, 42, 1], [8, 42, 6], [8, 42, 7], [8, 42, 8], [8, 42, 9], [8, 42, 12], [8, 42, 17], [8, 42, 25], [9, 0, 9], [9, 1, 2], [9, 1, 9], [9, 1, 18], [9, 1, 21], [9, 1, 24], [9, 1, 28], [9, 1, 34], [9, 1, 42], [9, 2, 1], [9, 2, 4], [9, 2, 9], [9, 2, 18], [9, 2, 21], [9, 2, 36], [9, 2, 37], [9, 2, 42], [9, 3, 6], [9, 3, 7], [9, 3, 8], [9, 3, 16], [9, 3, 25], [9, 3, 27], [9, 3, 32], [9, 3, 37], [9, 4, 2], [9, 4, 8], [9, 4, 18], [9, 4, 25], [9, 4, 27], [9, 4, 36], [9, 4, 37], [9, 4, 42], [9, 6, 3], [9, 6, 7], [9, 6, 12], [9, 6, 14], [9, 6, 16], [9, 6, 17], [9, 6, 27], [9, 6, 32], [9, 7, 3], [9, 7, 6], [9, 7, 8], [9, 7, 12], [9, 7, 14], [9, 7, 16], [9, 7, 27], [9, 7, 32], [9, 8, 3], [9, 8, 4], [9, 8, 7], [9, 8, 16], [9, 8, 25], [9, 8, 27], [9, 8, 36], [9, 8, 37], [9, 9, 0], [9, 9, 1], [9, 9, 2], [9, 9, 9], [9, 9, 17], [9, 9, 18], [9, 9, 21], [9, 9, 24], [9, 9, 28], [9, 9, 34], [9, 12, 6], [9, 12, 7], [9, 12, 14], [9, 12, 17], [9, 12, 24], [9, 12, 28], [9, 12, 32], [9, 12, 34], [9, 14, 6], [9, 14, 7], [9, 14, 12], [9, 14, 16], [9, 14, 17], [9, 14, 24], [9, 14, 28], [9, 14, 32], [9, 16, 3], [9, 16, 6], [9, 16, 7], [9, 16, 8], [9, 16, 14], [9, 16, 25], [9, 16, 27], [9, 16, 32], [9, 17, 6], [9, 17, 9], [9, 17, 12], [9, 17, 14], [9, 17, 24], [9, 17, 28], [9, 17, 32], [9, 17, 34], [9, 18, 1], [9, 18, 2], [9, 18, 4], [9, 18, 9], [9, 18, 21], [9, 18, 34], [9, 18, 36], [9, 18, 42], [9, 21, 1], [9, 21, 2], [9, 21, 9], [9, 21, 18], [9, 21, 24], [9, 21, 34], [9, 21, 36], [9, 21, 42], [9, 24, 1], [9, 24, 9], [9, 24, 12], [9, 24, 14], [9, 24, 17], [9, 24, 21], [9, 24, 28], [9, 24, 34], [9, 25, 3], [9, 25, 4], [9, 25, 8], [9, 25, 16], [9, 25, 27], [9, 25, 36], [9, 25, 37], [9, 25, 42], [9, 27, 3], [9, 27, 4], [9, 27, 6], [9, 27, 7], [9, 27, 8], [9, 27, 16], [9, 27, 25], [9, 27, 37], [9, 28, 1], [9, 28, 9], [9, 28, 12], [9, 28, 14], [9, 28, 17], [9, 28, 24], [9, 28, 32], [9, 28, 34], [9, 32, 3], [9, 32, 6], [9, 32, 7], [9, 32, 12], [9, 32, 14], [9, 32, 16], [9, 32, 17], [9, 32, 28], [9, 34, 1], [9, 34, 9], [9, 34, 12], [9, 34, 17], [9, 34, 18], [9, 34, 21], [9, 34, 24], [9, 34, 28], [9, 36, 2], [9, 36, 4], [9, 36, 8], [9, 36, 18], [9, 36, 21], [9, 36, 25], [9, 36, 37], [9, 36, 42], [9, 37, 2], [9, 37, 3], [9, 37, 4], [9, 37, 8], [9, 37, 25], [9, 37, 27], [9, 37, 36], [9, 37, 42], [9, 42, 1], [9, 42, 2], [9, 42, 4], [9, 42, 18], [9, 42, 21], [9, 42, 25], [9, 42, 36], [9, 42, 37], [10, 0, 10], [10, 1, 6], [10, 1, 8], [10, 1, 10], [10, 1, 13], [10, 1, 17], [10, 1, 29], [10, 1, 33], [10, 1, 36], [10, 2, 11], [10, 2, 12], [10, 2, 16], [10, 2, 19], [10, 2, 20], [10, 2, 25], [10, 2, 26], [10, 2, 34], [10, 3, 4], [10, 3, 5], [10, 3, 14], [10, 3, 18], [10, 3, 24], [10, 3, 30], [10, 3, 39], [10, 3, 40], [10, 4, 3], [10, 4, 5], [10, 4, 21], [10, 4, 22], [10, 4, 24], [10, 4, 32], [10, 4, 38], [10, 4, 40], [10, 5, 3], [10, 5, 4], [10, 5, 18], [10, 5, 24], [10, 5, 30], [10, 5, 38], [10, 5, 39], [10, 5, 40], [10, 6, 1], [10, 6, 8], [10, 6, 10], [10, 6, 13], [10, 6, 28], [10, 6, 31], [10, 6, 33], [10, 6, 36], [10, 7, 9], [10, 7, 15], [10, 7, 17], [10, 7, 23], [10, 7, 25], [10, 7, 42], [10, 7, 43], [10, 7, 44], [10, 8, 1], [10, 8, 6], [10, 8, 10], [10, 8, 17], [10, 8, 29], [10, 8, 33], [10, 8, 42], [10, 8, 44], [10, 9, 7], [10, 9, 12], [10, 9, 15], [10, 9, 23], [10, 9, 25], [10, 9, 26], [10, 9, 42], [10, 9, 43], [10, 10, 0], [10, 10, 1], [10, 10, 6], [10, 10, 8], [10, 10, 10], [10, 10, 13], [10, 10, 29], [10, 10, 31], [10, 10, 33], [10, 10, 36], [10, 11, 2], [10, 11, 16], [10, 11, 19], [10, 11, 20], [10, 11, 34], [10, 11, 37], [10, 11, 41], [10, 11, 46], [10, 12, 2], [10, 12, 9], [10, 12, 15], [10, 12, 16], [10, 12, 19], [10, 12, 20], [10, 12, 25], [10, 12, 26], [10, 13, 1], [10, 13, 6], [10, 13, 10], [10, 13, 28], [10, 13, 31], [10, 13, 33], [10, 13, 36], [10, 13, 45], [10, 14, 3], [10, 14, 18], [10, 14, 30], [10, 14, 34], [10, 14, 37], [10, 14, 39], [10, 14, 41], [10, 14, 46], [10, 15, 7], [10, 15, 9], [10, 15, 12], [10, 15, 20], [10, 15, 23], [10, 15, 25], [10, 15, 26], [10, 15, 43], [10, 16, 2], [10, 16, 11], [10, 16, 12], [10, 16, 19], [10, 16, 20], [10, 16, 34], [10, 16, 37], [10, 16, 41], [10, 17, 1], [10, 17, 7], [10, 17, 8], [10, 17, 23], [10, 17, 29], [10, 17, 33], [10, 17, 42], [10, 17, 44], [10, 18, 3], [10, 18, 5], [10, 18, 14], [10, 18, 24], [10, 18, 30], [10, 18, 37], [10, 18, 39], [10, 18, 46], [10, 19, 2], [10, 19, 11], [10, 19, 12], [10, 19, 16], [10, 19, 20], [10, 19, 26], [10, 19, 34], [10, 19, 41], [10, 20, 2], [10, 20, 11], [10, 20, 12], [10, 20, 15], [10, 20, 16], [10, 20, 19], [10, 20, 25], [10, 20, 26], [10, 21, 4], [10, 21, 22], [10, 21, 27], [10, 21, 28], [10, 21, 32], [10, 21, 35], [10, 21, 38], [10, 21, 45], [10, 22, 4], [10, 22, 21], [10, 22, 27], [10, 22, 32], [10, 22, 35], [10, 22, 38], [10, 22, 40], [10, 22, 45], [10, 23, 7], [10, 23, 9], [10, 23, 15], [10, 23, 17], [10, 23, 29], [10, 23, 42], [10, 23, 43], [10, 23, 44], [10, 24, 3], [10, 24, 4], [10, 24, 5], [10, 24, 18], [10, 24, 30], [10, 24, 32], [10, 24, 38], [10, 24, 40], [10, 25, 2], [10, 25, 7], [10, 25, 9], [10, 25, 12], [10, 25, 15], [10, 25, 20], [10, 25, 26], [10, 25, 43], [10, 26, 2], [10, 26, 9], [10, 26, 12], [10, 26, 15], [10, 26, 19], [10, 26, 20], [10, 26, 25], [10, 26, 43], [10, 27, 21], [10, 27, 22], [10, 27, 28], [10, 27, 31], [10, 27, 32], [10, 27, 35], [10, 27, 36], [10, 27, 45], [10, 28, 6], [10, 28, 13], [10, 28, 21], [10, 28, 27], [10, 28, 31], [10, 28, 35], [10, 28, 36], [10, 28, 45], [10, 29, 1], [10, 29, 8], [10, 29, 10], [10, 29, 17], [10, 29, 23], [10, 29, 33], [10, 29, 42], [10, 29, 44], [10, 30, 3], [10, 30, 5], [10, 30, 14], [10, 30, 18], [10, 30, 24], [10, 30, 39], [10, 30, 40], [10, 30, 46], [10, 31, 6], [10, 31, 10], [10, 31, 13], [10, 31, 27], [10, 31, 28], [10, 31, 35], [10, 31, 36], [10, 31, 45], [10, 32, 4], [10, 32, 21], [10, 32, 22], [10, 32, 24], [10, 32, 27], [10, 32, 35], [10, 32, 38], [10, 32, 40], [10, 33, 1], [10, 33, 6], [10, 33, 8], [10, 33, 10], [10, 33, 13], [10, 33, 17], [10, 33, 29], [10, 33, 44], [10, 34, 2], [10, 34, 11], [10, 34, 14], [10, 34, 16], [10, 34, 19], [10, 34, 37], [10, 34, 41], [10, 34, 46], [10, 35, 21], [10, 35, 22], [10, 35, 27], [10, 35, 28], [10, 35, 31], [10, 35, 32], [10, 35, 38], [10, 35, 45], [10, 36, 1], [10, 36, 6], [10, 36, 10], [10, 36, 13], [10, 36, 27], [10, 36, 28], [10, 36, 31], [10, 36, 45], [10, 37, 11], [10, 37, 14], [10, 37, 16], [10, 37, 18], [10, 37, 34], [10, 37, 39], [10, 37, 41], [10, 37, 46], [10, 38, 4], [10, 38, 5], [10, 38, 21], [10, 38, 22], [10, 38, 24], [10, 38, 32], [10, 38, 35], [10, 38, 40], [10, 39, 3], [10, 39, 5], [10, 39, 14], [10, 39, 18], [10, 39, 30], [10, 39, 37], [10, 39, 41], [10, 39, 46], [10, 40, 3], [10, 40, 4], [10, 40, 5], [10, 40, 22], [10, 40, 24], [10, 40, 30], [10, 40, 32], [10, 40, 38], [10, 41, 11], [10, 41, 14], [10, 41, 16], [10, 41, 19], [10, 41, 34], [10, 41, 37], [10, 41, 39], [10, 41, 46], [10, 42, 7], [10, 42, 8], [10, 42, 9], [10, 42, 17], [10, 42, 23], [10, 42, 29], [10, 42, 43], [10, 42, 44], [10, 43, 7], [10, 43, 9], [10, 43, 15], [10, 43, 23], [10, 43, 25], [10, 43, 26], [10, 43, 42], [10, 43, 44], [10, 44, 7], [10, 44, 8], [10, 44, 17], [10, 44, 23], [10, 44, 29], [10, 44, 33], [10, 44, 42], [10, 44, 43], [10, 45, 13], [10, 45, 21], [10, 45, 22], [10, 45, 27], [10, 45, 28], [10, 45, 31], [10, 45, 35], [10, 45, 36], [10, 46, 11], [10, 46, 14], [10, 46, 18], [10, 46, 30], [10, 46, 34], [10, 46, 37], [10, 46, 39], [10, 46, 41], [11, 0, 11], [11, 1, 2], [11, 1, 7], [11, 1, 11], [11, 1, 15], [11, 1, 22], [11, 1, 24], [11, 1, 27], [11, 1, 30], [11, 2, 1], [11, 2, 4], [11, 2, 7], [11, 2, 13], [11, 2, 14], [11, 2, 22], [11, 2, 30], [11, 2, 44], [11, 3, 6], [11, 3, 19], [11, 3, 21], [11, 3, 25], [11, 3, 33], [11, 3, 34], [11, 3, 43], [11, 3, 45], [11, 4, 2], [11, 4, 8], [11, 4, 13], [11, 4, 14], [11, 4, 26], [11, 4, 28], [11, 4, 41], [11, 4, 44], [11, 5, 8], [11, 5, 9], [11, 5, 10], [11, 5, 16], [11, 5, 26], [11, 5, 28], [11, 5, 35], [11, 5, 41], [11, 6, 3], [11, 6, 12], [11, 6, 19], [11, 6, 21], [11, 6, 38], [11, 6, 39], [11, 6, 42], [11, 6, 43], [11, 7, 1], [11, 7, 2], [11, 7, 11], [11, 7, 13], [11, 7, 14], [11, 7, 22], [11, 7, 27], [11, 7, 30], [11, 8, 4], [11, 8, 5], [11, 8, 9], [11, 8, 16], [11, 8, 26], [11, 8, 28], [11, 8, 35], [11, 8, 41], [11, 9, 5], [11, 9, 8], [11, 9, 10], [11, 9, 16], [11, 9, 18], [11, 9, 28], [11, 9, 35], [11, 9, 41], [11, 10, 5], [11, 10, 9], [11, 10, 16], [11, 10, 18], [11, 10, 20], [11, 10, 23], [11, 10, 32], [11, 10, 35], [11, 11, 0], [11, 11, 1], [11, 11, 7], [11, 11, 11], [11, 11, 15], [11, 11, 22], [11, 11, 24], [11, 11, 27], [11, 11, 29], [11, 11, 30], [11, 12, 6], [11, 12, 24], [11, 12, 29], [11, 12, 31], [11, 12, 37], [11, 12, 38], [11, 12, 39], [11, 12, 42], [11, 13, 2], [11, 13, 4], [11, 13, 7], [11, 13, 14], [11, 13, 22], [11, 13, 26], [11, 13, 30], [11, 13, 44], [11, 14, 2], [11, 14, 4], [11, 14, 7], [11, 14, 13], [11, 14, 22], [11, 14, 26], [11, 14, 28], [11, 14, 44], [11, 15, 1], [11, 15, 11], [11, 15, 24], [11, 15, 27], [11, 15, 29], [11, 15, 30], [11, 15, 31], [11, 15, 37], [11, 16, 5], [11, 16, 8], [11, 16, 9], [11, 16, 10], [11, 16, 18], [11, 16, 23], [11, 16, 32], [11, 16, 35], [11, 17, 20], [11, 17, 25], [11, 17, 32], [11, 17, 34], [11, 17, 36], [11, 17, 40], [11, 17, 45], [11, 17, 46], [11, 18, 9], [11, 18, 10], [11, 18, 16], [11, 18, 20], [11, 18, 23], [11, 18, 32], [11, 18, 35], [11, 18, 36], [11, 19, 3], [11, 19, 6], [11, 19, 21], [11, 19, 33], [11, 19, 38], [11, 19, 39], [11, 19, 42], [11, 19, 43], [11, 20, 10], [11, 20, 17], [11, 20, 18], [11, 20, 23], [11, 20, 32], [11, 20, 36], [11, 20, 40], [11, 20, 46], [11, 21, 3], [11, 21, 6], [11, 21, 19], [11, 21, 33], [11, 21, 34], [11, 21, 39], [11, 21, 42], [11, 21, 43], [11, 22, 1], [11, 22, 2], [11, 22, 7], [11, 22, 11], [11, 22, 13], [11, 22, 14], [11, 22, 30], [11, 22, 44], [11, 23, 10], [11, 23, 16], [11, 23, 18], [11, 23, 20], [11, 23, 32], [11, 23, 35], [11, 23, 36], [11, 23, 46], [11, 24, 1], [11, 24, 11], [11, 24, 12], [11, 24, 15], [11, 24, 27], [11, 24, 29], [11, 24, 31], [11, 24, 37], [11, 25, 3], [11, 25, 17], [11, 25, 33], [11, 25, 34], [11, 25, 36], [11, 25, 40], [11, 25, 45], [11, 25, 46], [11, 26, 4], [11, 26, 5], [11, 26, 8], [11, 26, 13], [11, 26, 14], [11, 26, 28], [11, 26, 41], [11, 26, 44], [11, 27, 1], [11, 27, 7], [11, 27, 11], [11, 27, 15], [11, 27, 24], [11, 27, 29], [11, 27, 30], [11, 27, 37], [11, 28, 4], [11, 28, 5], [11, 28, 8], [11, 28, 9], [11, 28, 14], [11, 28, 26], [11, 28, 41], [11, 28, 44], [11, 29, 11], [11, 29, 12], [11, 29, 15], [11, 29, 24], [11, 29, 27], [11, 29, 31], [11, 29, 37], [11, 29, 38], [11, 30, 1], [11, 30, 2], [11, 30, 7], [11, 30, 11], [11, 30, 13], [11, 30, 15], [11, 30, 22], [11, 30, 27], [11, 31, 12], [11, 31, 15], [11, 31, 24], [11, 31, 29], [11, 31, 37], [11, 31, 38], [11, 31, 39], [11, 31, 42], [11, 32, 10], [11, 32, 16], [11, 32, 17], [11, 32, 18], [11, 32, 20], [11, 32, 23], [11, 32, 36], [11, 32, 46], [11, 33, 3], [11, 33, 19], [11, 33, 21], [11, 33, 25], [11, 33, 34], [11, 33, 40], [11, 33, 43], [11, 33, 45], [11, 34, 3], [11, 34, 17], [11, 34, 21], [11, 34, 25], [11, 34, 33], [11, 34, 40], [11, 34, 43], [11, 34, 45], [11, 35, 5], [11, 35, 8], [11, 35, 9], [11, 35, 10], [11, 35, 16], [11, 35, 18], [11, 35, 23], [11, 35, 41], [11, 36, 17], [11, 36, 18], [11, 36, 20], [11, 36, 23], [11, 36, 25], [11, 36, 32], [11, 36, 40], [11, 36, 46], [11, 37, 12], [11, 37, 15], [11, 37, 24], [11, 37, 27], [11, 37, 29], [11, 37, 31], [11, 37, 38], [11, 37, 42], [11, 38, 6], [11, 38, 12], [11, 38, 19], [11, 38, 29], [11, 38, 31], [11, 38, 37], [11, 38, 39], [11, 38, 42], [11, 39, 6], [11, 39, 12], [11, 39, 19], [11, 39, 21], [11, 39, 31], [11, 39, 38], [11, 39, 42], [11, 39, 43], [11, 40, 17], [11, 40, 20], [11, 40, 25], [11, 40, 33], [11, 40, 34], [11, 40, 36], [11, 40, 45], [11, 40, 46], [11, 41, 4], [11, 41, 5], [11, 41, 8], [11, 41, 9], [11, 41, 26], [11, 41, 28], [11, 41, 35], [11, 41, 44], [11, 42, 6], [11, 42, 12], [11, 42, 19], [11, 42, 21], [11, 42, 31], [11, 42, 37], [11, 42, 38], [11, 42, 39], [11, 43, 3], [11, 43, 6], [11, 43, 19], [11, 43, 21], [11, 43, 33], [11, 43, 34], [11, 43, 39], [11, 43, 45], [11, 44, 2], [11, 44, 4], [11, 44, 13], [11, 44, 14], [11, 44, 22], [11, 44, 26], [11, 44, 28], [11, 44, 41], [11, 45, 3], [11, 45, 17], [11, 45, 25], [11, 45, 33], [11, 45, 34], [11, 45, 40], [11, 45, 43], [11, 45, 46], [11, 46, 17], [11, 46, 20], [11, 46, 23], [11, 46, 25], [11, 46, 32], [11, 46, 36], [11, 46, 40], [11, 46, 45], [12, 0, 12], [12, 1, 3], [12, 1, 4], [12, 1, 9], [12, 1, 12], [12, 1, 16], [12, 1, 17], [12, 1, 21], [12, 1, 36], [12, 2, 6], [12, 2, 8], [12, 2, 18], [12, 2, 24], [12, 2, 25], [12, 2, 32], [12, 2, 34], [12, 2, 42], [12, 3, 1], [12, 3, 4], [12, 3, 9], [12, 3, 12], [12, 3, 14], [12, 3, 16], [12, 3, 27], [12, 3, 36], [12, 4, 1], [12, 4, 3], [12, 4, 12], [12, 4, 16], [12, 4, 17], [12, 4, 21], [12, 4, 36], [12, 4, 37], [12, 6, 2], [12, 6, 7], [12, 6, 8], [12, 6, 18], [12, 6, 24], [12, 6, 25], [12, 6, 28], [12, 6, 32], [12, 7, 6], [12, 7, 16], [12, 7, 17], [12, 7, 18], [12, 7, 21], [12, 7, 25], [12, 7, 28], [12, 7, 37], [12, 8, 2], [12, 8, 6], [12, 8, 24], [12, 8, 25], [12, 8, 27], [12, 8, 32], [12, 8, 34], [12, 8, 42], [12, 9, 1], [12, 9, 3], [12, 9, 12], [12, 9, 14], [12, 9, 27], [12, 9, 34], [12, 9, 36], [12, 9, 42], [12, 12, 0], [12, 12, 1], [12, 12, 3], [12, 12, 4], [12, 12, 9], [12, 12, 12], [12, 12, 14], [12, 12, 16], [12, 12, 17], [12, 12, 36], [12, 14, 3], [12, 14, 9], [12, 14, 12], [12, 14, 27], [12, 14, 32], [12, 14, 34], [12, 14, 36], [12, 14, 42], [12, 16, 1], [12, 16, 3], [12, 16, 4], [12, 16, 7], [12, 16, 12], [12, 16, 17], [12, 16, 21], [12, 16, 37], [12, 17, 1], [12, 17, 4], [12, 17, 7], [12, 17, 12], [12, 17, 16], [12, 17, 21], [12, 17, 28], [12, 17, 37], [12, 18, 2], [12, 18, 6], [12, 18, 7], [12, 18, 21], [12, 18, 24], [12, 18, 25], [12, 18, 28], [12, 18, 37], [12, 21, 1], [12, 21, 4], [12, 21, 7], [12, 21, 16], [12, 21, 17], [12, 21, 18], [12, 21, 28], [12, 21, 37], [12, 24, 2], [12, 24, 6], [12, 24, 8], [12, 24, 18], [12, 24, 25], [12, 24, 28], [12, 24, 32], [12, 24, 34], [12, 25, 2], [12, 25, 6], [12, 25, 7], [12, 25, 8], [12, 25, 18], [12, 25, 24], [12, 25, 28], [12, 25, 37], [12, 27, 3], [12, 27, 8], [12, 27, 9], [12, 27, 14], [12, 27, 32], [12, 27, 34], [12, 27, 36], [12, 27, 42], [12, 28, 6], [12, 28, 7], [12, 28, 17], [12, 28, 18], [12, 28, 21], [12, 28, 24], [12, 28, 25], [12, 28, 37], [12, 32, 2], [12, 32, 6], [12, 32, 8], [12, 32, 14], [12, 32, 24], [12, 32, 27], [12, 32, 34], [12, 32, 42], [12, 34, 2], [12, 34, 8], [12, 34, 9], [12, 34, 14], [12, 34, 24], [12, 34, 27], [12, 34, 32], [12, 34, 42], [12, 36, 1], [12, 36, 3], [12, 36, 4], [12, 36, 9], [12, 36, 12], [12, 36, 14], [12, 36, 27], [12, 36, 42], [12, 37, 4], [12, 37, 7], [12, 37, 16], [12, 37, 17], [12, 37, 18], [12, 37, 21], [12, 37, 25], [12, 37, 28], [12, 42, 2], [12, 42, 8], [12, 42, 9], [12, 42, 14], [12, 42, 27], [12, 42, 32], [12, 42, 34], [12, 42, 36], [13, 0, 13], [13, 1, 13], [13, 1, 25], [13, 1, 28], [13, 1, 29], [13, 1, 32], [13, 1, 35], [13, 1, 42], [13, 1, 43], [13, 2, 3], [13, 2, 9], [13, 2, 11], [13, 2, 17], [13, 2, 23], [13, 2, 26], [13, 2, 37], [13, 2, 39], [13, 3, 2], [13, 3, 11], [13, 3, 28], [13, 3, 32], [13, 3, 35], [13, 3, 37], [13, 3, 39], [13, 3, 40], [13, 4, 5], [13, 4, 6], [13, 4, 18], [13, 4, 22], [13, 4, 27], [13, 4, 31], [13, 4, 34], [13, 4, 46], [13, 5, 4], [13, 5, 18], [13, 5, 19], [13, 5, 22], [13, 5, 27], [13, 5, 31], [13, 5, 34], [13, 5, 46], [13, 6, 4], [13, 6, 9], [13, 6, 17], [13, 6, 22], [13, 6, 23], [13, 6, 27], [13, 6, 31], [13, 6, 33], [13, 7, 8], [13, 7, 10], [13, 7, 12], [13, 7, 15], [13, 7, 19], [13, 7, 34], [13, 7, 36], [13, 7, 44], [13, 8, 7], [13, 8, 10], [13, 8, 12], [13, 8, 15], [13, 8, 21], [13, 8, 36], [13, 8, 44], [13, 8, 45], [13, 9, 2], [13, 9, 6], [13, 9, 11], [13, 9, 17], [13, 9, 23], [13, 9, 26], [13, 9, 33], [13, 9, 37], [13, 10, 7], [13, 10, 8], [13, 10, 15], [13, 10, 21], [13, 10, 36], [13, 10, 38], [13, 10, 44], [13, 10, 45], [13, 11, 2], [13, 11, 3], [13, 11, 9], [13, 11, 23], [13, 11, 26], [13, 11, 37], [13, 11, 39], [13, 11, 40], [13, 12, 7], [13, 12, 8], [13, 12, 15], [13, 12, 18], [13, 12, 19], [13, 12, 34], [13, 12, 44], [13, 12, 46], [13, 13, 0], [13, 13, 1], [13, 13, 13], [13, 13, 28], [13, 13, 29], [13, 13, 32], [13, 13, 35], [13, 13, 40], [13, 13, 42], [13, 13, 43], [13, 14, 16], [13, 14, 20], [13, 14, 21], [13, 14, 24], [13, 14, 25], [13, 14, 30], [13, 14, 38], [13, 14, 41], [13, 15, 7], [13, 15, 8], [13, 15, 10], [13, 15, 12], [13, 15, 19], [13, 15, 34], [13, 15, 44], [13, 15, 46], [13, 16, 14], [13, 16, 20], [13, 16, 24], [13, 16, 25], [13, 16, 30], [13, 16, 41], [13, 16, 42], [13, 16, 43], [13, 17, 2], [13, 17, 6], [13, 17, 9], [13, 17, 23], [13, 17, 26], [13, 17, 27], [13, 17, 31], [13, 17, 33], [13, 18, 4], [13, 18, 5], [13, 18, 12], [13, 18, 19], [13, 18, 22], [13, 18, 27], [13, 18, 34], [13, 18, 46], [13, 19, 5], [13, 19, 7], [13, 19, 12], [13, 19, 15], [13, 19, 18], [13, 19, 34], [13, 19, 44], [13, 19, 46], [13, 20, 14], [13, 20, 16], [13, 20, 25], [13, 20, 29], [13, 20, 30], [13, 20, 41], [13, 20, 42], [13, 20, 43], [13, 21, 8], [13, 21, 10], [13, 21, 14], [13, 21, 24], [13, 21, 30], [13, 21, 36], [13, 21, 38], [13, 21, 45], [13, 22, 4], [13, 22, 5], [13, 22, 6], [13, 22, 18], [13, 22, 27], [13, 22, 31], [13, 22, 33], [13, 22, 46], [13, 23, 2], [13, 23, 6], [13, 23, 9], [13, 23, 11], [13, 23, 17], [13, 23, 26], [13, 23, 31], [13, 23, 33], [13, 24, 14], [13, 24, 16], [13, 24, 21], [13, 24, 30], [13, 24, 36], [13, 24, 38], [13, 24, 41], [13, 24, 45], [13, 25, 1], [13, 25, 14], [13, 25, 16], [13, 25, 20], [13, 25, 29], [13, 25, 41], [13, 25, 42], [13, 25, 43], [13, 26, 2], [13, 26, 9], [13, 26, 11], [13, 26, 17], [13, 26, 23], [13, 26, 33], [13, 26, 37], [13, 26, 39], [13, 27, 4], [13, 27, 5], [13, 27, 6], [13, 27, 17], [13, 27, 18], [13, 27, 22], [13, 27, 31], [13, 27, 33], [13, 28, 1], [13, 28, 3], [13, 28, 13], [13, 28, 29], [13, 28, 32], [13, 28, 35], [13, 28, 40], [13, 28, 42], [13, 29, 1], [13, 29, 13], [13, 29, 20], [13, 29, 25], [13, 29, 28], [13, 29, 35], [13, 29, 42], [13, 29, 43], [13, 30, 14], [13, 30, 16], [13, 30, 20], [13, 30, 21], [13, 30, 24], [13, 30, 38], [13, 30, 41], [13, 30, 45], [13, 31, 4], [13, 31, 5], [13, 31, 6], [13, 31, 17], [13, 31, 22], [13, 31, 23], [13, 31, 27], [13, 31, 33], [13, 32, 1], [13, 32, 3], [13, 32, 13], [13, 32, 28], [13, 32, 35], [13, 32, 37], [13, 32, 39], [13, 32, 40], [13, 33, 6], [13, 33, 9], [13, 33, 17], [13, 33, 22], [13, 33, 23], [13, 33, 26], [13, 33, 27], [13, 33, 31], [13, 34, 4], [13, 34, 5], [13, 34, 7], [13, 34, 12], [13, 34, 15], [13, 34, 18], [13, 34, 19], [13, 34, 46], [13, 35, 1], [13, 35, 3], [13, 35, 13], [13, 35, 28], [13, 35, 29], [13, 35, 32], [13, 35, 39], [13, 35, 40], [13, 36, 7], [13, 36, 8], [13, 36, 10], [13, 36, 21], [13, 36, 24], [13, 36, 38], [13, 36, 44], [13, 36, 45], [13, 37, 2], [13, 37, 3], [13, 37, 9], [13, 37, 11], [13, 37, 26], [13, 37, 32], [13, 37, 39], [13, 37, 40], [13, 38, 10], [13, 38, 14], [13, 38, 21], [13, 38, 24], [13, 38, 30], [13, 38, 36], [13, 38, 41], [13, 38, 45], [13, 39, 2], [13, 39, 3], [13, 39, 11], [13, 39, 26], [13, 39, 32], [13, 39, 35], [13, 39, 37], [13, 39, 40], [13, 40, 3], [13, 40, 11], [13, 40, 13], [13, 40, 28], [13, 40, 32], [13, 40, 35], [13, 40, 37], [13, 40, 39], [13, 41, 14], [13, 41, 16], [13, 41, 20], [13, 41, 24], [13, 41, 25], [13, 41, 30], [13, 41, 38], [13, 41, 43], [13, 42, 1], [13, 42, 13], [13, 42, 16], [13, 42, 20], [13, 42, 25], [13, 42, 28], [13, 42, 29], [13, 42, 43], [13, 43, 1], [13, 43, 13], [13, 43, 16], [13, 43, 20], [13, 43, 25], [13, 43, 29], [13, 43, 41], [13, 43, 42], [13, 44, 7], [13, 44, 8], [13, 44, 10], [13, 44, 12], [13, 44, 15], [13, 44, 19], [13, 44, 36], [13, 44, 45], [13, 45, 8], [13, 45, 10], [13, 45, 21], [13, 45, 24], [13, 45, 30], [13, 45, 36], [13, 45, 38], [13, 45, 44], [13, 46, 4], [13, 46, 5], [13, 46, 12], [13, 46, 15], [13, 46, 18], [13, 46, 19], [13, 46, 22], [13, 46, 34], [14, 0, 14], [14, 1, 6], [14, 1, 8], [14, 1, 14], [14, 1, 17], [14, 1, 18], [14, 1, 34], [14, 1, 36], [14, 1, 37], [14, 2, 12], [14, 2, 16], [14, 2, 21], [14, 2, 25], [14, 2, 27], [14, 2, 28], [14, 2, 34], [14, 2, 36], [14, 3, 4], [14, 3, 7], [14, 3, 8], [14, 3, 14], [14, 3, 17], [14, 3, 18], [14, 3, 24], [14, 3, 42], [14, 4, 3], [14, 4, 7], [14, 4, 9], [14, 4, 21], [14, 4, 24], [14, 4, 25], [14, 4, 32], [14, 4, 42], [14, 6, 1], [14, 6, 8], [14, 6, 14], [14, 6, 16], [14, 6, 28], [14, 6, 34], [14, 6, 36], [14, 6, 37], [14, 7, 3], [14, 7, 4], [14, 7, 9], [14, 7, 17], [14, 7, 24], [14, 7, 25], [14, 7, 32], [14, 7, 42], [14, 8, 1], [14, 8, 3], [14, 8, 6], [14, 8, 14], [14, 8, 17], [14, 8, 18], [14, 8, 37], [14, 8, 42], [14, 9, 4], [14, 9, 7], [14, 9, 12], [14, 9, 21], [14, 9, 24], [14, 9, 25], [14, 9, 32], [14, 9, 42], [14, 12, 2], [14, 12, 9], [14, 12, 16], [14, 12, 21], [14, 12, 25], [14, 12, 27], [14, 12, 28], [14, 12, 32], [14, 14, 0], [14, 14, 1], [14, 14, 3], [14, 14, 6], [14, 14, 8], [14, 14, 14], [14, 14, 17], [14, 14, 18], [14, 14, 34], [14, 14, 37], [14, 16, 2], [14, 16, 6], [14, 16, 12], [14, 16, 27], [14, 16, 28], [14, 16, 34], [14, 16, 36], [14, 16, 37], [14, 17, 1], [14, 17, 3], [14, 17, 7], [14, 17, 8], [14, 17, 14], [14, 17, 18], [14, 17, 24], [14, 17, 42], [14, 18, 1], [14, 18, 3], [14, 18, 8], [14, 18, 14], [14, 18, 17], [14, 18, 24], [14, 18, 37], [14, 18, 42], [14, 21, 2], [14, 21, 4], [14, 21, 9], [14, 21, 12], [14, 21, 25], [14, 21, 27], [14, 21, 28], [14, 21, 32], [14, 24, 3], [14, 24, 4], [14, 24, 7], [14, 24, 9], [14, 24, 17], [14, 24, 18], [14, 24, 32], [14, 24, 42], [14, 25, 2], [14, 25, 4], [14, 25, 7], [14, 25, 9], [14, 25, 12], [14, 25, 21], [14, 25, 27], [14, 25, 32], [14, 27, 2], [14, 27, 12], [14, 27, 16], [14, 27, 21], [14, 27, 25], [14, 27, 28], [14, 27, 32], [14, 27, 36], [14, 28, 2], [14, 28, 6], [14, 28, 12], [14, 28, 16], [14, 28, 21], [14, 28, 27], [14, 28, 34], [14, 28, 36], [14, 32, 4], [14, 32, 7], [14, 32, 9], [14, 32, 12], [14, 32, 21], [14, 32, 24], [14, 32, 25], [14, 32, 27], [14, 34, 1], [14, 34, 2], [14, 34, 6], [14, 34, 14], [14, 34, 16], [14, 34, 28], [14, 34, 36], [14, 34, 37], [14, 36, 1], [14, 36, 2], [14, 36, 6], [14, 36, 16], [14, 36, 27], [14, 36, 28], [14, 36, 34], [14, 36, 37], [14, 37, 1], [14, 37, 6], [14, 37, 8], [14, 37, 14], [14, 37, 16], [14, 37, 18], [14, 37, 34], [14, 37, 36], [14, 42, 3], [14, 42, 4], [14, 42, 7], [14, 42, 8], [14, 42, 9], [14, 42, 17], [14, 42, 18], [14, 42, 24], [15, 0, 15], [15, 1, 6], [15, 1, 8], [15, 1, 14], [15, 1, 15], [15, 1, 22], [15, 1, 26], [15, 1, 37], [15, 1, 38], [15, 2, 5], [15, 2, 12], [15, 2, 16], [15, 2, 27], [15, 2, 28], [15, 2, 29], [15, 2, 30], [15, 2, 44], [15, 3, 17], [15, 3, 18], [15, 3, 19], [15, 3, 20], [15, 3, 24], [15, 3, 31], [15, 3, 42], [15, 3, 45], [15, 4, 7], [15, 4, 9], [15, 4, 10], [15, 4, 11], [15, 4, 13], [15, 4, 24], [15, 4, 32], [15, 4, 41], [15, 5, 2], [15, 5, 16], [15, 5, 23], [15, 5, 28], [15, 5, 30], [15, 5, 36], [15, 5, 40], [15, 5, 44], [15, 6, 1], [15, 6, 15], [15, 6, 34], [15, 6, 36], [15, 6, 37], [15, 6, 38], [15, 6, 40], [15, 6, 43], [15, 7, 4], [15, 7, 9], [15, 7, 11], [15, 7, 13], [15, 7, 24], [15, 7, 31], [15, 7, 41], [15, 7, 42], [15, 8, 1], [15, 8, 14], [15, 8, 17], [15, 8, 18], [15, 8, 20], [15, 8, 22], [15, 8, 26], [15, 8, 35], [15, 9, 4], [15, 9, 7], [15, 9, 10], [15, 9, 13], [15, 9, 25], [15, 9, 32], [15, 9, 41], [15, 9, 46], [15, 10, 4], [15, 10, 9], [15, 10, 13], [15, 10, 25], [15, 10, 32], [15, 10, 33], [15, 10, 41], [15, 10, 46], [15, 11, 4], [15, 11, 7], [15, 11, 13], [15, 11, 19], [15, 11, 24], [15, 11, 31], [15, 11, 41], [15, 11, 42], [15, 12, 2], [15, 12, 21], [15, 12, 25], [15, 12, 27], [15, 12, 29], [15, 12, 30], [15, 12, 33], [15, 12, 39], [15, 13, 4], [15, 13, 7], [15, 13, 9], [15, 13, 10], [15, 13, 11], [15, 13, 24], [15, 13, 31], [15, 13, 41], [15, 14, 1], [15, 14, 8], [15, 14, 15], [15, 14, 18], [15, 14, 22], [15, 14, 26], [15, 14, 35], [15, 14, 37], [15, 15, 0], [15, 15, 1], [15, 15, 6], [15, 15, 14], [15, 15, 15], [15, 15, 22], [15, 15, 26], [15, 15, 37], [15, 15, 38], [15, 15, 43], [15, 16, 2], [15, 16, 5], [15, 16, 23], [15, 16, 28], [15, 16, 34], [15, 16, 36], [15, 16, 40], [15, 16, 44], [15, 17, 3], [15, 17, 8], [15, 17, 18], [15, 17, 19], [15, 17, 20], [15, 17, 35], [15, 17, 42], [15, 17, 45], [15, 18, 3], [15, 18, 8], [15, 18, 14], [15, 18, 17], [15, 18, 20], [15, 18, 26], [15, 18, 35], [15, 18, 45], [15, 19, 3], [15, 19, 11], [15, 19, 17], [15, 19, 20], [15, 19, 24], [15, 19, 31], [15, 19, 42], [15, 19, 45], [15, 20, 3], [15, 20, 8], [15, 20, 17], [15, 20, 18], [15, 20, 19], [15, 20, 26], [15, 20, 35], [15, 20, 45], [15, 21, 12], [15, 21, 25], [15, 21, 27], [15, 21, 29], [15, 21, 32], [15, 21, 33], [15, 21, 39], [15, 21, 46], [15, 22, 1], [15, 22, 8], [15, 22, 14], [15, 22, 15], [15, 22, 26], [15, 22, 35], [15, 22, 37], [15, 22, 38], [15, 23, 5], [15, 23, 16], [15, 23, 28], [15, 23, 34], [15, 23, 36], [15, 23, 40], [15, 23, 43], [15, 23, 44], [15, 24, 3], [15, 24, 4], [15, 24, 7], [15, 24, 11], [15, 24, 13], [15, 24, 19], [15, 24, 31], [15, 24, 42], [15, 25, 9], [15, 25, 10], [15, 25, 12], [15, 25, 21], [15, 25, 32], [15, 25, 33], [15, 25, 39], [15, 25, 46], [15, 26, 1], [15, 26, 8], [15, 26, 14], [15, 26, 15], [15, 26, 18], [15, 26, 20], [15, 26, 22], [15, 26, 35], [15, 27, 2], [15, 27, 12], [15, 27, 21], [15, 27, 28], [15, 27, 29], [15, 27, 30], [15, 27, 39], [15, 27, 44], [15, 28, 2], [15, 28, 5], [15, 28, 16], [15, 28, 23], [15, 28, 27], [15, 28, 30], [15, 28, 36], [15, 28, 44], [15, 29, 2], [15, 29, 12], [15, 29, 21], [15, 29, 27], [15, 29, 30], [15, 29, 33], [15, 29, 39], [15, 29, 44], [15, 30, 2], [15, 30, 5], [15, 30, 12], [15, 30, 27], [15, 30, 28], [15, 30, 29], [15, 30, 39], [15, 30, 44], [15, 31, 3], [15, 31, 7], [15, 31, 11], [15, 31, 13], [15, 31, 19], [15, 31, 24], [15, 31, 42], [15, 31, 45], [15, 32, 4], [15, 32, 9], [15, 32, 10], [15, 32, 21], [15, 32, 25], [15, 32, 33], [15, 32, 41], [15, 32, 46], [15, 33, 10], [15, 33, 12], [15, 33, 21], [15, 33, 25], [15, 33, 29], [15, 33, 32], [15, 33, 39], [15, 33, 46], [15, 34, 6], [15, 34, 16], [15, 34, 23], [15, 34, 36], [15, 34, 37], [15, 34, 38], [15, 34, 40], [15, 34, 43], [15, 35, 8], [15, 35, 14], [15, 35, 17], [15, 35, 18], [15, 35, 20], [15, 35, 22], [15, 35, 26], [15, 35, 45], [15, 36, 5], [15, 36, 6], [15, 36, 16], [15, 36, 23], [15, 36, 28], [15, 36, 34], [15, 36, 40], [15, 36, 43], [15, 37, 1], [15, 37, 6], [15, 37, 14], [15, 37, 15], [15, 37, 22], [15, 37, 34], [15, 37, 38], [15, 37, 43], [15, 38, 1], [15, 38, 6], [15, 38, 15], [15, 38, 22], [15, 38, 34], [15, 38, 37], [15, 38, 40], [15, 38, 43], [15, 39, 12], [15, 39, 21], [15, 39, 25], [15, 39, 27], [15, 39, 29], [15, 39, 30], [15, 39, 33], [15, 39, 46], [15, 40, 5], [15, 40, 6], [15, 40, 16], [15, 40, 23], [15, 40, 34], [15, 40, 36], [15, 40, 38], [15, 40, 43], [15, 41, 4], [15, 41, 7], [15, 41, 9], [15, 41, 10], [15, 41, 11], [15, 41, 13], [15, 41, 32], [15, 41, 46], [15, 42, 3], [15, 42, 7], [15, 42, 11], [15, 42, 17], [15, 42, 19], [15, 42, 24], [15, 42, 31], [15, 42, 45], [15, 43, 6], [15, 43, 15], [15, 43, 23], [15, 43, 34], [15, 43, 36], [15, 43, 37], [15, 43, 38], [15, 43, 40], [15, 44, 2], [15, 44, 5], [15, 44, 16], [15, 44, 23], [15, 44, 27], [15, 44, 28], [15, 44, 29], [15, 44, 30], [15, 45, 3], [15, 45, 17], [15, 45, 18], [15, 45, 19], [15, 45, 20], [15, 45, 31], [15, 45, 35], [15, 45, 42], [15, 46, 9], [15, 46, 10], [15, 46, 21], [15, 46, 25], [15, 46, 32], [15, 46, 33], [15, 46, 39], [15, 46, 41], [16, 0, 16], [16, 1, 3], [16, 1, 7], [16, 1, 9], [16, 1, 16], [16, 1, 18], [16, 1, 21], [16, 1, 27], [16, 1, 34], [16, 2, 6], [16, 2, 7], [16, 2, 14], [16, 2, 18], [16, 2, 21], [16, 2, 32], [16, 2, 36], [16, 2, 42], [16, 3, 1], [16, 3, 7], [16, 3, 8], [16, 3, 9], [16, 3, 16], [16, 3, 21], [16, 3, 27], [16, 3, 34], [16, 4, 12], [16, 4, 14], [16, 4, 17], [16, 4, 25], [16, 4, 28], [16, 4, 36], [16, 4, 37], [16, 4, 42], [16, 6, 2], [16, 6, 7], [16, 6, 14], [16, 6, 16], [16, 6, 18], [16, 6, 21], [16, 6, 32], [16, 6, 42], [16, 7, 1], [16, 7, 2], [16, 7, 3], [16, 7, 6], [16, 7, 16], [16, 7, 18], [16, 7, 21], [16, 7, 32], [16, 8, 3], [16, 8, 9], [16, 8, 24], [16, 8, 25], [16, 8, 27], [16, 8, 28], [16, 8, 34], [16, 8, 37], [16, 9, 1], [16, 9, 3], [16, 9, 8], [16, 9, 16], [16, 9, 21], [16, 9, 24], [16, 9, 27], [16, 9, 34], [16, 12, 4], [16, 12, 14], [16, 12, 17], [16, 12, 28], [16, 12, 32], [16, 12, 36], [16, 12, 37], [16, 12, 42], [16, 14, 2], [16, 14, 4], [16, 14, 6], [16, 14, 12], [16, 14, 17], [16, 14, 32], [16, 14, 36], [16, 14, 42], [16, 16, 0], [16, 16, 1], [16, 16, 3], [16, 16, 6], [16, 16, 7], [16, 16, 9], [16, 16, 16], [16, 16, 18], [16, 16, 21], [16, 16, 27], [16, 17, 4], [16, 17, 12], [16, 17, 14], [16, 17, 24], [16, 17, 25], [16, 17, 28], [16, 17, 36], [16, 17, 37], [16, 18, 1], [16, 18, 2], [16, 18, 6], [16, 18, 7], [16, 18, 16], [16, 18, 21], [16, 18, 32], [16, 18, 42], [16, 21, 1], [16, 21, 2], [16, 21, 3], [16, 21, 6], [16, 21, 7], [16, 21, 9], [16, 21, 16], [16, 21, 18], [16, 24, 8], [16, 24, 9], [16, 24, 17], [16, 24, 25], [16, 24, 27], [16, 24, 28], [16, 24, 34], [16, 24, 37], [16, 25, 4], [16, 25, 8], [16, 25, 17], [16, 25, 24], [16, 25, 27], [16, 25, 28], [16, 25, 34], [16, 25, 37], [16, 27, 1], [16, 27, 3], [16, 27, 8], [16, 27, 9], [16, 27, 16], [16, 27, 24], [16, 27, 25], [16, 27, 34], [16, 28, 4], [16, 28, 8], [16, 28, 12], [16, 28, 17], [16, 28, 24], [16, 28, 25], [16, 28, 34], [16, 28, 37], [16, 32, 2], [16, 32, 6], [16, 32, 7], [16, 32, 12], [16, 32, 14], [16, 32, 18], [16, 32, 36], [16, 32, 42], [16, 34, 1], [16, 34, 3], [16, 34, 8], [16, 34, 9], [16, 34, 24], [16, 34, 25], [16, 34, 27], [16, 34, 28], [16, 36, 2], [16, 36, 4], [16, 36, 12], [16, 36, 14], [16, 36, 17], [16, 36, 32], [16, 36, 37], [16, 36, 42], [16, 37, 4], [16, 37, 8], [16, 37, 12], [16, 37, 17], [16, 37, 24], [16, 37, 25], [16, 37, 28], [16, 37, 36], [16, 42, 2], [16, 42, 4], [16, 42, 6], [16, 42, 12], [16, 42, 14], [16, 42, 18], [16, 42, 32], [16, 42, 36], [17, 0, 17], [17, 1, 2], [17, 1, 7], [17, 1, 17], [17, 1, 24], [17, 1, 25], [17, 1, 27], [17, 1, 32], [17, 1, 36], [17, 2, 1], [17, 2, 3], [17, 2, 4], [17, 2, 7], [17, 2, 14], [17, 2, 17], [17, 2, 25], [17, 2, 34], [17, 3, 2], [17, 3, 4], [17, 3, 6], [17, 3, 14], [17, 3, 21], [17, 3, 25], [17, 3, 28], [17, 3, 34], [17, 4, 2], [17, 4, 3], [17, 4, 6], [17, 4, 8], [17, 4, 14], [17, 4, 21], [17, 4, 28], [17, 4, 34], [17, 6, 3], [17, 6, 4], [17, 6, 8], [17, 6, 9], [17, 6, 12], [17, 6, 21], [17, 6, 28], [17, 6, 42], [17, 7, 1], [17, 7, 2], [17, 7, 14], [17, 7, 17], [17, 7, 25], [17, 7, 27], [17, 7, 34], [17, 7, 36], [17, 8, 4], [17, 8, 6], [17, 8, 9], [17, 8, 12], [17, 8, 16], [17, 8, 21], [17, 8, 28], [17, 8, 42], [17, 9, 6], [17, 9, 8], [17, 9, 12], [17, 9, 16], [17, 9, 18], [17, 9, 28], [17, 9, 37], [17, 9, 42], [17, 12, 6], [17, 12, 8], [17, 12, 9], [17, 12, 16], [17, 12, 18], [17, 12, 24], [17, 12, 37], [17, 12, 42], [17, 14, 2], [17, 14, 3], [17, 14, 4], [17, 14, 7], [17, 14, 21], [17, 14, 25], [17, 14, 28], [17, 14, 34], [17, 16, 8], [17, 16, 9], [17, 16, 12], [17, 16, 18], [17, 16, 24], [17, 16, 32], [17, 16, 37], [17, 16, 42], [17, 17, 0], [17, 17, 1], [17, 17, 2], [17, 17, 7], [17, 17, 17], [17, 17, 25], [17, 17, 27], [17, 17, 32], [17, 17, 34], [17, 17, 36], [17, 18, 9], [17, 18, 12], [17, 18, 16], [17, 18, 24], [17, 18, 27], [17, 18, 32], [17, 18, 36], [17, 18, 37], [17, 21, 3], [17, 21, 4], [17, 21, 6], [17, 21, 8], [17, 21, 14], [17, 21, 28], [17, 21, 34], [17, 21, 42], [17, 24, 1], [17, 24, 12], [17, 24, 16], [17, 24, 18], [17, 24, 27], [17, 24, 32], [17, 24, 36], [17, 24, 37], [17, 25, 1], [17, 25, 2], [17, 25, 3], [17, 25, 7], [17, 25, 14], [17, 25, 17], [17, 25, 34], [17, 25, 36], [17, 27, 1], [17, 27, 7], [17, 27, 17], [17, 27, 18], [17, 27, 24], [17, 27, 32], [17, 27, 36], [17, 27, 37], [17, 28, 3], [17, 28, 4], [17, 28, 6], [17, 28, 8], [17, 28, 9], [17, 28, 14], [17, 28, 21], [17, 28, 42], [17, 32, 1], [17, 32, 16], [17, 32, 17], [17, 32, 18], [17, 32, 24], [17, 32, 27], [17, 32, 36], [17, 32, 37], [17, 34, 2], [17, 34, 3], [17, 34, 4], [17, 34, 7], [17, 34, 14], [17, 34, 17], [17, 34, 21], [17, 34, 25], [17, 36, 1], [17, 36, 7], [17, 36, 17], [17, 36, 18], [17, 36, 24], [17, 36, 25], [17, 36, 27], [17, 36, 32], [17, 37, 9], [17, 37, 12], [17, 37, 16], [17, 37, 18], [17, 37, 24], [17, 37, 27], [17, 37, 32], [17, 37, 42], [17, 42, 6], [17, 42, 8], [17, 42, 9], [17, 42, 12], [17, 42, 16], [17, 42, 21], [17, 42, 28], [17, 42, 37], [18, 0, 18], [18, 1, 4], [18, 1, 12], [18, 1, 18], [18, 1, 25], [18, 1, 28], [18, 1, 32], [18, 1, 34], [18, 1, 42], [18, 2, 3], [18, 2, 8], [18, 2, 9], [18, 2, 17], [18, 2, 21], [18, 2, 24], [18, 2, 36], [18, 2, 37], [18, 3, 2], [18, 3, 7], [18, 3, 8], [18, 3, 12], [18, 3, 28], [18, 3, 32], [18, 3, 36], [18, 3, 37], [18, 4, 1], [18, 4, 6], [18, 4, 16], [18, 4, 18], [18, 4, 25], [18, 4, 27], [18, 4, 34], [18, 4, 42], [18, 6, 4], [18, 6, 9], [18, 6, 14], [18, 6, 16], [18, 6, 17], [18, 6, 24], [18, 6, 25], [18, 6, 27], [18, 7, 3], [18, 7, 8], [18, 7, 12], [18, 7, 28], [18, 7, 32], [18, 7, 34], [18, 7, 36], [18, 7, 37], [18, 8, 2], [18, 8, 3], [18, 8, 7], [18, 8, 12], [18, 8, 21], [18, 8, 32], [18, 8, 36], [18, 8, 37], [18, 9, 2], [18, 9, 6], [18, 9, 14], [18, 9, 17], [18, 9, 21], [18, 9, 24], [18, 9, 36], [18, 9, 37], [18, 12, 1], [18, 12, 3], [18, 12, 7], [18, 12, 8], [18, 12, 18], [18, 12, 28], [18, 12, 32], [18, 12, 34], [18, 14, 6], [18, 14, 9], [18, 14, 16], [18, 14, 17], [18, 14, 21], [18, 14, 24], [18, 14, 25], [18, 14, 27], [18, 16, 4], [18, 16, 6], [18, 16, 14], [18, 16, 17], [18, 16, 24], [18, 16, 25], [18, 16, 27], [18, 16, 42], [18, 17, 2], [18, 17, 6], [18, 17, 9], [18, 17, 14], [18, 17, 16], [18, 17, 21], [18, 17, 24], [18, 17, 27], [18, 18, 0], [18, 18, 1], [18, 18, 4], [18, 18, 12], [18, 18, 18], [18, 18, 25], [18, 18, 27], [18, 18, 28], [18, 18, 34], [18, 18, 42], [18, 21, 2], [18, 21, 8], [18, 21, 9], [18, 21, 14], [18, 21, 17], [18, 21, 24], [18, 21, 36], [18, 21, 37], [18, 24, 2], [18, 24, 6], [18, 24, 9], [18, 24, 14], [18, 24, 16], [18, 24, 17], [18, 24, 21], [18, 24, 36], [18, 25, 1], [18, 25, 4], [18, 25, 6], [18, 25, 14], [18, 25, 16], [18, 25, 18], [18, 25, 27], [18, 25, 42], [18, 27, 4], [18, 27, 6], [18, 27, 14], [18, 27, 16], [18, 27, 17], [18, 27, 18], [18, 27, 25], [18, 27, 42], [18, 28, 1], [18, 28, 3], [18, 28, 7], [18, 28, 12], [18, 28, 18], [18, 28, 32], [18, 28, 34], [18, 28, 42], [18, 32, 1], [18, 32, 3], [18, 32, 7], [18, 32, 8], [18, 32, 12], [18, 32, 28], [18, 32, 34], [18, 32, 37], [18, 34, 1], [18, 34, 4], [18, 34, 7], [18, 34, 12], [18, 34, 18], [18, 34, 28], [18, 34, 32], [18, 34, 42], [18, 36, 2], [18, 36, 3], [18, 36, 7], [18, 36, 8], [18, 36, 9], [18, 36, 21], [18, 36, 24], [18, 36, 37], [18, 37, 2], [18, 37, 3], [18, 37, 7], [18, 37, 8], [18, 37, 9], [18, 37, 21], [18, 37, 32], [18, 37, 36], [18, 42, 1], [18, 42, 4], [18, 42, 16], [18, 42, 18], [18, 42, 25], [18, 42, 27], [18, 42, 28], [18, 42, 34], [19, 0, 19], [19, 1, 5], [19, 1, 14], [19, 1, 19], [19, 1, 25], [19, 1, 31], [19, 1, 32], [19, 1, 37], [19, 1, 44], [19, 2, 3], [19, 2, 10], [19, 2, 15], [19, 2, 17], [19, 2, 27], [19, 2, 28], [19, 2, 38], [19, 2, 41], [19, 3, 2], [19, 3, 10], [19, 3, 15], [19, 3, 17], [19, 3, 28], [19, 3, 38], [19, 3, 42], [19, 3, 46], [19, 4, 6], [19, 4, 7], [19, 4, 9], [19, 4, 20], [19, 4, 29], [19, 4, 30], [19, 4, 34], [19, 4, 35], [19, 5, 1], [19, 5, 14], [19, 5, 19], [19, 5, 23], [19, 5, 25], [19, 5, 31], [19, 5, 32], [19, 5, 44], [19, 6, 4], [19, 6, 9], [19, 6, 20], [19, 6, 29], [19, 6, 30], [19, 6, 34], [19, 6, 37], [19, 6, 45], [19, 7, 4], [19, 7, 24], [19, 7, 26], [19, 7, 29], [19, 7, 34], [19, 7, 35], [19, 7, 36], [19, 7, 39], [19, 8, 11], [19, 8, 12], [19, 8, 13], [19, 8, 14], [19, 8, 18], [19, 8, 21], [19, 8, 23], [19, 8, 40], [19, 9, 4], [19, 9, 6], [19, 9, 20], [19, 9, 30], [19, 9, 32], [19, 9, 37], [19, 9, 44], [19, 9, 45], [19, 10, 2], [19, 10, 3], [19, 10, 15], [19, 10, 17], [19, 10, 28], [19, 10, 38], [19, 10, 41], [19, 10, 46], [19, 11, 8], [19, 11, 12], [19, 11, 13], [19, 11, 14], [19, 11, 21], [19, 11, 23], [19, 11, 31], [19, 11, 40], [19, 12, 8], [19, 12, 11], [19, 12, 13], [19, 12, 18], [19, 12, 21], [19, 12, 27], [19, 12, 40], [19, 12, 43], [19, 13, 8], [19, 13, 11], [19, 13, 12], [19, 13, 18], [19, 13, 27], [19, 13, 40], [19, 13, 41], [19, 13, 43], [19, 14, 1], [19, 14, 5], [19, 14, 8], [19, 14, 11], [19, 14, 21], [19, 14, 23], [19, 14, 25], [19, 14, 31], [19, 15, 2], [19, 15, 3], [19, 15, 10], [19, 15, 22], [19, 15, 28], [19, 15, 38], [19, 15, 42], [19, 15, 46], [19, 16, 22], [19, 16, 24], [19, 16, 26], [19, 16, 28], [19, 16, 33], [19, 16, 36], [19, 16, 42], [19, 16, 46], [19, 17, 2], [19, 17, 3], [19, 17, 10], [19, 17, 18], [19, 17, 27], [19, 17, 38], [19, 17, 41], [19, 17, 43], [19, 18, 8], [19, 18, 12], [19, 18, 13], [19, 18, 17], [19, 18, 27], [19, 18, 40], [19, 18, 41], [19, 18, 43], [19, 19, 0], [19, 19, 1], [19, 19, 5], [19, 19, 19], [19, 19, 25], [19, 19, 31], [19, 19, 32], [19, 19, 37], [19, 19, 44], [19, 19, 45], [19, 20, 4], [19, 20, 6], [19, 20, 9], [19, 20, 29], [19, 20, 30], [19, 20, 34], [19, 20, 35], [19, 20, 45], [19, 21, 8], [19, 21, 11], [19, 21, 12], [19, 21, 14], [19, 21, 23], [19, 21, 25], [19, 21, 31], [19, 21, 40], [19, 22, 15], [19, 22, 16], [19, 22, 24], [19, 22, 26], [19, 22, 28], [19, 22, 33], [19, 22, 42], [19, 22, 46], [19, 23, 5], [19, 23, 8], [19, 23, 11], [19, 23, 14], [19, 23, 21], [19, 23, 25], [19, 23, 31], [19, 23, 40], [19, 24, 7], [19, 24, 16], [19, 24, 22], [19, 24, 26], [19, 24, 33], [19, 24, 36], [19, 24, 39], [19, 24, 42], [19, 25, 1], [19, 25, 5], [19, 25, 14], [19, 25, 19], [19, 25, 21], [19, 25, 23], [19, 25, 31], [19, 25, 32], [19, 26, 7], [19, 26, 16], [19, 26, 22], [19, 26, 24], [19, 26, 33], [19, 26, 35], [19, 26, 36], [19, 26, 39], [19, 27, 2], [19, 27, 12], [19, 27, 13], [19, 27, 17], [19, 27, 18], [19, 27, 38], [19, 27, 41], [19, 27, 43], [19, 28, 2], [19, 28, 3], [19, 28, 10], [19, 28, 15], [19, 28, 16], [19, 28, 22], [19, 28, 42], [19, 28, 46], [19, 29, 4], [19, 29, 6], [19, 29, 7], [19, 29, 20], [19, 29, 30], [19, 29, 34], [19, 29, 35], [19, 29, 39], [19, 30, 4], [19, 30, 6], [19, 30, 9], [19, 30, 20], [19, 30, 29], [19, 30, 37], [19, 30, 44], [19, 30, 45], [19, 31, 1], [19, 31, 5], [19, 31, 11], [19, 31, 14], [19, 31, 19], [19, 31, 21], [19, 31, 23], [19, 31, 25], [19, 32, 1], [19, 32, 5], [19, 32, 9], [19, 32, 19], [19, 32, 25], [19, 32, 37], [19, 32, 44], [19, 32, 45], [19, 33, 16], [19, 33, 22], [19, 33, 24], [19, 33, 26], [19, 33, 36], [19, 33, 39], [19, 33, 42], [19, 33, 46], [19, 34, 4], [19, 34, 6], [19, 34, 7], [19, 34, 20], [19, 34, 29], [19, 34, 35], [19, 34, 36], [19, 34, 39], [19, 35, 4], [19, 35, 7], [19, 35, 20], [19, 35, 26], [19, 35, 29], [19, 35, 34], [19, 35, 36], [19, 35, 39], [19, 36, 7], [19, 36, 16], [19, 36, 24], [19, 36, 26], [19, 36, 33], [19, 36, 34], [19, 36, 35], [19, 36, 39], [19, 37, 1], [19, 37, 6], [19, 37, 9], [19, 37, 19], [19, 37, 30], [19, 37, 32], [19, 37, 44], [19, 37, 45], [19, 38, 2], [19, 38, 3], [19, 38, 10], [19, 38, 15], [19, 38, 17], [19, 38, 27], [19, 38, 41], [19, 38, 43], [19, 39, 7], [19, 39, 24], [19, 39, 26], [19, 39, 29], [19, 39, 33], [19, 39, 34], [19, 39, 35], [19, 39, 36], [19, 40, 8], [19, 40, 11], [19, 40, 12], [19, 40, 13], [19, 40, 18], [19, 40, 21], [19, 40, 23], [19, 40, 43], [19, 41, 2], [19, 41, 10], [19, 41, 13], [19, 41, 17], [19, 41, 18], [19, 41, 27], [19, 41, 38], [19, 41, 43], [19, 42, 3], [19, 42, 15], [19, 42, 16], [19, 42, 22], [19, 42, 24], [19, 42, 28], [19, 42, 33], [19, 42, 46], [19, 43, 12], [19, 43, 13], [19, 43, 17], [19, 43, 18], [19, 43, 27], [19, 43, 38], [19, 43, 40], [19, 43, 41], [19, 44, 1], [19, 44, 5], [19, 44, 9], [19, 44, 19], [19, 44, 30], [19, 44, 32], [19, 44, 37], [19, 44, 45], [19, 45, 6], [19, 45, 9], [19, 45, 19], [19, 45, 20], [19, 45, 30], [19, 45, 32], [19, 45, 37], [19, 45, 44], [19, 46, 3], [19, 46, 10], [19, 46, 15], [19, 46, 16], [19, 46, 22], [19, 46, 28], [19, 46, 33], [19, 46, 42], [20, 0, 20], [20, 1, 2], [20, 1, 4], [20, 1, 10], [20, 1, 12], [20, 1, 20], [20, 1, 24], [20, 1, 33], [20, 1, 40], [20, 2, 1], [20, 2, 4], [20, 2, 8], [20, 2, 19], [20, 2, 20], [20, 2, 24], [20, 2, 33], [20, 2, 40], [20, 3, 5], [20, 3, 6], [20, 3, 12], [20, 3, 13], [20, 3, 25], [20, 3, 26], [20, 3, 30], [20, 3, 36], [20, 4, 1], [20, 4, 2], [20, 4, 8], [20, 4, 16], [20, 4, 19], [20, 4, 33], [20, 4, 38], [20, 4, 40], [20, 5, 3], [20, 5, 6], [20, 5, 10], [20, 5, 12], [20, 5, 13], [20, 5, 20], [20, 5, 24], [20, 5, 26], [20, 6, 3], [20, 6, 5], [20, 6, 10], [20, 6, 12], [20, 6, 13], [20, 6, 24], [20, 6, 25], [20, 6, 26], [20, 7, 14], [20, 7, 23], [20, 7, 27], [20, 7, 28], [20, 7, 37], [20, 7, 43], [20, 7, 45], [20, 7, 46], [20, 8, 2], [20, 8, 4], [20, 8, 16], [20, 8, 19], [20, 8, 29], [20, 8, 32], [20, 8, 33], [20, 8, 38], [20, 9, 14], [20, 9, 15], [20, 9, 18], [20, 9, 28], [20, 9, 31], [20, 9, 36], [20, 9, 39], [20, 9, 43], [20, 10, 1], [20, 10, 5], [20, 10, 6], [20, 10, 12], [20, 10, 20], [20, 10, 24], [20, 10, 26], [20, 10, 40], [20, 11, 16], [20, 11, 17], [20, 11, 22], [20, 11, 29], [20, 11, 32], [20, 11, 34], [20, 11, 38], [20, 11, 44], [20, 12, 1], [20, 12, 3], [20, 12, 5], [20, 12, 6], [20, 12, 10], [20, 12, 20], [20, 12, 24], [20, 12, 26], [20, 13, 3], [20, 13, 5], [20, 13, 6], [20, 13, 15], [20, 13, 25], [20, 13, 26], [20, 13, 30], [20, 13, 36], [20, 14, 7], [20, 14, 9], [20, 14, 27], [20, 14, 28], [20, 14, 39], [20, 14, 43], [20, 14, 45], [20, 14, 46], [20, 15, 9], [20, 15, 13], [20, 15, 18], [20, 15, 25], [20, 15, 30], [20, 15, 31], [20, 15, 36], [20, 15, 39], [20, 16, 4], [20, 16, 8], [20, 16, 11], [20, 16, 17], [20, 16, 19], [20, 16, 29], [20, 16, 32], [20, 16, 38], [20, 17, 11], [20, 17, 16], [20, 17, 21], [20, 17, 22], [20, 17, 29], [20, 17, 32], [20, 17, 34], [20, 17, 44], [20, 18, 9], [20, 18, 15], [20, 18, 25], [20, 18, 28], [20, 18, 30], [20, 18, 31], [20, 18, 36], [20, 18, 39], [20, 19, 2], [20, 19, 4], [20, 19, 8], [20, 19, 16], [20, 19, 29], [20, 19, 33], [20, 19, 38], [20, 19, 40], [20, 20, 0], [20, 20, 1], [20, 20, 2], [20, 20, 5], [20, 20, 10], [20, 20, 12], [20, 20, 20], [20, 20, 24], [20, 20, 33], [20, 20, 40], [20, 21, 17], [20, 21, 22], [20, 21, 34], [20, 21, 35], [20, 21, 37], [20, 21, 41], [20, 21, 42], [20, 21, 44], [20, 22, 11], [20, 22, 17], [20, 22, 21], [20, 22, 29], [20, 22, 32], [20, 22, 34], [20, 22, 41], [20, 22, 44], [20, 23, 7], [20, 23, 27], [20, 23, 35], [20, 23, 37], [20, 23, 41], [20, 23, 42], [20, 23, 45], [20, 23, 46], [20, 24, 1], [20, 24, 2], [20, 24, 5], [20, 24, 6], [20, 24, 10], [20, 24, 12], [20, 24, 20], [20, 24, 40], [20, 25, 3], [20, 25, 6], [20, 25, 13], [20, 25, 15], [20, 25, 18], [20, 25, 26], [20, 25, 30], [20, 25, 36], [20, 26, 3], [20, 26, 5], [20, 26, 6], [20, 26, 10], [20, 26, 12], [20, 26, 13], [20, 26, 25], [20, 26, 30], [20, 27, 7], [20, 27, 14], [20, 27, 23], [20, 27, 35], [20, 27, 37], [20, 27, 42], [20, 27, 45], [20, 27, 46], [20, 28, 7], [20, 28, 9], [20, 28, 14], [20, 28, 18], [20, 28, 31], [20, 28, 39], [20, 28, 43], [20, 28, 45], [20, 29, 8], [20, 29, 11], [20, 29, 16], [20, 29, 17], [20, 29, 19], [20, 29, 22], [20, 29, 32], [20, 29, 38], [20, 30, 3], [20, 30, 13], [20, 30, 15], [20, 30, 18], [20, 30, 25], [20, 30, 26], [20, 30, 31], [20, 30, 36], [20, 31, 9], [20, 31, 15], [20, 31, 18], [20, 31, 28], [20, 31, 30], [20, 31, 36], [20, 31, 39], [20, 31, 43], [20, 32, 8], [20, 32, 11], [20, 32, 16], [20, 32, 17], [20, 32, 22], [20, 32, 29], [20, 32, 34], [20, 32, 38], [20, 33, 1], [20, 33, 2], [20, 33, 4], [20, 33, 8], [20, 33, 19], [20, 33, 20], [20, 33, 38], [20, 33, 40], [20, 34, 11], [20, 34, 17], [20, 34, 21], [20, 34, 22], [20, 34, 32], [20, 34, 41], [20, 34, 42], [20, 34, 44], [20, 35, 21], [20, 35, 23], [20, 35, 27], [20, 35, 37], [20, 35, 41], [20, 35, 42], [20, 35, 44], [20, 35, 46], [20, 36, 3], [20, 36, 9], [20, 36, 13], [20, 36, 15], [20, 36, 18], [20, 36, 25], [20, 36, 30], [20, 36, 31], [20, 37, 7], [20, 37, 21], [20, 37, 23], [20, 37, 27], [20, 37, 35], [20, 37, 41], [20, 37, 42], [20, 37, 46], [20, 38, 4], [20, 38, 8], [20, 38, 11], [20, 38, 16], [20, 38, 19], [20, 38, 29], [20, 38, 32], [20, 38, 33], [20, 39, 9], [20, 39, 14], [20, 39, 15], [20, 39, 18], [20, 39, 28], [20, 39, 31], [20, 39, 43], [20, 39, 45], [20, 40, 1], [20, 40, 2], [20, 40, 4], [20, 40, 10], [20, 40, 19], [20, 40, 20], [20, 40, 24], [20, 40, 33], [20, 41, 21], [20, 41, 22], [20, 41, 23], [20, 41, 34], [20, 41, 35], [20, 41, 37], [20, 41, 42], [20, 41, 44], [20, 42, 21], [20, 42, 23], [20, 42, 27], [20, 42, 34], [20, 42, 35], [20, 42, 37], [20, 42, 41], [20, 42, 44], [20, 43, 7], [20, 43, 9], [20, 43, 14], [20, 43, 28], [20, 43, 31], [20, 43, 39], [20, 43, 45], [20, 43, 46], [20, 44, 11], [20, 44, 17], [20, 44, 21], [20, 44, 22], [20, 44, 34], [20, 44, 35], [20, 44, 41], [20, 44, 42], [20, 45, 7], [20, 45, 14], [20, 45, 23], [20, 45, 27], [20, 45, 28], [20, 45, 39], [20, 45, 43], [20, 45, 46], [20, 46, 7], [20, 46, 14], [20, 46, 23], [20, 46, 27], [20, 46, 35], [20, 46, 37], [20, 46, 43], [20, 46, 45], [21, 0, 21], [21, 1, 2], [21, 1, 9], [21, 1, 18], [21, 1, 21], [21, 1, 24], [21, 1, 28], [21, 1, 34], [21, 1, 42], [21, 2, 1], [21, 2, 4], [21, 2, 9], [21, 2, 18], [21, 2, 21], [21, 2, 36], [21, 2, 37], [21, 2, 42], [21, 3, 6], [21, 3, 7], [21, 3, 8], [21, 3, 16], [21, 3, 25], [21, 3, 27], [21, 3, 32], [21, 3, 37], [21, 4, 2], [21, 4, 8], [21, 4, 18], [21, 4, 25], [21, 4, 27], [21, 4, 36], [21, 4, 37], [21, 4, 42], [21, 6, 3], [21, 6, 7], [21, 6, 12], [21, 6, 14], [21, 6, 16], [21, 6, 17], [21, 6, 27], [21, 6, 32], [21, 7, 3], [21, 7, 6], [21, 7, 8], [21, 7, 12], [21, 7, 14], [21, 7, 16], [21, 7, 27], [21, 7, 32], [21, 8, 3], [21, 8, 4], [21, 8, 7], [21, 8, 16], [21, 8, 25], [21, 8, 27], [21, 8, 36], [21, 8, 37], [21, 9, 1], [21, 9, 2], [21, 9, 17], [21, 9, 18], [21, 9, 21], [21, 9, 24], [21, 9, 28], [21, 9, 34], [21, 12, 6], [21, 12, 7], [21, 12, 14], [21, 12, 17], [21, 12, 24], [21, 12, 28], [21, 12, 32], [21, 12, 34], [21, 14, 6], [21, 14, 7], [21, 14, 12], [21, 14, 16], [21, 14, 17], [21, 14, 24], [21, 14, 28], [21, 14, 32], [21, 16, 3], [21, 16, 6], [21, 16, 7], [21, 16, 8], [21, 16, 14], [21, 16, 25], [21, 16, 27], [21, 16, 32], [21, 17, 6], [21, 17, 9], [21, 17, 12], [21, 17, 14], [21, 17, 24], [21, 17, 28], [21, 17, 32], [21, 17, 34], [21, 18, 1], [21, 18, 2], [21, 18, 4], [21, 18, 9], [21, 18, 21], [21, 18, 34], [21, 18, 36], [21, 18, 42], [21, 21, 0], [21, 21, 1], [21, 21, 2], [21, 21, 9], [21, 21, 18], [21, 21, 21], [21, 21, 24], [21, 21, 34], [21, 21, 36], [21, 21, 42], [21, 24, 1], [21, 24, 9], [21, 24, 12], [21, 24, 14], [21, 24, 17], [21, 24, 21], [21, 24, 28], [21, 24, 34], [21, 25, 3], [21, 25, 4], [21, 25, 8], [21, 25, 16], [21, 25, 27], [21, 25, 36], [21, 25, 37], [21, 25, 42], [21, 27, 3], [21, 27, 4], [21, 27, 6], [21, 27, 7], [21, 27, 8], [21, 27, 16], [21, 27, 25], [21, 27, 37], [21, 28, 1], [21, 28, 9], [21, 28, 12], [21, 28, 14], [21, 28, 17], [21, 28, 24], [21, 28, 32], [21, 28, 34], [21, 32, 3], [21, 32, 6], [21, 32, 7], [21, 32, 12], [21, 32, 14], [21, 32, 16], [21, 32, 17], [21, 32, 28], [21, 34, 1], [21, 34, 9], [21, 34, 12], [21, 34, 17], [21, 34, 18], [21, 34, 21], [21, 34, 24], [21, 34, 28], [21, 36, 2], [21, 36, 4], [21, 36, 8], [21, 36, 18], [21, 36, 21], [21, 36, 25], [21, 36, 37], [21, 36, 42], [21, 37, 2], [21, 37, 3], [21, 37, 4], [21, 37, 8], [21, 37, 25], [21, 37, 27], [21, 37, 36], [21, 37, 42], [21, 42, 1], [21, 42, 2], [21, 42, 4], [21, 42, 18], [21, 42, 21], [21, 42, 25], [21, 42, 36], [21, 42, 37], [22, 0, 22], [22, 1, 6], [22, 1, 8], [22, 1, 14], [22, 1, 15], [22, 1, 22], [22, 1, 26], [22, 1, 37], [22, 1, 38], [22, 2, 5], [22, 2, 12], [22, 2, 16], [22, 2, 27], [22, 2, 28], [22, 2, 29], [22, 2, 30], [22, 2, 44], [22, 3, 17], [22, 3, 18], [22, 3, 19], [22, 3, 20], [22, 3, 24], [22, 3, 31], [22, 3, 42], [22, 3, 45], [22, 4, 7], [22, 4, 9], [22, 4, 10], [22, 4, 11], [22, 4, 13], [22, 4, 24], [22, 4, 32], [22, 4, 41], [22, 5, 2], [22, 5, 16], [22, 5, 23], [22, 5, 28], [22, 5, 30], [22, 5, 36], [22, 5, 40], [22, 5, 44], [22, 6, 1], [22, 6, 15], [22, 6, 34], [22, 6, 36], [22, 6, 37], [22, 6, 38], [22, 6, 40], [22, 6, 43], [22, 7, 4], [22, 7, 9], [22, 7, 11], [22, 7, 13], [22, 7, 24], [22, 7, 31], [22, 7, 41], [22, 7, 42], [22, 8, 1], [22, 8, 14], [22, 8, 17], [22, 8, 18], [22, 8, 20], [22, 8, 22], [22, 8, 26], [22, 8, 35], [22, 9, 4], [22, 9, 7], [22, 9, 10], [22, 9, 13], [22, 9, 25], [22, 9, 32], [22, 9, 41], [22, 9, 46], [22, 10, 4], [22, 10, 9], [22, 10, 13], [22, 10, 25], [22, 10, 32], [22, 10, 33], [22, 10, 41], [22, 10, 46], [22, 11, 4], [22, 11, 7], [22, 11, 13], [22, 11, 19], [22, 11, 24], [22, 11, 31], [22, 11, 41], [22, 11, 42], [22, 12, 2], [22, 12, 21], [22, 12, 25], [22, 12, 27], [22, 12, 29], [22, 12, 30], [22, 12, 33], [22, 12, 39], [22, 13, 4], [22, 13, 7], [22, 13, 9], [22, 13, 10], [22, 13, 11], [22, 13, 24], [22, 13, 31], [22, 13, 41], [22, 14, 1], [22, 14, 8], [22, 14, 15], [22, 14, 18], [22, 14, 22], [22, 14, 26], [22, 14, 35], [22, 14, 37], [22, 15, 1], [22, 15, 6], [22, 15, 14], [22, 15, 22], [22, 15, 26], [22, 15, 37], [22, 15, 38], [22, 15, 43], [22, 16, 2], [22, 16, 5], [22, 16, 23], [22, 16, 28], [22, 16, 34], [22, 16, 36], [22, 16, 40], [22, 16, 44], [22, 17, 3], [22, 17, 8], [22, 17, 18], [22, 17, 19], [22, 17, 20], [22, 17, 35], [22, 17, 42], [22, 17, 45], [22, 18, 3], [22, 18, 8], [22, 18, 14], [22, 18, 17], [22, 18, 20], [22, 18, 26], [22, 18, 35], [22, 18, 45], [22, 19, 3], [22, 19, 11], [22, 19, 17], [22, 19, 20], [22, 19, 24], [22, 19, 31], [22, 19, 42], [22, 19, 45], [22, 20, 3], [22, 20, 8], [22, 20, 17], [22, 20, 18], [22, 20, 19], [22, 20, 26], [22, 20, 35], [22, 20, 45], [22, 21, 12], [22, 21, 25], [22, 21, 27], [22, 21, 29], [22, 21, 32], [22, 21, 33], [22, 21, 39], [22, 21, 46], [22, 22, 0], [22, 22, 1], [22, 22, 8], [22, 22, 14], [22, 22, 15], [22, 22, 22], [22, 22, 26], [22, 22, 35], [22, 22, 37], [22, 22, 38], [22, 23, 5], [22, 23, 16], [22, 23, 28], [22, 23, 34], [22, 23, 36], [22, 23, 40], [22, 23, 43], [22, 23, 44], [22, 24, 3], [22, 24, 4], [22, 24, 7], [22, 24, 11], [22, 24, 13], [22, 24, 19], [22, 24, 31], [22, 24, 42], [22, 25, 9], [22, 25, 10], [22, 25, 12], [22, 25, 21], [22, 25, 32], [22, 25, 33], [22, 25, 39], [22, 25, 46], [22, 26, 1], [22, 26, 8], [22, 26, 14], [22, 26, 15], [22, 26, 18], [22, 26, 20], [22, 26, 22], [22, 26, 35], [22, 27, 2], [22, 27, 12], [22, 27, 21], [22, 27, 28], [22, 27, 29], [22, 27, 30], [22, 27, 39], [22, 27, 44], [22, 28, 2], [22, 28, 5], [22, 28, 16], [22, 28, 23], [22, 28, 27], [22, 28, 30], [22, 28, 36], [22, 28, 44], [22, 29, 2], [22, 29, 12], [22, 29, 21], [22, 29, 27], [22, 29, 30], [22, 29, 33], [22, 29, 39], [22, 29, 44], [22, 30, 2], [22, 30, 5], [22, 30, 12], [22, 30, 27], [22, 30, 28], [22, 30, 29], [22, 30, 39], [22, 30, 44], [22, 31, 3], [22, 31, 7], [22, 31, 11], [22, 31, 13], [22, 31, 19], [22, 31, 24], [22, 31, 42], [22, 31, 45], [22, 32, 4], [22, 32, 9], [22, 32, 10], [22, 32, 21], [22, 32, 25], [22, 32, 33], [22, 32, 41], [22, 32, 46], [22, 33, 10], [22, 33, 12], [22, 33, 21], [22, 33, 25], [22, 33, 29], [22, 33, 32], [22, 33, 39], [22, 33, 46], [22, 34, 6], [22, 34, 16], [22, 34, 23], [22, 34, 36], [22, 34, 37], [22, 34, 38], [22, 34, 40], [22, 34, 43], [22, 35, 8], [22, 35, 14], [22, 35, 17], [22, 35, 18], [22, 35, 20], [22, 35, 22], [22, 35, 26], [22, 35, 45], [22, 36, 5], [22, 36, 6], [22, 36, 16], [22, 36, 23], [22, 36, 28], [22, 36, 34], [22, 36, 40], [22, 36, 43], [22, 37, 1], [22, 37, 6], [22, 37, 14], [22, 37, 15], [22, 37, 22], [22, 37, 34], [22, 37, 38], [22, 37, 43], [22, 38, 1], [22, 38, 6], [22, 38, 15], [22, 38, 22], [22, 38, 34], [22, 38, 37], [22, 38, 40], [22, 38, 43], [22, 39, 12], [22, 39, 21], [22, 39, 25], [22, 39, 27], [22, 39, 29], [22, 39, 30], [22, 39, 33], [22, 39, 46], [22, 40, 5], [22, 40, 6], [22, 40, 16], [22, 40, 23], [22, 40, 34], [22, 40, 36], [22, 40, 38], [22, 40, 43], [22, 41, 4], [22, 41, 7], [22, 41, 9], [22, 41, 10], [22, 41, 11], [22, 41, 13], [22, 41, 32], [22, 41, 46], [22, 42, 3], [22, 42, 7], [22, 42, 11], [22, 42, 17], [22, 42, 19], [22, 42, 24], [22, 42, 31], [22, 42, 45], [22, 43, 6], [22, 43, 15], [22, 43, 23], [22, 43, 34], [22, 43, 36], [22, 43, 37], [22, 43, 38], [22, 43, 40], [22, 44, 2], [22, 44, 5], [22, 44, 16], [22, 44, 23], [22, 44, 27], [22, 44, 28], [22, 44, 29], [22, 44, 30], [22, 45, 3], [22, 45, 17], [22, 45, 18], [22, 45, 19], [22, 45, 20], [22, 45, 31], [22, 45, 35], [22, 45, 42], [22, 46, 9], [22, 46, 10], [22, 46, 21], [22, 46, 25], [22, 46, 32], [22, 46, 33], [22, 46, 39], [22, 46, 41], [23, 0, 23], [23, 1, 3], [23, 1, 4], [23, 1, 12], [23, 1, 16], [23, 1, 23], [23, 1, 39], [23, 1, 41], [23, 1, 45], [23, 2, 6], [23, 2, 8], [23, 2, 24], [23, 2, 31], [23, 2, 32], [23, 2, 35], [23, 2, 43], [23, 2, 46], [23, 3, 1], [23, 3, 9], [23, 3, 12], [23, 3, 22], [23, 3, 23], [23, 3, 29], [23, 3, 36], [23, 3, 41], [23, 4, 1], [23, 4, 12], [23, 4, 15], [23, 4, 16], [23, 4, 17], [23, 4, 23], [23, 4, 39], [23, 4, 45], [23, 5, 7], [23, 5, 13], [23, 5, 15], [23, 5, 17], [23, 5, 20], [23, 5, 21], [23, 5, 33], [23, 5, 37], [23, 6, 2], [23, 6, 11], [23, 6, 18], [23, 6, 24], [23, 6, 25], [23, 6, 35], [23, 6, 44], [23, 6, 46], [23, 7, 5], [23, 7, 18], [23, 7, 20], [23, 7, 21], [23, 7, 28], [23, 7, 33], [23, 7, 37], [23, 7, 38], [23, 8, 2], [23, 8, 24], [23, 8, 30], [23, 8, 31], [23, 8, 32], [23, 8, 34], [23, 8, 43], [23, 8, 46], [23, 9, 3], [23, 9, 14], [23, 9, 19], [23, 9, 22], [23, 9, 27], [23, 9, 29], [23, 9, 36], [23, 9, 40], [23, 10, 14], [23, 10, 19], [23, 10, 26], [23, 10, 27], [23, 10, 30], [23, 10, 34], [23, 10, 40], [23, 10, 42], [23, 11, 6], [23, 11, 18], [23, 11, 25], [23, 11, 28], [23, 11, 33], [23, 11, 35], [23, 11, 38], [23, 11, 44], [23, 12, 1], [23, 12, 3], [23, 12, 4], [23, 12, 22], [23, 12, 23], [23, 12, 36], [23, 12, 41], [23, 12, 45], [23, 13, 5], [23, 13, 15], [23, 13, 16], [23, 13, 17], [23, 13, 20], [23, 13, 21], [23, 13, 37], [23, 13, 39], [23, 14, 9], [23, 14, 10], [23, 14, 19], [23, 14, 27], [23, 14, 29], [23, 14, 36], [23, 14, 40], [23, 14, 42], [23, 15, 4], [23, 15, 5], [23, 15, 13], [23, 15, 16], [23, 15, 17], [23, 15, 21], [23, 15, 39], [23, 15, 45], [23, 16, 1], [23, 16, 4], [23, 16, 13], [23, 16, 15], [23, 16, 17], [23, 16, 21], [23, 16, 39], [23, 16, 45], [23, 17, 4], [23, 17, 5], [23, 17, 13], [23, 17, 15], [23, 17, 16], [23, 17, 21], [23, 17, 37], [23, 17, 39], [23, 18, 6], [23, 18, 7], [23, 18, 11], [23, 18, 25], [23, 18, 28], [23, 18, 33], [23, 18, 38], [23, 18, 44], [23, 19, 9], [23, 19, 10], [23, 19, 14], [23, 19, 22], [23, 19, 27], [23, 19, 29], [23, 19, 36], [23, 19, 40], [23, 20, 5], [23, 20, 7], [23, 20, 13], [23, 20, 21], [23, 20, 28], [23, 20, 33], [23, 20, 37], [23, 20, 38], [23, 21, 5], [23, 21, 7], [23, 21, 13], [23, 21, 15], [23, 21, 16], [23, 21, 17], [23, 21, 20], [23, 21, 37], [23, 22, 3], [23, 22, 9], [23, 22, 12], [23, 22, 19], [23, 22, 23], [23, 22, 29], [23, 22, 36], [23, 22, 41], [23, 23, 0], [23, 23, 1], [23, 23, 3], [23, 23, 4], [23, 23, 12], [23, 23, 22], [23, 23, 23], [23, 23, 39], [23, 23, 41], [23, 23, 45], [23, 24, 2], [23, 24, 6], [23, 24, 8], [23, 24, 25], [23, 24, 35], [23, 24, 43], [23, 24, 44], [23, 24, 46], [23, 25, 6], [23, 25, 11], [23, 25, 18], [23, 25, 24], [23, 25, 28], [23, 25, 35], [23, 25, 38], [23, 25, 44], [23, 26, 10], [23, 26, 27], [23, 26, 30], [23, 26, 31], [23, 26, 32], [23, 26, 34], [23, 26, 40], [23, 26, 42], [23, 27, 9], [23, 27, 10], [23, 27, 14], [23, 27, 19], [23, 27, 26], [23, 27, 34], [23, 27, 40], [23, 27, 42], [23, 28, 7], [23, 28, 11], [23, 28, 18], [23, 28, 20], [23, 28, 25], [23, 28, 33], [23, 28, 37], [23, 28, 38], [23, 29, 3], [23, 29, 9], [23, 29, 14], [23, 29, 19], [23, 29, 22], [23, 29, 36], [23, 29, 40], [23, 29, 41], [23, 30, 8], [23, 30, 10], [23, 30, 26], [23, 30, 31], [23, 30, 32], [23, 30, 34], [23, 30, 42], [23, 30, 43], [23, 31, 2], [23, 31, 8], [23, 31, 26], [23, 31, 30], [23, 31, 32], [23, 31, 34], [23, 31, 43], [23, 31, 46], [23, 32, 2], [23, 32, 8], [23, 32, 26], [23, 32, 30], [23, 32, 31], [23, 32, 34], [23, 32, 42], [23, 32, 43], [23, 33, 5], [23, 33, 7], [23, 33, 11], [23, 33, 18], [23, 33, 20], [23, 33, 28], [23, 33, 37], [23, 33, 38], [23, 34, 8], [23, 34, 10], [23, 34, 26], [23, 34, 27], [23, 34, 30], [23, 34, 31], [23, 34, 32], [23, 34, 42], [23, 35, 2], [23, 35, 6], [23, 35, 11], [23, 35, 24], [23, 35, 25], [23, 35, 43], [23, 35, 44], [23, 35, 46], [23, 36, 3], [23, 36, 9], [23, 36, 12], [23, 36, 14], [23, 36, 19], [23, 36, 22], [23, 36, 29], [23, 36, 41], [23, 37, 5], [23, 37, 7], [23, 37, 13], [23, 37, 17], [23, 37, 20], [23, 37, 21], [23, 37, 28], [23, 37, 33], [23, 38, 7], [23, 38, 11], [23, 38, 18], [23, 38, 20], [23, 38, 25], [23, 38, 28], [23, 38, 33], [23, 38, 44], [23, 39, 1], [23, 39, 4], [23, 39, 13], [23, 39, 15], [23, 39, 16], [23, 39, 17], [23, 39, 23], [23, 39, 45], [23, 40, 9], [23, 40, 10], [23, 40, 14], [23, 40, 19], [23, 40, 26], [23, 40, 27], [23, 40, 29], [23, 40, 42], [23, 41, 1], [23, 41, 3], [23, 41, 12], [23, 41, 22], [23, 41, 23], [23, 41, 29], [23, 41, 36], [23, 41, 45], [23, 42, 10], [23, 42, 14], [23, 42, 26], [23, 42, 27], [23, 42, 30], [23, 42, 32], [23, 42, 34], [23, 42, 40], [23, 43, 2], [23, 43, 8], [23, 43, 24], [23, 43, 30], [23, 43, 31], [23, 43, 32], [23, 43, 35], [23, 43, 46], [23, 44, 6], [23, 44, 11], [23, 44, 18], [23, 44, 24], [23, 44, 25], [23, 44, 35], [23, 44, 38], [23, 44, 46], [23, 45, 1], [23, 45, 4], [23, 45, 12], [23, 45, 15], [23, 45, 16], [23, 45, 23], [23, 45, 39], [23, 45, 41], [23, 46, 2], [23, 46, 6], [23, 46, 8], [23, 46, 24], [23, 46, 31], [23, 46, 35], [23, 46, 43], [23, 46, 44], [24, 0, 24], [24, 1, 2], [24, 1, 3], [24, 1, 4], [24, 1, 6], [24, 1, 8], [24, 1, 12], [24, 1, 16], [24, 1, 24], [24, 2, 1], [24, 2, 4], [24, 2, 6], [24, 2, 8], [24, 2, 12], [24, 2, 16], [24, 2, 24], [24, 2, 32], [24, 3, 1], [24, 3, 6], [24, 3, 9], [24, 3, 12], [24, 3, 18], [24, 3, 24], [24, 3, 25], [24, 3, 36], [24, 4, 1], [24, 4, 2], [24, 4, 8], [24, 4, 12], [24, 4, 16], [24, 4, 17], [24, 4, 24], [24, 4, 32], [24, 6, 1], [24, 6, 2], [24, 6, 3], [24, 6, 12], [24, 6, 18], [24, 6, 24], [24, 6, 25], [24, 6, 36], [24, 7, 9], [24, 7, 14], [24, 7, 18], [24, 7, 21], [24, 7, 27], [24, 7, 28], [24, 7, 37], [24, 7, 42], [24, 8, 1], [24, 8, 2], [24, 8, 4], [24, 8, 16], [24, 8, 17], [24, 8, 24], [24, 8, 32], [24, 8, 34], [24, 9, 3], [24, 9, 7], [24, 9, 14], [24, 9, 18], [24, 9, 25], [24, 9, 27], [24, 9, 28], [24, 9, 36], [24, 12, 1], [24, 12, 2], [24, 12, 3], [24, 12, 4], [24, 12, 6], [24, 12, 24], [24, 12, 25], [24, 12, 36], [24, 14, 7], [24, 14, 9], [24, 14, 18], [24, 14, 27], [24, 14, 28], [24, 14, 36], [24, 14, 37], [24, 14, 42], [24, 16, 1], [24, 16, 2], [24, 16, 4], [24, 16, 8], [24, 16, 17], [24, 16, 21], [24, 16, 32], [24, 16, 34], [24, 17, 4], [24, 17, 8], [24, 17, 16], [24, 17, 21], [24, 17, 32], [24, 17, 34], [24, 17, 37], [24, 17, 42], [24, 18, 3], [24, 18, 6], [24, 18, 7], [24, 18, 9], [24, 18, 14], [24, 18, 25], [24, 18, 28], [24, 18, 36], [24, 21, 7], [24, 21, 16], [24, 21, 17], [24, 21, 27], [24, 21, 32], [24, 21, 34], [24, 21, 37], [24, 21, 42], [24, 24, 0], [24, 24, 1], [24, 24, 2], [24, 24, 3], [24, 24, 4], [24, 24, 6], [24, 24, 8], [24, 24, 12], [24, 24, 24], [24, 24, 25], [24, 25, 3], [24, 25, 6], [24, 25, 9], [24, 25, 12], [24, 25, 18], [24, 25, 24], [24, 25, 28], [24, 25, 36], [24, 27, 7], [24, 27, 9], [24, 27, 14], [24, 27, 21], [24, 27, 28], [24, 27, 34], [24, 27, 37], [24, 27, 42], [24, 28, 7], [24, 28, 9], [24, 28, 14], [24, 28, 18], [24, 28, 25], [24, 28, 27], [24, 28, 36], [24, 28, 37], [24, 32, 2], [24, 32, 4], [24, 32, 8], [24, 32, 16], [24, 32, 17], [24, 32, 21], [24, 32, 34], [24, 32, 42], [24, 34, 8], [24, 34, 16], [24, 34, 17], [24, 34, 21], [24, 34, 27], [24, 34, 32], [24, 34, 37], [24, 34, 42], [24, 36, 3], [24, 36, 6], [24, 36, 9], [24, 36, 12], [24, 36, 14], [24, 36, 18], [24, 36, 25], [24, 36, 28], [24, 37, 7], [24, 37, 14], [24, 37, 17], [24, 37, 21], [24, 37, 27], [24, 37, 28], [24, 37, 34], [24, 37, 42], [24, 42, 7], [24, 42, 14], [24, 42, 17], [24, 42, 21], [24, 42, 27], [24, 42, 32], [24, 42, 34], [24, 42, 37], [25, 0, 25], [25, 1, 6], [25, 1, 8], [25, 1, 9], [25, 1, 14], [25, 1, 21], [25, 1, 25], [25, 1, 32], [25, 1, 37], [25, 2, 3], [25, 2, 12], [25, 2, 16], [25, 2, 17], [25, 2, 18], [25, 2, 27], [25, 2, 28], [25, 2, 42], [25, 3, 2], [25, 3, 16], [25, 3, 17], [25, 3, 18], [25, 3, 24], [25, 3, 27], [25, 3, 28], [25, 3, 42], [25, 4, 6], [25, 4, 7], [25, 4, 9], [25, 4, 24], [25, 4, 32], [25, 4, 34], [25, 4, 36], [25, 4, 37], [25, 6, 1], [25, 6, 4], [25, 6, 7], [25, 6, 9], [25, 6, 32], [25, 6, 34], [25, 6, 36], [25, 6, 37], [25, 7, 4], [25, 7, 6], [25, 7, 9], [25, 7, 16], [25, 7, 24], [25, 7, 34], [25, 7, 36], [25, 7, 42], [25, 8, 1], [25, 8, 12], [25, 8, 14], [25, 8, 17], [25, 8, 18], [25, 8, 21], [25, 8, 25], [25, 8, 27], [25, 9, 1], [25, 9, 4], [25, 9, 6], [25, 9, 7], [25, 9, 25], [25, 9, 32], [25, 9, 34], [25, 9, 37], [25, 12, 2], [25, 12, 8], [25, 12, 14], [25, 12, 17], [25, 12, 18], [25, 12, 21], [25, 12, 25], [25, 12, 27], [25, 14, 1], [25, 14, 8], [25, 14, 12], [25, 14, 18], [25, 14, 21], [25, 14, 25], [25, 14, 32], [25, 14, 37], [25, 16, 2], [25, 16, 3], [25, 16, 7], [25, 16, 24], [25, 16, 28], [25, 16, 34], [25, 16, 36], [25, 16, 42], [25, 17, 2], [25, 17, 3], [25, 17, 8], [25, 17, 12], [25, 17, 18], [25, 17, 27], [25, 17, 28], [25, 17, 42], [25, 18, 2], [25, 18, 3], [25, 18, 8], [25, 18, 12], [25, 18, 14], [25, 18, 17], [25, 18, 21], [25, 18, 27], [25, 21, 1], [25, 21, 8], [25, 21, 12], [25, 21, 14], [25, 21, 18], [25, 21, 25], [25, 21, 27], [25, 21, 32], [25, 24, 3], [25, 24, 4], [25, 24, 7], [25, 24, 16], [25, 24, 28], [25, 24, 34], [25, 24, 36], [25, 24, 42], [25, 25, 0], [25, 25, 1], [25, 25, 8], [25, 25, 9], [25, 25, 12], [25, 25, 14], [25, 25, 21], [25, 25, 25], [25, 25, 32], [25, 25, 37], [25, 27, 2], [25, 27, 3], [25, 27, 8], [25, 27, 12], [25, 27, 17], [25, 27, 18], [25, 27, 21], [25, 27, 28], [25, 28, 2], [25, 28, 3], [25, 28, 16], [25, 28, 17], [25, 28, 24], [25, 28, 27], [25, 28, 36], [25, 28, 42], [25, 32, 1], [25, 32, 4], [25, 32, 6], [25, 32, 9], [25, 32, 14], [25, 32, 21], [25, 32, 25], [25, 32, 37], [25, 34, 4], [25, 34, 6], [25, 34, 7], [25, 34, 9], [25, 34, 16], [25, 34, 24], [25, 34, 36], [25, 34, 37], [25, 36, 4], [25, 36, 6], [25, 36, 7], [25, 36, 16], [25, 36, 24], [25, 36, 28], [25, 36, 34], [25, 36, 42], [25, 37, 1], [25, 37, 4], [25, 37, 6], [25, 37, 9], [25, 37, 14], [25, 37, 25], [25, 37, 32], [25, 37, 34], [25, 42, 2], [25, 42, 3], [25, 42, 7], [25, 42, 16], [25, 42, 17], [25, 42, 24], [25, 42, 28], [25, 42, 36], [26, 0, 26], [26, 1, 18], [26, 1, 23], [26, 1, 26], [26, 1, 28], [26, 1, 34], [26, 1, 38], [26, 1, 42], [26, 1, 45], [26, 2, 5], [26, 2, 9], [26, 2, 21], [26, 2, 29], [26, 2, 36], [26, 2, 37], [26, 2, 43], [26, 2, 46], [26, 3, 7], [26, 3, 8], [26, 3, 20], [26, 3, 22], [26, 3, 31], [26, 3, 32], [26, 3, 37], [26, 3, 41], [26, 4, 10], [26, 4, 11], [26, 4, 18], [26, 4, 25], [26, 4, 27], [26, 4, 39], [26, 4, 42], [26, 4, 45], [26, 5, 2], [26, 5, 21], [26, 5, 22], [26, 5, 29], [26, 5, 36], [26, 5, 37], [26, 5, 43], [26, 5, 46], [26, 6, 14], [26, 6, 15], [26, 6, 16], [26, 6, 17], [26, 6, 27], [26, 6, 35], [26, 6, 40], [26, 6, 44], [26, 7, 3], [26, 7, 8], [26, 7, 12], [26, 7, 20], [26, 7, 31], [26, 7, 32], [26, 7, 33], [26, 7, 41], [26, 8, 3], [26, 8, 7], [26, 8, 20], [26, 8, 22], [26, 8, 31], [26, 8, 36], [26, 8, 37], [26, 8, 43], [26, 9, 2], [26, 9, 13], [26, 9, 17], [26, 9, 19], [26, 9, 21], [26, 9, 24], [26, 9, 29], [26, 9, 46], [26, 10, 4], [26, 10, 11], [26, 10, 25], [26, 10, 27], [26, 10, 39], [26, 10, 42], [26, 10, 44], [26, 10, 45], [26, 11, 4], [26, 11, 10], [26, 11, 18], [26, 11, 25], [26, 11, 26], [26, 11, 39], [26, 11, 42], [26, 11, 45], [26, 12, 7], [26, 12, 23], [26, 12, 28], [26, 12, 30], [26, 12, 32], [26, 12, 33], [26, 12, 34], [26, 12, 41], [26, 13, 9], [26, 13, 17], [26, 13, 19], [26, 13, 21], [26, 13, 24], [26, 13, 29], [26, 13, 35], [26, 13, 46], [26, 14, 6], [26, 14, 15], [26, 14, 16], [26, 14, 17], [26, 14, 19], [26, 14, 24], [26, 14, 35], [26, 14, 40], [26, 15, 6], [26, 15, 14], [26, 15, 16], [26, 15, 17], [26, 15, 19], [26, 15, 35], [26, 15, 40], [26, 15, 44], [26, 16, 6], [26, 16, 14], [26, 16, 15], [26, 16, 25], [26, 16, 27], [26, 16, 39], [26, 16, 40], [26, 16, 44], [26, 17, 6], [26, 17, 9], [26, 17, 13], [26, 17, 14], [26, 17, 15], [26, 17, 19], [26, 17, 24], [26, 17, 35], [26, 18, 1], [26, 18, 4], [26, 18, 11], [26, 18, 26], [26, 18, 34], [26, 18, 38], [26, 18, 42], [26, 18, 45], [26, 19, 9], [26, 19, 13], [26, 19, 14], [26, 19, 15], [26, 19, 17], [26, 19, 24], [26, 19, 35], [26, 19, 46], [26, 20, 3], [26, 20, 7], [26, 20, 8], [26, 20, 22], [26, 20, 31], [26, 20, 37], [26, 20, 41], [26, 20, 43], [26, 21, 2], [26, 21, 5], [26, 21, 9], [26, 21, 13], [26, 21, 24], [26, 21, 29], [26, 21, 36], [26, 21, 46], [26, 22, 3], [26, 22, 5], [26, 22, 8], [26, 22, 20], [26, 22, 31], [26, 22, 36], [26, 22, 37], [26, 22, 43], [26, 23, 1], [26, 23, 12], [26, 23, 26], [26, 23, 28], [26, 23, 30], [26, 23, 33], [26, 23, 34], [26, 23, 38], [26, 24, 9], [26, 24, 13], [26, 24, 14], [26, 24, 17], [26, 24, 19], [26, 24, 21], [26, 24, 35], [26, 24, 46], [26, 25, 4], [26, 25, 10], [26, 25, 11], [26, 25, 16], [26, 25, 27], [26, 25, 39], [26, 25, 42], [26, 25, 44], [26, 26, 0], [26, 26, 1], [26, 26, 11], [26, 26, 18], [26, 26, 23], [26, 26, 26], [26, 26, 34], [26, 26, 38], [26, 26, 42], [26, 26, 45], [26, 27, 4], [26, 27, 6], [26, 27, 10], [26, 27, 16], [26, 27, 25], [26, 27, 39], [26, 27, 40], [26, 27, 44], [26, 28, 1], [26, 28, 12], [26, 28, 23], [26, 28, 30], [26, 28, 32], [26, 28, 33], [26, 28, 34], [26, 28, 38], [26, 29, 2], [26, 29, 5], [26, 29, 9], [26, 29, 13], [26, 29, 21], [26, 29, 36], [26, 29, 43], [26, 29, 46], [26, 30, 12], [26, 30, 23], [26, 30, 28], [26, 30, 32], [26, 30, 33], [26, 30, 34], [26, 30, 38], [26, 30, 41], [26, 31, 3], [26, 31, 7], [26, 31, 8], [26, 31, 20], [26, 31, 22], [26, 31, 32], [26, 31, 33], [26, 31, 41], [26, 32, 3], [26, 32, 7], [26, 32, 12], [26, 32, 28], [26, 32, 30], [26, 32, 31], [26, 32, 33], [26, 32, 41], [26, 33, 7], [26, 33, 12], [26, 33, 23], [26, 33, 28], [26, 33, 30], [26, 33, 31], [26, 33, 32], [26, 33, 41], [26, 34, 1], [26, 34, 12], [26, 34, 18], [26, 34, 23], [26, 34, 26], [26, 34, 28], [26, 34, 30], [26, 34, 38], [26, 35, 6], [26, 35, 13], [26, 35, 14], [26, 35, 15], [26, 35, 17], [26, 35, 19], [26, 35, 24], [26, 35, 40], [26, 36, 2], [26, 36, 5], [26, 36, 8], [26, 36, 21], [26, 36, 22], [26, 36, 29], [26, 36, 37], [26, 36, 43], [26, 37, 2], [26, 37, 3], [26, 37, 5], [26, 37, 8], [26, 37, 20], [26, 37, 22], [26, 37, 36], [26, 37, 43], [26, 38, 1], [26, 38, 18], [26, 38, 23], [26, 38, 26], [26, 38, 28], [26, 38, 30], [26, 38, 34], [26, 38, 45], [26, 39, 4], [26, 39, 10], [26, 39, 11], [26, 39, 16], [26, 39, 25], [26, 39, 27], [26, 39, 40], [26, 39, 44], [26, 40, 6], [26, 40, 14], [26, 40, 15], [26, 40, 16], [26, 40, 27], [26, 40, 35], [26, 40, 39], [26, 40, 44], [26, 41, 3], [26, 41, 7], [26, 41, 12], [26, 41, 20], [26, 41, 30], [26, 41, 31], [26, 41, 32], [26, 41, 33], [26, 42, 1], [26, 42, 4], [26, 42, 10], [26, 42, 11], [26, 42, 18], [26, 42, 25], [26, 42, 26], [26, 42, 45], [26, 43, 2], [26, 43, 5], [26, 43, 8], [26, 43, 20], [26, 43, 22], [26, 43, 29], [26, 43, 36], [26, 43, 37], [26, 44, 6], [26, 44, 10], [26, 44, 15], [26, 44, 16], [26, 44, 25], [26, 44, 27], [26, 44, 39], [26, 44, 40], [26, 45, 1], [26, 45, 4], [26, 45, 10], [26, 45, 11], [26, 45, 18], [26, 45, 26], [26, 45, 38], [26, 45, 42], [26, 46, 2], [26, 46, 5], [26, 46, 9], [26, 46, 13], [26, 46, 19], [26, 46, 21], [26, 46, 24], [26, 46, 29], [27, 0, 27], [27, 1, 2], [27, 1, 4], [27, 1, 7], [27, 1, 12], [27, 1, 14], [27, 1, 24], [27, 1, 27], [27, 1, 37], [27, 2, 1], [27, 2, 4], [27, 2, 7], [27, 2, 8], [27, 2, 14], [27, 2, 24], [27, 2, 27], [27, 2, 28], [27, 3, 6], [27, 3, 12], [27, 3, 17], [27, 3, 21], [27, 3, 25], [27, 3, 34], [27, 3, 36], [27, 3, 42], [27, 4, 1], [27, 4, 2], [27, 4, 7], [27, 4, 8], [27, 4, 9], [27, 4, 14], [27, 4, 16], [27, 4, 28], [27, 6, 3], [27, 6, 12], [27, 6, 21], [27, 6, 24], [27, 6, 25], [27, 6, 34], [27, 6, 37], [27, 6, 42], [27, 7, 1], [27, 7, 2], [27, 7, 4], [27, 7, 14], [27, 7, 24], [27, 7, 27], [27, 7, 28], [27, 7, 37], [27, 8, 2], [27, 8, 4], [27, 8, 9], [27, 8, 14], [27, 8, 16], [27, 8, 18], [27, 8, 28], [27, 8, 32], [27, 9, 4], [27, 9, 8], [27, 9, 14], [27, 9, 16], [27, 9, 18], [27, 9, 28], [27, 9, 32], [27, 9, 36], [27, 12, 1], [27, 12, 3], [27, 12, 6], [27, 12, 21], [27, 12, 24], [27, 12, 27], [27, 12, 37], [27, 12, 42], [27, 14, 1], [27, 14, 2], [27, 14, 4], [27, 14, 7], [27, 14, 8], [27, 14, 9], [27, 14, 27], [27, 14, 28], [27, 16, 4], [27, 16, 8], [27, 16, 9], [27, 16, 17], [27, 16, 18], [27, 16, 28], [27, 16, 32], [27, 16, 36], [27, 17, 3], [27, 17, 16], [27, 17, 18], [27, 17, 21], [27, 17, 25], [27, 17, 32], [27, 17, 34], [27, 17, 36], [27, 18, 8], [27, 18, 9], [27, 18, 16], [27, 18, 17], [27, 18, 25], [27, 18, 28], [27, 18, 32], [27, 18, 36], [27, 21, 3], [27, 21, 6], [27, 21, 12], [27, 21, 17], [27, 21, 25], [27, 21, 34], [27, 21, 37], [27, 21, 42], [27, 24, 1], [27, 24, 2], [27, 24, 6], [27, 24, 7], [27, 24, 12], [27, 24, 27], [27, 24, 37], [27, 24, 42], [27, 25, 3], [27, 25, 6], [27, 25, 17], [27, 25, 18], [27, 25, 21], [27, 25, 32], [27, 25, 34], [27, 25, 36], [27, 27, 0], [27, 27, 1], [27, 27, 2], [27, 27, 7], [27, 27, 12], [27, 27, 14], [27, 27, 24], [27, 27, 27], [27, 27, 37], [27, 27, 42], [27, 28, 2], [27, 28, 4], [27, 28, 7], [27, 28, 8], [27, 28, 9], [27, 28, 14], [27, 28, 16], [27, 28, 18], [27, 32, 8], [27, 32, 9], [27, 32, 16], [27, 32, 17], [27, 32, 18], [27, 32, 25], [27, 32, 34], [27, 32, 36], [27, 34, 3], [27, 34, 6], [27, 34, 17], [27, 34, 21], [27, 34, 25], [27, 34, 32], [27, 34, 36], [27, 34, 42], [27, 36, 3], [27, 36, 9], [27, 36, 16], [27, 36, 17], [27, 36, 18], [27, 36, 25], [27, 36, 32], [27, 36, 34], [27, 37, 1], [27, 37, 6], [27, 37, 7], [27, 37, 12], [27, 37, 21], [27, 37, 24], [27, 37, 27], [27, 37, 42], [27, 42, 3], [27, 42, 6], [27, 42, 12], [27, 42, 21], [27, 42, 24], [27, 42, 27], [27, 42, 34], [27, 42, 37], [28, 0, 28], [28, 1, 3], [28, 1, 14], [28, 1, 16], [28, 1, 25], [28, 1, 28], [28, 1, 32], [28, 1, 37], [28, 1, 42], [28, 2, 3], [28, 2, 6], [28, 2, 9], [28, 2, 17], [28, 2, 27], [28, 2, 28], [28, 2, 32], [28, 2, 37], [28, 3, 1], [28, 3, 2], [28, 3, 9], [28, 3, 17], [28, 3, 28], [28, 3, 32], [28, 3, 37], [28, 3, 42], [28, 4, 6], [28, 4, 7], [28, 4, 9], [28, 4, 12], [28, 4, 17], [28, 4, 18], [28, 4, 27], [28, 4, 34], [28, 6, 2], [28, 6, 4], [28, 6, 9], [28, 6, 17], [28, 6, 18], [28, 6, 27], [28, 6, 34], [28, 6, 37], [28, 7, 4], [28, 7, 8], [28, 7, 12], [28, 7, 18], [28, 7, 21], [28, 7, 24], [28, 7, 34], [28, 7, 36], [28, 8, 7], [28, 8, 12], [28, 8, 14], [28, 8, 18], [28, 8, 21], [28, 8, 24], [28, 8, 34], [28, 8, 36], [28, 9, 2], [28, 9, 3], [28, 9, 4], [28, 9, 6], [28, 9, 17], [28, 9, 27], [28, 9, 32], [28, 9, 37], [28, 12, 4], [28, 12, 7], [28, 12, 8], [28, 12, 18], [28, 12, 21], [28, 12, 27], [28, 12, 34], [28, 12, 36], [28, 14, 1], [28, 14, 8], [28, 14, 16], [28, 14, 21], [28, 14, 24], [28, 14, 25], [28, 14, 36], [28, 14, 42], [28, 16, 1], [28, 16, 14], [28, 16, 21], [28, 16, 24], [28, 16, 25], [28, 16, 28], [28, 16, 36], [28, 16, 42], [28, 17, 2], [28, 17, 3], [28, 17, 4], [28, 17, 6], [28, 17, 9], [28, 17, 18], [28, 17, 27], [28, 17, 37], [28, 18, 4], [28, 18, 6], [28, 18, 7], [28, 18, 8], [28, 18, 12], [28, 18, 17], [28, 18, 27], [28, 18, 34], [28, 21, 7], [28, 21, 8], [28, 21, 12], [28, 21, 14], [28, 21, 16], [28, 21, 24], [28, 21, 25], [28, 21, 36], [28, 24, 7], [28, 24, 8], [28, 24, 14], [28, 24, 16], [28, 24, 21], [28, 24, 25], [28, 24, 36], [28, 24, 42], [28, 25, 1], [28, 25, 14], [28, 25, 16], [28, 25, 21], [28, 25, 24], [28, 25, 28], [28, 25, 32], [28, 25, 42], [28, 27, 2], [28, 27, 4], [28, 27, 6], [28, 27, 9], [28, 27, 12], [28, 27, 17], [28, 27, 18], [28, 27, 34], [28, 28, 0], [28, 28, 1], [28, 28, 2], [28, 28, 3], [28, 28, 16], [28, 28, 25], [28, 28, 28], [28, 28, 32], [28, 28, 37], [28, 28, 42], [28, 32, 1], [28, 32, 2], [28, 32, 3], [28, 32, 9], [28, 32, 25], [28, 32, 28], [28, 32, 37], [28, 32, 42], [28, 34, 4], [28, 34, 6], [28, 34, 7], [28, 34, 8], [28, 34, 12], [28, 34, 18], [28, 34, 27], [28, 34, 36], [28, 36, 7], [28, 36, 8], [28, 36, 12], [28, 36, 14], [28, 36, 16], [28, 36, 21], [28, 36, 24], [28, 36, 34], [28, 37, 1], [28, 37, 2], [28, 37, 3], [28, 37, 6], [28, 37, 9], [28, 37, 17], [28, 37, 28], [28, 37, 32], [28, 42, 1], [28, 42, 3], [28, 42, 14], [28, 42, 16], [28, 42, 24], [28, 42, 25], [28, 42, 28], [28, 42, 32], [29, 0, 29], [29, 1, 13], [29, 1, 25], [29, 1, 28], [29, 1, 29], [29, 1, 32], [29, 1, 35], [29, 1, 42], [29, 1, 43], [29, 2, 3], [29, 2, 9], [29, 2, 11], [29, 2, 17], [29, 2, 23], [29, 2, 26], [29, 2, 37], [29, 2, 39], [29, 3, 2], [29, 3, 11], [29, 3, 28], [29, 3, 32], [29, 3, 35], [29, 3, 37], [29, 3, 39], [29, 3, 40], [29, 4, 5], [29, 4, 6], [29, 4, 18], [29, 4, 22], [29, 4, 27], [29, 4, 31], [29, 4, 34], [29, 4, 46], [29, 5, 4], [29, 5, 18], [29, 5, 19], [29, 5, 22], [29, 5, 27], [29, 5, 31], [29, 5, 34], [29, 5, 46], [29, 6, 4], [29, 6, 9], [29, 6, 17], [29, 6, 22], [29, 6, 23], [29, 6, 27], [29, 6, 31], [29, 6, 33], [29, 7, 8], [29, 7, 10], [29, 7, 12], [29, 7, 15], [29, 7, 19], [29, 7, 34], [29, 7, 36], [29, 7, 44], [29, 8, 7], [29, 8, 10], [29, 8, 12], [29, 8, 15], [29, 8, 21], [29, 8, 36], [29, 8, 44], [29, 8, 45], [29, 9, 2], [29, 9, 6], [29, 9, 11], [29, 9, 17], [29, 9, 23], [29, 9, 26], [29, 9, 33], [29, 9, 37], [29, 10, 7], [29, 10, 8], [29, 10, 15], [29, 10, 21], [29, 10, 36], [29, 10, 38], [29, 10, 44], [29, 10, 45], [29, 11, 2], [29, 11, 3], [29, 11, 9], [29, 11, 23], [29, 11, 26], [29, 11, 37], [29, 11, 39], [29, 11, 40], [29, 12, 7], [29, 12, 8], [29, 12, 15], [29, 12, 18], [29, 12, 19], [29, 12, 34], [29, 12, 44], [29, 12, 46], [29, 13, 1], [29, 13, 28], [29, 13, 29], [29, 13, 32], [29, 13, 35], [29, 13, 40], [29, 13, 42], [29, 13, 43], [29, 14, 16], [29, 14, 20], [29, 14, 21], [29, 14, 24], [29, 14, 25], [29, 14, 30], [29, 14, 38], [29, 14, 41], [29, 15, 7], [29, 15, 8], [29, 15, 10], [29, 15, 12], [29, 15, 19], [29, 15, 34], [29, 15, 44], [29, 15, 46], [29, 16, 14], [29, 16, 20], [29, 16, 24], [29, 16, 25], [29, 16, 30], [29, 16, 41], [29, 16, 42], [29, 16, 43], [29, 17, 2], [29, 17, 6], [29, 17, 9], [29, 17, 23], [29, 17, 26], [29, 17, 27], [29, 17, 31], [29, 17, 33], [29, 18, 4], [29, 18, 5], [29, 18, 12], [29, 18, 19], [29, 18, 22], [29, 18, 27], [29, 18, 34], [29, 18, 46], [29, 19, 5], [29, 19, 7], [29, 19, 12], [29, 19, 15], [29, 19, 18], [29, 19, 34], [29, 19, 44], [29, 19, 46], [29, 20, 14], [29, 20, 16], [29, 20, 25], [29, 20, 29], [29, 20, 30], [29, 20, 41], [29, 20, 42], [29, 20, 43], [29, 21, 8], [29, 21, 10], [29, 21, 14], [29, 21, 24], [29, 21, 30], [29, 21, 36], [29, 21, 38], [29, 21, 45], [29, 22, 4], [29, 22, 5], [29, 22, 6], [29, 22, 18], [29, 22, 27], [29, 22, 31], [29, 22, 33], [29, 22, 46], [29, 23, 2], [29, 23, 6], [29, 23, 9], [29, 23, 11], [29, 23, 17], [29, 23, 26], [29, 23, 31], [29, 23, 33], [29, 24, 14], [29, 24, 16], [29, 24, 21], [29, 24, 30], [29, 24, 36], [29, 24, 38], [29, 24, 41], [29, 24, 45], [29, 25, 1], [29, 25, 14], [29, 25, 16], [29, 25, 20], [29, 25, 29], [29, 25, 41], [29, 25, 42], [29, 25, 43], [29, 26, 2], [29, 26, 9], [29, 26, 11], [29, 26, 17], [29, 26, 23], [29, 26, 33], [29, 26, 37], [29, 26, 39], [29, 27, 4], [29, 27, 5], [29, 27, 6], [29, 27, 17], [29, 27, 18], [29, 27, 22], [29, 27, 31], [29, 27, 33], [29, 28, 1], [29, 28, 3], [29, 28, 13], [29, 28, 29], [29, 28, 32], [29, 28, 35], [29, 28, 40], [29, 28, 42], [29, 29, 0], [29, 29, 1], [29, 29, 13], [29, 29, 20], [29, 29, 25], [29, 29, 28], [29, 29, 29], [29, 29, 35], [29, 29, 42], [29, 29, 43], [29, 30, 14], [29, 30, 16], [29, 30, 20], [29, 30, 21], [29, 30, 24], [29, 30, 38], [29, 30, 41], [29, 30, 45], [29, 31, 4], [29, 31, 5], [29, 31, 6], [29, 31, 17], [29, 31, 22], [29, 31, 23], [29, 31, 27], [29, 31, 33], [29, 32, 1], [29, 32, 3], [29, 32, 13], [29, 32, 28], [29, 32, 35], [29, 32, 37], [29, 32, 39], [29, 32, 40], [29, 33, 6], [29, 33, 9], [29, 33, 17], [29, 33, 22], [29, 33, 23], [29, 33, 26], [29, 33, 27], [29, 33, 31], [29, 34, 4], [29, 34, 5], [29, 34, 7], [29, 34, 12], [29, 34, 15], [29, 34, 18], [29, 34, 19], [29, 34, 46], [29, 35, 1], [29, 35, 3], [29, 35, 13], [29, 35, 28], [29, 35, 29], [29, 35, 32], [29, 35, 39], [29, 35, 40], [29, 36, 7], [29, 36, 8], [29, 36, 10], [29, 36, 21], [29, 36, 24], [29, 36, 38], [29, 36, 44], [29, 36, 45], [29, 37, 2], [29, 37, 3], [29, 37, 9], [29, 37, 11], [29, 37, 26], [29, 37, 32], [29, 37, 39], [29, 37, 40], [29, 38, 10], [29, 38, 14], [29, 38, 21], [29, 38, 24], [29, 38, 30], [29, 38, 36], [29, 38, 41], [29, 38, 45], [29, 39, 2], [29, 39, 3], [29, 39, 11], [29, 39, 26], [29, 39, 32], [29, 39, 35], [29, 39, 37], [29, 39, 40], [29, 40, 3], [29, 40, 11], [29, 40, 13], [29, 40, 28], [29, 40, 32], [29, 40, 35], [29, 40, 37], [29, 40, 39], [29, 41, 14], [29, 41, 16], [29, 41, 20], [29, 41, 24], [29, 41, 25], [29, 41, 30], [29, 41, 38], [29, 41, 43], [29, 42, 1], [29, 42, 13], [29, 42, 16], [29, 42, 20], [29, 42, 25], [29, 42, 28], [29, 42, 29], [29, 42, 43], [29, 43, 1], [29, 43, 13], [29, 43, 16], [29, 43, 20], [29, 43, 25], [29, 43, 29], [29, 43, 41], [29, 43, 42], [29, 44, 7], [29, 44, 8], [29, 44, 10], [29, 44, 12], [29, 44, 15], [29, 44, 19], [29, 44, 36], [29, 44, 45], [29, 45, 8], [29, 45, 10], [29, 45, 21], [29, 45, 24], [29, 45, 30], [29, 45, 36], [29, 45, 38], [29, 45, 44], [29, 46, 4], [29, 46, 5], [29, 46, 12], [29, 46, 15], [29, 46, 18], [29, 46, 19], [29, 46, 22], [29, 46, 34], [30, 0, 30], [30, 1, 2], [30, 1, 7], [30, 1, 11], [30, 1, 15], [30, 1, 22], [30, 1, 24], [30, 1, 27], [30, 1, 30], [30, 2, 1], [30, 2, 4], [30, 2, 7], [30, 2, 13], [30, 2, 14], [30, 2, 22], [30, 2, 30], [30, 2, 44], [30, 3, 6], [30, 3, 19], [30, 3, 21], [30, 3, 25], [30, 3, 33], [30, 3, 34], [30, 3, 43], [30, 3, 45], [30, 4, 2], [30, 4, 8], [30, 4, 13], [30, 4, 14], [30, 4, 26], [30, 4, 28], [30, 4, 41], [30, 4, 44], [30, 5, 8], [30, 5, 9], [30, 5, 10], [30, 5, 16], [30, 5, 26], [30, 5, 28], [30, 5, 35], [30, 5, 41], [30, 6, 3], [30, 6, 12], [30, 6, 19], [30, 6, 21], [30, 6, 38], [30, 6, 39], [30, 6, 42], [30, 6, 43], [30, 7, 1], [30, 7, 2], [30, 7, 11], [30, 7, 13], [30, 7, 14], [30, 7, 22], [30, 7, 27], [30, 7, 30], [30, 8, 4], [30, 8, 5], [30, 8, 9], [30, 8, 16], [30, 8, 26], [30, 8, 28], [30, 8, 35], [30, 8, 41], [30, 9, 5], [30, 9, 8], [30, 9, 10], [30, 9, 16], [30, 9, 18], [30, 9, 28], [30, 9, 35], [30, 9, 41], [30, 10, 5], [30, 10, 9], [30, 10, 16], [30, 10, 18], [30, 10, 20], [30, 10, 23], [30, 10, 32], [30, 10, 35], [30, 11, 1], [30, 11, 7], [30, 11, 15], [30, 11, 22], [30, 11, 24], [30, 11, 27], [30, 11, 29], [30, 11, 30], [30, 12, 6], [30, 12, 24], [30, 12, 29], [30, 12, 31], [30, 12, 37], [30, 12, 38], [30, 12, 39], [30, 12, 42], [30, 13, 2], [30, 13, 4], [30, 13, 7], [30, 13, 14], [30, 13, 22], [30, 13, 26], [30, 13, 30], [30, 13, 44], [30, 14, 2], [30, 14, 4], [30, 14, 7], [30, 14, 13], [30, 14, 22], [30, 14, 26], [30, 14, 28], [30, 14, 44], [30, 15, 1], [30, 15, 11], [30, 15, 24], [30, 15, 27], [30, 15, 29], [30, 15, 30], [30, 15, 31], [30, 15, 37], [30, 16, 5], [30, 16, 8], [30, 16, 9], [30, 16, 10], [30, 16, 18], [30, 16, 23], [30, 16, 32], [30, 16, 35], [30, 17, 20], [30, 17, 25], [30, 17, 32], [30, 17, 34], [30, 17, 36], [30, 17, 40], [30, 17, 45], [30, 17, 46], [30, 18, 9], [30, 18, 10], [30, 18, 16], [30, 18, 20], [30, 18, 23], [30, 18, 32], [30, 18, 35], [30, 18, 36], [30, 19, 3], [30, 19, 6], [30, 19, 21], [30, 19, 33], [30, 19, 38], [30, 19, 39], [30, 19, 42], [30, 19, 43], [30, 20, 10], [30, 20, 17], [30, 20, 18], [30, 20, 23], [30, 20, 32], [30, 20, 36], [30, 20, 40], [30, 20, 46], [30, 21, 3], [30, 21, 6], [30, 21, 19], [30, 21, 33], [30, 21, 34], [30, 21, 39], [30, 21, 42], [30, 21, 43], [30, 22, 1], [30, 22, 2], [30, 22, 7], [30, 22, 11], [30, 22, 13], [30, 22, 14], [30, 22, 30], [30, 22, 44], [30, 23, 10], [30, 23, 16], [30, 23, 18], [30, 23, 20], [30, 23, 32], [30, 23, 35], [30, 23, 36], [30, 23, 46], [30, 24, 1], [30, 24, 11], [30, 24, 12], [30, 24, 15], [30, 24, 27], [30, 24, 29], [30, 24, 31], [30, 24, 37], [30, 25, 3], [30, 25, 17], [30, 25, 33], [30, 25, 34], [30, 25, 36], [30, 25, 40], [30, 25, 45], [30, 25, 46], [30, 26, 4], [30, 26, 5], [30, 26, 8], [30, 26, 13], [30, 26, 14], [30, 26, 28], [30, 26, 41], [30, 26, 44], [30, 27, 1], [30, 27, 7], [30, 27, 11], [30, 27, 15], [30, 27, 24], [30, 27, 29], [30, 27, 30], [30, 27, 37], [30, 28, 4], [30, 28, 5], [30, 28, 8], [30, 28, 9], [30, 28, 14], [30, 28, 26], [30, 28, 41], [30, 28, 44], [30, 29, 11], [30, 29, 12], [30, 29, 15], [30, 29, 24], [30, 29, 27], [30, 29, 31], [30, 29, 37], [30, 29, 38], [30, 30, 0], [30, 30, 1], [30, 30, 2], [30, 30, 7], [30, 30, 11], [30, 30, 13], [30, 30, 15], [30, 30, 22], [30, 30, 27], [30, 30, 30], [30, 31, 12], [30, 31, 15], [30, 31, 24], [30, 31, 29], [30, 31, 37], [30, 31, 38], [30, 31, 39], [30, 31, 42], [30, 32, 10], [30, 32, 16], [30, 32, 17], [30, 32, 18], [30, 32, 20], [30, 32, 23], [30, 32, 36], [30, 32, 46], [30, 33, 3], [30, 33, 19], [30, 33, 21], [30, 33, 25], [30, 33, 34], [30, 33, 40], [30, 33, 43], [30, 33, 45], [30, 34, 3], [30, 34, 17], [30, 34, 21], [30, 34, 25], [30, 34, 33], [30, 34, 40], [30, 34, 43], [30, 34, 45], [30, 35, 5], [30, 35, 8], [30, 35, 9], [30, 35, 10], [30, 35, 16], [30, 35, 18], [30, 35, 23], [30, 35, 41], [30, 36, 17], [30, 36, 18], [30, 36, 20], [30, 36, 23], [30, 36, 25], [30, 36, 32], [30, 36, 40], [30, 36, 46], [30, 37, 12], [30, 37, 15], [30, 37, 24], [30, 37, 27], [30, 37, 29], [30, 37, 31], [30, 37, 38], [30, 37, 42], [30, 38, 6], [30, 38, 12], [30, 38, 19], [30, 38, 29], [30, 38, 31], [30, 38, 37], [30, 38, 39], [30, 38, 42], [30, 39, 6], [30, 39, 12], [30, 39, 19], [30, 39, 21], [30, 39, 31], [30, 39, 38], [30, 39, 42], [30, 39, 43], [30, 40, 17], [30, 40, 20], [30, 40, 25], [30, 40, 33], [30, 40, 34], [30, 40, 36], [30, 40, 45], [30, 40, 46], [30, 41, 4], [30, 41, 5], [30, 41, 8], [30, 41, 9], [30, 41, 26], [30, 41, 28], [30, 41, 35], [30, 41, 44], [30, 42, 6], [30, 42, 12], [30, 42, 19], [30, 42, 21], [30, 42, 31], [30, 42, 37], [30, 42, 38], [30, 42, 39], [30, 43, 3], [30, 43, 6], [30, 43, 19], [30, 43, 21], [30, 43, 33], [30, 43, 34], [30, 43, 39], [30, 43, 45], [30, 44, 2], [30, 44, 4], [30, 44, 13], [30, 44, 14], [30, 44, 22], [30, 44, 26], [30, 44, 28], [30, 44, 41], [30, 45, 3], [30, 45, 17], [30, 45, 25], [30, 45, 33], [30, 45, 34], [30, 45, 40], [30, 45, 43], [30, 45, 46], [30, 46, 17], [30, 46, 20], [30, 46, 23], [30, 46, 25], [30, 46, 32], [30, 46, 36], [30, 46, 40], [30, 46, 45], [31, 0, 31], [31, 1, 9], [31, 1, 18], [31, 1, 20], [31, 1, 21], [31, 1, 31], [31, 1, 34], [31, 1, 40], [31, 1, 44], [31, 2, 15], [31, 2, 18], [31, 2, 21], [31, 2, 33], [31, 2, 36], [31, 2, 40], [31, 2, 41], [31, 2, 42], [31, 3, 7], [31, 3, 8], [31, 3, 13], [31, 3, 16], [31, 3, 26], [31, 3, 27], [31, 3, 38], [31, 3, 46], [31, 4, 19], [31, 4, 25], [31, 4, 30], [31, 4, 33], [31, 4, 35], [31, 4, 36], [31, 4, 37], [31, 4, 42], [31, 5, 6], [31, 5, 11], [31, 5, 12], [31, 5, 14], [31, 5, 29], [31, 5, 32], [31, 5, 43], [31, 5, 45], [31, 6, 5], [31, 6, 7], [31, 6, 14], [31, 6, 16], [31, 6, 26], [31, 6, 29], [31, 6, 32], [31, 6, 45], [31, 7, 3], [31, 7, 6], [31, 7, 16], [31, 7, 26], [31, 7, 29], [31, 7, 32], [31, 7, 45], [31, 7, 46], [31, 8, 3], [31, 8, 13], [31, 8, 19], [31, 8, 23], [31, 8, 25], [31, 8, 27], [31, 8, 37], [31, 8, 38], [31, 9, 1], [31, 9, 20], [31, 9, 21], [31, 9, 24], [31, 9, 31], [31, 9, 34], [31, 9, 39], [31, 9, 44], [31, 10, 11], [31, 10, 12], [31, 10, 17], [31, 10, 22], [31, 10, 24], [31, 10, 28], [31, 10, 39], [31, 10, 43], [31, 11, 5], [31, 11, 10], [31, 11, 12], [31, 11, 14], [31, 11, 17], [31, 11, 32], [31, 11, 43], [31, 11, 45], [31, 12, 5], [31, 12, 10], [31, 12, 11], [31, 12, 14], [31, 12, 17], [31, 12, 28], [31, 12, 32], [31, 12, 43], [31, 13, 3], [31, 13, 8], [31, 13, 19], [31, 13, 23], [31, 13, 25], [31, 13, 27], [31, 13, 38], [31, 13, 46], [31, 14, 5], [31, 14, 6], [31, 14, 11], [31, 14, 12], [31, 14, 17], [31, 14, 32], [31, 14, 43], [31, 14, 45], [31, 15, 2], [31, 15, 18], [31, 15, 33], [31, 15, 35], [31, 15, 36], [31, 15, 40], [31, 15, 41], [31, 15, 42], [31, 16, 3], [31, 16, 6], [31, 16, 7], [31, 16, 26], [31, 16, 27], [31, 16, 29], [31, 16, 38], [31, 16, 46], [31, 17, 10], [31, 17, 11], [31, 17, 12], [31, 17, 14], [31, 17, 22], [31, 17, 24], [31, 17, 28], [31, 17, 43], [31, 18, 1], [31, 18, 2], [31, 18, 15], [31, 18, 21], [31, 18, 31], [31, 18, 40], [31, 18, 41], [31, 18, 42], [31, 19, 4], [31, 19, 8], [31, 19, 13], [31, 19, 23], [31, 19, 25], [31, 19, 30], [31, 19, 35], [31, 19, 37], [31, 20, 1], [31, 20, 9], [31, 20, 22], [31, 20, 24], [31, 20, 31], [31, 20, 34], [31, 20, 39], [31, 20, 44], [31, 21, 1], [31, 21, 2], [31, 21, 9], [31, 21, 18], [31, 21, 31], [31, 21, 40], [31, 21, 41], [31, 21, 44], [31, 22, 10], [31, 22, 17], [31, 22, 20], [31, 22, 24], [31, 22, 28], [31, 22, 34], [31, 22, 39], [31, 22, 43], [31, 23, 8], [31, 23, 13], [31, 23, 19], [31, 23, 25], [31, 23, 27], [31, 23, 30], [31, 23, 37], [31, 23, 38], [31, 24, 9], [31, 24, 10], [31, 24, 17], [31, 24, 20], [31, 24, 22], [31, 24, 28], [31, 24, 34], [31, 24, 39], [31, 25, 4], [31, 25, 8], [31, 25, 13], [31, 25, 19], [31, 25, 23], [31, 25, 27], [31, 25, 30], [31, 25, 37], [31, 26, 3], [31, 26, 6], [31, 26, 7], [31, 26, 16], [31, 26, 29], [31, 26, 38], [31, 26, 45], [31, 26, 46], [31, 27, 3], [31, 27, 8], [31, 27, 13], [31, 27, 16], [31, 27, 23], [31, 27, 25], [31, 27, 38], [31, 27, 46], [31, 28, 10], [31, 28, 12], [31, 28, 17], [31, 28, 22], [31, 28, 24], [31, 28, 34], [31, 28, 39], [31, 28, 43], [31, 29, 5], [31, 29, 6], [31, 29, 7], [31, 29, 16], [31, 29, 26], [31, 29, 32], [31, 29, 45], [31, 29, 46], [31, 30, 4], [31, 30, 19], [31, 30, 23], [31, 30, 25], [31, 30, 33], [31, 30, 35], [31, 30, 36], [31, 30, 37], [31, 31, 0], [31, 31, 1], [31, 31, 9], [31, 31, 18], [31, 31, 20], [31, 31, 21], [31, 31, 31], [31, 31, 40], [31, 31, 41], [31, 31, 44], [31, 32, 5], [31, 32, 6], [31, 32, 7], [31, 32, 11], [31, 32, 12], [31, 32, 14], [31, 32, 29], [31, 32, 45], [31, 33, 2], [31, 33, 4], [31, 33, 15], [31, 33, 30], [31, 33, 35], [31, 33, 36], [31, 33, 41], [31, 33, 42], [31, 34, 1], [31, 34, 9], [31, 34, 20], [31, 34, 22], [31, 34, 24], [31, 34, 28], [31, 34, 39], [31, 34, 44], [31, 35, 4], [31, 35, 15], [31, 35, 19], [31, 35, 30], [31, 35, 33], [31, 35, 36], [31, 35, 37], [31, 35, 42], [31, 36, 2], [31, 36, 4], [31, 36, 15], [31, 36, 30], [31, 36, 33], [31, 36, 35], [31, 36, 37], [31, 36, 42], [31, 37, 4], [31, 37, 8], [31, 37, 19], [31, 37, 23], [31, 37, 25], [31, 37, 30], [31, 37, 35], [31, 37, 36], [31, 38, 3], [31, 38, 8], [31, 38, 13], [31, 38, 16], [31, 38, 23], [31, 38, 26], [31, 38, 27], [31, 38, 46], [31, 39, 9], [31, 39, 10], [31, 39, 20], [31, 39, 22], [31, 39, 24], [31, 39, 28], [31, 39, 34], [31, 39, 44], [31, 40, 1], [31, 40, 2], [31, 40, 15], [31, 40, 18], [31, 40, 21], [31, 40, 31], [31, 40, 41], [31, 40, 44], [31, 41, 2], [31, 41, 15], [31, 41, 18], [31, 41, 21], [31, 41, 31], [31, 41, 33], [31, 41, 40], [31, 41, 42], [31, 42, 2], [31, 42, 4], [31, 42, 15], [31, 42, 18], [31, 42, 33], [31, 42, 35], [31, 42, 36], [31, 42, 41], [31, 43, 5], [31, 43, 10], [31, 43, 11], [31, 43, 12], [31, 43, 14], [31, 43, 17], [31, 43, 22], [31, 43, 28], [31, 44, 1], [31, 44, 9], [31, 44, 20], [31, 44, 21], [31, 44, 31], [31, 44, 34], [31, 44, 39], [31, 44, 40], [31, 45, 5], [31, 45, 6], [31, 45, 7], [31, 45, 11], [31, 45, 14], [31, 45, 26], [31, 45, 29], [31, 45, 32], [31, 46, 3], [31, 46, 7], [31, 46, 13], [31, 46, 16], [31, 46, 26], [31, 46, 27], [31, 46, 29], [31, 46, 38], [32, 0, 32], [32, 1, 6], [32, 1, 8], [32, 1, 9], [32, 1, 14], [32, 1, 21], [32, 1, 25], [32, 1, 32], [32, 1, 37], [32, 2, 3], [32, 2, 12], [32, 2, 16], [32, 2, 17], [32, 2, 18], [32, 2, 27], [32, 2, 28], [32, 2, 42], [32, 3, 2], [32, 3, 16], [32, 3, 17], [32, 3, 18], [32, 3, 24], [32, 3, 27], [32, 3, 28], [32, 3, 42], [32, 4, 6], [32, 4, 7], [32, 4, 9], [32, 4, 24], [32, 4, 32], [32, 4, 34], [32, 4, 36], [32, 4, 37], [32, 6, 1], [32, 6, 4], [32, 6, 7], [32, 6, 9], [32, 6, 32], [32, 6, 34], [32, 6, 36], [32, 6, 37], [32, 7, 4], [32, 7, 6], [32, 7, 9], [32, 7, 16], [32, 7, 24], [32, 7, 34], [32, 7, 36], [32, 7, 42], [32, 8, 1], [32, 8, 12], [32, 8, 14], [32, 8, 17], [32, 8, 18], [32, 8, 21], [32, 8, 25], [32, 8, 27], [32, 9, 1], [32, 9, 4], [32, 9, 6], [32, 9, 7], [32, 9, 25], [32, 9, 32], [32, 9, 34], [32, 9, 37], [32, 12, 2], [32, 12, 8], [32, 12, 14], [32, 12, 17], [32, 12, 18], [32, 12, 21], [32, 12, 25], [32, 12, 27], [32, 14, 1], [32, 14, 8], [32, 14, 12], [32, 14, 18], [32, 14, 21], [32, 14, 25], [32, 14, 32], [32, 14, 37], [32, 16, 2], [32, 16, 3], [32, 16, 7], [32, 16, 24], [32, 16, 28], [32, 16, 34], [32, 16, 36], [32, 16, 42], [32, 17, 2], [32, 17, 3], [32, 17, 8], [32, 17, 12], [32, 17, 18], [32, 17, 27], [32, 17, 28], [32, 17, 42], [32, 18, 2], [32, 18, 3], [32, 18, 8], [32, 18, 12], [32, 18, 14], [32, 18, 17], [32, 18, 21], [32, 18, 27], [32, 21, 1], [32, 21, 8], [32, 21, 12], [32, 21, 14], [32, 21, 18], [32, 21, 25], [32, 21, 27], [32, 21, 32], [32, 24, 3], [32, 24, 4], [32, 24, 7], [32, 24, 16], [32, 24, 28], [32, 24, 34], [32, 24, 36], [32, 24, 42], [32, 25, 1], [32, 25, 8], [32, 25, 9], [32, 25, 12], [32, 25, 14], [32, 25, 21], [32, 25, 32], [32, 25, 37], [32, 27, 2], [32, 27, 3], [32, 27, 8], [32, 27, 12], [32, 27, 17], [32, 27, 18], [32, 27, 21], [32, 27, 28], [32, 28, 2], [32, 28, 3], [32, 28, 16], [32, 28, 17], [32, 28, 24], [32, 28, 27], [32, 28, 36], [32, 28, 42], [32, 32, 0], [32, 32, 1], [32, 32, 4], [32, 32, 6], [32, 32, 9], [32, 32, 14], [32, 32, 21], [32, 32, 25], [32, 32, 32], [32, 32, 37], [32, 34, 4], [32, 34, 6], [32, 34, 7], [32, 34, 9], [32, 34, 16], [32, 34, 24], [32, 34, 36], [32, 34, 37], [32, 36, 4], [32, 36, 6], [32, 36, 7], [32, 36, 16], [32, 36, 24], [32, 36, 28], [32, 36, 34], [32, 36, 42], [32, 37, 1], [32, 37, 4], [32, 37, 6], [32, 37, 9], [32, 37, 14], [32, 37, 25], [32, 37, 32], [32, 37, 34], [32, 42, 2], [32, 42, 3], [32, 42, 7], [32, 42, 16], [32, 42, 17], [32, 42, 24], [32, 42, 28], [32, 42, 36], [33, 0, 33], [33, 1, 6], [33, 1, 8], [33, 1, 10], [33, 1, 13], [33, 1, 17], [33, 1, 29], [33, 1, 33], [33, 1, 36], [33, 2, 11], [33, 2, 12], [33, 2, 16], [33, 2, 19], [33, 2, 20], [33, 2, 25], [33, 2, 26], [33, 2, 34], [33, 3, 4], [33, 3, 5], [33, 3, 14], [33, 3, 18], [33, 3, 24], [33, 3, 30], [33, 3, 39], [33, 3, 40], [33, 4, 3], [33, 4, 5], [33, 4, 21], [33, 4, 22], [33, 4, 24], [33, 4, 32], [33, 4, 38], [33, 4, 40], [33, 5, 3], [33, 5, 4], [33, 5, 18], [33, 5, 24], [33, 5, 30], [33, 5, 38], [33, 5, 39], [33, 5, 40], [33, 6, 1], [33, 6, 8], [33, 6, 10], [33, 6, 13], [33, 6, 28], [33, 6, 31], [33, 6, 33], [33, 6, 36], [33, 7, 9], [33, 7, 15], [33, 7, 17], [33, 7, 23], [33, 7, 25], [33, 7, 42], [33, 7, 43], [33, 7, 44], [33, 8, 1], [33, 8, 6], [33, 8, 10], [33, 8, 17], [33, 8, 29], [33, 8, 33], [33, 8, 42], [33, 8, 44], [33, 9, 7], [33, 9, 12], [33, 9, 15], [33, 9, 23], [33, 9, 25], [33, 9, 26], [33, 9, 42], [33, 9, 43], [33, 10, 1], [33, 10, 6], [33, 10, 8], [33, 10, 13], [33, 10, 29], [33, 10, 31], [33, 10, 33], [33, 10, 36], [33, 11, 2], [33, 11, 16], [33, 11, 19], [33, 11, 20], [33, 11, 34], [33, 11, 37], [33, 11, 41], [33, 11, 46], [33, 12, 2], [33, 12, 9], [33, 12, 15], [33, 12, 16], [33, 12, 19], [33, 12, 20], [33, 12, 25], [33, 12, 26], [33, 13, 1], [33, 13, 6], [33, 13, 10], [33, 13, 28], [33, 13, 31], [33, 13, 33], [33, 13, 36], [33, 13, 45], [33, 14, 3], [33, 14, 18], [33, 14, 30], [33, 14, 34], [33, 14, 37], [33, 14, 39], [33, 14, 41], [33, 14, 46], [33, 15, 7], [33, 15, 9], [33, 15, 12], [33, 15, 20], [33, 15, 23], [33, 15, 25], [33, 15, 26], [33, 15, 43], [33, 16, 2], [33, 16, 11], [33, 16, 12], [33, 16, 19], [33, 16, 20], [33, 16, 34], [33, 16, 37], [33, 16, 41], [33, 17, 1], [33, 17, 7], [33, 17, 8], [33, 17, 23], [33, 17, 29], [33, 17, 33], [33, 17, 42], [33, 17, 44], [33, 18, 3], [33, 18, 5], [33, 18, 14], [33, 18, 24], [33, 18, 30], [33, 18, 37], [33, 18, 39], [33, 18, 46], [33, 19, 2], [33, 19, 11], [33, 19, 12], [33, 19, 16], [33, 19, 20], [33, 19, 26], [33, 19, 34], [33, 19, 41], [33, 20, 2], [33, 20, 11], [33, 20, 12], [33, 20, 15], [33, 20, 16], [33, 20, 19], [33, 20, 25], [33, 20, 26], [33, 21, 4], [33, 21, 22], [33, 21, 27], [33, 21, 28], [33, 21, 32], [33, 21, 35], [33, 21, 38], [33, 21, 45], [33, 22, 4], [33, 22, 21], [33, 22, 27], [33, 22, 32], [33, 22, 35], [33, 22, 38], [33, 22, 40], [33, 22, 45], [33, 23, 7], [33, 23, 9], [33, 23, 15], [33, 23, 17], [33, 23, 29], [33, 23, 42], [33, 23, 43], [33, 23, 44], [33, 24, 3], [33, 24, 4], [33, 24, 5], [33, 24, 18], [33, 24, 30], [33, 24, 32], [33, 24, 38], [33, 24, 40], [33, 25, 2], [33, 25, 7], [33, 25, 9], [33, 25, 12], [33, 25, 15], [33, 25, 20], [33, 25, 26], [33, 25, 43], [33, 26, 2], [33, 26, 9], [33, 26, 12], [33, 26, 15], [33, 26, 19], [33, 26, 20], [33, 26, 25], [33, 26, 43], [33, 27, 21], [33, 27, 22], [33, 27, 28], [33, 27, 31], [33, 27, 32], [33, 27, 35], [33, 27, 36], [33, 27, 45], [33, 28, 6], [33, 28, 13], [33, 28, 21], [33, 28, 27], [33, 28, 31], [33, 28, 35], [33, 28, 36], [33, 28, 45], [33, 29, 1], [33, 29, 8], [33, 29, 10], [33, 29, 17], [33, 29, 23], [33, 29, 33], [33, 29, 42], [33, 29, 44], [33, 30, 3], [33, 30, 5], [33, 30, 14], [33, 30, 18], [33, 30, 24], [33, 30, 39], [33, 30, 40], [33, 30, 46], [33, 31, 6], [33, 31, 10], [33, 31, 13], [33, 31, 27], [33, 31, 28], [33, 31, 35], [33, 31, 36], [33, 31, 45], [33, 32, 4], [33, 32, 21], [33, 32, 22], [33, 32, 24], [33, 32, 27], [33, 32, 35], [33, 32, 38], [33, 32, 40], [33, 33, 0], [33, 33, 1], [33, 33, 6], [33, 33, 8], [33, 33, 10], [33, 33, 13], [33, 33, 17], [33, 33, 29], [33, 33, 33], [33, 33, 44], [33, 34, 2], [33, 34, 11], [33, 34, 14], [33, 34, 16], [33, 34, 19], [33, 34, 37], [33, 34, 41], [33, 34, 46], [33, 35, 21], [33, 35, 22], [33, 35, 27], [33, 35, 28], [33, 35, 31], [33, 35, 32], [33, 35, 38], [33, 35, 45], [33, 36, 1], [33, 36, 6], [33, 36, 10], [33, 36, 13], [33, 36, 27], [33, 36, 28], [33, 36, 31], [33, 36, 45], [33, 37, 11], [33, 37, 14], [33, 37, 16], [33, 37, 18], [33, 37, 34], [33, 37, 39], [33, 37, 41], [33, 37, 46], [33, 38, 4], [33, 38, 5], [33, 38, 21], [33, 38, 22], [33, 38, 24], [33, 38, 32], [33, 38, 35], [33, 38, 40], [33, 39, 3], [33, 39, 5], [33, 39, 14], [33, 39, 18], [33, 39, 30], [33, 39, 37], [33, 39, 41], [33, 39, 46], [33, 40, 3], [33, 40, 4], [33, 40, 5], [33, 40, 22], [33, 40, 24], [33, 40, 30], [33, 40, 32], [33, 40, 38], [33, 41, 11], [33, 41, 14], [33, 41, 16], [33, 41, 19], [33, 41, 34], [33, 41, 37], [33, 41, 39], [33, 41, 46], [33, 42, 7], [33, 42, 8], [33, 42, 9], [33, 42, 17], [33, 42, 23], [33, 42, 29], [33, 42, 43], [33, 42, 44], [33, 43, 7], [33, 43, 9], [33, 43, 15], [33, 43, 23], [33, 43, 25], [33, 43, 26], [33, 43, 42], [33, 43, 44], [33, 44, 7], [33, 44, 8], [33, 44, 17], [33, 44, 23], [33, 44, 29], [33, 44, 33], [33, 44, 42], [33, 44, 43], [33, 45, 13], [33, 45, 21], [33, 45, 22], [33, 45, 27], [33, 45, 28], [33, 45, 31], [33, 45, 35], [33, 45, 36], [33, 46, 11], [33, 46, 14], [33, 46, 18], [33, 46, 30], [33, 46, 34], [33, 46, 37], [33, 46, 39], [33, 46, 41], [34, 0, 34], [34, 1, 4], [34, 1, 12], [34, 1, 18], [34, 1, 25], [34, 1, 28], [34, 1, 32], [34, 1, 34], [34, 1, 42], [34, 2, 3], [34, 2, 8], [34, 2, 9], [34, 2, 17], [34, 2, 21], [34, 2, 24], [34, 2, 36], [34, 2, 37], [34, 3, 2], [34, 3, 7], [34, 3, 8], [34, 3, 12], [34, 3, 28], [34, 3, 32], [34, 3, 36], [34, 3, 37], [34, 4, 1], [34, 4, 6], [34, 4, 16], [34, 4, 18], [34, 4, 25], [34, 4, 27], [34, 4, 34], [34, 4, 42], [34, 6, 4], [34, 6, 9], [34, 6, 14], [34, 6, 16], [34, 6, 17], [34, 6, 24], [34, 6, 25], [34, 6, 27], [34, 7, 3], [34, 7, 8], [34, 7, 12], [34, 7, 28], [34, 7, 32], [34, 7, 34], [34, 7, 36], [34, 7, 37], [34, 8, 2], [34, 8, 3], [34, 8, 7], [34, 8, 12], [34, 8, 21], [34, 8, 32], [34, 8, 36], [34, 8, 37], [34, 9, 2], [34, 9, 6], [34, 9, 14], [34, 9, 17], [34, 9, 21], [34, 9, 24], [34, 9, 36], [34, 9, 37], [34, 12, 1], [34, 12, 3], [34, 12, 7], [34, 12, 8], [34, 12, 18], [34, 12, 28], [34, 12, 32], [34, 12, 34], [34, 14, 6], [34, 14, 9], [34, 14, 16], [34, 14, 17], [34, 14, 21], [34, 14, 24], [34, 14, 25], [34, 14, 27], [34, 16, 4], [34, 16, 6], [34, 16, 14], [34, 16, 17], [34, 16, 24], [34, 16, 25], [34, 16, 27], [34, 16, 42], [34, 17, 2], [34, 17, 6], [34, 17, 9], [34, 17, 14], [34, 17, 16], [34, 17, 21], [34, 17, 24], [34, 17, 27], [34, 18, 1], [34, 18, 4], [34, 18, 12], [34, 18, 25], [34, 18, 27], [34, 18, 28], [34, 18, 34], [34, 18, 42], [34, 21, 2], [34, 21, 8], [34, 21, 9], [34, 21, 14], [34, 21, 17], [34, 21, 24], [34, 21, 36], [34, 21, 37], [34, 24, 2], [34, 24, 6], [34, 24, 9], [34, 24, 14], [34, 24, 16], [34, 24, 17], [34, 24, 21], [34, 24, 36], [34, 25, 1], [34, 25, 4], [34, 25, 6], [34, 25, 14], [34, 25, 16], [34, 25, 18], [34, 25, 27], [34, 25, 42], [34, 27, 4], [34, 27, 6], [34, 27, 14], [34, 27, 16], [34, 27, 17], [34, 27, 18], [34, 27, 25], [34, 27, 42], [34, 28, 1], [34, 28, 3], [34, 28, 7], [34, 28, 12], [34, 28, 18], [34, 28, 32], [34, 28, 34], [34, 28, 42], [34, 32, 1], [34, 32, 3], [34, 32, 7], [34, 32, 8], [34, 32, 12], [34, 32, 28], [34, 32, 34], [34, 32, 37], [34, 34, 0], [34, 34, 1], [34, 34, 4], [34, 34, 7], [34, 34, 12], [34, 34, 18], [34, 34, 28], [34, 34, 32], [34, 34, 34], [34, 34, 42], [34, 36, 2], [34, 36, 3], [34, 36, 7], [34, 36, 8], [34, 36, 9], [34, 36, 21], [34, 36, 24], [34, 36, 37], [34, 37, 2], [34, 37, 3], [34, 37, 7], [34, 37, 8], [34, 37, 9], [34, 37, 21], [34, 37, 32], [34, 37, 36], [34, 42, 1], [34, 42, 4], [34, 42, 16], [34, 42, 18], [34, 42, 25], [34, 42, 27], [34, 42, 28], [34, 42, 34], [35, 0, 35], [35, 1, 3], [35, 1, 9], [35, 1, 11], [35, 1, 16], [35, 1, 21], [35, 1, 30], [35, 1, 35], [35, 1, 43], [35, 2, 6], [35, 2, 13], [35, 2, 18], [35, 2, 22], [35, 2, 23], [35, 2, 32], [35, 2, 39], [35, 2, 42], [35, 3, 1], [35, 3, 9], [35, 3, 11], [35, 3, 16], [35, 3, 27], [35, 3, 33], [35, 3, 35], [35, 3, 43], [35, 4, 12], [35, 4, 17], [35, 4, 26], [35, 4, 31], [35, 4, 36], [35, 4, 37], [35, 4, 44], [35, 4, 46], [35, 5, 8], [35, 5, 9], [35, 5, 11], [35, 5, 15], [35, 5, 27], [35, 5, 33], [35, 5, 34], [35, 5, 45], [35, 6, 2], [35, 6, 7], [35, 6, 18], [35, 6, 19], [35, 6, 22], [35, 6, 23], [35, 6, 32], [35, 6, 39], [35, 7, 6], [35, 7, 10], [35, 7, 16], [35, 7, 18], [35, 7, 19], [35, 7, 21], [35, 7, 22], [35, 7, 30], [35, 8, 5], [35, 8, 15], [35, 8, 24], [35, 8, 25], [35, 8, 27], [35, 8, 34], [35, 8, 41], [35, 8, 45], [35, 9, 1], [35, 9, 3], [35, 9, 5], [35, 9, 11], [35, 9, 27], [35, 9, 33], [35, 9, 34], [35, 9, 35], [35, 10, 7], [35, 10, 16], [35, 10, 18], [35, 10, 19], [35, 10, 21], [35, 10, 22], [35, 10, 30], [35, 10, 43], [35, 11, 1], [35, 11, 3], [35, 11, 5], [35, 11, 9], [35, 11, 27], [35, 11, 33], [35, 11, 35], [35, 11, 43], [35, 12, 4], [35, 12, 14], [35, 12, 17], [35, 12, 31], [35, 12, 36], [35, 12, 38], [35, 12, 44], [35, 12, 46], [35, 13, 2], [35, 13, 14], [35, 13, 20], [35, 13, 23], [35, 13, 32], [35, 13, 38], [35, 13, 39], [35, 13, 42], [35, 14, 12], [35, 14, 13], [35, 14, 20], [35, 14, 32], [35, 14, 36], [35, 14, 38], [35, 14, 42], [35, 14, 44], [35, 15, 5], [35, 15, 8], [35, 15, 24], [35, 15, 27], [35, 15, 33], [35, 15, 34], [35, 15, 41], [35, 15, 45], [35, 16, 1], [35, 16, 3], [35, 16, 7], [35, 16, 10], [35, 16, 21], [35, 16, 30], [35, 16, 35], [35, 16, 43], [35, 17, 4], [35, 17, 12], [35, 17, 26], [35, 17, 28], [35, 17, 31], [35, 17, 37], [35, 17, 40], [35, 17, 46], [35, 18, 2], [35, 18, 6], [35, 18, 7], [35, 18, 10], [35, 18, 19], [35, 18, 21], [35, 18, 22], [35, 18, 23], [35, 19, 6], [35, 19, 7], [35, 19, 10], [35, 19, 18], [35, 19, 21], [35, 19, 22], [35, 19, 23], [35, 19, 30], [35, 20, 13], [35, 20, 14], [35, 20, 32], [35, 20, 36], [35, 20, 38], [35, 20, 39], [35, 20, 42], [35, 20, 44], [35, 21, 1], [35, 21, 7], [35, 21, 10], [35, 21, 16], [35, 21, 18], [35, 21, 19], [35, 21, 30], [35, 21, 43], [35, 22, 2], [35, 22, 6], [35, 22, 7], [35, 22, 10], [35, 22, 18], [35, 22, 19], [35, 22, 23], [35, 22, 39], [35, 23, 2], [35, 23, 6], [35, 23, 13], [35, 23, 18], [35, 23, 19], [35, 23, 22], [35, 23, 32], [35, 23, 39], [35, 24, 8], [35, 24, 15], [35, 24, 25], [35, 24, 28], [35, 24, 29], [35, 24, 34], [35, 24, 41], [35, 24, 45], [35, 25, 8], [35, 25, 24], [35, 25, 28], [35, 25, 29], [35, 25, 37], [35, 25, 40], [35, 25, 41], [35, 25, 45], [35, 26, 4], [35, 26, 17], [35, 26, 28], [35, 26, 29], [35, 26, 31], [35, 26, 37], [35, 26, 40], [35, 26, 46], [35, 27, 3], [35, 27, 5], [35, 27, 8], [35, 27, 9], [35, 27, 11], [35, 27, 15], [35, 27, 33], [35, 27, 34], [35, 28, 17], [35, 28, 24], [35, 28, 25], [35, 28, 26], [35, 28, 29], [35, 28, 37], [35, 28, 40], [35, 28, 41], [35, 29, 24], [35, 29, 25], [35, 29, 26], [35, 29, 28], [35, 29, 37], [35, 29, 40], [35, 29, 41], [35, 29, 45], [35, 30, 1], [35, 30, 7], [35, 30, 10], [35, 30, 16], [35, 30, 19], [35, 30, 21], [35, 30, 35], [35, 30, 43], [35, 31, 4], [35, 31, 12], [35, 31, 17], [35, 31, 26], [35, 31, 37], [35, 31, 40], [35, 31, 44], [35, 31, 46], [35, 32, 2], [35, 32, 6], [35, 32, 13], [35, 32, 14], [35, 32, 20], [35, 32, 23], [35, 32, 39], [35, 32, 42], [35, 33, 3], [35, 33, 5], [35, 33, 9], [35, 33, 11], [35, 33, 15], [35, 33, 27], [35, 33, 34], [35, 33, 35], [35, 34, 5], [35, 34, 8], [35, 34, 9], [35, 34, 15], [35, 34, 24], [35, 34, 27], [35, 34, 33], [35, 34, 45], [35, 35, 0], [35, 35, 1], [35, 35, 3], [35, 35, 9], [35, 35, 11], [35, 35, 16], [35, 35, 30], [35, 35, 33], [35, 35, 35], [35, 35, 43], [35, 36, 4], [35, 36, 12], [35, 36, 14], [35, 36, 20], [35, 36, 38], [35, 36, 42], [35, 36, 44], [35, 36, 46], [35, 37, 4], [35, 37, 17], [35, 37, 25], [35, 37, 26], [35, 37, 28], [35, 37, 29], [35, 37, 31], [35, 37, 40], [35, 38, 12], [35, 38, 13], [35, 38, 14], [35, 38, 20], [35, 38, 36], [35, 38, 42], [35, 38, 44], [35, 38, 46], [35, 39, 2], [35, 39, 6], [35, 39, 13], [35, 39, 20], [35, 39, 22], [35, 39, 23], [35, 39, 32], [35, 39, 42], [35, 40, 17], [35, 40, 25], [35, 40, 26], [35, 40, 28], [35, 40, 29], [35, 40, 31], [35, 40, 37], [35, 40, 41], [35, 41, 8], [35, 41, 15], [35, 41, 24], [35, 41, 25], [35, 41, 28], [35, 41, 29], [35, 41, 40], [35, 41, 45], [35, 42, 2], [35, 42, 13], [35, 42, 14], [35, 42, 20], [35, 42, 32], [35, 42, 36], [35, 42, 38], [35, 42, 39], [35, 43, 1], [35, 43, 3], [35, 43, 10], [35, 43, 11], [35, 43, 16], [35, 43, 21], [35, 43, 30], [35, 43, 35], [35, 44, 4], [35, 44, 12], [35, 44, 14], [35, 44, 20], [35, 44, 31], [35, 44, 36], [35, 44, 38], [35, 44, 46], [35, 45, 5], [35, 45, 8], [35, 45, 15], [35, 45, 24], [35, 45, 25], [35, 45, 29], [35, 45, 34], [35, 45, 41], [35, 46, 4], [35, 46, 12], [35, 46, 17], [35, 46, 26], [35, 46, 31], [35, 46, 36], [35, 46, 38], [35, 46, 44], [36, 0, 36], [36, 1, 2], [36, 1, 7], [36, 1, 17], [36, 1, 24], [36, 1, 25], [36, 1, 27], [36, 1, 32], [36, 1, 36], [36, 2, 1], [36, 2, 3], [36, 2, 4], [36, 2, 7], [36, 2, 14], [36, 2, 17], [36, 2, 25], [36, 2, 34], [36, 3, 2], [36, 3, 4], [36, 3, 6], [36, 3, 14], [36, 3, 21], [36, 3, 25], [36, 3, 28], [36, 3, 34], [36, 4, 2], [36, 4, 3], [36, 4, 6], [36, 4, 8], [36, 4, 14], [36, 4, 21], [36, 4, 28], [36, 4, 34], [36, 6, 3], [36, 6, 4], [36, 6, 8], [36, 6, 9], [36, 6, 12], [36, 6, 21], [36, 6, 28], [36, 6, 42], [36, 7, 1], [36, 7, 2], [36, 7, 14], [36, 7, 17], [36, 7, 25], [36, 7, 27], [36, 7, 34], [36, 7, 36], [36, 8, 4], [36, 8, 6], [36, 8, 9], [36, 8, 12], [36, 8, 16], [36, 8, 21], [36, 8, 28], [36, 8, 42], [36, 9, 6], [36, 9, 8], [36, 9, 12], [36, 9, 16], [36, 9, 18], [36, 9, 28], [36, 9, 37], [36, 9, 42], [36, 12, 6], [36, 12, 8], [36, 12, 9], [36, 12, 16], [36, 12, 18], [36, 12, 24], [36, 12, 37], [36, 12, 42], [36, 14, 2], [36, 14, 3], [36, 14, 4], [36, 14, 7], [36, 14, 21], [36, 14, 25], [36, 14, 28], [36, 14, 34], [36, 16, 8], [36, 16, 9], [36, 16, 12], [36, 16, 18], [36, 16, 24], [36, 16, 32], [36, 16, 37], [36, 16, 42], [36, 17, 1], [36, 17, 2], [36, 17, 7], [36, 17, 25], [36, 17, 27], [36, 17, 32], [36, 17, 34], [36, 17, 36], [36, 18, 9], [36, 18, 12], [36, 18, 16], [36, 18, 24], [36, 18, 27], [36, 18, 32], [36, 18, 36], [36, 18, 37], [36, 21, 3], [36, 21, 4], [36, 21, 6], [36, 21, 8], [36, 21, 14], [36, 21, 28], [36, 21, 34], [36, 21, 42], [36, 24, 1], [36, 24, 12], [36, 24, 16], [36, 24, 18], [36, 24, 27], [36, 24, 32], [36, 24, 36], [36, 24, 37], [36, 25, 1], [36, 25, 2], [36, 25, 3], [36, 25, 7], [36, 25, 14], [36, 25, 17], [36, 25, 34], [36, 25, 36], [36, 27, 1], [36, 27, 7], [36, 27, 17], [36, 27, 18], [36, 27, 24], [36, 27, 32], [36, 27, 36], [36, 27, 37], [36, 28, 3], [36, 28, 4], [36, 28, 6], [36, 28, 8], [36, 28, 9], [36, 28, 14], [36, 28, 21], [36, 28, 42], [36, 32, 1], [36, 32, 16], [36, 32, 17], [36, 32, 18], [36, 32, 24], [36, 32, 27], [36, 32, 36], [36, 32, 37], [36, 34, 2], [36, 34, 3], [36, 34, 4], [36, 34, 7], [36, 34, 14], [36, 34, 17], [36, 34, 21], [36, 34, 25], [36, 36, 0], [36, 36, 1], [36, 36, 7], [36, 36, 17], [36, 36, 18], [36, 36, 24], [36, 36, 25], [36, 36, 27], [36, 36, 32], [36, 36, 36], [36, 37, 9], [36, 37, 12], [36, 37, 16], [36, 37, 18], [36, 37, 24], [36, 37, 27], [36, 37, 32], [36, 37, 42], [36, 42, 6], [36, 42, 8], [36, 42, 9], [36, 42, 12], [36, 42, 16], [36, 42, 21], [36, 42, 28], [36, 42, 37], [37, 0, 37], [37, 1, 6], [37, 1, 8], [37, 1, 14], [37, 1, 17], [37, 1, 18], [37, 1, 34], [37, 1, 36], [37, 1, 37], [37, 2, 12], [37, 2, 16], [37, 2, 21], [37, 2, 25], [37, 2, 27], [37, 2, 28], [37, 2, 34], [37, 2, 36], [37, 3, 4], [37, 3, 7], [37, 3, 8], [37, 3, 14], [37, 3, 17], [37, 3, 18], [37, 3, 24], [37, 3, 42], [37, 4, 3], [37, 4, 7], [37, 4, 9], [37, 4, 21], [37, 4, 24], [37, 4, 25], [37, 4, 32], [37, 4, 42], [37, 6, 1], [37, 6, 8], [37, 6, 14], [37, 6, 16], [37, 6, 28], [37, 6, 34], [37, 6, 36], [37, 6, 37], [37, 7, 3], [37, 7, 4], [37, 7, 9], [37, 7, 17], [37, 7, 24], [37, 7, 25], [37, 7, 32], [37, 7, 42], [37, 8, 1], [37, 8, 3], [37, 8, 6], [37, 8, 14], [37, 8, 17], [37, 8, 18], [37, 8, 37], [37, 8, 42], [37, 9, 4], [37, 9, 7], [37, 9, 12], [37, 9, 21], [37, 9, 24], [37, 9, 25], [37, 9, 32], [37, 9, 42], [37, 12, 2], [37, 12, 9], [37, 12, 16], [37, 12, 21], [37, 12, 25], [37, 12, 27], [37, 12, 28], [37, 12, 32], [37, 14, 1], [37, 14, 3], [37, 14, 6], [37, 14, 8], [37, 14, 17], [37, 14, 18], [37, 14, 34], [37, 14, 37], [37, 16, 2], [37, 16, 6], [37, 16, 12], [37, 16, 27], [37, 16, 28], [37, 16, 34], [37, 16, 36], [37, 16, 37], [37, 17, 1], [37, 17, 3], [37, 17, 7], [37, 17, 8], [37, 17, 14], [37, 17, 18], [37, 17, 24], [37, 17, 42], [37, 18, 1], [37, 18, 3], [37, 18, 8], [37, 18, 14], [37, 18, 17], [37, 18, 24], [37, 18, 37], [37, 18, 42], [37, 21, 2], [37, 21, 4], [37, 21, 9], [37, 21, 12], [37, 21, 25], [37, 21, 27], [37, 21, 28], [37, 21, 32], [37, 24, 3], [37, 24, 4], [37, 24, 7], [37, 24, 9], [37, 24, 17], [37, 24, 18], [37, 24, 32], [37, 24, 42], [37, 25, 2], [37, 25, 4], [37, 25, 7], [37, 25, 9], [37, 25, 12], [37, 25, 21], [37, 25, 27], [37, 25, 32], [37, 27, 2], [37, 27, 12], [37, 27, 16], [37, 27, 21], [37, 27, 25], [37, 27, 28], [37, 27, 32], [37, 27, 36], [37, 28, 2], [37, 28, 6], [37, 28, 12], [37, 28, 16], [37, 28, 21], [37, 28, 27], [37, 28, 34], [37, 28, 36], [37, 32, 4], [37, 32, 7], [37, 32, 9], [37, 32, 12], [37, 32, 21], [37, 32, 24], [37, 32, 25], [37, 32, 27], [37, 34, 1], [37, 34, 2], [37, 34, 6], [37, 34, 14], [37, 34, 16], [37, 34, 28], [37, 34, 36], [37, 34, 37], [37, 36, 1], [37, 36, 2], [37, 36, 6], [37, 36, 16], [37, 36, 27], [37, 36, 28], [37, 36, 34], [37, 36, 37], [37, 37, 0], [37, 37, 1], [37, 37, 6], [37, 37, 8], [37, 37, 14], [37, 37, 16], [37, 37, 18], [37, 37, 34], [37, 37, 36], [37, 37, 37], [37, 42, 3], [37, 42, 4], [37, 42, 7], [37, 42, 8], [37, 42, 9], [37, 42, 17], [37, 42, 18], [37, 42, 24], [38, 0, 38], [38, 1, 18], [38, 1, 23], [38, 1, 26], [38, 1, 28], [38, 1, 34], [38, 1, 38], [38, 1, 42], [38, 1, 45], [38, 2, 5], [38, 2, 9], [38, 2, 21], [38, 2, 29], [38, 2, 36], [38, 2, 37], [38, 2, 43], [38, 2, 46], [38, 3, 7], [38, 3, 8], [38, 3, 20], [38, 3, 22], [38, 3, 31], [38, 3, 32], [38, 3, 37], [38, 3, 41], [38, 4, 10], [38, 4, 11], [38, 4, 18], [38, 4, 25], [38, 4, 27], [38, 4, 39], [38, 4, 42], [38, 4, 45], [38, 5, 2], [38, 5, 21], [38, 5, 22], [38, 5, 29], [38, 5, 36], [38, 5, 37], [38, 5, 43], [38, 5, 46], [38, 6, 14], [38, 6, 15], [38, 6, 16], [38, 6, 17], [38, 6, 27], [38, 6, 35], [38, 6, 40], [38, 6, 44], [38, 7, 3], [38, 7, 8], [38, 7, 12], [38, 7, 20], [38, 7, 31], [38, 7, 32], [38, 7, 33], [38, 7, 41], [38, 8, 3], [38, 8, 7], [38, 8, 20], [38, 8, 22], [38, 8, 31], [38, 8, 36], [38, 8, 37], [38, 8, 43], [38, 9, 2], [38, 9, 13], [38, 9, 17], [38, 9, 19], [38, 9, 21], [38, 9, 24], [38, 9, 29], [38, 9, 46], [38, 10, 4], [38, 10, 11], [38, 10, 25], [38, 10, 27], [38, 10, 39], [38, 10, 42], [38, 10, 44], [38, 10, 45], [38, 11, 4], [38, 11, 10], [38, 11, 18], [38, 11, 25], [38, 11, 26], [38, 11, 39], [38, 11, 42], [38, 11, 45], [38, 12, 7], [38, 12, 23], [38, 12, 28], [38, 12, 30], [38, 12, 32], [38, 12, 33], [38, 12, 34], [38, 12, 41], [38, 13, 9], [38, 13, 17], [38, 13, 19], [38, 13, 21], [38, 13, 24], [38, 13, 29], [38, 13, 35], [38, 13, 46], [38, 14, 6], [38, 14, 15], [38, 14, 16], [38, 14, 17], [38, 14, 19], [38, 14, 24], [38, 14, 35], [38, 14, 40], [38, 15, 6], [38, 15, 14], [38, 15, 16], [38, 15, 17], [38, 15, 19], [38, 15, 35], [38, 15, 40], [38, 15, 44], [38, 16, 6], [38, 16, 14], [38, 16, 15], [38, 16, 25], [38, 16, 27], [38, 16, 39], [38, 16, 40], [38, 16, 44], [38, 17, 6], [38, 17, 9], [38, 17, 13], [38, 17, 14], [38, 17, 15], [38, 17, 19], [38, 17, 24], [38, 17, 35], [38, 18, 1], [38, 18, 4], [38, 18, 11], [38, 18, 26], [38, 18, 34], [38, 18, 38], [38, 18, 42], [38, 18, 45], [38, 19, 9], [38, 19, 13], [38, 19, 14], [38, 19, 15], [38, 19, 17], [38, 19, 24], [38, 19, 35], [38, 19, 46], [38, 20, 3], [38, 20, 7], [38, 20, 8], [38, 20, 22], [38, 20, 31], [38, 20, 37], [38, 20, 41], [38, 20, 43], [38, 21, 2], [38, 21, 5], [38, 21, 9], [38, 21, 13], [38, 21, 24], [38, 21, 29], [38, 21, 36], [38, 21, 46], [38, 22, 3], [38, 22, 5], [38, 22, 8], [38, 22, 20], [38, 22, 31], [38, 22, 36], [38, 22, 37], [38, 22, 43], [38, 23, 1], [38, 23, 12], [38, 23, 26], [38, 23, 28], [38, 23, 30], [38, 23, 33], [38, 23, 34], [38, 23, 38], [38, 24, 9], [38, 24, 13], [38, 24, 14], [38, 24, 17], [38, 24, 19], [38, 24, 21], [38, 24, 35], [38, 24, 46], [38, 25, 4], [38, 25, 10], [38, 25, 11], [38, 25, 16], [38, 25, 27], [38, 25, 39], [38, 25, 42], [38, 25, 44], [38, 26, 1], [38, 26, 11], [38, 26, 18], [38, 26, 23], [38, 26, 34], [38, 26, 38], [38, 26, 42], [38, 26, 45], [38, 27, 4], [38, 27, 6], [38, 27, 10], [38, 27, 16], [38, 27, 25], [38, 27, 39], [38, 27, 40], [38, 27, 44], [38, 28, 1], [38, 28, 12], [38, 28, 23], [38, 28, 30], [38, 28, 32], [38, 28, 33], [38, 28, 34], [38, 28, 38], [38, 29, 2], [38, 29, 5], [38, 29, 9], [38, 29, 13], [38, 29, 21], [38, 29, 36], [38, 29, 43], [38, 29, 46], [38, 30, 12], [38, 30, 23], [38, 30, 28], [38, 30, 32], [38, 30, 33], [38, 30, 34], [38, 30, 38], [38, 30, 41], [38, 31, 3], [38, 31, 7], [38, 31, 8], [38, 31, 20], [38, 31, 22], [38, 31, 32], [38, 31, 33], [38, 31, 41], [38, 32, 3], [38, 32, 7], [38, 32, 12], [38, 32, 28], [38, 32, 30], [38, 32, 31], [38, 32, 33], [38, 32, 41], [38, 33, 7], [38, 33, 12], [38, 33, 23], [38, 33, 28], [38, 33, 30], [38, 33, 31], [38, 33, 32], [38, 33, 41], [38, 34, 1], [38, 34, 12], [38, 34, 18], [38, 34, 23], [38, 34, 26], [38, 34, 28], [38, 34, 30], [38, 34, 38], [38, 35, 6], [38, 35, 13], [38, 35, 14], [38, 35, 15], [38, 35, 17], [38, 35, 19], [38, 35, 24], [38, 35, 40], [38, 36, 2], [38, 36, 5], [38, 36, 8], [38, 36, 21], [38, 36, 22], [38, 36, 29], [38, 36, 37], [38, 36, 43], [38, 37, 2], [38, 37, 3], [38, 37, 5], [38, 37, 8], [38, 37, 20], [38, 37, 22], [38, 37, 36], [38, 37, 43], [38, 38, 0], [38, 38, 1], [38, 38, 18], [38, 38, 23], [38, 38, 26], [38, 38, 28], [38, 38, 30], [38, 38, 34], [38, 38, 38], [38, 38, 45], [38, 39, 4], [38, 39, 10], [38, 39, 11], [38, 39, 16], [38, 39, 25], [38, 39, 27], [38, 39, 40], [38, 39, 44], [38, 40, 6], [38, 40, 14], [38, 40, 15], [38, 40, 16], [38, 40, 27], [38, 40, 35], [38, 40, 39], [38, 40, 44], [38, 41, 3], [38, 41, 7], [38, 41, 12], [38, 41, 20], [38, 41, 30], [38, 41, 31], [38, 41, 32], [38, 41, 33], [38, 42, 1], [38, 42, 4], [38, 42, 10], [38, 42, 11], [38, 42, 18], [38, 42, 25], [38, 42, 26], [38, 42, 45], [38, 43, 2], [38, 43, 5], [38, 43, 8], [38, 43, 20], [38, 43, 22], [38, 43, 29], [38, 43, 36], [38, 43, 37], [38, 44, 6], [38, 44, 10], [38, 44, 15], [38, 44, 16], [38, 44, 25], [38, 44, 27], [38, 44, 39], [38, 44, 40], [38, 45, 1], [38, 45, 4], [38, 45, 10], [38, 45, 11], [38, 45, 18], [38, 45, 26], [38, 45, 38], [38, 45, 42], [38, 46, 2], [38, 46, 5], [38, 46, 9], [38, 46, 13], [38, 46, 19], [38, 46, 21], [38, 46, 24], [38, 46, 29], [39, 0, 39], [39, 1, 5], [39, 1, 7], [39, 1, 17], [39, 1, 19], [39, 1, 27], [39, 1, 36], [39, 1, 39], [39, 1, 41], [39, 2, 7], [39, 2, 10], [39, 2, 14], [39, 2, 25], [39, 2, 31], [39, 2, 34], [39, 2, 35], [39, 2, 38], [39, 3, 4], [39, 3, 10], [39, 3, 14], [39, 3, 15], [39, 3, 21], [39, 3, 23], [39, 3, 29], [39, 3, 34], [39, 4, 3], [39, 4, 14], [39, 4, 15], [39, 4, 20], [39, 4, 21], [39, 4, 23], [39, 4, 28], [39, 4, 29], [39, 5, 1], [39, 5, 7], [39, 5, 17], [39, 5, 25], [39, 5, 35], [39, 5, 38], [39, 5, 39], [39, 5, 41], [39, 6, 8], [39, 6, 11], [39, 6, 20], [39, 6, 21], [39, 6, 28], [39, 6, 30], [39, 6, 42], [39, 6, 46], [39, 7, 1], [39, 7, 2], [39, 7, 5], [39, 7, 17], [39, 7, 25], [39, 7, 35], [39, 7, 38], [39, 7, 39], [39, 8, 6], [39, 8, 9], [39, 8, 11], [39, 8, 28], [39, 8, 30], [39, 8, 40], [39, 8, 42], [39, 8, 46], [39, 9, 8], [39, 9, 12], [39, 9, 16], [39, 9, 22], [39, 9, 30], [39, 9, 40], [39, 9, 42], [39, 9, 45], [39, 10, 2], [39, 10, 3], [39, 10, 14], [39, 10, 23], [39, 10, 29], [39, 10, 31], [39, 10, 34], [39, 10, 35], [39, 11, 6], [39, 11, 8], [39, 11, 15], [39, 11, 20], [39, 11, 21], [39, 11, 28], [39, 11, 30], [39, 11, 46], [39, 12, 9], [39, 12, 13], [39, 12, 16], [39, 12, 22], [39, 12, 37], [39, 12, 40], [39, 12, 42], [39, 12, 45], [39, 13, 12], [39, 13, 16], [39, 13, 18], [39, 13, 22], [39, 13, 33], [39, 13, 37], [39, 13, 44], [39, 13, 45], [39, 14, 2], [39, 14, 3], [39, 14, 4], [39, 14, 10], [39, 14, 23], [39, 14, 29], [39, 14, 31], [39, 14, 34], [39, 15, 3], [39, 15, 4], [39, 15, 11], [39, 15, 20], [39, 15, 21], [39, 15, 23], [39, 15, 28], [39, 15, 29], [39, 16, 9], [39, 16, 12], [39, 16, 13], [39, 16, 18], [39, 16, 22], [39, 16, 33], [39, 16, 37], [39, 16, 45], [39, 17, 1], [39, 17, 5], [39, 17, 7], [39, 17, 25], [39, 17, 36], [39, 17, 38], [39, 17, 39], [39, 17, 41], [39, 18, 13], [39, 18, 16], [39, 18, 24], [39, 18, 32], [39, 18, 33], [39, 18, 37], [39, 18, 43], [39, 18, 44], [39, 19, 1], [39, 19, 26], [39, 19, 27], [39, 19, 32], [39, 19, 36], [39, 19, 39], [39, 19, 41], [39, 19, 43], [39, 20, 4], [39, 20, 6], [39, 20, 11], [39, 20, 15], [39, 20, 21], [39, 20, 23], [39, 20, 28], [39, 20, 46], [39, 21, 3], [39, 21, 4], [39, 21, 6], [39, 21, 11], [39, 21, 15], [39, 21, 20], [39, 21, 23], [39, 21, 28], [39, 22, 9], [39, 22, 12], [39, 22, 13], [39, 22, 16], [39, 22, 30], [39, 22, 40], [39, 22, 42], [39, 22, 45], [39, 23, 3], [39, 23, 4], [39, 23, 10], [39, 23, 14], [39, 23, 15], [39, 23, 20], [39, 23, 21], [39, 23, 29], [39, 24, 18], [39, 24, 26], [39, 24, 27], [39, 24, 32], [39, 24, 33], [39, 24, 37], [39, 24, 43], [39, 24, 44], [39, 25, 2], [39, 25, 5], [39, 25, 7], [39, 25, 17], [39, 25, 31], [39, 25, 34], [39, 25, 35], [39, 25, 38], [39, 26, 19], [39, 26, 24], [39, 26, 27], [39, 26, 32], [39, 26, 36], [39, 26, 41], [39, 26, 43], [39, 26, 44], [39, 27, 1], [39, 27, 19], [39, 27, 24], [39, 27, 26], [39, 27, 32], [39, 27, 36], [39, 27, 41], [39, 27, 43], [39, 28, 4], [39, 28, 6], [39, 28, 8], [39, 28, 11], [39, 28, 15], [39, 28, 20], [39, 28, 21], [39, 28, 46], [39, 29, 3], [39, 29, 4], [39, 29, 10], [39, 29, 14], [39, 29, 15], [39, 29, 23], [39, 29, 31], [39, 29, 34], [39, 30, 6], [39, 30, 8], [39, 30, 9], [39, 30, 11], [39, 30, 22], [39, 30, 40], [39, 30, 42], [39, 30, 46], [39, 31, 2], [39, 31, 10], [39, 31, 14], [39, 31, 25], [39, 31, 29], [39, 31, 34], [39, 31, 35], [39, 31, 38], [39, 32, 18], [39, 32, 19], [39, 32, 24], [39, 32, 26], [39, 32, 27], [39, 32, 36], [39, 32, 43], [39, 32, 44], [39, 33, 13], [39, 33, 16], [39, 33, 18], [39, 33, 24], [39, 33, 37], [39, 33, 43], [39, 33, 44], [39, 33, 45], [39, 34, 2], [39, 34, 3], [39, 34, 10], [39, 34, 14], [39, 34, 25], [39, 34, 29], [39, 34, 31], [39, 34, 35], [39, 35, 2], [39, 35, 5], [39, 35, 7], [39, 35, 10], [39, 35, 25], [39, 35, 31], [39, 35, 34], [39, 35, 38], [39, 36, 1], [39, 36, 17], [39, 36, 19], [39, 36, 26], [39, 36, 27], [39, 36, 32], [39, 36, 39], [39, 36, 41], [39, 37, 12], [39, 37, 13], [39, 37, 16], [39, 37, 18], [39, 37, 24], [39, 37, 33], [39, 37, 44], [39, 37, 45], [39, 38, 2], [39, 38, 5], [39, 38, 7], [39, 38, 17], [39, 38, 25], [39, 38, 31], [39, 38, 35], [39, 38, 39], [39, 39, 0], [39, 39, 1], [39, 39, 5], [39, 39, 7], [39, 39, 17], [39, 39, 19], [39, 39, 36], [39, 39, 38], [39, 39, 39], [39, 39, 41], [39, 40, 8], [39, 40, 9], [39, 40, 12], [39, 40, 22], [39, 40, 30], [39, 40, 42], [39, 40, 45], [39, 40, 46], [39, 41, 1], [39, 41, 5], [39, 41, 17], [39, 41, 19], [39, 41, 26], [39, 41, 27], [39, 41, 36], [39, 41, 39], [39, 42, 6], [39, 42, 8], [39, 42, 9], [39, 42, 12], [39, 42, 22], [39, 42, 30], [39, 42, 40], [39, 42, 46], [39, 43, 18], [39, 43, 19], [39, 43, 24], [39, 43, 26], [39, 43, 27], [39, 43, 32], [39, 43, 33], [39, 43, 44], [39, 44, 13], [39, 44, 18], [39, 44, 24], [39, 44, 26], [39, 44, 32], [39, 44, 33], [39, 44, 37], [39, 44, 43], [39, 45, 9], [39, 45, 12], [39, 45, 13], [39, 45, 16], [39, 45, 22], [39, 45, 33], [39, 45, 37], [39, 45, 40], [39, 46, 6], [39, 46, 8], [39, 46, 11], [39, 46, 20], [39, 46, 28], [39, 46, 30], [39, 46, 40], [39, 46, 42], [40, 0, 40], [40, 1, 2], [40, 1, 4], [40, 1, 10], [40, 1, 12], [40, 1, 20], [40, 1, 24], [40, 1, 33], [40, 1, 40], [40, 2, 1], [40, 2, 4], [40, 2, 8], [40, 2, 19], [40, 2, 20], [40, 2, 24], [40, 2, 33], [40, 2, 40], [40, 3, 5], [40, 3, 6], [40, 3, 12], [40, 3, 13], [40, 3, 25], [40, 3, 26], [40, 3, 30], [40, 3, 36], [40, 4, 1], [40, 4, 2], [40, 4, 8], [40, 4, 16], [40, 4, 19], [40, 4, 33], [40, 4, 38], [40, 4, 40], [40, 5, 3], [40, 5, 6], [40, 5, 10], [40, 5, 12], [40, 5, 13], [40, 5, 20], [40, 5, 24], [40, 5, 26], [40, 6, 3], [40, 6, 5], [40, 6, 10], [40, 6, 12], [40, 6, 13], [40, 6, 24], [40, 6, 25], [40, 6, 26], [40, 7, 14], [40, 7, 23], [40, 7, 27], [40, 7, 28], [40, 7, 37], [40, 7, 43], [40, 7, 45], [40, 7, 46], [40, 8, 2], [40, 8, 4], [40, 8, 16], [40, 8, 19], [40, 8, 29], [40, 8, 32], [40, 8, 33], [40, 8, 38], [40, 9, 14], [40, 9, 15], [40, 9, 18], [40, 9, 28], [40, 9, 31], [40, 9, 36], [40, 9, 39], [40, 9, 43], [40, 10, 1], [40, 10, 5], [40, 10, 6], [40, 10, 12], [40, 10, 20], [40, 10, 24], [40, 10, 26], [40, 10, 40], [40, 11, 16], [40, 11, 17], [40, 11, 22], [40, 11, 29], [40, 11, 32], [40, 11, 34], [40, 11, 38], [40, 11, 44], [40, 12, 1], [40, 12, 3], [40, 12, 5], [40, 12, 6], [40, 12, 10], [40, 12, 20], [40, 12, 24], [40, 12, 26], [40, 13, 3], [40, 13, 5], [40, 13, 6], [40, 13, 15], [40, 13, 25], [40, 13, 26], [40, 13, 30], [40, 13, 36], [40, 14, 7], [40, 14, 9], [40, 14, 27], [40, 14, 28], [40, 14, 39], [40, 14, 43], [40, 14, 45], [40, 14, 46], [40, 15, 9], [40, 15, 13], [40, 15, 18], [40, 15, 25], [40, 15, 30], [40, 15, 31], [40, 15, 36], [40, 15, 39], [40, 16, 4], [40, 16, 8], [40, 16, 11], [40, 16, 17], [40, 16, 19], [40, 16, 29], [40, 16, 32], [40, 16, 38], [40, 17, 11], [40, 17, 16], [40, 17, 21], [40, 17, 22], [40, 17, 29], [40, 17, 32], [40, 17, 34], [40, 17, 44], [40, 18, 9], [40, 18, 15], [40, 18, 25], [40, 18, 28], [40, 18, 30], [40, 18, 31], [40, 18, 36], [40, 18, 39], [40, 19, 2], [40, 19, 4], [40, 19, 8], [40, 19, 16], [40, 19, 29], [40, 19, 33], [40, 19, 38], [40, 19, 40], [40, 20, 1], [40, 20, 2], [40, 20, 5], [40, 20, 10], [40, 20, 12], [40, 20, 24], [40, 20, 33], [40, 20, 40], [40, 21, 17], [40, 21, 22], [40, 21, 34], [40, 21, 35], [40, 21, 37], [40, 21, 41], [40, 21, 42], [40, 21, 44], [40, 22, 11], [40, 22, 17], [40, 22, 21], [40, 22, 29], [40, 22, 32], [40, 22, 34], [40, 22, 41], [40, 22, 44], [40, 23, 7], [40, 23, 27], [40, 23, 35], [40, 23, 37], [40, 23, 41], [40, 23, 42], [40, 23, 45], [40, 23, 46], [40, 24, 1], [40, 24, 2], [40, 24, 5], [40, 24, 6], [40, 24, 10], [40, 24, 12], [40, 24, 20], [40, 24, 40], [40, 25, 3], [40, 25, 6], [40, 25, 13], [40, 25, 15], [40, 25, 18], [40, 25, 26], [40, 25, 30], [40, 25, 36], [40, 26, 3], [40, 26, 5], [40, 26, 6], [40, 26, 10], [40, 26, 12], [40, 26, 13], [40, 26, 25], [40, 26, 30], [40, 27, 7], [40, 27, 14], [40, 27, 23], [40, 27, 35], [40, 27, 37], [40, 27, 42], [40, 27, 45], [40, 27, 46], [40, 28, 7], [40, 28, 9], [40, 28, 14], [40, 28, 18], [40, 28, 31], [40, 28, 39], [40, 28, 43], [40, 28, 45], [40, 29, 8], [40, 29, 11], [40, 29, 16], [40, 29, 17], [40, 29, 19], [40, 29, 22], [40, 29, 32], [40, 29, 38], [40, 30, 3], [40, 30, 13], [40, 30, 15], [40, 30, 18], [40, 30, 25], [40, 30, 26], [40, 30, 31], [40, 30, 36], [40, 31, 9], [40, 31, 15], [40, 31, 18], [40, 31, 28], [40, 31, 30], [40, 31, 36], [40, 31, 39], [40, 31, 43], [40, 32, 8], [40, 32, 11], [40, 32, 16], [40, 32, 17], [40, 32, 22], [40, 32, 29], [40, 32, 34], [40, 32, 38], [40, 33, 1], [40, 33, 2], [40, 33, 4], [40, 33, 8], [40, 33, 19], [40, 33, 20], [40, 33, 38], [40, 33, 40], [40, 34, 11], [40, 34, 17], [40, 34, 21], [40, 34, 22], [40, 34, 32], [40, 34, 41], [40, 34, 42], [40, 34, 44], [40, 35, 21], [40, 35, 23], [40, 35, 27], [40, 35, 37], [40, 35, 41], [40, 35, 42], [40, 35, 44], [40, 35, 46], [40, 36, 3], [40, 36, 9], [40, 36, 13], [40, 36, 15], [40, 36, 18], [40, 36, 25], [40, 36, 30], [40, 36, 31], [40, 37, 7], [40, 37, 21], [40, 37, 23], [40, 37, 27], [40, 37, 35], [40, 37, 41], [40, 37, 42], [40, 37, 46], [40, 38, 4], [40, 38, 8], [40, 38, 11], [40, 38, 16], [40, 38, 19], [40, 38, 29], [40, 38, 32], [40, 38, 33], [40, 39, 9], [40, 39, 14], [40, 39, 15], [40, 39, 18], [40, 39, 28], [40, 39, 31], [40, 39, 43], [40, 39, 45], [40, 40, 0], [40, 40, 1], [40, 40, 2], [40, 40, 4], [40, 40, 10], [40, 40, 19], [40, 40, 20], [40, 40, 24], [40, 40, 33], [40, 40, 40], [40, 41, 21], [40, 41, 22], [40, 41, 23], [40, 41, 34], [40, 41, 35], [40, 41, 37], [40, 41, 42], [40, 41, 44], [40, 42, 21], [40, 42, 23], [40, 42, 27], [40, 42, 34], [40, 42, 35], [40, 42, 37], [40, 42, 41], [40, 42, 44], [40, 43, 7], [40, 43, 9], [40, 43, 14], [40, 43, 28], [40, 43, 31], [40, 43, 39], [40, 43, 45], [40, 43, 46], [40, 44, 11], [40, 44, 17], [40, 44, 21], [40, 44, 22], [40, 44, 34], [40, 44, 35], [40, 44, 41], [40, 44, 42], [40, 45, 7], [40, 45, 14], [40, 45, 23], [40, 45, 27], [40, 45, 28], [40, 45, 39], [40, 45, 43], [40, 45, 46], [40, 46, 7], [40, 46, 14], [40, 46, 23], [40, 46, 27], [40, 46, 35], [40, 46, 37], [40, 46, 43], [40, 46, 45], [41, 0, 41], [41, 1, 5], [41, 1, 7], [41, 1, 17], [41, 1, 19], [41, 1, 27], [41, 1, 36], [41, 1, 39], [41, 1, 41], [41, 2, 7], [41, 2, 10], [41, 2, 14], [41, 2, 25], [41, 2, 31], [41, 2, 34], [41, 2, 35], [41, 2, 38], [41, 3, 4], [41, 3, 10], [41, 3, 14], [41, 3, 15], [41, 3, 21], [41, 3, 23], [41, 3, 29], [41, 3, 34], [41, 4, 3], [41, 4, 14], [41, 4, 15], [41, 4, 20], [41, 4, 21], [41, 4, 23], [41, 4, 28], [41, 4, 29], [41, 5, 1], [41, 5, 7], [41, 5, 17], [41, 5, 25], [41, 5, 35], [41, 5, 38], [41, 5, 39], [41, 5, 41], [41, 6, 8], [41, 6, 11], [41, 6, 20], [41, 6, 21], [41, 6, 28], [41, 6, 30], [41, 6, 42], [41, 6, 46], [41, 7, 1], [41, 7, 2], [41, 7, 5], [41, 7, 17], [41, 7, 25], [41, 7, 35], [41, 7, 38], [41, 7, 39], [41, 8, 6], [41, 8, 9], [41, 8, 11], [41, 8, 28], [41, 8, 30], [41, 8, 40], [41, 8, 42], [41, 8, 46], [41, 9, 8], [41, 9, 12], [41, 9, 16], [41, 9, 22], [41, 9, 30], [41, 9, 40], [41, 9, 42], [41, 9, 45], [41, 10, 2], [41, 10, 3], [41, 10, 14], [41, 10, 23], [41, 10, 29], [41, 10, 31], [41, 10, 34], [41, 10, 35], [41, 11, 6], [41, 11, 8], [41, 11, 15], [41, 11, 20], [41, 11, 21], [41, 11, 28], [41, 11, 30], [41, 11, 46], [41, 12, 9], [41, 12, 13], [41, 12, 16], [41, 12, 22], [41, 12, 37], [41, 12, 40], [41, 12, 42], [41, 12, 45], [41, 13, 12], [41, 13, 16], [41, 13, 18], [41, 13, 22], [41, 13, 33], [41, 13, 37], [41, 13, 44], [41, 13, 45], [41, 14, 2], [41, 14, 3], [41, 14, 4], [41, 14, 10], [41, 14, 23], [41, 14, 29], [41, 14, 31], [41, 14, 34], [41, 15, 3], [41, 15, 4], [41, 15, 11], [41, 15, 20], [41, 15, 21], [41, 15, 23], [41, 15, 28], [41, 15, 29], [41, 16, 9], [41, 16, 12], [41, 16, 13], [41, 16, 18], [41, 16, 22], [41, 16, 33], [41, 16, 37], [41, 16, 45], [41, 17, 1], [41, 17, 5], [41, 17, 7], [41, 17, 25], [41, 17, 36], [41, 17, 38], [41, 17, 39], [41, 17, 41], [41, 18, 13], [41, 18, 16], [41, 18, 24], [41, 18, 32], [41, 18, 33], [41, 18, 37], [41, 18, 43], [41, 18, 44], [41, 19, 1], [41, 19, 26], [41, 19, 27], [41, 19, 32], [41, 19, 36], [41, 19, 39], [41, 19, 41], [41, 19, 43], [41, 20, 4], [41, 20, 6], [41, 20, 11], [41, 20, 15], [41, 20, 21], [41, 20, 23], [41, 20, 28], [41, 20, 46], [41, 21, 3], [41, 21, 4], [41, 21, 6], [41, 21, 11], [41, 21, 15], [41, 21, 20], [41, 21, 23], [41, 21, 28], [41, 22, 9], [41, 22, 12], [41, 22, 13], [41, 22, 16], [41, 22, 30], [41, 22, 40], [41, 22, 42], [41, 22, 45], [41, 23, 3], [41, 23, 4], [41, 23, 10], [41, 23, 14], [41, 23, 15], [41, 23, 20], [41, 23, 21], [41, 23, 29], [41, 24, 18], [41, 24, 26], [41, 24, 27], [41, 24, 32], [41, 24, 33], [41, 24, 37], [41, 24, 43], [41, 24, 44], [41, 25, 2], [41, 25, 5], [41, 25, 7], [41, 25, 17], [41, 25, 31], [41, 25, 34], [41, 25, 35], [41, 25, 38], [41, 26, 19], [41, 26, 24], [41, 26, 27], [41, 26, 32], [41, 26, 36], [41, 26, 41], [41, 26, 43], [41, 26, 44], [41, 27, 1], [41, 27, 19], [41, 27, 24], [41, 27, 26], [41, 27, 32], [41, 27, 36], [41, 27, 41], [41, 27, 43], [41, 28, 4], [41, 28, 6], [41, 28, 8], [41, 28, 11], [41, 28, 15], [41, 28, 20], [41, 28, 21], [41, 28, 46], [41, 29, 3], [41, 29, 4], [41, 29, 10], [41, 29, 14], [41, 29, 15], [41, 29, 23], [41, 29, 31], [41, 29, 34], [41, 30, 6], [41, 30, 8], [41, 30, 9], [41, 30, 11], [41, 30, 22], [41, 30, 40], [41, 30, 42], [41, 30, 46], [41, 31, 2], [41, 31, 10], [41, 31, 14], [41, 31, 25], [41, 31, 29], [41, 31, 34], [41, 31, 35], [41, 31, 38], [41, 32, 18], [41, 32, 19], [41, 32, 24], [41, 32, 26], [41, 32, 27], [41, 32, 36], [41, 32, 43], [41, 32, 44], [41, 33, 13], [41, 33, 16], [41, 33, 18], [41, 33, 24], [41, 33, 37], [41, 33, 43], [41, 33, 44], [41, 33, 45], [41, 34, 2], [41, 34, 3], [41, 34, 10], [41, 34, 14], [41, 34, 25], [41, 34, 29], [41, 34, 31], [41, 34, 35], [41, 35, 2], [41, 35, 5], [41, 35, 7], [41, 35, 10], [41, 35, 25], [41, 35, 31], [41, 35, 34], [41, 35, 38], [41, 36, 1], [41, 36, 17], [41, 36, 19], [41, 36, 26], [41, 36, 27], [41, 36, 32], [41, 36, 39], [41, 36, 41], [41, 37, 12], [41, 37, 13], [41, 37, 16], [41, 37, 18], [41, 37, 24], [41, 37, 33], [41, 37, 44], [41, 37, 45], [41, 38, 2], [41, 38, 5], [41, 38, 7], [41, 38, 17], [41, 38, 25], [41, 38, 31], [41, 38, 35], [41, 38, 39], [41, 39, 1], [41, 39, 5], [41, 39, 7], [41, 39, 17], [41, 39, 19], [41, 39, 36], [41, 39, 38], [41, 39, 41], [41, 40, 8], [41, 40, 9], [41, 40, 12], [41, 40, 22], [41, 40, 30], [41, 40, 42], [41, 40, 45], [41, 40, 46], [41, 41, 0], [41, 41, 1], [41, 41, 5], [41, 41, 17], [41, 41, 19], [41, 41, 26], [41, 41, 27], [41, 41, 36], [41, 41, 39], [41, 41, 41], [41, 42, 6], [41, 42, 8], [41, 42, 9], [41, 42, 12], [41, 42, 22], [41, 42, 30], [41, 42, 40], [41, 42, 46], [41, 43, 18], [41, 43, 19], [41, 43, 24], [41, 43, 26], [41, 43, 27], [41, 43, 32], [41, 43, 33], [41, 43, 44], [41, 44, 13], [41, 44, 18], [41, 44, 24], [41, 44, 26], [41, 44, 32], [41, 44, 33], [41, 44, 37], [41, 44, 43], [41, 45, 9], [41, 45, 12], [41, 45, 13], [41, 45, 16], [41, 45, 22], [41, 45, 33], [41, 45, 37], [41, 45, 40], [41, 46, 6], [41, 46, 8], [41, 46, 11], [41, 46, 20], [41, 46, 28], [41, 46, 30], [41, 46, 40], [41, 46, 42], [42, 0, 42], [42, 1, 3], [42, 1, 14], [42, 1, 16], [42, 1, 25], [42, 1, 28], [42, 1, 32], [42, 1, 37], [42, 1, 42], [42, 2, 3], [42, 2, 6], [42, 2, 9], [42, 2, 17], [42, 2, 27], [42, 2, 28], [42, 2, 32], [42, 2, 37], [42, 3, 1], [42, 3, 2], [42, 3, 9], [42, 3, 17], [42, 3, 28], [42, 3, 32], [42, 3, 37], [42, 3, 42], [42, 4, 6], [42, 4, 7], [42, 4, 9], [42, 4, 12], [42, 4, 17], [42, 4, 18], [42, 4, 27], [42, 4, 34], [42, 6, 2], [42, 6, 4], [42, 6, 9], [42, 6, 17], [42, 6, 18], [42, 6, 27], [42, 6, 34], [42, 6, 37], [42, 7, 4], [42, 7, 8], [42, 7, 12], [42, 7, 18], [42, 7, 21], [42, 7, 24], [42, 7, 34], [42, 7, 36], [42, 8, 7], [42, 8, 12], [42, 8, 14], [42, 8, 18], [42, 8, 21], [42, 8, 24], [42, 8, 34], [42, 8, 36], [42, 9, 2], [42, 9, 3], [42, 9, 4], [42, 9, 6], [42, 9, 17], [42, 9, 27], [42, 9, 32], [42, 9, 37], [42, 12, 4], [42, 12, 7], [42, 12, 8], [42, 12, 18], [42, 12, 21], [42, 12, 27], [42, 12, 34], [42, 12, 36], [42, 14, 1], [42, 14, 8], [42, 14, 16], [42, 14, 21], [42, 14, 24], [42, 14, 25], [42, 14, 36], [42, 14, 42], [42, 16, 1], [42, 16, 14], [42, 16, 21], [42, 16, 24], [42, 16, 25], [42, 16, 28], [42, 16, 36], [42, 16, 42], [42, 17, 2], [42, 17, 3], [42, 17, 4], [42, 17, 6], [42, 17, 9], [42, 17, 18], [42, 17, 27], [42, 17, 37], [42, 18, 4], [42, 18, 6], [42, 18, 7], [42, 18, 8], [42, 18, 12], [42, 18, 17], [42, 18, 27], [42, 18, 34], [42, 21, 7], [42, 21, 8], [42, 21, 12], [42, 21, 14], [42, 21, 16], [42, 21, 24], [42, 21, 25], [42, 21, 36], [42, 24, 7], [42, 24, 8], [42, 24, 14], [42, 24, 16], [42, 24, 21], [42, 24, 25], [42, 24, 36], [42, 24, 42], [42, 25, 1], [42, 25, 14], [42, 25, 16], [42, 25, 21], [42, 25, 24], [42, 25, 28], [42, 25, 32], [42, 25, 42], [42, 27, 2], [42, 27, 4], [42, 27, 6], [42, 27, 9], [42, 27, 12], [42, 27, 17], [42, 27, 18], [42, 27, 34], [42, 28, 1], [42, 28, 2], [42, 28, 3], [42, 28, 16], [42, 28, 25], [42, 28, 32], [42, 28, 37], [42, 28, 42], [42, 32, 1], [42, 32, 2], [42, 32, 3], [42, 32, 9], [42, 32, 25], [42, 32, 28], [42, 32, 37], [42, 32, 42], [42, 34, 4], [42, 34, 6], [42, 34, 7], [42, 34, 8], [42, 34, 12], [42, 34, 18], [42, 34, 27], [42, 34, 36], [42, 36, 7], [42, 36, 8], [42, 36, 12], [42, 36, 14], [42, 36, 16], [42, 36, 21], [42, 36, 24], [42, 36, 34], [42, 37, 1], [42, 37, 2], [42, 37, 3], [42, 37, 6], [42, 37, 9], [42, 37, 17], [42, 37, 28], [42, 37, 32], [42, 42, 0], [42, 42, 1], [42, 42, 3], [42, 42, 14], [42, 42, 16], [42, 42, 24], [42, 42, 25], [42, 42, 28], [42, 42, 32], [42, 42, 42], [43, 0, 43], [43, 1, 3], [43, 1, 9], [43, 1, 11], [43, 1, 16], [43, 1, 21], [43, 1, 30], [43, 1, 35], [43, 1, 43], [43, 2, 6], [43, 2, 13], [43, 2, 18], [43, 2, 22], [43, 2, 23], [43, 2, 32], [43, 2, 39], [43, 2, 42], [43, 3, 1], [43, 3, 9], [43, 3, 11], [43, 3, 16], [43, 3, 27], [43, 3, 33], [43, 3, 35], [43, 3, 43], [43, 4, 12], [43, 4, 17], [43, 4, 26], [43, 4, 31], [43, 4, 36], [43, 4, 37], [43, 4, 44], [43, 4, 46], [43, 5, 8], [43, 5, 9], [43, 5, 11], [43, 5, 15], [43, 5, 27], [43, 5, 33], [43, 5, 34], [43, 5, 45], [43, 6, 2], [43, 6, 7], [43, 6, 18], [43, 6, 19], [43, 6, 22], [43, 6, 23], [43, 6, 32], [43, 6, 39], [43, 7, 6], [43, 7, 10], [43, 7, 16], [43, 7, 18], [43, 7, 19], [43, 7, 21], [43, 7, 22], [43, 7, 30], [43, 8, 5], [43, 8, 15], [43, 8, 24], [43, 8, 25], [43, 8, 27], [43, 8, 34], [43, 8, 41], [43, 8, 45], [43, 9, 1], [43, 9, 3], [43, 9, 5], [43, 9, 11], [43, 9, 27], [43, 9, 33], [43, 9, 34], [43, 9, 35], [43, 10, 7], [43, 10, 16], [43, 10, 18], [43, 10, 19], [43, 10, 21], [43, 10, 22], [43, 10, 30], [43, 10, 43], [43, 11, 1], [43, 11, 3], [43, 11, 5], [43, 11, 9], [43, 11, 27], [43, 11, 33], [43, 11, 35], [43, 11, 43], [43, 12, 4], [43, 12, 14], [43, 12, 17], [43, 12, 31], [43, 12, 36], [43, 12, 38], [43, 12, 44], [43, 12, 46], [43, 13, 2], [43, 13, 14], [43, 13, 20], [43, 13, 23], [43, 13, 32], [43, 13, 38], [43, 13, 39], [43, 13, 42], [43, 14, 12], [43, 14, 13], [43, 14, 20], [43, 14, 32], [43, 14, 36], [43, 14, 38], [43, 14, 42], [43, 14, 44], [43, 15, 5], [43, 15, 8], [43, 15, 24], [43, 15, 27], [43, 15, 33], [43, 15, 34], [43, 15, 41], [43, 15, 45], [43, 16, 1], [43, 16, 3], [43, 16, 7], [43, 16, 10], [43, 16, 21], [43, 16, 30], [43, 16, 35], [43, 16, 43], [43, 17, 4], [43, 17, 12], [43, 17, 26], [43, 17, 28], [43, 17, 31], [43, 17, 37], [43, 17, 40], [43, 17, 46], [43, 18, 2], [43, 18, 6], [43, 18, 7], [43, 18, 10], [43, 18, 19], [43, 18, 21], [43, 18, 22], [43, 18, 23], [43, 19, 6], [43, 19, 7], [43, 19, 10], [43, 19, 18], [43, 19, 21], [43, 19, 22], [43, 19, 23], [43, 19, 30], [43, 20, 13], [43, 20, 14], [43, 20, 32], [43, 20, 36], [43, 20, 38], [43, 20, 39], [43, 20, 42], [43, 20, 44], [43, 21, 1], [43, 21, 7], [43, 21, 10], [43, 21, 16], [43, 21, 18], [43, 21, 19], [43, 21, 30], [43, 21, 43], [43, 22, 2], [43, 22, 6], [43, 22, 7], [43, 22, 10], [43, 22, 18], [43, 22, 19], [43, 22, 23], [43, 22, 39], [43, 23, 2], [43, 23, 6], [43, 23, 13], [43, 23, 18], [43, 23, 19], [43, 23, 22], [43, 23, 32], [43, 23, 39], [43, 24, 8], [43, 24, 15], [43, 24, 25], [43, 24, 28], [43, 24, 29], [43, 24, 34], [43, 24, 41], [43, 24, 45], [43, 25, 8], [43, 25, 24], [43, 25, 28], [43, 25, 29], [43, 25, 37], [43, 25, 40], [43, 25, 41], [43, 25, 45], [43, 26, 4], [43, 26, 17], [43, 26, 28], [43, 26, 29], [43, 26, 31], [43, 26, 37], [43, 26, 40], [43, 26, 46], [43, 27, 3], [43, 27, 5], [43, 27, 8], [43, 27, 9], [43, 27, 11], [43, 27, 15], [43, 27, 33], [43, 27, 34], [43, 28, 17], [43, 28, 24], [43, 28, 25], [43, 28, 26], [43, 28, 29], [43, 28, 37], [43, 28, 40], [43, 28, 41], [43, 29, 24], [43, 29, 25], [43, 29, 26], [43, 29, 28], [43, 29, 37], [43, 29, 40], [43, 29, 41], [43, 29, 45], [43, 30, 1], [43, 30, 7], [43, 30, 10], [43, 30, 16], [43, 30, 19], [43, 30, 21], [43, 30, 35], [43, 30, 43], [43, 31, 4], [43, 31, 12], [43, 31, 17], [43, 31, 26], [43, 31, 37], [43, 31, 40], [43, 31, 44], [43, 31, 46], [43, 32, 2], [43, 32, 6], [43, 32, 13], [43, 32, 14], [43, 32, 20], [43, 32, 23], [43, 32, 39], [43, 32, 42], [43, 33, 3], [43, 33, 5], [43, 33, 9], [43, 33, 11], [43, 33, 15], [43, 33, 27], [43, 33, 34], [43, 33, 35], [43, 34, 5], [43, 34, 8], [43, 34, 9], [43, 34, 15], [43, 34, 24], [43, 34, 27], [43, 34, 33], [43, 34, 45], [43, 35, 1], [43, 35, 3], [43, 35, 9], [43, 35, 11], [43, 35, 16], [43, 35, 30], [43, 35, 33], [43, 35, 43], [43, 36, 4], [43, 36, 12], [43, 36, 14], [43, 36, 20], [43, 36, 38], [43, 36, 42], [43, 36, 44], [43, 36, 46], [43, 37, 4], [43, 37, 17], [43, 37, 25], [43, 37, 26], [43, 37, 28], [43, 37, 29], [43, 37, 31], [43, 37, 40], [43, 38, 12], [43, 38, 13], [43, 38, 14], [43, 38, 20], [43, 38, 36], [43, 38, 42], [43, 38, 44], [43, 38, 46], [43, 39, 2], [43, 39, 6], [43, 39, 13], [43, 39, 20], [43, 39, 22], [43, 39, 23], [43, 39, 32], [43, 39, 42], [43, 40, 17], [43, 40, 25], [43, 40, 26], [43, 40, 28], [43, 40, 29], [43, 40, 31], [43, 40, 37], [43, 40, 41], [43, 41, 8], [43, 41, 15], [43, 41, 24], [43, 41, 25], [43, 41, 28], [43, 41, 29], [43, 41, 40], [43, 41, 45], [43, 42, 2], [43, 42, 13], [43, 42, 14], [43, 42, 20], [43, 42, 32], [43, 42, 36], [43, 42, 38], [43, 42, 39], [43, 43, 0], [43, 43, 1], [43, 43, 3], [43, 43, 10], [43, 43, 11], [43, 43, 16], [43, 43, 21], [43, 43, 30], [43, 43, 35], [43, 43, 43], [43, 44, 4], [43, 44, 12], [43, 44, 14], [43, 44, 20], [43, 44, 31], [43, 44, 36], [43, 44, 38], [43, 44, 46], [43, 45, 5], [43, 45, 8], [43, 45, 15], [43, 45, 24], [43, 45, 25], [43, 45, 29], [43, 45, 34], [43, 45, 41], [43, 46, 4], [43, 46, 12], [43, 46, 17], [43, 46, 26], [43, 46, 31], [43, 46, 36], [43, 46, 38], [43, 46, 44], [44, 0, 44], [44, 1, 9], [44, 1, 18], [44, 1, 20], [44, 1, 21], [44, 1, 31], [44, 1, 34], [44, 1, 40], [44, 1, 44], [44, 2, 15], [44, 2, 18], [44, 2, 21], [44, 2, 33], [44, 2, 36], [44, 2, 40], [44, 2, 41], [44, 2, 42], [44, 3, 7], [44, 3, 8], [44, 3, 13], [44, 3, 16], [44, 3, 26], [44, 3, 27], [44, 3, 38], [44, 3, 46], [44, 4, 19], [44, 4, 25], [44, 4, 30], [44, 4, 33], [44, 4, 35], [44, 4, 36], [44, 4, 37], [44, 4, 42], [44, 5, 6], [44, 5, 11], [44, 5, 12], [44, 5, 14], [44, 5, 29], [44, 5, 32], [44, 5, 43], [44, 5, 45], [44, 6, 5], [44, 6, 7], [44, 6, 14], [44, 6, 16], [44, 6, 26], [44, 6, 29], [44, 6, 32], [44, 6, 45], [44, 7, 3], [44, 7, 6], [44, 7, 16], [44, 7, 26], [44, 7, 29], [44, 7, 32], [44, 7, 45], [44, 7, 46], [44, 8, 3], [44, 8, 13], [44, 8, 19], [44, 8, 23], [44, 8, 25], [44, 8, 27], [44, 8, 37], [44, 8, 38], [44, 9, 1], [44, 9, 20], [44, 9, 21], [44, 9, 24], [44, 9, 31], [44, 9, 34], [44, 9, 39], [44, 9, 44], [44, 10, 11], [44, 10, 12], [44, 10, 17], [44, 10, 22], [44, 10, 24], [44, 10, 28], [44, 10, 39], [44, 10, 43], [44, 11, 5], [44, 11, 10], [44, 11, 12], [44, 11, 14], [44, 11, 17], [44, 11, 32], [44, 11, 43], [44, 11, 45], [44, 12, 5], [44, 12, 10], [44, 12, 11], [44, 12, 14], [44, 12, 17], [44, 12, 28], [44, 12, 32], [44, 12, 43], [44, 13, 3], [44, 13, 8], [44, 13, 19], [44, 13, 23], [44, 13, 25], [44, 13, 27], [44, 13, 38], [44, 13, 46], [44, 14, 5], [44, 14, 6], [44, 14, 11], [44, 14, 12], [44, 14, 17], [44, 14, 32], [44, 14, 43], [44, 14, 45], [44, 15, 2], [44, 15, 18], [44, 15, 33], [44, 15, 35], [44, 15, 36], [44, 15, 40], [44, 15, 41], [44, 15, 42], [44, 16, 3], [44, 16, 6], [44, 16, 7], [44, 16, 26], [44, 16, 27], [44, 16, 29], [44, 16, 38], [44, 16, 46], [44, 17, 10], [44, 17, 11], [44, 17, 12], [44, 17, 14], [44, 17, 22], [44, 17, 24], [44, 17, 28], [44, 17, 43], [44, 18, 1], [44, 18, 2], [44, 18, 15], [44, 18, 21], [44, 18, 31], [44, 18, 40], [44, 18, 41], [44, 18, 42], [44, 19, 4], [44, 19, 8], [44, 19, 13], [44, 19, 23], [44, 19, 25], [44, 19, 30], [44, 19, 35], [44, 19, 37], [44, 20, 1], [44, 20, 9], [44, 20, 22], [44, 20, 24], [44, 20, 31], [44, 20, 34], [44, 20, 39], [44, 20, 44], [44, 21, 1], [44, 21, 2], [44, 21, 9], [44, 21, 18], [44, 21, 31], [44, 21, 40], [44, 21, 41], [44, 21, 44], [44, 22, 10], [44, 22, 17], [44, 22, 20], [44, 22, 24], [44, 22, 28], [44, 22, 34], [44, 22, 39], [44, 22, 43], [44, 23, 8], [44, 23, 13], [44, 23, 19], [44, 23, 25], [44, 23, 27], [44, 23, 30], [44, 23, 37], [44, 23, 38], [44, 24, 9], [44, 24, 10], [44, 24, 17], [44, 24, 20], [44, 24, 22], [44, 24, 28], [44, 24, 34], [44, 24, 39], [44, 25, 4], [44, 25, 8], [44, 25, 13], [44, 25, 19], [44, 25, 23], [44, 25, 27], [44, 25, 30], [44, 25, 37], [44, 26, 3], [44, 26, 6], [44, 26, 7], [44, 26, 16], [44, 26, 29], [44, 26, 38], [44, 26, 45], [44, 26, 46], [44, 27, 3], [44, 27, 8], [44, 27, 13], [44, 27, 16], [44, 27, 23], [44, 27, 25], [44, 27, 38], [44, 27, 46], [44, 28, 10], [44, 28, 12], [44, 28, 17], [44, 28, 22], [44, 28, 24], [44, 28, 34], [44, 28, 39], [44, 28, 43], [44, 29, 5], [44, 29, 6], [44, 29, 7], [44, 29, 16], [44, 29, 26], [44, 29, 32], [44, 29, 45], [44, 29, 46], [44, 30, 4], [44, 30, 19], [44, 30, 23], [44, 30, 25], [44, 30, 33], [44, 30, 35], [44, 30, 36], [44, 30, 37], [44, 31, 1], [44, 31, 9], [44, 31, 18], [44, 31, 20], [44, 31, 21], [44, 31, 40], [44, 31, 41], [44, 31, 44], [44, 32, 5], [44, 32, 6], [44, 32, 7], [44, 32, 11], [44, 32, 12], [44, 32, 14], [44, 32, 29], [44, 32, 45], [44, 33, 2], [44, 33, 4], [44, 33, 15], [44, 33, 30], [44, 33, 35], [44, 33, 36], [44, 33, 41], [44, 33, 42], [44, 34, 1], [44, 34, 9], [44, 34, 20], [44, 34, 22], [44, 34, 24], [44, 34, 28], [44, 34, 39], [44, 34, 44], [44, 35, 4], [44, 35, 15], [44, 35, 19], [44, 35, 30], [44, 35, 33], [44, 35, 36], [44, 35, 37], [44, 35, 42], [44, 36, 2], [44, 36, 4], [44, 36, 15], [44, 36, 30], [44, 36, 33], [44, 36, 35], [44, 36, 37], [44, 36, 42], [44, 37, 4], [44, 37, 8], [44, 37, 19], [44, 37, 23], [44, 37, 25], [44, 37, 30], [44, 37, 35], [44, 37, 36], [44, 38, 3], [44, 38, 8], [44, 38, 13], [44, 38, 16], [44, 38, 23], [44, 38, 26], [44, 38, 27], [44, 38, 46], [44, 39, 9], [44, 39, 10], [44, 39, 20], [44, 39, 22], [44, 39, 24], [44, 39, 28], [44, 39, 34], [44, 39, 44], [44, 40, 1], [44, 40, 2], [44, 40, 15], [44, 40, 18], [44, 40, 21], [44, 40, 31], [44, 40, 41], [44, 40, 44], [44, 41, 2], [44, 41, 15], [44, 41, 18], [44, 41, 21], [44, 41, 31], [44, 41, 33], [44, 41, 40], [44, 41, 42], [44, 42, 2], [44, 42, 4], [44, 42, 15], [44, 42, 18], [44, 42, 33], [44, 42, 35], [44, 42, 36], [44, 42, 41], [44, 43, 5], [44, 43, 10], [44, 43, 11], [44, 43, 12], [44, 43, 14], [44, 43, 17], [44, 43, 22], [44, 43, 28], [44, 44, 0], [44, 44, 1], [44, 44, 9], [44, 44, 20], [44, 44, 21], [44, 44, 31], [44, 44, 34], [44, 44, 39], [44, 44, 40], [44, 44, 44], [44, 45, 5], [44, 45, 6], [44, 45, 7], [44, 45, 11], [44, 45, 14], [44, 45, 26], [44, 45, 29], [44, 45, 32], [44, 46, 3], [44, 46, 7], [44, 46, 13], [44, 46, 16], [44, 46, 26], [44, 46, 27], [44, 46, 29], [44, 46, 38], [45, 0, 45], [45, 1, 3], [45, 1, 4], [45, 1, 12], [45, 1, 16], [45, 1, 23], [45, 1, 39], [45, 1, 41], [45, 1, 45], [45, 2, 6], [45, 2, 8], [45, 2, 24], [45, 2, 31], [45, 2, 32], [45, 2, 35], [45, 2, 43], [45, 2, 46], [45, 3, 1], [45, 3, 9], [45, 3, 12], [45, 3, 22], [45, 3, 23], [45, 3, 29], [45, 3, 36], [45, 3, 41], [45, 4, 1], [45, 4, 12], [45, 4, 15], [45, 4, 16], [45, 4, 17], [45, 4, 23], [45, 4, 39], [45, 4, 45], [45, 5, 7], [45, 5, 13], [45, 5, 15], [45, 5, 17], [45, 5, 20], [45, 5, 21], [45, 5, 33], [45, 5, 37], [45, 6, 2], [45, 6, 11], [45, 6, 18], [45, 6, 24], [45, 6, 25], [45, 6, 35], [45, 6, 44], [45, 6, 46], [45, 7, 5], [45, 7, 18], [45, 7, 20], [45, 7, 21], [45, 7, 28], [45, 7, 33], [45, 7, 37], [45, 7, 38], [45, 8, 2], [45, 8, 24], [45, 8, 30], [45, 8, 31], [45, 8, 32], [45, 8, 34], [45, 8, 43], [45, 8, 46], [45, 9, 3], [45, 9, 14], [45, 9, 19], [45, 9, 22], [45, 9, 27], [45, 9, 29], [45, 9, 36], [45, 9, 40], [45, 10, 14], [45, 10, 19], [45, 10, 26], [45, 10, 27], [45, 10, 30], [45, 10, 34], [45, 10, 40], [45, 10, 42], [45, 11, 6], [45, 11, 18], [45, 11, 25], [45, 11, 28], [45, 11, 33], [45, 11, 35], [45, 11, 38], [45, 11, 44], [45, 12, 1], [45, 12, 3], [45, 12, 4], [45, 12, 22], [45, 12, 23], [45, 12, 36], [45, 12, 41], [45, 12, 45], [45, 13, 5], [45, 13, 15], [45, 13, 16], [45, 13, 17], [45, 13, 20], [45, 13, 21], [45, 13, 37], [45, 13, 39], [45, 14, 9], [45, 14, 10], [45, 14, 19], [45, 14, 27], [45, 14, 29], [45, 14, 36], [45, 14, 40], [45, 14, 42], [45, 15, 4], [45, 15, 5], [45, 15, 13], [45, 15, 16], [45, 15, 17], [45, 15, 21], [45, 15, 39], [45, 15, 45], [45, 16, 1], [45, 16, 4], [45, 16, 13], [45, 16, 15], [45, 16, 17], [45, 16, 21], [45, 16, 39], [45, 16, 45], [45, 17, 4], [45, 17, 5], [45, 17, 13], [45, 17, 15], [45, 17, 16], [45, 17, 21], [45, 17, 37], [45, 17, 39], [45, 18, 6], [45, 18, 7], [45, 18, 11], [45, 18, 25], [45, 18, 28], [45, 18, 33], [45, 18, 38], [45, 18, 44], [45, 19, 9], [45, 19, 10], [45, 19, 14], [45, 19, 22], [45, 19, 27], [45, 19, 29], [45, 19, 36], [45, 19, 40], [45, 20, 5], [45, 20, 7], [45, 20, 13], [45, 20, 21], [45, 20, 28], [45, 20, 33], [45, 20, 37], [45, 20, 38], [45, 21, 5], [45, 21, 7], [45, 21, 13], [45, 21, 15], [45, 21, 16], [45, 21, 17], [45, 21, 20], [45, 21, 37], [45, 22, 3], [45, 22, 9], [45, 22, 12], [45, 22, 19], [45, 22, 23], [45, 22, 29], [45, 22, 36], [45, 22, 41], [45, 23, 1], [45, 23, 3], [45, 23, 4], [45, 23, 12], [45, 23, 22], [45, 23, 39], [45, 23, 41], [45, 23, 45], [45, 24, 2], [45, 24, 6], [45, 24, 8], [45, 24, 25], [45, 24, 35], [45, 24, 43], [45, 24, 44], [45, 24, 46], [45, 25, 6], [45, 25, 11], [45, 25, 18], [45, 25, 24], [45, 25, 28], [45, 25, 35], [45, 25, 38], [45, 25, 44], [45, 26, 10], [45, 26, 27], [45, 26, 30], [45, 26, 31], [45, 26, 32], [45, 26, 34], [45, 26, 40], [45, 26, 42], [45, 27, 9], [45, 27, 10], [45, 27, 14], [45, 27, 19], [45, 27, 26], [45, 27, 34], [45, 27, 40], [45, 27, 42], [45, 28, 7], [45, 28, 11], [45, 28, 18], [45, 28, 20], [45, 28, 25], [45, 28, 33], [45, 28, 37], [45, 28, 38], [45, 29, 3], [45, 29, 9], [45, 29, 14], [45, 29, 19], [45, 29, 22], [45, 29, 36], [45, 29, 40], [45, 29, 41], [45, 30, 8], [45, 30, 10], [45, 30, 26], [45, 30, 31], [45, 30, 32], [45, 30, 34], [45, 30, 42], [45, 30, 43], [45, 31, 2], [45, 31, 8], [45, 31, 26], [45, 31, 30], [45, 31, 32], [45, 31, 34], [45, 31, 43], [45, 31, 46], [45, 32, 2], [45, 32, 8], [45, 32, 26], [45, 32, 30], [45, 32, 31], [45, 32, 34], [45, 32, 42], [45, 32, 43], [45, 33, 5], [45, 33, 7], [45, 33, 11], [45, 33, 18], [45, 33, 20], [45, 33, 28], [45, 33, 37], [45, 33, 38], [45, 34, 8], [45, 34, 10], [45, 34, 26], [45, 34, 27], [45, 34, 30], [45, 34, 31], [45, 34, 32], [45, 34, 42], [45, 35, 2], [45, 35, 6], [45, 35, 11], [45, 35, 24], [45, 35, 25], [45, 35, 43], [45, 35, 44], [45, 35, 46], [45, 36, 3], [45, 36, 9], [45, 36, 12], [45, 36, 14], [45, 36, 19], [45, 36, 22], [45, 36, 29], [45, 36, 41], [45, 37, 5], [45, 37, 7], [45, 37, 13], [45, 37, 17], [45, 37, 20], [45, 37, 21], [45, 37, 28], [45, 37, 33], [45, 38, 7], [45, 38, 11], [45, 38, 18], [45, 38, 20], [45, 38, 25], [45, 38, 28], [45, 38, 33], [45, 38, 44], [45, 39, 1], [45, 39, 4], [45, 39, 13], [45, 39, 15], [45, 39, 16], [45, 39, 17], [45, 39, 23], [45, 39, 45], [45, 40, 9], [45, 40, 10], [45, 40, 14], [45, 40, 19], [45, 40, 26], [45, 40, 27], [45, 40, 29], [45, 40, 42], [45, 41, 1], [45, 41, 3], [45, 41, 12], [45, 41, 22], [45, 41, 23], [45, 41, 29], [45, 41, 36], [45, 41, 45], [45, 42, 10], [45, 42, 14], [45, 42, 26], [45, 42, 27], [45, 42, 30], [45, 42, 32], [45, 42, 34], [45, 42, 40], [45, 43, 2], [45, 43, 8], [45, 43, 24], [45, 43, 30], [45, 43, 31], [45, 43, 32], [45, 43, 35], [45, 43, 46], [45, 44, 6], [45, 44, 11], [45, 44, 18], [45, 44, 24], [45, 44, 25], [45, 44, 35], [45, 44, 38], [45, 44, 46], [45, 45, 0], [45, 45, 1], [45, 45, 4], [45, 45, 12], [45, 45, 15], [45, 45, 16], [45, 45, 23], [45, 45, 39], [45, 45, 41], [45, 45, 45], [45, 46, 2], [45, 46, 6], [45, 46, 8], [45, 46, 24], [45, 46, 31], [45, 46, 35], [45, 46, 43], [45, 46, 44], [46, 0, 46], [46, 1, 1], [46, 1, 46], [46, 46, 0], [46, 46, 1], [46, 46, 46]]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p1-ff-nikodym-d3-p47/tests/check.py b/tasks/optimize-ae-p1-ff-nikodym-d3-p47/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..6345846c9b9114bf209db5350d6863485823b433 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-nikodym-d3-p47/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-p47/tests/instance.json b/tasks/optimize-ae-p1-ff-nikodym-d3-p47/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..5f2376c838434e0b357cd192cc1151f9ba21ed04 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-nikodym-d3-p47/tests/instance.json @@ -0,0 +1 @@ +{"p": 47, "direction": "minimize", "baseline": 103823, "best_known": 91492, "family": "ae_p1_ff_nikodym", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p1-ff-nikodym-d3-p47/tests/run.py b/tasks/optimize-ae-p1-ff-nikodym-d3-p47/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p1-ff-nikodym-d3-p47/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/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-p47/tests/test.sh b/tasks/optimize-ae-p1-ff-nikodym-d3-p47/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p1-ff-nikodym-d3-p47/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n24/environment/Dockerfile b/tasks/optimize-ae-p41-sphere-max-volume-n24/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..06d0365485bd1fc9437a07fafe38cb8333e9ac65 --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n24/environment/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.11.16-slim +RUN apt-get update && apt-get install -y --no-install-recommends tmux curl git procps build-essential \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --no-cache-dir numpy==2.4.6 scipy==1.17.1 sympy==1.14.0 networkx==3.6.1 \ + python-sat==1.9.dev15 z3-solver==5.1.0.0 PuLP==3.3.2 ortools==9.15.6755 +WORKDIR /workdir +COPY instance.json /workdir/instance.json diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n24/environment/instance.json b/tasks/optimize-ae-p41-sphere-max-volume-n24/environment/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..8f0c9bcae24a2df83fefc4f754856eb7299a281d --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n24/environment/instance.json @@ -0,0 +1 @@ +{"n": 24, "direction": "maximize", "family": "ae_p41_sphere_max_volume", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n24/solution/solve.sh b/tasks/optimize-ae-p41-sphere-max-volume-n24/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..a8610ed52c1a892e97f3a1437ae0eabcd4d74ef8 --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n24/solution/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.070923823115126, -0.4050356566622, 0.911545900186576], [-0.332291826166834, 0.232997800786158, 0.913944291021901], [0.520973463284443, 0.145739701298005, 0.841038994351024], [-0.54888435899145, -0.475075143376454, 0.687771450847145], [0.061617269121407, 0.749843856389104, 0.658739328704106], [0.621602530011849, -0.573533363979301, 0.533544538989442], [-0.90661567016335, 0.049579392631791, 0.419034497912191], [0.700158257277536, 0.632999856698028, 0.330287142023968], [-0.048527463405538, -0.932659522654881, 0.357479090432704], [-0.626172781369059, 0.719392358487302, 0.300636462230739], [0.983988938785555, -0.070438690921864, 0.163719758028438], [-0.781612454345361, -0.623132111733057, 0.028077438261396], [0.107504639542509, 0.993856020916845, -0.026324174520215], [0.585814780813172, -0.792927798051698, -0.167590422332845], [-0.944049896719427, 0.144107524363827, -0.296652682316827], [0.760282646639415, 0.541240287141111, -0.359206415302363], [-0.160868684063409, -0.929612560670521, -0.331574657552872], [-0.529074401618601, 0.739956207320043, -0.415385470136422], [0.81521688230665, -0.21668445380851, -0.537093364583788], [-0.602786245674942, -0.452271149617887, -0.65734279432304], [0.104580738338667, 0.719451856084308, -0.686623547473711], [0.152697824143723, -0.516263983159323, -0.842706873233062], [-0.378262619198459, 0.157759395001811, -0.912156436257391], [0.376554432992458, 0.15895986137304, -0.912654656190386]]} +RLMATH_EOF diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n24/tests/check.py b/tasks/optimize-ae-p41-sphere-max-volume-n24/tests/check.py new file mode 100644 index 0000000000000000000000000000000000000000..58b6521809868700c39ccbae7ef07cd7c99c8d83 --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n24/tests/check.py @@ -0,0 +1,23 @@ +"""n points on the unit sphere maximizing the volume of their convex hull (AlphaEvolve problem 41). + +Upstream bug fixed: the notebook summed |det|/6 of origin-pyramids over (QJ-joggled) hull facets, which +over-counts whenever the origin lies outside the hull (e.g. all points in one hemisphere). We use the exact +hull volume (scipy ConvexHull.volume) of the normalized points, without joggling.""" +import numpy as np +from scipy.spatial import ConvexHull + +from run import Invalid, float_matrix + + +def check(inst, ans): + n = inst["n"] + p = np.array(float_matrix(ans.get("points"), n, 3, "points")) + nr = np.linalg.norm(p, axis=1) + if (nr < 1e-9).any() or (nr > 1e9).any(): + raise Invalid("every point needs a non-zero, finite norm (it is projected to the unit sphere)") + p = p / nr[:, None] + try: + v = ConvexHull(p).volume + except Exception as e: # degenerate (coplanar) input + raise Invalid(f"degenerate hull: {type(e).__name__}") + return float(v), {} diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n24/tests/instance.json b/tasks/optimize-ae-p41-sphere-max-volume-n24/tests/instance.json new file mode 100644 index 0000000000000000000000000000000000000000..4090b2f49b3d0f364c4f8e467cbc9e3ff6a49b57 --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n24/tests/instance.json @@ -0,0 +1 @@ +{"n": 24, "direction": "maximize", "best_known": 3.283995205283, "baseline": 2.066038750170485, "family": "ae_p41_sphere_max_volume", "subset": "optimize"} \ No newline at end of file diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n24/tests/run.py b/tasks/optimize-ae-p41-sphere-max-volume-n24/tests/run.py new file mode 100644 index 0000000000000000000000000000000000000000..9f6db6107aa1f8132aeb1abdcf9bbf100792e48a --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n24/tests/run.py @@ -0,0 +1,127 @@ +"""rlmath runtime grader. Copied into every task as /tests/run.py next to /tests/check.py. + +Deterministic; no LLM in the reward path. Runs with python3 + numpy/scipy/sympy/networkx only. + + python3 /tests/run.py /tests/instance.json /workdir/answer.json + +Prints the reward in [0, 1] and writes /logs/verifier/details.json when that directory exists. + +check.py must define check(inst, ans) -> (value, extra_dict) and raise Invalid for a bad answer. + construct : value is ignored; a returned check means the witness is valid -> reward 1.0 + optimize : value is the raw objective; reward = 0.1 + 0.9 * progress, where + progress = clip((s - baseline) / (best_known - baseline), 0, 1) (maximize) + clip((baseline - s) / (baseline - best_known), 0, 1) (minimize) + inst must carry "direction", "baseline", "best_known". +""" +import json +import math +import os +import sys + +VALID_FLOOR = 0.1 + + +class Invalid(Exception): + pass + + +# ------------------------------------------------------------ input helpers + +def int_list(v, n=None, lo=None, hi=None, name="list"): + if not isinstance(v, list): + raise Invalid(f"{name} must be a list") + if n is not None and len(v) != n: + raise Invalid(f"{name} must have length {n}, got {len(v)}") + for x in v: + if isinstance(x, bool) or not isinstance(x, int): + raise Invalid(f"{name} must contain integers only") + if (lo is not None and x < lo) or (hi is not None and x > hi): + raise Invalid(f"{name} entry {x} out of range [{lo}, {hi}]") + return v + + +def as_int(x, name="value", lo=None, hi=None): + return int_list([x], 1, lo, hi, name)[0] + + +def num(x, name="value"): + if isinstance(x, bool) or not isinstance(x, (int, float)): + raise Invalid(f"{name} must be a number") + if not math.isfinite(x): + raise Invalid(f"{name} is not finite") + return float(x) + + +def float_matrix(v, rows=None, cols=None, name="matrix"): + if not isinstance(v, list) or (rows is not None and len(v) != rows): + raise Invalid(f"{name} must be a list of {rows} rows") + out = [] + for r in v: + if not isinstance(r, list) or (cols is not None and len(r) != cols): + raise Invalid(f"each row of {name} must have {cols} numbers") + out.append([num(x, name) for x in r]) + return out + + +def float_list(v, n=None, name="list"): + if not isinstance(v, list) or (n is not None and len(v) != n): + raise Invalid(f"{name} must be a list of length {n}") + return [num(x, name) for x in v] + + +# ------------------------------------------------------------------ reward + +def optimize_reward(inst, s): + b, best = inst["baseline"], inst["best_known"] + if inst.get("progress_scale") == "log": + # for non-negative losses spanning orders of magnitude (e.g. overlap loss -> 0); + # progress is measured in log10(value + floor) + f = inst.get("log_floor", 1e-3) + b, best, s = (math.log10(max(x, 0.0) + f) for x in (b, best, s)) + if inst["direction"] == "maximize": + p = (s - b) / (best - b) + else: + p = (b - s) / (b - best) + return VALID_FLOOR + (1 - VALID_FLOOR) * max(0.0, min(1.0, p)) + + +def grade(inst, ans, check): + try: + if not isinstance(ans, dict): + raise Invalid("answer must be a JSON object") + value, extra = check(inst, ans) + if inst.get("subset") == "optimize": + s = float(value) + if not math.isfinite(s): + raise Invalid("non-finite score") + return optimize_reward(inst, s), {"valid": True, "raw_score": s, **(extra or {})} + return 1.0, {"valid": True, **(extra or {})} + except Invalid as e: + return 0.0, {"valid": False, "error": str(e)} + except Exception as e: # any malformed answer + return 0.0, {"valid": False, "error": f"{type(e).__name__}: {e}"} + + +def main(): + here = os.path.dirname(os.path.abspath(__file__)) + sys.path.insert(0, here) + # import ourselves as `run` so check.py's `from run import Invalid` is the same class + import run as R # noqa: E402 + import check as family # noqa: E402 + + inst = json.load(open(sys.argv[1])) + try: + ans = json.load(open(sys.argv[2])) + except Exception as e: + reward, det = 0.0, {"valid": False, "error": f"unreadable answer: {e}"} + else: + reward, det = R.grade(inst, ans, family.check) + det["reward"] = reward + if os.path.isdir("/logs/verifier"): + with open("/logs/verifier/details.json", "w") as f: + json.dump(det, f) + print(reward) + + +if __name__ == "__main__": + main() diff --git a/tasks/optimize-ae-p41-sphere-max-volume-n24/tests/test.sh b/tasks/optimize-ae-p41-sphere-max-volume-n24/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..648521fa89684f62943a573f74ce3cb75cd3ae29 --- /dev/null +++ b/tasks/optimize-ae-p41-sphere-max-volume-n24/tests/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash +mkdir -p /logs/verifier +if [ ! -s /workdir/answer.json ]; then + echo '{"valid": false, "error": "no /workdir/answer.json"}' > /logs/verifier/details.json + echo 0 > /logs/verifier/reward.txt + exit 0 +fi +timeout 290 python3 /tests/run.py /tests/instance.json /workdir/answer.json \ + > /logs/verifier/reward.txt 2> /logs/verifier/grader.log || echo 0 > /logs/verifier/reward.txt