Datasets:
Add mbppplus 378, codeforces 408, cc_valid 117 independent val configs
Browse filesFiles changed (10)
- README.mdAdded+30
- cc_valid/evaluator.pyAdded+697
- cc_valid/sample_submission.csvAdded+352
- cc_valid/validation-00000-of-00001.parquetAdded+3
- codeforces/evaluator.pyAdded+689
- codeforces/sample_submission.csvAdded+1225
- codeforces/validation-00000-of-00001.parquetAdded+3
- mbppplus/evaluator.pyAdded+177
- mbppplus/sample_submission.csvAdded+1135
- mbppplus/validation-00000-of-00001.parquetAdded+3
123456789101112131415161718192021222324252627282930---license: apache-2.0task_categories: [text-generation]tags: [code, zevo, validation]configs:- config_name: mbppplus data_files: - split: validation path: mbppplus/validation-*.parquet- config_name: codeforces data_files: - split: validation path: codeforces/validation-*.parquet- config_name: cc_valid data_files: - split: validation path: cc_valid/validation-*.parquet---
# zero-code L1 independent validation sets
Three **separate** configs. Not mixed into one split. Task test stays `Tommysha/zero-code-l1-lcb-v5-test` (LCB v5 279).
| config | split | rows | source | Zevo independent val ||---|---|---:|---|---|| `mbppplus` | validation | 378 | `evalplus/mbppplus` test, as-is plus `id`/`entry_point` | yes (≥200) || `codeforces` | validation | 408 | `agentica-org/DeepCoder-Preview-Dataset` `codeforces` test, plus `id` | yes (≥200) || `cc_valid` | validation | 117 | `Tommysha/zero-code-l1-cc-valid` / `deepmind/code_contests` valid | Hub copy only. Zevo rejects independent val < 200 |
Gold solutions are not in `mbppplus` (`code` dropped). Each config has its own `evaluator.py` and `sample_submission.csv`.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697#!/usr/bin/env python3"""Zevo custom evaluator for zero-code L1 CodeContests valid (117 problems), pass@1.Schema matches LiveCodeBench rows so the same testing_util grades stdin tests.
Usage (Zevo protocol): python3 evaluator.py PREDICTIONS_CSV SCORING_SET METRICS_JSON PREDICTIONS_CSV: columns id,prediction (raw model output; the last ``` fenced block is the program) SCORING_SET: the Test set rows (parquet / jsonl / json / csv) with id, public_test_cases, private_test_cases, metadata METRICS_JSON: written as {"score": pass@1, "correct": ..., "total": ..., "by_difficulty": {...}}Grading is LiveCodeBench's own testing_util (vendored verbatim below, numpy import dropped: it was unused),with LCB's defaults: timeout 6 s per test, all public + private tests must pass, missing prediction = fail.Stdlib only (pyarrow/pandas needed only if SCORING_SET is parquet)."""# ---------------- vendored: lcb_runner/evaluation/testing_util.py @ 28fef95 ----------------import astimport jsonimport sysimport faulthandlerimport platform
# used for debugging to time stepsfrom datetime import datetime
# to run the solution files we're using a timing based approachimport signal
from io import StringIO
# used for testing the code that reads from inputfrom unittest.mock import patch, mock_open
# from pyext import RuntimeModulefrom types import ModuleType
from enum import Enumfrom decimal import Decimalimport time
import_string = "from string import *\nfrom re import *\nfrom datetime import *\nfrom collections import *\nfrom heapq import *\nfrom bisect import *\nfrom copy import *\nfrom math import *\nfrom random import *\nfrom statistics import *\nfrom itertools import *\nfrom functools import *\nfrom operator import *\nfrom io import *\nfrom sys import *\nfrom json import *\nfrom builtins import *\nfrom typing import *\nimport string\nimport re\nimport datetime\nimport collections\nimport heapq\nimport bisect\nimport copy\nimport math\nimport random\nimport statistics\nimport itertools\nimport functools\nimport operator\nimport io\nimport sys\nimport json\nsys.setrecursionlimit(50000)\n"
def truncatefn(s, length=300): if isinstance(s, str): pass else: s = str(s) if len(s) <= length: return s
return s[: length // 2] + "...(truncated) ..." + s[-length // 2 :]
class CODE_TYPE(Enum): call_based = 0 standard_input = 1
# stuff for setting up signal timerclass TimeoutException(Exception): pass
def timeout_handler(signum, frame): print("timeout occured: alarm went off") raise TimeoutException
# used to capture stdout as a list# from https://stackoverflow.com/a/16571630/6416660# alternative use redirect_stdout() from contextlibclass Capturing(list): def __enter__(self): self._stdout = sys.stdout sys.stdout = self._stringio = StringIO() # Make closing the StringIO a no-op self._stringio.close = lambda x: 1 return self
def __exit__(self, *args): self.append(self._stringio.getvalue()) del self._stringio # free up some memory sys.stdout = self._stdout
# Custom mock for sys.stdin that supports buffer attributeclass MockStdinWithBuffer: def __init__(self, inputs: str): self.inputs = inputs self._stringio = StringIO(inputs) self.buffer = MockBuffer(inputs)
def read(self, *args): return self.inputs
def readline(self, *args): return self._stringio.readline(*args)
def readlines(self, *args): return self.inputs.split("\n")
def __getattr__(self, name): # Delegate other attributes to StringIO return getattr(self._stringio, name)
class MockBuffer: def __init__(self, inputs: str): self.inputs = inputs.encode("utf-8") # Convert to bytes
def read(self, *args): # Return as byte strings that can be split return self.inputs
def readline(self, *args): return self.inputs.split(b"\n")[0] + b"\n"
def clean_if_name(code: str) -> str: try: astree = ast.parse(code) last_block = astree.body[-1] if isinstance(last_block, ast.If): condition = last_block.test if ast.unparse(condition).strip() == "__name__ == '__main__'": code = ( ast.unparse(astree.body[:-1]) + "\n" + ast.unparse(last_block.body) # type: ignore ) except: pass
return code
def make_function(code: str) -> str: try: import_stmts = [] all_other_stmts = [] astree = ast.parse(code) for stmt in astree.body: if isinstance(stmt, (ast.Import, ast.ImportFrom)): import_stmts.append(stmt) else: all_other_stmts.append(stmt)
function_ast = ast.FunctionDef( name="wrapped_function", args=ast.arguments( posonlyargs=[], args=[], kwonlyargs=[], kw_defaults=[], defaults=[] ), body=all_other_stmts, decorator_list=[], lineno=-1, ) main_code = ( import_string + "\n" + ast.unparse(import_stmts) # type: ignore + "\n" + ast.unparse(function_ast) # type: ignore ) return main_code except Exception as e: return code
def call_method(method, inputs):
if isinstance(inputs, list): inputs = "\n".join(inputs)
inputs_line_iterator = iter(inputs.split("\n"))
# Create custom stdin mock with buffer support mock_stdin = MockStdinWithBuffer(inputs)
# sys.setrecursionlimit(10000)
# @patch('builtins.input', side_effect=inputs.split("\n")) @patch("builtins.open", mock_open(read_data=inputs)) @patch("sys.stdin", mock_stdin) # Use our custom mock instead of StringIO @patch("sys.stdin.readline", lambda *args: next(inputs_line_iterator)) @patch("sys.stdin.readlines", lambda *args: inputs.split("\n")) @patch("sys.stdin.read", lambda *args: inputs) # @patch('sys.stdout.write', print) def _inner_call_method(_method): try: return _method() except SystemExit as e: pass finally: pass
return _inner_call_method(method)
def get_function(compiled_sol, fn_name: str): # type: ignore try: assert hasattr(compiled_sol, fn_name) return getattr(compiled_sol, fn_name) except Exception as e: return
def compile_code(code: str, timeout: int): signal.alarm(timeout) try: tmp_sol = ModuleType("tmp_sol", "") exec(code, tmp_sol.__dict__) if "class Solution" in code: # leetcode wraps solutions in `Solution` # this is a hack to check if it is leetcode solution or not # currently livecodebench only supports LeetCode but # else condition allows future extensibility to other platforms compiled_sol = tmp_sol.Solution() else: # do nothing in the other case since function is accesible compiled_sol = tmp_sol
assert compiled_sol is not None finally: signal.alarm(0)
return compiled_sol
def convert_line_to_decimals(line: str) -> tuple[bool, list[Decimal]]: try: decimal_line = [Decimal(elem) for elem in line.split()] except: return False, [] return True, decimal_line
def get_stripped_lines(val: str): ## you don't want empty lines to add empty list after splitlines! val = val.strip()
return [val_line.strip() for val_line in val.split("\n")]
def grade_call_based( code: str, all_inputs: list, all_outputs: list, fn_name: str, timeout: int): # call-based clean up logic # need to wrap in try-catch logic after to catch the correct errors, but for now this is fine. code = import_string + "\n\n" + code compiled_sol = compile_code(code, timeout)
if compiled_sol is None: return
method = get_function(compiled_sol, fn_name)
if method is None: return
all_inputs = [ [json.loads(line) for line in inputs.split("\n")] for inputs in all_inputs ]
all_outputs = [json.loads(output) for output in all_outputs]
total_execution = 0 all_results = [] for idx, (gt_inp, gt_out) in enumerate(zip(all_inputs, all_outputs)): signal.alarm(timeout) faulthandler.enable() try: # can lock here so time is useful start = time.time() prediction = method(*gt_inp) total_execution += time.time() - start signal.alarm(0)
# don't penalize model if it produces tuples instead of lists # ground truth sequences are not tuples if isinstance(prediction, tuple): prediction = list(prediction)
tmp_result = prediction == gt_out
# handle floating point comparisons
all_results.append(tmp_result)
if not tmp_result: return all_results, { "output": truncatefn(prediction), "inputs": truncatefn(gt_inp), "expected": truncatefn(gt_out), "error_code": -2, "error_message": "Wrong Answer", } except Exception as e: signal.alarm(0) if "timeoutexception" in repr(e).lower(): all_results.append(-3) return all_results, { "error": repr(e), "error_code": -3, "error_message": "Time Limit Exceeded", "inputs": truncatefn(gt_inp), "expected": truncatefn(gt_out), } else: all_results.append(-4) return all_results, { "error": repr(e), "error_code": -4, "error_message": "Runtime Error", "inputs": truncatefn(gt_inp), "expected": truncatefn(gt_out), }
finally: signal.alarm(0) faulthandler.disable()
return all_results, {"execution time": total_execution}
def grade_stdio( code: str, all_inputs: list, all_outputs: list, timeout: int,): ## runtime doesn't interact well with __name__ == '__main__' code = clean_if_name(code)
## we wrap the given code inside another function code = make_function(code)
compiled_sol = compile_code(code, timeout) if compiled_sol is None: return
method = get_function(compiled_sol, "wrapped_function")
if method is None: return
all_results = [] total_execution_time = 0 for idx, (gt_inp, gt_out) in enumerate(zip(all_inputs, all_outputs)): signal.alarm(timeout) faulthandler.enable()
signal.alarm(timeout) with Capturing() as captured_output: try: start = time.time() call_method(method, gt_inp) total_execution_time += time.time() - start # reset the alarm signal.alarm(0) except Exception as e: signal.alarm(0) if "timeoutexception" in repr(e).lower(): all_results.append(-3) return all_results, { "error": repr(e), "error_code": -3, "error_message": "Time Limit Exceeded", "inputs": truncatefn(gt_inp), "expected": truncatefn(gt_out), } else: all_results.append(-4) return all_results, { "error": repr(e), "error_code": -4, "error_message": "Runtime Error", "inputs": truncatefn(gt_inp), "expected": truncatefn(gt_out), }
finally: signal.alarm(0) faulthandler.disable()
prediction = captured_output[0]
stripped_prediction_lines = get_stripped_lines(prediction) stripped_gt_out_lines = get_stripped_lines(gt_out)
## WA happens in multiple circumstances ## so cache the return to make it clean! WA_send_args = { "output": truncatefn(prediction), "inputs": truncatefn(gt_inp), "expected": truncatefn(gt_out), "error_code": -2, }
if len(stripped_prediction_lines) != len(stripped_gt_out_lines): all_results.append(-2) WA_send_args["error_message"] = "Wrong answer: mismatched output length" return all_results, WA_send_args
for output_line_idx, ( stripped_prediction_line, stripped_gt_out_line, ) in enumerate(zip(stripped_prediction_lines, stripped_gt_out_lines)): WA_send_args["error_message"] = ( f"Wrong answer at {output_line_idx=}: {truncatefn(stripped_prediction_line)} != {truncatefn(stripped_gt_out_line)}" )
## CASE 1: exact match if stripped_prediction_line == stripped_gt_out_line: continue
## CASE 2: element-wise comparision ## if there are floating elements ## use `decimal` library for good floating point comparision ## otherwise gotcha: np.isclose(50000000000000000, 50000000000000001) = True ## note that we should always be able to convert to decimals
success, decimal_prediction_line = convert_line_to_decimals( stripped_prediction_line ) if not success: all_results.append(-2) return all_results, WA_send_args success, decimal_gtout_line = convert_line_to_decimals(stripped_gt_out_line) if not success: all_results.append(-2) return all_results, WA_send_args
if decimal_prediction_line == decimal_gtout_line: continue
all_results.append(-2) return all_results, WA_send_args all_results.append(True)
return all_results, {"execution time": total_execution_time}
def run_test(sample, test=None, debug=False, timeout=6): """ if test(generated_code) is not None it'll try to run the code. otherwise it'll just return an input and output pair. """ signal.signal(signal.SIGALRM, timeout_handler)
# Disable functionalities that can make destructive changes to the test. # max memory is set to 4GB reliability_guard()
if debug: print(f"start = {datetime.now().time()}")
try: in_outs = json.loads(sample["input_output"]) except ValueError as e: raise e in_outs = None
if in_outs: if in_outs.get("fn_name") is None: which_type = CODE_TYPE.standard_input # Standard input method_name = None
else: which_type = CODE_TYPE.call_based # Call-based method_name = in_outs["fn_name"]
if debug: print(f"loaded input_output = {datetime.now().time()}")
if test is None: assert False, "should not happen: test code is none" return in_outs, {"error": "no test code provided"} elif test is not None: results = [] sol = import_string if debug: print(f"loading test code = {datetime.now().time()}")
if which_type == CODE_TYPE.call_based: signal.alarm(timeout) try: results, metadata = grade_call_based( code=test, all_inputs=in_outs["inputs"], all_outputs=in_outs["outputs"], fn_name=method_name, timeout=timeout, ) return results, metadata except Exception as e: return [-4], { "error_code": -4, "error_message": f"Error during testing: {e}", } finally: signal.alarm(0) elif which_type == CODE_TYPE.standard_input: # sol # if code has if __name__ == "__main__": then remove it
signal.alarm(timeout) try: results, metadata = grade_stdio( code=test, all_inputs=in_outs["inputs"], all_outputs=in_outs["outputs"], timeout=timeout, ) return results, metadata except Exception as e: return [-4], { "error_code": -4, "error_message": f"Error during testing: {e}", } finally: signal.alarm(0)
def reliability_guard(maximum_memory_bytes=None): """ This disables various destructive functions and prevents the generated code from interfering with the test (e.g. fork bomb, killing other processes, removing filesystem files, etc.) WARNING This function is NOT a security sandbox. Untrusted code, including, model- generated code, should not be blindly executed outside of one. See the Codex paper for more information about OpenAI's code sandbox, and proceed with caution. """
if maximum_memory_bytes is not None: import resource
resource.setrlimit( resource.RLIMIT_AS, (maximum_memory_bytes, maximum_memory_bytes) ) resource.setrlimit( resource.RLIMIT_DATA, (maximum_memory_bytes, maximum_memory_bytes) ) if not platform.uname().system == "Darwin": resource.setrlimit( resource.RLIMIT_STACK, (maximum_memory_bytes, maximum_memory_bytes) )
faulthandler.disable()
import builtins
# builtins.exit = None builtins.quit = None
import os
os.environ["OMP_NUM_THREADS"] = "1"
os.kill = None os.system = None os.putenv = None os.remove = None os.removedirs = None os.rmdir = None os.fchdir = None os.setuid = None os.fork = None os.forkpty = None os.killpg = None os.rename = None os.renames = None os.truncate = None os.replace = None os.unlink = None os.fchmod = None os.fchown = None os.chmod = None os.chown = None os.chroot = None os.fchdir = None os.lchflags = None os.lchmod = None os.lchown = None os.getcwd = None os.chdir = None
import shutil
shutil.rmtree = None shutil.move = None shutil.chown = None
import subprocess
subprocess.Popen = None # type: ignore
# run as __main__ (Zevo), __builtins__ is the module, not its dict (__builtins__ if isinstance(__builtins__, dict) else __builtins__.__dict__)["help"] = None
import sys
sys.modules["ipdb"] = None sys.modules["joblib"] = None sys.modules["resource"] = None sys.modules["psutil"] = None sys.modules["tkinter"] = None
# ---------------- Zevo entry point ----------------import base64, csv, multiprocessing, pickle, zlib, osfrom concurrent.futures import ProcessPoolExecutor
def extract_code(output: str) -> str: # LCB extract_code for chat/R1 styles: text between the last two ``` lines. lines = output.split("\n") idx = [i for i, line in enumerate(lines) if "```" in line] if len(idx) < 2: return "" return "\n".join(lines[idx[-2] + 1: idx[-1]])
def decode_tests(row): pub = json.loads(row["public_test_cases"]) priv = row["private_test_cases"] try: priv = json.loads(priv) except Exception: priv = json.loads(pickle.loads(zlib.decompress(base64.b64decode(priv.encode("utf-8"))))) meta = row["metadata"] if isinstance(row["metadata"], dict) else json.loads(row["metadata"] or "{}") tests = pub + priv return {"input_output": json.dumps({"inputs": [t["input"] for t in tests], "outputs": [t["output"] for t in tests], "fn_name": meta.get("func_name")})}
def _run(sample, code, result, timeout): res, _ = run_test(sample, test=code, debug=False, timeout=timeout) result.append(res)
def check(args): # LCB check_correctness: run in a child process with a global timeout. sample, code, timeout = args if not code.strip(): return False manager = multiprocessing.Manager() result = manager.list() p = multiprocessing.Process(target=_run, args=(sample, code, result, timeout)) p.start() n = len(json.loads(sample["input_output"])["inputs"]) p.join(timeout=(timeout + 1) * n + 5) if p.is_alive(): p.kill() if not result: return False res = result[0] return bool(res) and all(r is True or (not isinstance(r, bool) and r == 1) for r in res)
def load_rows(path): ext = os.path.splitext(path)[1].lower() if ext == ".parquet": import pyarrow.parquet as pq return pq.read_table(path).to_pylist() if ext == ".jsonl": return [json.loads(l) for l in open(path, encoding="utf-8") if l.strip()] if ext == ".json": d = json.load(open(path, encoding="utf-8")) return d if isinstance(d, list) else d.get("data", d.get("rows")) csv.field_size_limit(sys.maxsize) return list(csv.DictReader(open(path, newline="", encoding="utf-8")))
def main(): pred_path, set_path, out_path = sys.argv[1:4] csv.field_size_limit(sys.maxsize) preds = {r["id"]: r.get("prediction") or "" for r in csv.DictReader(open(pred_path, newline="", encoding="utf-8"))} rows = load_rows(set_path) jobs = [(decode_tests(r), extract_code(preds.get(str(r["id"]), "")), 6) for r in rows] workers = int(os.environ.get("LCB_EVAL_WORKERS", min(16, os.cpu_count() or 1))) with ProcessPoolExecutor(max_workers=workers) as ex: ok = list(ex.map(check, jobs)) by = {} for r, k in zip(rows, ok): d = by.setdefault(r.get("difficulty", "all"), [0, 0]) d[0] += k; d[1] += 1 total = len(rows); correct = sum(ok) out = {"score": correct / total if total else 0.0, "correct": correct, "total": total, "missing_predictions": sum(str(r["id"]) not in preds for r in rows), "by_difficulty": {k: round(v[0] / v[1], 4) for k, v in by.items()}} json.dump(out, open(out_path, "w", encoding="utf-8")) print(json.dumps(out))
if __name__ == "__main__": main()123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352id,prediction
1548_C._The_Three_Little_Pigs,"```python# solution```"
1548_D1._Gregor_and_the_Odd_Cows_Easy,"```python# solution```"
1548_D2._Gregor_and_the_Odd_Cows_Hard,"```python# solution```"
1548_E._Gregor_and_the_Two_Painters,"```python# solution```"
1549_A._Gregor_and_Cryptography,"```python# solution```"
1549_B._Gregor_and_the_Pawn_Game,"```python# solution```"
1549_C._Web_of_Lies,"```python# solution```"
1549_D._Integers_Have_Friends,"```python# solution```"
1551_A._Polycarp_and_Coins,"```python# solution```"
1551_B1._Wonderful_Coloring_-_1,"```python# solution```"
1551_B2._Wonderful_Coloring_-_2,"```python# solution```"
1551_C._Interesting_Story,"```python# solution```"
1551_D1._Domino_easy_version,"```python# solution```"
1551_D2._Domino_hard_version,"```python# solution```"
1551_E._Fixed_Points,"```python# solution```"
1551_F._Equidistant_Vertices,"```python# solution```"
1552_A._Subsequence_Permutation,"```python# solution```"
1552_B._Running_for_Gold,"```python# solution```"
1552_C._Maximize_the_Intersections,"```python# solution```"
1552_D._Array_Differentiation,"```python# solution```"
1552_E._Colors_and_Intervals,"```python# solution```"
1552_F._Telepanting,"```python# solution```"
1552_G._A_Serious_Referee,"```python# solution```"
1552_I._Organizing_a_Music_Festival,"```python# solution```"
1553_A._Digits_Sum,"```python# solution```"
1553_B._Reverse_String,"```python# solution```"
1553_C._Penalty,"```python# solution```"
1553_D._Backspace,"```python# solution```"
1553_E._Permutation_Shift,"```python# solution```"
1553_F._Pairwise_Modulo,"```python# solution```"
1553_G._Common_Divisor_Graph,"```python# solution```"
1553_H._XOR_and_Distance,"```python# solution```"
1553_I._Stairs,"```python# solution```"
1554_A._Cherry,"```python# solution```"
1554_B._Cobb,"```python# solution```"
1554_C._Mikasa,"```python# solution```"
1554_D._Diane,"```python# solution```"
1554_E._You,"```python# solution```"
1555_A._PizzaForces,"```python# solution```"
1555_B._Two_Tables,"```python# solution```"
1555_C._Coin_Rows,"```python# solution```"
1555_D._Say_No_to_Palindromes,"```python# solution```"
1555_E._Boring_Segments,"```python# solution```"
1555_F._Good_Graph,"```python# solution```"
1556_A._A_Variety_of_Operations,"```python# solution```"
1556_B._Take_Your_Places,"```python# solution```"
1556_C._Compressed_Bracket_Sequence,"```python# solution```"
1556_D._Take_a_Guess,"```python# solution```"
1556_E._Equilibrium,"```python# solution```"
1556_F._Sports_Betting,"```python# solution```"
1556_G._Gates_to_Another_World,"```python# solution```"
1556_H._DIY_Tree,"```python# solution```"
1557_A._Ezzat_and_Two_Subsequences,"```python# solution```"
1557_B._Moamen_and_k-subarrays,"```python# solution```"
1557_C._Moamen_and_XOR,"```python# solution```"
1557_D._Ezzat_and_Grid,"```python# solution```"
1557_E._Assiut_Chess,"```python# solution```"
1558_C._Bottom-Tier_Reversals,"```python# solution```"
1558_D._Top-Notch_Insertions,"```python# solution```"
1558_E._Down_Below,"```python# solution```"
1559_A._Mocha_and_Math,"```python# solution```"
1559_B._Mocha_and_Red_and_Blue,"```python# solution```"
1559_C._Mocha_and_Hiking,"```python# solution```"
1559_D1._Mocha_and_Diana_Easy_Version,"```python# solution```"
1559_D2._Mocha_and_Diana_Hard_Version,"```python# solution```"
1559_E._Mocha_and_Stars,"```python# solution```"
1560_A._Dislike_of_Threes,"```python# solution```"
1560_B._Who_s_Opposite,"```python# solution```"
1560_C._Infinity_Table,"```python# solution```"
1560_D._Make_a_Power_of_Two,"```python# solution```"
1560_E._Polycarp_and_String_Transformation,"```python# solution```"
1560_F1._Nearest_Beautiful_Number_easy_version,"```python# solution```"
1560_F2._Nearest_Beautiful_Number_hard_version,"```python# solution```"
1561_A._Simply_Strange_Sort,"```python# solution```"
1561_B._Charmed_by_the_Game,"```python# solution```"
1561_C._Deep_Down_Below,"```python# solution```"
1561_D1._Up_the_Strip_simplified_version,"```python# solution```"
1561_D2._Up_the_Strip,"```python# solution```"
1562_A._The_Miracle_and_the_Sleeper,"```python# solution```"
1562_B._Scenes_From_a_Memory,"```python# solution```"
1562_C._Rings,"```python# solution```"
1562_D1._Two_Hundred_Twenty_One_easy_version,"```python# solution```"
1562_D2._Two_Hundred_Twenty_One_hard_version,"```python# solution```"
1562_E._Rescue_Niwen,"```python# solution```"
1566_A._Median_Maximization,"```python# solution```"
1566_B._MIN-MEX_Cut,"```python# solution```"
1566_C._MAX-MEX_Cut,"```python# solution```"
1566_D1._Seating_Arrangements_easy_version,"```python# solution```"
1566_D2._Seating_Arrangements_hard_version,"```python# solution```"
1566_E._Buds_Re-hanging,"```python# solution```"
1566_F._Points_Movement,"```python# solution```"
1566_G._Four_Vertices,"```python# solution```"
1566_H._Xor-quiz,"```python# solution```"
1567_B._MEXor_Mixup,"```python# solution```"
1567_C._Carrying_Conundrum,"```python# solution```"
1567_D._Expression_Evaluation_Error,"```python# solution```"
1567_E._Non-Decreasing_Dilemma,"```python# solution```"
1567_F._One-Four_Overload,"```python# solution```"
1569_A._Balanced_Substring,"```python# solution```"
1569_B._Chess_Tournament,"```python# solution```"
1569_C._Jury_Meeting,"```python# solution```"
1569_D._Inconvenient_Pairs,"```python# solution```"
1569_E._Playoff_Restoration,"```python# solution```"
1569_F._Palindromic_Hamiltonian_Path,"```python# solution```"
1572_B._Xor_of_3,"```python# solution```"
1572_C._Paint,"```python# solution```"
1572_D._Bridge_Club,"```python# solution```"
1572_E._Polygon,"```python# solution```"
1572_F._Stations,"```python# solution```"
1573_A._Countdown,"```python# solution```"
1573_C._Book,"```python# solution```"
1574_A._Regular_Bracket_Sequences,"```python# solution```"
1574_B._Combinatorics_Homework,"```python# solution```"
1574_C._Slay_the_Dragon,"```python# solution```"
1574_D._The_Strongest_Build,"```python# solution```"
1574_E._Coloring,"```python# solution```"
1574_F._Occurrences,"```python# solution```"123version https://git-lfs.github.com/spec/v1oid sha256:92cc93ed23ca9635a84bbdd5ee66025010df30a3fe88f5edd83477733fd9acbesize 234595123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689#!/usr/bin/env python3"""Zevo custom evaluator for DeepCoder Codeforces val (408), pass@1.
Hub: Tommysha/zero-code-l1-val config codeforces split validation.Rows: id, problem, tests (JSON list of {input, output} stdin cases).
Usage: python3 evaluator.py PREDICTIONS_CSV SCORING_SET METRICS_JSONStdlib only (pyarrow only if SCORING_SET is parquet). Timeout 6 s per test."""# ---------------- vendored: lcb_runner/evaluation/testing_util.py @ 28fef95 ----------------import astimport jsonimport sysimport faulthandlerimport platform
# used for debugging to time stepsfrom datetime import datetime
# to run the solution files we're using a timing based approachimport signal
from io import StringIO
# used for testing the code that reads from inputfrom unittest.mock import patch, mock_open
# from pyext import RuntimeModulefrom types import ModuleType
from enum import Enumfrom decimal import Decimalimport time
import_string = "from string import *\nfrom re import *\nfrom datetime import *\nfrom collections import *\nfrom heapq import *\nfrom bisect import *\nfrom copy import *\nfrom math import *\nfrom random import *\nfrom statistics import *\nfrom itertools import *\nfrom functools import *\nfrom operator import *\nfrom io import *\nfrom sys import *\nfrom json import *\nfrom builtins import *\nfrom typing import *\nimport string\nimport re\nimport datetime\nimport collections\nimport heapq\nimport bisect\nimport copy\nimport math\nimport random\nimport statistics\nimport itertools\nimport functools\nimport operator\nimport io\nimport sys\nimport json\nsys.setrecursionlimit(50000)\n"
def truncatefn(s, length=300): if isinstance(s, str): pass else: s = str(s) if len(s) <= length: return s
return s[: length // 2] + "...(truncated) ..." + s[-length // 2 :]
class CODE_TYPE(Enum): call_based = 0 standard_input = 1
# stuff for setting up signal timerclass TimeoutException(Exception): pass
def timeout_handler(signum, frame): print("timeout occured: alarm went off") raise TimeoutException
# used to capture stdout as a list# from https://stackoverflow.com/a/16571630/6416660# alternative use redirect_stdout() from contextlibclass Capturing(list): def __enter__(self): self._stdout = sys.stdout sys.stdout = self._stringio = StringIO() # Make closing the StringIO a no-op self._stringio.close = lambda x: 1 return self
def __exit__(self, *args): self.append(self._stringio.getvalue()) del self._stringio # free up some memory sys.stdout = self._stdout
# Custom mock for sys.stdin that supports buffer attributeclass MockStdinWithBuffer: def __init__(self, inputs: str): self.inputs = inputs self._stringio = StringIO(inputs) self.buffer = MockBuffer(inputs)
def read(self, *args): return self.inputs
def readline(self, *args): return self._stringio.readline(*args)
def readlines(self, *args): return self.inputs.split("\n")
def __getattr__(self, name): # Delegate other attributes to StringIO return getattr(self._stringio, name)
class MockBuffer: def __init__(self, inputs: str): self.inputs = inputs.encode("utf-8") # Convert to bytes
def read(self, *args): # Return as byte strings that can be split return self.inputs
def readline(self, *args): return self.inputs.split(b"\n")[0] + b"\n"
def clean_if_name(code: str) -> str: try: astree = ast.parse(code) last_block = astree.body[-1] if isinstance(last_block, ast.If): condition = last_block.test if ast.unparse(condition).strip() == "__name__ == '__main__'": code = ( ast.unparse(astree.body[:-1]) + "\n" + ast.unparse(last_block.body) # type: ignore ) except: pass
return code
def make_function(code: str) -> str: try: import_stmts = [] all_other_stmts = [] astree = ast.parse(code) for stmt in astree.body: if isinstance(stmt, (ast.Import, ast.ImportFrom)): import_stmts.append(stmt) else: all_other_stmts.append(stmt)
function_ast = ast.FunctionDef( name="wrapped_function", args=ast.arguments( posonlyargs=[], args=[], kwonlyargs=[], kw_defaults=[], defaults=[] ), body=all_other_stmts, decorator_list=[], lineno=-1, ) main_code = ( import_string + "\n" + ast.unparse(import_stmts) # type: ignore + "\n" + ast.unparse(function_ast) # type: ignore ) return main_code except Exception as e: return code
def call_method(method, inputs):
if isinstance(inputs, list): inputs = "\n".join(inputs)
inputs_line_iterator = iter(inputs.split("\n"))
# Create custom stdin mock with buffer support mock_stdin = MockStdinWithBuffer(inputs)
# sys.setrecursionlimit(10000)
# @patch('builtins.input', side_effect=inputs.split("\n")) @patch("builtins.open", mock_open(read_data=inputs)) @patch("sys.stdin", mock_stdin) # Use our custom mock instead of StringIO @patch("sys.stdin.readline", lambda *args: next(inputs_line_iterator)) @patch("sys.stdin.readlines", lambda *args: inputs.split("\n")) @patch("sys.stdin.read", lambda *args: inputs) # @patch('sys.stdout.write', print) def _inner_call_method(_method): try: return _method() except SystemExit as e: pass finally: pass
return _inner_call_method(method)
def get_function(compiled_sol, fn_name: str): # type: ignore try: assert hasattr(compiled_sol, fn_name) return getattr(compiled_sol, fn_name) except Exception as e: return
def compile_code(code: str, timeout: int): signal.alarm(timeout) try: tmp_sol = ModuleType("tmp_sol", "") exec(code, tmp_sol.__dict__) if "class Solution" in code: # leetcode wraps solutions in `Solution` # this is a hack to check if it is leetcode solution or not # currently livecodebench only supports LeetCode but # else condition allows future extensibility to other platforms compiled_sol = tmp_sol.Solution() else: # do nothing in the other case since function is accesible compiled_sol = tmp_sol
assert compiled_sol is not None finally: signal.alarm(0)
return compiled_sol
def convert_line_to_decimals(line: str) -> tuple[bool, list[Decimal]]: try: decimal_line = [Decimal(elem) for elem in line.split()] except: return False, [] return True, decimal_line
def get_stripped_lines(val: str): ## you don't want empty lines to add empty list after splitlines! val = val.strip()
return [val_line.strip() for val_line in val.split("\n")]
def grade_call_based( code: str, all_inputs: list, all_outputs: list, fn_name: str, timeout: int): # call-based clean up logic # need to wrap in try-catch logic after to catch the correct errors, but for now this is fine. code = import_string + "\n\n" + code compiled_sol = compile_code(code, timeout)
if compiled_sol is None: return
method = get_function(compiled_sol, fn_name)
if method is None: return
all_inputs = [ [json.loads(line) for line in inputs.split("\n")] for inputs in all_inputs ]
all_outputs = [json.loads(output) for output in all_outputs]
total_execution = 0 all_results = [] for idx, (gt_inp, gt_out) in enumerate(zip(all_inputs, all_outputs)): signal.alarm(timeout) faulthandler.enable() try: # can lock here so time is useful start = time.time() prediction = method(*gt_inp) total_execution += time.time() - start signal.alarm(0)
# don't penalize model if it produces tuples instead of lists # ground truth sequences are not tuples if isinstance(prediction, tuple): prediction = list(prediction)
tmp_result = prediction == gt_out
# handle floating point comparisons
all_results.append(tmp_result)
if not tmp_result: return all_results, { "output": truncatefn(prediction), "inputs": truncatefn(gt_inp), "expected": truncatefn(gt_out), "error_code": -2, "error_message": "Wrong Answer", } except Exception as e: signal.alarm(0) if "timeoutexception" in repr(e).lower(): all_results.append(-3) return all_results, { "error": repr(e), "error_code": -3, "error_message": "Time Limit Exceeded", "inputs": truncatefn(gt_inp), "expected": truncatefn(gt_out), } else: all_results.append(-4) return all_results, { "error": repr(e), "error_code": -4, "error_message": "Runtime Error", "inputs": truncatefn(gt_inp), "expected": truncatefn(gt_out), }
finally: signal.alarm(0) faulthandler.disable()
return all_results, {"execution time": total_execution}
def grade_stdio( code: str, all_inputs: list, all_outputs: list, timeout: int,): ## runtime doesn't interact well with __name__ == '__main__' code = clean_if_name(code)
## we wrap the given code inside another function code = make_function(code)
compiled_sol = compile_code(code, timeout) if compiled_sol is None: return
method = get_function(compiled_sol, "wrapped_function")
if method is None: return
all_results = [] total_execution_time = 0 for idx, (gt_inp, gt_out) in enumerate(zip(all_inputs, all_outputs)): signal.alarm(timeout) faulthandler.enable()
signal.alarm(timeout) with Capturing() as captured_output: try: start = time.time() call_method(method, gt_inp) total_execution_time += time.time() - start # reset the alarm signal.alarm(0) except Exception as e: signal.alarm(0) if "timeoutexception" in repr(e).lower(): all_results.append(-3) return all_results, { "error": repr(e), "error_code": -3, "error_message": "Time Limit Exceeded", "inputs": truncatefn(gt_inp), "expected": truncatefn(gt_out), } else: all_results.append(-4) return all_results, { "error": repr(e), "error_code": -4, "error_message": "Runtime Error", "inputs": truncatefn(gt_inp), "expected": truncatefn(gt_out), }
finally: signal.alarm(0) faulthandler.disable()
prediction = captured_output[0]
stripped_prediction_lines = get_stripped_lines(prediction) stripped_gt_out_lines = get_stripped_lines(gt_out)
## WA happens in multiple circumstances ## so cache the return to make it clean! WA_send_args = { "output": truncatefn(prediction), "inputs": truncatefn(gt_inp), "expected": truncatefn(gt_out), "error_code": -2, }
if len(stripped_prediction_lines) != len(stripped_gt_out_lines): all_results.append(-2) WA_send_args["error_message"] = "Wrong answer: mismatched output length" return all_results, WA_send_args
for output_line_idx, ( stripped_prediction_line, stripped_gt_out_line, ) in enumerate(zip(stripped_prediction_lines, stripped_gt_out_lines)): WA_send_args["error_message"] = ( f"Wrong answer at {output_line_idx=}: {truncatefn(stripped_prediction_line)} != {truncatefn(stripped_gt_out_line)}" )
## CASE 1: exact match if stripped_prediction_line == stripped_gt_out_line: continue
## CASE 2: element-wise comparision ## if there are floating elements ## use `decimal` library for good floating point comparision ## otherwise gotcha: np.isclose(50000000000000000, 50000000000000001) = True ## note that we should always be able to convert to decimals
success, decimal_prediction_line = convert_line_to_decimals( stripped_prediction_line ) if not success: all_results.append(-2) return all_results, WA_send_args success, decimal_gtout_line = convert_line_to_decimals(stripped_gt_out_line) if not success: all_results.append(-2) return all_results, WA_send_args
if decimal_prediction_line == decimal_gtout_line: continue
all_results.append(-2) return all_results, WA_send_args all_results.append(True)
return all_results, {"execution time": total_execution_time}
def run_test(sample, test=None, debug=False, timeout=6): """ if test(generated_code) is not None it'll try to run the code. otherwise it'll just return an input and output pair. """ signal.signal(signal.SIGALRM, timeout_handler)
# Disable functionalities that can make destructive changes to the test. # max memory is set to 4GB reliability_guard()
if debug: print(f"start = {datetime.now().time()}")
try: in_outs = json.loads(sample["input_output"]) except ValueError as e: raise e in_outs = None
if in_outs: if in_outs.get("fn_name") is None: which_type = CODE_TYPE.standard_input # Standard input method_name = None
else: which_type = CODE_TYPE.call_based # Call-based method_name = in_outs["fn_name"]
if debug: print(f"loaded input_output = {datetime.now().time()}")
if test is None: assert False, "should not happen: test code is none" return in_outs, {"error": "no test code provided"} elif test is not None: results = [] sol = import_string if debug: print(f"loading test code = {datetime.now().time()}")
if which_type == CODE_TYPE.call_based: signal.alarm(timeout) try: results, metadata = grade_call_based( code=test, all_inputs=in_outs["inputs"], all_outputs=in_outs["outputs"], fn_name=method_name, timeout=timeout, ) return results, metadata except Exception as e: return [-4], { "error_code": -4, "error_message": f"Error during testing: {e}", } finally: signal.alarm(0) elif which_type == CODE_TYPE.standard_input: # sol # if code has if __name__ == "__main__": then remove it
signal.alarm(timeout) try: results, metadata = grade_stdio( code=test, all_inputs=in_outs["inputs"], all_outputs=in_outs["outputs"], timeout=timeout, ) return results, metadata except Exception as e: return [-4], { "error_code": -4, "error_message": f"Error during testing: {e}", } finally: signal.alarm(0)
def reliability_guard(maximum_memory_bytes=None): """ This disables various destructive functions and prevents the generated code from interfering with the test (e.g. fork bomb, killing other processes, removing filesystem files, etc.) WARNING This function is NOT a security sandbox. Untrusted code, including, model- generated code, should not be blindly executed outside of one. See the Codex paper for more information about OpenAI's code sandbox, and proceed with caution. """
if maximum_memory_bytes is not None: import resource
resource.setrlimit( resource.RLIMIT_AS, (maximum_memory_bytes, maximum_memory_bytes) ) resource.setrlimit( resource.RLIMIT_DATA, (maximum_memory_bytes, maximum_memory_bytes) ) if not platform.uname().system == "Darwin": resource.setrlimit( resource.RLIMIT_STACK, (maximum_memory_bytes, maximum_memory_bytes) )
faulthandler.disable()
import builtins
# builtins.exit = None builtins.quit = None
import os
os.environ["OMP_NUM_THREADS"] = "1"
os.kill = None os.system = None os.putenv = None os.remove = None os.removedirs = None os.rmdir = None os.fchdir = None os.setuid = None os.fork = None os.forkpty = None os.killpg = None os.rename = None os.renames = None os.truncate = None os.replace = None os.unlink = None os.fchmod = None os.fchown = None os.chmod = None os.chown = None os.chroot = None os.fchdir = None os.lchflags = None os.lchmod = None os.lchown = None os.getcwd = None os.chdir = None
import shutil
shutil.rmtree = None shutil.move = None shutil.chown = None
import subprocess
subprocess.Popen = None # type: ignore
# run as __main__ (Zevo), __builtins__ is the module, not its dict (__builtins__ if isinstance(__builtins__, dict) else __builtins__.__dict__)["help"] = None
import sys
sys.modules["ipdb"] = None sys.modules["joblib"] = None sys.modules["resource"] = None sys.modules["psutil"] = None sys.modules["tkinter"] = None
# ---------------- Zevo entry point ----------------import base64, csv, multiprocessing, pickle, zlib, osfrom concurrent.futures import ProcessPoolExecutor
def extract_code(output: str) -> str: lines = output.split("\n") idx = [i for i, line in enumerate(lines) if "```" in line] if len(idx) >= 2: return "\n".join(lines[idx[-2] + 1: idx[-1]]) return (output or "").strip()
def decode_tests(row): ts = row["tests"] if isinstance(ts, str): ts = json.loads(ts) ts = ts or [] return {"input_output": json.dumps({ "inputs": [t.get("input", "") for t in ts], "outputs": [t.get("output", "") for t in ts], "fn_name": None, })}
def _run(sample, code, result, timeout): res, _ = run_test(sample, test=code, debug=False, timeout=timeout) result.append(res)
def check(args): # LCB check_correctness: run in a child process with a global timeout. sample, code, timeout = args if not code.strip(): return False manager = multiprocessing.Manager() result = manager.list() p = multiprocessing.Process(target=_run, args=(sample, code, result, timeout)) p.start() n = len(json.loads(sample["input_output"])["inputs"]) p.join(timeout=(timeout + 1) * n + 5) if p.is_alive(): p.kill() if not result: return False res = result[0] return bool(res) and all(r is True or (not isinstance(r, bool) and r == 1) for r in res)
def load_rows(path): ext = os.path.splitext(path)[1].lower() if ext == ".parquet": import pyarrow.parquet as pq return pq.read_table(path).to_pylist() if ext == ".jsonl": return [json.loads(l) for l in open(path, encoding="utf-8") if l.strip()] if ext == ".json": d = json.load(open(path, encoding="utf-8")) return d if isinstance(d, list) else d.get("data", d.get("rows")) csv.field_size_limit(sys.maxsize) return list(csv.DictReader(open(path, newline="", encoding="utf-8")))
def main(): pred_path, set_path, out_path = sys.argv[1:4] csv.field_size_limit(sys.maxsize) preds = {r["id"]: r.get("prediction") or "" for r in csv.DictReader(open(pred_path, newline="", encoding="utf-8"))} rows = load_rows(set_path) jobs = [(decode_tests(r), extract_code(preds.get(str(r["id"]), "")), 6) for r in rows] workers = int(os.environ.get("LCB_EVAL_WORKERS", min(16, os.cpu_count() or 1))) with ProcessPoolExecutor(max_workers=workers) as ex: ok = list(ex.map(check, jobs)) by = {} for r, k in zip(rows, ok): d = by.setdefault(r.get("difficulty", "all"), [0, 0]) d[0] += k; d[1] += 1 total = len(rows); correct = sum(ok) out = {"score": correct / total if total else 0.0, "correct": correct, "total": total, "missing_predictions": sum(str(r["id"]) not in preds for r in rows), "by_difficulty": {k: round(v[0] / v[1], 4) for k, v in by.items()}} json.dump(out, open(out_path, "w", encoding="utf-8")) print(json.dumps(out))
if __name__ == "__main__": main()1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225id,prediction
cf-7523ff0de46ffb62,"```python# solution```"
cf-c02443ec23f88353,"```python# solution```"
cf-7ac66687aa5eab54,"```python# solution```"
cf-e76762ee2f865346,"```python# solution```"
cf-8a7b37d147fff9f2,"```python# solution```"
cf-d64ea36c259258bd,"```python# solution```"
cf-71cdab7c3ed2a9e3,"```python# solution```"
cf-d5bc0040e507c601,"```python# solution```"
cf-c9dc2fe6951af63c,"```python# solution```"
cf-f022f97a83aecd81,"```python# solution```"
cf-03989708ba80f434,"```python# solution```"
cf-6b96f12da81e3aa6,"```python# solution```"
cf-27257141f88d7919,"```python# solution```"
cf-0c54c4db17b4a002,"```python# solution```"
cf-d269d3c95353659a,"```python# solution```"
cf-2846ab5c0f8efc0a,"```python# solution```"
cf-7ae26c5706fd4fd1,"```python# solution```"
cf-3a92d2c8dbf1ac59,"```python# solution```"
cf-d894a01fb8ac77eb,"```python# solution```"
cf-6d4279adcb1fad9f,"```python# solution```"
cf-d0e6b6fcda95bed7,"```python# solution```"
cf-aa9efedb39810f70,"```python# solution```"
cf-2900b66654b363c3,"```python# solution```"
cf-d3d645b73b59c21d,"```python# solution```"
cf-5500d3fcb5e5722a,"```python# solution```"
cf-1aa2747d93916bb1,"```python# solution```"
cf-faae40af5e76d60b,"```python# solution```"
cf-5bdc7b104350f60f,"```python# solution```"
cf-4dcb5afc4dd0896d,"```python# solution```"
cf-eb141c5086038eac,"```python# solution```"
cf-56bd4e1044a4fc5a,"```python# solution```"
cf-241362537a821837,"```python# solution```"
cf-2504211e2da6bf85,"```python# solution```"
cf-fe72bd8119780ec8,"```python# solution```"
cf-1ca08b48bd892578,"```python# solution```"
cf-7f5b6e4b96fcd311,"```python# solution```"
cf-79fa4a4184718719,"```python# solution```"
cf-11cfb743bc719098,"```python# solution```"
cf-80c6887ef976a83f,"```python# solution```"
cf-0ca0714ae890d497,"```python# solution```"
cf-ee1166e86da8a5bc,"```python# solution```"
cf-01dda202b0218b62,"```python# solution```"
cf-94ba82d61a989906,"```python# solution```"
cf-686973a2ba447968,"```python# solution```"
cf-1087f5de081a27de,"```python# solution```"
cf-bf629747f8647fbd,"```python# solution```"
cf-200064be45810647,"```python# solution```"
cf-978389c1f63e8c56,"```python# solution```"
cf-53bbfadfc69af54a,"```python# solution```"
cf-b15b42ca21d6498c,"```python# solution```"
cf-09d4b3eee7968b29,"```python# solution```"
cf-97100ad837e06861,"```python# solution```"
cf-cc1dd97084442fd7,"```python# solution```"
cf-61505319ac981d75,"```python# solution```"
cf-2e5b5d04f1d95a7f,"```python# solution```"
cf-336a44a84724d94f,"```python# solution```"
cf-1bc44fec8f5fbeb5,"```python# solution```"
cf-4857ca2b46ac76e5,"```python# solution```"
cf-83c9c92eee2f2fad,"```python# solution```"
cf-546e2bfd848ad791,"```python# solution```"
cf-c5781db3fd9b0c93,"```python# solution```"
cf-6b1da5c26358bb68,"```python# solution```"
cf-bc5062c8c3e0ab6e,"```python# solution```"
cf-d0c531ba295dc35b,"```python# solution```"
cf-7ab2686a86e7e11b,"```python# solution```"
cf-46b5d0f266fb5973,"```python# solution```"
cf-575a7dd3dacefcac,"```python# solution```"
cf-62950c42317da0ea,"```python# solution```"
cf-4035efd555f39da9,"```python# solution```"
cf-71583b418f5b422f,"```python# solution```"
cf-d9a92f5b1ca467a7,"```python# solution```"
cf-ee148c8d94fef8f0,"```python# solution```"
cf-12ded724e7b4e8ce,"```python# solution```"
cf-e3b3e78d8d33ea08,"```python# solution```"
cf-6948ecd6286e913c,"```python# solution```"
cf-5fdd0e04ea336294,"```python# solution```"
cf-50b61b3d8c1fef5e,"```python# solution```"
cf-895ee117276fc985,"```python# solution```"
cf-b9be4f453fa811fd,"```python# solution```"
cf-35558baff322d158,"```python# solution```"
cf-39dc6d797ec012dc,"```python# solution```"
cf-26164dd358b25b03,"```python# solution```"
cf-85d614b42c653847,"```python# solution```"
cf-3b24035b37b7e3d0,"```python# solution```"
cf-5f489f6285179bc0,"```python# solution```"
cf-4d8452a6dc8692ee,"```python# solution```"
cf-3210cc15125b1902,"```python# solution```"
cf-68791d88924e8208,"```python# solution```"
cf-d81d9c8ba952a505,"```python# solution```"
cf-5fa3fb3b49dbd702,"```python# solution```"
cf-a7fa9759eff61255,"```python# solution```"
cf-5118104022fa64fe,"```python# solution```"
cf-7d90be3588221da2,"```python# solution```"
cf-650d93f12b4cd5ba,"```python# solution```"
cf-2034d12ca0220544,"```python# solution```"
cf-8a750ad6391674a9,"```python# solution```"
cf-1f0b89e27db09b4b,"```python# solution```"
cf-f90a85e39db3bde3,"```python# solution```"
cf-9474cceabd190d0e,"```python# solution```"
cf-10c296908f2b0a5f,"```python# solution```"
cf-221072dc36214997,"```python# solution```"
cf-8f39e6c702501551,"```python# solution```"
cf-669639e067f94619,"```python# solution```"
cf-b3cdd9336cdbad21,"```python# solution```"
cf-5e9d0047aca5fcd3,"```python# solution```"
cf-50a8c0c707c1b907,"```python# solution```"
cf-5bae67e9f7e11a8b,"```python# solution```"
cf-09fb79acee3ca230,"```python# solution```"
cf-a5588da658a1be0c,"```python# solution```"
cf-f82bf3ec8a29e0fa,"```python# solution```"
cf-c5eb57e3cf07b61f,"```python# solution```"
cf-30ba13a749db8bc7,"```python# solution```"
cf-a7e1dfb8e3b12bc1,"```python# solution```"
cf-f798fd88bad8fc48,"```python# solution```"
cf-e7510edf5c14124e,"```python# solution```"
cf-0aab0be1d320d720,"```python# solution```"
cf-b8b2a08f1a3286a6,"```python# solution```"
cf-dffe1fc7a37fd6bc,"```python# solution```"
cf-8ee59b3823b970d0,"```python# solution```"
cf-77f4f41be4eba94f,"```python# solution```"
cf-3748298c6fa84b8d,"```python# solution```"
cf-0c93176b7ce4364f,"```python# solution```"
cf-03c511813008a86d,"```python# solution```"
cf-b09aec76d1837c24,"```python# solution```"
cf-391bac3dfdc536db,"```python# solution```"
cf-46174ab40f15f729,"```python# solution```"
cf-7fcf6af9ecb30c92,"```python# solution```"
cf-9efc6692005e91ce,"```python# solution```"
cf-2943e7e34664e8c5,"```python# solution```"
cf-d69c116dbaad1972,"```python# solution```"
cf-d01ce37257534804,"```python# solution```"
cf-7e9f19df18c2ba41,"```python# solution```"
cf-0309babcf9dda96c,"```python# solution```"
cf-006d0934620370cc,"```python# solution```"
cf-2a52cabaf43650dc,"```python# solution```"
cf-c9f48f65ee0d3d5b,"```python# solution```"
cf-59cd2c8e2e10e192,"```python# solution```"
cf-70f7ff90284b48c2,"```python# solution```"
cf-9f97358eb1d62bec,"```python# solution```"
cf-5567773d14325bc8,"```python# solution```"
cf-13aef844372c5001,"```python# solution```"
cf-b14e6b9c9dcf66b9,"```python# solution```"
cf-cbbcd7f62b037500,"```python# solution```"
cf-a321048f5888ef51,"```python# solution```"
cf-397118f1dab2c7fb,"```python# solution```"
cf-98130539ebad9e70,"```python# solution```"
cf-ff3ec5fb2b0cc895,"```python# solution```"
cf-624a4450163844ef,"```python# solution```"
cf-cf90f5c1db71888e,"```python# solution```"
cf-d67c6cc0447e5f8c,"```python# solution```"
cf-44618e82f0098b93,"```python# solution```"
cf-7d2a5031279c6736,"```python# solution```"
cf-4ed3d1f699f7dddc,"```python# solution```"
cf-25c02b9bea693993,"```python# solution```"
cf-3619874544e5ccea,"```python# solution```"
cf-12dc8eda8f35fdfa,"```python# solution```"
cf-a984e5ceced107d1,"```python# solution```"
cf-61cbafb0ef257ccc,"```python# solution```"
cf-4cc55667fe935a5a,"```python# solution```"
cf-a4f027f8e14a0af2,"```python# solution```"
cf-04727798f98b4a4c,"```python# solution```"
cf-b2ff548846ed597d,"```python# solution```"
cf-eaab552d285cde6c,"```python# solution```"
cf-365ba03e7f5b85b7,"```python# solution```"
cf-8b79081aebc62bc7,"```python# solution```"
cf-a302895c661ba29f,"```python# solution```"
cf-75772844aa9cad85,"```python# solution```"
cf-99080af17eb1bf1c,"```python# solution```"
cf-e8e17264de612d6e,"```python# solution```"
cf-6f4343760a24ac63,"```python# solution```"
cf-ad0962212fea178b,"```python# solution```"
cf-8362c209625003cf,"```python# solution```"
cf-a2c4cb90b1253c45,"```python# solution```"
cf-c125dbf9485fd3ed,"```python# solution```"
cf-84a3c25300a6786d,"```python# solution```"
cf-07f17213c5153858,"```python# solution```"
cf-ee48ac1d46404f98,"```python# solution```"
cf-5e6dca6776327096,"```python# solution```"
cf-3d117b411889e077,"```python# solution```"
cf-76bcb693a884b96a,"```python# solution```"
cf-613410f2f2802e71,"```python# solution```"
cf-9a28ec78eb695a72,"```python# solution```"
cf-c920adb1f14fead4,"```python# solution```"
cf-1c2348462e0ffb5b,"```python# solution```"
cf-5a56f3b6d7d96629,"```python# solution```"
cf-b403ad23f9df01b5,"```python# solution```"
cf-8a01dee6edff6646,"```python# solution```"
cf-36dd48709d4c6cec,"```python# solution```"
cf-e5b32d29e5e18804,"```python# solution```"
cf-a55eb159ec9f7c5e,"```python# solution```"
cf-3038f57f582b92b7,"```python# solution```"
cf-dd14fb3b657481f5,"```python# solution```"
cf-4ee06e376cf46d6d,"```python# solution```"
cf-25416861a5241d3c,"```python# solution```"
cf-daf5280b3d547cdc,"```python# solution```"
cf-dcd26549d309c08f,"```python# solution```"
cf-de92f4a76c782ead,"```python# solution```"
cf-a61cf5630d697657,"```python# solution```"
cf-e75d947160f43f48,"```python# solution```"
cf-19a2223b29a4e32b,"```python# solution```"
cf-8d9c2ecd53154735,"```python# solution```"
cf-fae8a3c0ea1ddda9,"```python# solution```"
cf-56d0d66fd32f536a,"```python# solution```"
cf-b6ae539aa0ece0b5,"```python# solution```"
cf-89c6dc80bc6e178e,"```python# solution```"
cf-82930680859be479,"```python# solution```"
cf-bdc784eca7e75ac8,"```python# solution```"
cf-85d6865110fbdf3d,"```python# solution```"
cf-10527c7c686d8515,"```python# solution```"
cf-4c4b8d8245f50929,"```python# solution```"
cf-9c0469c0fcf57c19,"```python# solution```"
cf-9ef290c1a24d9496,"```python# solution```"
cf-431573f1d7bb301d,"```python# solution```"
cf-6509e4f0d2d3100d,"```python# solution```"
cf-5bdb7848972b5212,"```python# solution```"
cf-8221d090c4c1cba5,"```python# solution```"
cf-959ea79f76be5608,"```python# solution```"
cf-9b1e3b8346a5605b,"```python# solution```"
cf-415b4a43628643f6,"```python# solution```"
cf-c9470bcbb7ff7c74,"```python# solution```"
cf-e252fafef16e86e1,"```python# solution```"
cf-08e76c4162c3d5d6,"```python# solution```"
cf-7e7d615540984d8a,"```python# solution```"
cf-7473fec259254b1c,"```python# solution```"
cf-a57c0f59d3211ae9,"```python# solution```"
cf-bb8f0c3d3c490a16,"```python# solution```"
cf-48ed90584336d45b,"```python# solution```"
cf-af0cc196db1195da,"```python# solution```"
cf-ccab0ea22013d32a,"```python# solution```"
cf-62aff2d5503b50d8,"```python# solution```"
cf-251153bc63e3b74c,"```python# solution```"
cf-37283be4276e6343,"```python# solution```"
cf-ad009460a07112af,"```python# solution```"
cf-4141bfa06ec30e04,"```python# solution```"
cf-0757720cc194cf68,"```python# solution```"
cf-373d6eae4d68b10f,"```python# solution```"
cf-066d7b94a8ba2f5e,"```python# solution```"
cf-a91e4148a27de25b,"```python# solution```"
cf-ef4740448ba278f7,"```python# solution```"
cf-ccc3594c0c1b5c2c,"```python# solution```"
cf-dedaaf5226c93873,"```python# solution```"
cf-46fd459513a94580,"```python# solution```"
cf-4fdc1ced5ae60f9b,"```python# solution```"
cf-bf4e0736612c9400,"```python# solution```"
cf-d87021af5ddc9f8b,"```python# solution```"
cf-349680720454272a,"```python# solution```"
cf-0526124d47568401,"```python# solution```"
cf-91f7b911644f0970,"```python# solution```"
cf-8fedf6fe29ad244c,"```python# solution```"
cf-af684689a8afbcf6,"```python# solution```"
cf-8ee03fd4c2b09cb3,"```python# solution```"
cf-510311b247c2a19e,"```python# solution```"
cf-e7ae750c92c8e0f5,"```python# solution```"
cf-af009a97dd4077c8,"```python# solution```"
cf-9f6e7573a17c06b7,"```python# solution```"
cf-c0f526bb96097552,"```python# solution```"
cf-b7147a313054c784,"```python# solution```"
cf-17d6a269c86fedc9,"```python# solution```"
cf-680e009b3b57c60e,"```python# solution```"
cf-f07bcf245f7c6329,"```python# solution```"
cf-0877e2b8639e3e16,"```python# solution```"
cf-dbe9ec8bfe54400e,"```python# solution```"
cf-3ef1867eaeef3d80,"```python# solution```"
cf-fdcc0441621400eb,"```python# solution```"
cf-e0db689e88ac0b62,"```python# solution```"
cf-6e18c7a2f8068bd1,"```python# solution```"
cf-40f91b03df8c336b,"```python# solution```"
cf-1dad6e6e625a63cf,"```python# solution```"
cf-5d662d4b78832aff,"```python# solution```"
cf-7ea47ac04494131d,"```python# solution```"
cf-3ab136690610c574,"```python# solution```"
cf-290abc7279c8a39e,"```python# solution```"
cf-7f0558cfec9091ee,"```python# solution```"
cf-97ab4138236f1ad7,"```python# solution```"
cf-7519982cbe364897,"```python# solution```"
cf-bb72f5fc8c85820f,"```python# solution```"
cf-ef9780f611bdc70e,"```python# solution```"
cf-1747e3b07ad42b08,"```python# solution```"
cf-56826b2758490b0f,"```python# solution```"
cf-7fb65d4554f7be7b,"```python# solution```"
cf-a671a8189b7eee8f,"```python# solution```"
cf-afe72577721c1c8a,"```python# solution```"
cf-d73f65b6c744baaf,"```python# solution```"
cf-ac1d78d8afe1b4d5,"```python# solution```"
cf-a5fcf217bcab67d1,"```python# solution```"
cf-0adfcf12b9b5542a,"```python# solution```"
cf-20b67af882fa6c9e,"```python# solution```"
cf-864d08c8ea8064b6,"```python# solution```"
cf-ba65a57637e12845,"```python# solution```"
cf-85a8951962050b3c,"```python# solution```"
cf-2fcacee04da27b58,"```python# solution```"
cf-1c9e12b94ae11466,"```python# solution```"
cf-3d0b086e89aea455,"```python# solution```"
cf-3a59d9bb53941e81,"```python# solution```"
cf-0fd4c8078bb81537,"```python# solution```"
cf-aa2d4497db2db3d5,"```python# solution```"
cf-e3147c5900e6cc63,"```python# solution```"
cf-676fd6d86ea858b3,"```python# solution```"
cf-b060389d148d7399,"```python# solution```"
cf-165031e106d9579e,"```python# solution```"
cf-927ef5ee37abb90f,"```python# solution```"
cf-7353ae3e3d5f3d0b,"```python# solution```"
cf-ea1f1541b5c8454f,"```python# solution```"
cf-15e45b1911b3e4e7,"```python# solution```"
cf-6fef6d1056feef04,"```python# solution```"
cf-94b6b03e91be2643,"```python# solution```"
cf-6ab0ad36a045292b,"```python# solution```"
cf-76d6ed3b05e44cc5,"```python# solution```"
cf-ccc86e312b9a72b6,"```python# solution```"
cf-e46f5d10f4f6b9e2,"```python# solution```"
cf-e80ee4f1bd66e00c,"```python# solution```"
cf-3ff70330e9bd5851,"```python# solution```"
cf-66b44d18bf3f1229,"```python# solution```"
cf-436f82981620c033,"```python# solution```"
cf-89eea5f86fb6ebb4,"```python# solution```"
cf-706e3e333b48079e,"```python# solution```"
cf-d54a1d5f15855120,"```python# solution```"
cf-843c7943207d0df5,"```python# solution```"
cf-5fbb4804b2415192,"```python# solution```"
cf-71cf2d6283f94dfd,"```python# solution```"
cf-67aa378e15b57d64,"```python# solution```"
cf-43fb67e72853e2e5,"```python# solution```"
cf-3ce83ec5e0603ae5,"```python# solution```"
cf-19a38180e0e87858,"```python# solution```"
cf-df0dc437c0fbbdeb,"```python# solution```"
cf-73e865e4391e99f0,"```python# solution```"
cf-7e8845d65ed86a24,"```python# solution```"
cf-d512d677498083dd,"```python# solution```"
cf-a4dc6a5905b6f0a7,"```python# solution```"
cf-9f6d0188dbcd667c,"```python# solution```"
cf-ad3dd8ea8e119aa8,"```python# solution```"
cf-281938abb20c7d61,"```python# solution```"
cf-d667316e2d79898f,"```python# solution```"
cf-f95b769319395f3e,"```python# solution```"
cf-07291d50bf76371a,"```python# solution```"
cf-aefaed1c66d42f67,"```python# solution```"
cf-2efb650f65bf54c1,"```python# solution```"
cf-eb056907043004f5,"```python# solution```"
cf-69860e572ae76e65,"```python# solution```"
cf-f167a4c521d758ef,"```python# solution```"
cf-04ab4db50fee9878,"```python# solution```"
cf-a20b0f12afdb98d1,"```python# solution```"
cf-096ac99dd6272319,"```python# solution```"
cf-76e6da6b6bf3d9eb,"```python# solution```"
cf-7ef1f384d514abab,"```python# solution```"
cf-16bd8fc76704aa81,"```python# solution```"
cf-dc923558da033b1c,"```python# solution```"
cf-7c13dfa0ef352a16,"```python# solution```"
cf-c98fee3bc1536f4e,"```python# solution```"
cf-d65b9cb01a214927,"```python# solution```"
cf-9de31a6b4b6c49e1,"```python# solution```"
cf-4af7a96237e05e2b,"```python# solution```"
cf-a4f2e07ca1096000,"```python# solution```"
cf-13dfdd9a1d14bc2f,"```python# solution```"
cf-25378698aa2a5f89,"```python# solution```"
cf-536c180a69717c33,"```python# solution```"
cf-045a216da08d07f3,"```python# solution```"
cf-f64a6806bfedd6a7,"```python# solution```"
cf-8b1215cf044e376e,"```python# solution```"
cf-8ab490bf85751d6a,"```python# solution```"
cf-f0a263534d579fe0,"```python# solution```"
cf-f533054f83e34460,"```python# solution```"
cf-1668e0321983a6ae,"```python# solution```"
cf-8720db27d7cd975a,"```python# solution```"
cf-292ab5a75e2207ef,"```python# solution```"
cf-61b2729dbba80f00,"```python# solution```"
cf-d5deaceac78834a9,"```python# solution```"
cf-03d5b1dd2e52eb5b,"```python# solution```"
cf-8f8bd06f486e8d1c,"```python# solution```"
cf-20b318abdf7ae6d9,"```python# solution```"
cf-32977146b46780d6,"```python# solution```"
cf-c7d80a8a8df85cd6,"```python# solution```"
cf-e51817fc02f9f753,"```python# solution```"
cf-45e99b03d772395c,"```python# solution```"
cf-246910d3d3940676,"```python# solution```"
cf-deb17639a6b2b215,"```python# solution```"
cf-6658c2b63bd7a06b,"```python# solution```"
cf-bc8d0c3f3a71c6b8,"```python# solution```"
cf-fb6a192dbcaa9a01,"```python# solution```"
cf-af2def7b035bf294,"```python# solution```"
cf-ed181f91c348aa5d,"```python# solution```"
cf-f5920212ad402b18,"```python# solution```"
cf-2a0e1ce2ca1fc740,"```python# solution```"
cf-2915154b1688e74a,"```python# solution```"
cf-4e32f442e57c2a77,"```python# solution```"
cf-010ecd306c4e0a9f,"```python# solution```"
cf-ce04106a30b8ac00,"```python# solution```"
cf-957b94809727ae81,"```python# solution```"
cf-ad33e1233cd4c342,"```python# solution```"
cf-d5491a1f34bd4b65,"```python# solution```"
cf-bc4af4d11e791351,"```python# solution```"
cf-0de916666c619ddf,"```python# solution```"
cf-2b49b989c0a12b12,"```python# solution```"
cf-a8b24e975163e76d,"```python# solution```"
cf-355edd46e49305a6,"```python# solution```"
cf-5f35ca6cc5422f64,"```python# solution```"
cf-86515d2a498d71a5,"```python# solution```"
cf-56de34d27bf720f6,"```python# solution```"
cf-173f76cf8bfaef3b,"```python# solution```"
cf-996e5eed51fcd7b6,"```python# solution```"
cf-17e1fa836091feb2,"```python# solution```"
cf-c59ddc4c20e3d5e6,"```python# solution```"
cf-fe1630ecb3faa5a3,"```python# solution```"
cf-b5ce86eaa1b00bf4,"```python# solution```"
cf-0ad302842053c28d,"```python# solution```"
cf-e48325d6d4340252,"```python# solution```"
cf-becab5c5e88a3441,"```python# solution```"
cf-554cbdf43b3fb726,"```python# solution```"123version https://git-lfs.github.com/spec/v1oid sha256:186fdac5b30ff50b3122ebbdf1728aef48960457cd3ab852f8993e3381127b00size 306700123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177#!/usr/bin/env python3"""Zevo custom evaluator for MBPP+ val (378), pass@1.
Hub: Tommysha/zero-code-l1-val config mbppplus split validation.Rows: id, prompt, entry_point, test_imports, test_list, test (EvalPlus plus harness).Does not use the gold `code` column.
Usage: python3 evaluator.py PREDICTIONS_CSV SCORING_SET METRICS_JSONStdlib only (pyarrow only if SCORING_SET is parquet). Timeout 10 s per problem.If numpy is missing, a tiny shim satisfies `import numpy as np` in the plus harness."""import astimport csvimport jsonimport multiprocessingimport osimport sysimport tracebackfrom concurrent.futures import ProcessPoolExecutor
TIMEOUT = 10
def extract_code(output: str) -> str: lines = (output or "").split("\n") idx = [i for i, line in enumerate(lines) if "```" in line] if len(idx) >= 2: body = "\n".join(lines[idx[-2] + 1: idx[-1]]) if body.lstrip().startswith("python"): body = "\n".join(body.split("\n")[1:]) return body return (output or "").strip()
def _numpy_shim(): class _NP: ndarray = type("ndarray", (), {}) float64 = "float64" float32 = "float32"
@staticmethod def allclose(a, b, rtol=1e-07, atol=1e-06, equal_nan=False): def _flat(x): if isinstance(x, (list, tuple, set)): out = [] for i in x: out.extend(_flat(i)) return out return [x] aa, bb = _flat(a), _flat(b) if len(aa) != len(bb): return False for x, y in zip(aa, bb): try: xf, yf = float(x), float(y) except (TypeError, ValueError): if x != y: return False continue if xf != xf or yf != yf: if not equal_nan: return False continue scale = max(abs(yf), abs(xf)) if abs(xf - yf) > atol + rtol * scale: return False return True
return _NP()
def _run_one(code, test, test_list, test_imports, result): try: ns = {} for imp in test_imports or []: exec(imp, ns, ns) exec(code, ns, ns) plus = (test or "").strip() if plus: if "numpy" not in sys.modules: try: import numpy # noqa: F401 except Exception: sys.modules["numpy"] = _numpy_shim() exec(plus, ns, ns) else: for stmt in test_list or []: exec(stmt, ns, ns) result.append(True) except Exception: result.append(False)
def check(args): code, test, test_list, test_imports = args if not (code or "").strip(): return False try: ast.parse(code) except SyntaxError: return False manager = multiprocessing.Manager() result = manager.list() p = multiprocessing.Process( target=_run_one, args=(code, test, test_list, test_imports, result) ) p.start() p.join(timeout=TIMEOUT + 2) if p.is_alive(): p.kill() p.join(1) return bool(result) and result[0] is True
def load_rows(path): ext = os.path.splitext(path)[1].lower() if ext == ".parquet": import pyarrow.parquet as pq return pq.read_table(path).to_pylist() if ext == ".jsonl": return [json.loads(l) for l in open(path, encoding="utf-8") if l.strip()] if ext == ".json": d = json.load(open(path, encoding="utf-8")) return d if isinstance(d, list) else d.get("data", d.get("rows")) csv.field_size_limit(sys.maxsize) return list(csv.DictReader(open(path, newline="", encoding="utf-8")))
def _list_field(v): if v is None: return [] if isinstance(v, list): return v if isinstance(v, str): s = v.strip() if not s: return [] try: parsed = json.loads(s) if isinstance(parsed, list): return parsed except Exception: pass return [s] return list(v)
def main(): pred_path, set_path, out_path = sys.argv[1:4] csv.field_size_limit(sys.maxsize) preds = {r["id"]: r.get("prediction") or "" for r in csv.DictReader(open(pred_path, newline="", encoding="utf-8"))} rows = load_rows(set_path) jobs = [] for r in rows: jobs.append(( extract_code(preds.get(str(r["id"]), "")), r.get("test") or "", _list_field(r.get("test_list")), _list_field(r.get("test_imports")), )) workers = int(os.environ.get("LCB_EVAL_WORKERS", min(8, os.cpu_count() or 1))) with ProcessPoolExecutor(max_workers=workers) as ex: ok = list(ex.map(check, jobs)) total = len(rows) correct = sum(ok) out = { "score": correct / total if total else 0.0, "correct": correct, "total": total, "missing_predictions": sum(str(r["id"]) not in preds for r in rows), } json.dump(out, open(out_path, "w", encoding="utf-8")) print(json.dumps(out))
if __name__ == "__main__": main()1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135id,prediction
Mbpp/2,"```python# solution```"
Mbpp/3,"```python# solution```"
Mbpp/4,"```python# solution```"
Mbpp/6,"```python# solution```"
Mbpp/7,"```python# solution```"
Mbpp/8,"```python# solution```"
Mbpp/9,"```python# solution```"
Mbpp/11,"```python# solution```"
Mbpp/12,"```python# solution```"
Mbpp/14,"```python# solution```"
Mbpp/16,"```python# solution```"
Mbpp/17,"```python# solution```"
Mbpp/18,"```python# solution```"
Mbpp/19,"```python# solution```"
Mbpp/20,"```python# solution```"
Mbpp/56,"```python# solution```"
Mbpp/57,"```python# solution```"
Mbpp/58,"```python# solution```"
Mbpp/59,"```python# solution```"
Mbpp/61,"```python# solution```"
Mbpp/62,"```python# solution```"
Mbpp/63,"```python# solution```"
Mbpp/64,"```python# solution```"
Mbpp/65,"```python# solution```"
Mbpp/66,"```python# solution```"
Mbpp/67,"```python# solution```"
Mbpp/68,"```python# solution```"
Mbpp/69,"```python# solution```"
Mbpp/70,"```python# solution```"
Mbpp/71,"```python# solution```"
Mbpp/72,"```python# solution```"
Mbpp/74,"```python# solution```"
Mbpp/75,"```python# solution```"
Mbpp/77,"```python# solution```"
Mbpp/79,"```python# solution```"
Mbpp/80,"```python# solution```"
Mbpp/82,"```python# solution```"
Mbpp/84,"```python# solution```"
Mbpp/85,"```python# solution```"
Mbpp/86,"```python# solution```"
Mbpp/87,"```python# solution```"
Mbpp/88,"```python# solution```"
Mbpp/89,"```python# solution```"
Mbpp/90,"```python# solution```"
Mbpp/91,"```python# solution```"
Mbpp/92,"```python# solution```"
Mbpp/93,"```python# solution```"
Mbpp/94,"```python# solution```"
Mbpp/95,"```python# solution```"
Mbpp/96,"```python# solution```"
Mbpp/97,"```python# solution```"
Mbpp/98,"```python# solution```"
Mbpp/99,"```python# solution```"
Mbpp/100,"```python# solution```"
Mbpp/101,"```python# solution```"
Mbpp/102,"```python# solution```"
Mbpp/103,"```python# solution```"
Mbpp/104,"```python# solution```"
Mbpp/105,"```python# solution```"
Mbpp/106,"```python# solution```"
Mbpp/108,"```python# solution```"
Mbpp/109,"```python# solution```"
Mbpp/111,"```python# solution```"
Mbpp/113,"```python# solution```"
Mbpp/116,"```python# solution```"
Mbpp/118,"```python# solution```"
Mbpp/119,"```python# solution```"
Mbpp/120,"```python# solution```"
Mbpp/123,"```python# solution```"
Mbpp/124,"```python# solution```"
Mbpp/125,"```python# solution```"
Mbpp/126,"```python# solution```"
Mbpp/127,"```python# solution```"
Mbpp/128,"```python# solution```"
Mbpp/129,"```python# solution```"
Mbpp/130,"```python# solution```"
Mbpp/131,"```python# solution```"
Mbpp/132,"```python# solution```"
Mbpp/133,"```python# solution```"
Mbpp/135,"```python# solution```"
Mbpp/137,"```python# solution```"
Mbpp/138,"```python# solution```"
Mbpp/139,"```python# solution```"
Mbpp/140,"```python# solution```"
Mbpp/141,"```python# solution```"
Mbpp/142,"```python# solution```"
Mbpp/145,"```python# solution```"
Mbpp/160,"```python# solution```"
Mbpp/161,"```python# solution```"
Mbpp/162,"```python# solution```"
Mbpp/165,"```python# solution```"
Mbpp/166,"```python# solution```"
Mbpp/167,"```python# solution```"
Mbpp/168,"```python# solution```"
Mbpp/170,"```python# solution```"
Mbpp/171,"```python# solution```"
Mbpp/172,"```python# solution```"
Mbpp/222,"```python# solution```"
Mbpp/223,"```python# solution```"
Mbpp/224,"```python# solution```"
Mbpp/226,"```python# solution```"
Mbpp/227,"```python# solution```"
Mbpp/230,"```python# solution```"
Mbpp/232,"```python# solution```"
Mbpp/233,"```python# solution```"
Mbpp/234,"```python# solution```"
Mbpp/235,"```python# solution```"
Mbpp/237,"```python# solution```"
Mbpp/238,"```python# solution```"
Mbpp/239,"```python# solution```"
Mbpp/240,"```python# solution```"
Mbpp/242,"```python# solution```"
Mbpp/244,"```python# solution```"
Mbpp/245,"```python# solution```"
Mbpp/247,"```python# solution```"
Mbpp/250,"```python# solution```"
Mbpp/251,"```python# solution```"
Mbpp/252,"```python# solution```"
Mbpp/253,"```python# solution```"
Mbpp/255,"```python# solution```"
Mbpp/256,"```python# solution```"
Mbpp/257,"```python# solution```"
Mbpp/259,"```python# solution```"
Mbpp/260,"```python# solution```"
Mbpp/261,"```python# solution```"
Mbpp/262,"```python# solution```"
Mbpp/264,"```python# solution```"
Mbpp/265,"```python# solution```"
Mbpp/266,"```python# solution```"
Mbpp/267,"```python# solution```"
Mbpp/268,"```python# solution```"
Mbpp/269,"```python# solution```"
Mbpp/270,"```python# solution```"
Mbpp/271,"```python# solution```"
Mbpp/272,"```python# solution```"
Mbpp/273,"```python# solution```"
Mbpp/274,"```python# solution```"
Mbpp/276,"```python# solution```"
Mbpp/277,"```python# solution```"
Mbpp/278,"```python# solution```"
Mbpp/279,"```python# solution```"
Mbpp/280,"```python# solution```"
Mbpp/281,"```python# solution```"
Mbpp/282,"```python# solution```"
Mbpp/283,"```python# solution```"
Mbpp/284,"```python# solution```"
Mbpp/285,"```python# solution```"
Mbpp/286,"```python# solution```"
Mbpp/287,"```python# solution```"
Mbpp/290,"```python# solution```"
Mbpp/292,"```python# solution```"
Mbpp/293,"```python# solution```"
Mbpp/294,"```python# solution```"
Mbpp/296,"```python# solution```"
Mbpp/297,"```python# solution```"
Mbpp/299,"```python# solution```"
Mbpp/300,"```python# solution```"
Mbpp/301,"```python# solution```"
Mbpp/305,"```python# solution```"
Mbpp/306,"```python# solution```"
Mbpp/308,"```python# solution```"
Mbpp/309,"```python# solution```"
Mbpp/310,"```python# solution```"
Mbpp/311,"```python# solution```"
Mbpp/312,"```python# solution```"
Mbpp/388,"```python# solution```"
Mbpp/389,"```python# solution```"
Mbpp/390,"```python# solution```"
Mbpp/391,"```python# solution```"
Mbpp/392,"```python# solution```"
Mbpp/394,"```python# solution```"
Mbpp/395,"```python# solution```"
Mbpp/397,"```python# solution```"
Mbpp/398,"```python# solution```"
Mbpp/404,"```python# solution```"
Mbpp/405,"```python# solution```"
Mbpp/406,"```python# solution```"
Mbpp/409,"```python# solution```"
Mbpp/410,"```python# solution```"
Mbpp/412,"```python# solution```"
Mbpp/413,"```python# solution```"
Mbpp/414,"```python# solution```"
Mbpp/415,"```python# solution```"
Mbpp/418,"```python# solution```"
Mbpp/419,"```python# solution```"
Mbpp/420,"```python# solution```"
Mbpp/421,"```python# solution```"
Mbpp/422,"```python# solution```"
Mbpp/424,"```python# solution```"
Mbpp/425,"```python# solution```"
Mbpp/426,"```python# solution```"
Mbpp/427,"```python# solution```"
Mbpp/428,"```python# solution```"
Mbpp/429,"```python# solution```"
Mbpp/430,"```python# solution```"
Mbpp/432,"```python# solution```"
Mbpp/433,"```python# solution```"
Mbpp/435,"```python# solution```"
Mbpp/436,"```python# solution```"
Mbpp/437,"```python# solution```"
Mbpp/439,"```python# solution```"
Mbpp/440,"```python# solution```"
Mbpp/441,"```python# solution```"
Mbpp/445,"```python# solution```"
Mbpp/446,"```python# solution```"
Mbpp/447,"```python# solution```"
Mbpp/448,"```python# solution```"
Mbpp/450,"```python# solution```"
Mbpp/451,"```python# solution```"
Mbpp/453,"```python# solution```"
Mbpp/454,"```python# solution```"
Mbpp/455,"```python# solution```"
Mbpp/456,"```python# solution```"
Mbpp/457,"```python# solution```"
Mbpp/458,"```python# solution```"
Mbpp/459,"```python# solution```"
Mbpp/460,"```python# solution```"
Mbpp/462,"```python# solution```"
Mbpp/463,"```python# solution```"
Mbpp/465,"```python# solution```"
Mbpp/468,"```python# solution```"
Mbpp/470,"```python# solution```"
Mbpp/471,"```python# solution```"
Mbpp/472,"```python# solution```"
Mbpp/473,"```python# solution```"
Mbpp/474,"```python# solution```"
Mbpp/475,"```python# solution```"
Mbpp/476,"```python# solution```"
Mbpp/477,"```python# solution```"
Mbpp/478,"```python# solution```"
Mbpp/479,"```python# solution```"
Mbpp/554,"```python# solution```"
Mbpp/555,"```python# solution```"
Mbpp/556,"```python# solution```"
Mbpp/557,"```python# solution```"
Mbpp/558,"```python# solution```"
Mbpp/559,"```python# solution```"
Mbpp/560,"```python# solution```"
Mbpp/562,"```python# solution```"
Mbpp/563,"```python# solution```"
Mbpp/564,"```python# solution```"
Mbpp/565,"```python# solution```"
Mbpp/566,"```python# solution```"
Mbpp/567,"```python# solution```"
Mbpp/568,"```python# solution```"
Mbpp/569,"```python# solution```"
Mbpp/572,"```python# solution```"
Mbpp/573,"```python# solution```"
Mbpp/576,"```python# solution```"
Mbpp/577,"```python# solution```"
Mbpp/578,"```python# solution```"
Mbpp/579,"```python# solution```"
Mbpp/580,"```python# solution```"
Mbpp/581,"```python# solution```"
Mbpp/583,"```python# solution```"
Mbpp/585,"```python# solution```"
Mbpp/586,"```python# solution```"
Mbpp/587,"```python# solution```"
Mbpp/588,"```python# solution```"
Mbpp/589,"```python# solution```"
Mbpp/590,"```python# solution```"
Mbpp/591,"```python# solution```"
Mbpp/592,"```python# solution```"
Mbpp/593,"```python# solution```"
Mbpp/594,"```python# solution```"
Mbpp/596,"```python# solution```"
Mbpp/597,"```python# solution```"
Mbpp/598,"```python# solution```"
Mbpp/599,"```python# solution```"
Mbpp/600,"```python# solution```"
Mbpp/602,"```python# solution```"
Mbpp/603,"```python# solution```"
Mbpp/604,"```python# solution```"
Mbpp/605,"```python# solution```"
Mbpp/606,"```python# solution```"
Mbpp/607,"```python# solution```"
Mbpp/608,"```python# solution```"
Mbpp/610,"```python# solution```"
Mbpp/611,"```python# solution```"
Mbpp/612,"```python# solution```"
Mbpp/614,"```python# solution```"
Mbpp/615,"```python# solution```"
Mbpp/616,"```python# solution```"
Mbpp/618,"```python# solution```"
Mbpp/619,"```python# solution```"
Mbpp/620,"```python# solution```"
Mbpp/622,"```python# solution```"
Mbpp/623,"```python# solution```"
Mbpp/624,"```python# solution```"
Mbpp/626,"```python# solution```"
Mbpp/628,"```python# solution```"
Mbpp/629,"```python# solution```"
Mbpp/630,"```python# solution```"
Mbpp/631,"```python# solution```"
Mbpp/632,"```python# solution```"
Mbpp/633,"```python# solution```"
Mbpp/635,"```python# solution```"
Mbpp/637,"```python# solution```"
Mbpp/638,"```python# solution```"
Mbpp/639,"```python# solution```"
Mbpp/641,"```python# solution```"
Mbpp/643,"```python# solution```"
Mbpp/644,"```python# solution```"
Mbpp/720,"```python# solution```"
Mbpp/721,"```python# solution```"
Mbpp/722,"```python# solution```"
Mbpp/723,"```python# solution```"
Mbpp/724,"```python# solution```"
Mbpp/725,"```python# solution```"
Mbpp/726,"```python# solution```"
Mbpp/728,"```python# solution```"
Mbpp/730,"```python# solution```"
Mbpp/731,"```python# solution```"
Mbpp/732,"```python# solution```"
Mbpp/733,"```python# solution```"
Mbpp/734,"```python# solution```"
Mbpp/735,"```python# solution```"
Mbpp/736,"```python# solution```"
Mbpp/737,"```python# solution```"
Mbpp/739,"```python# solution```"
Mbpp/740,"```python# solution```"
Mbpp/741,"```python# solution```"
Mbpp/742,"```python# solution```"
Mbpp/743,"```python# solution```"
Mbpp/744,"```python# solution```"
Mbpp/745,"```python# solution```"
Mbpp/748,"```python# solution```"
Mbpp/749,"```python# solution```"
Mbpp/750,"```python# solution```"
Mbpp/751,"```python# solution```"
Mbpp/752,"```python# solution```"
Mbpp/753,"```python# solution```"
Mbpp/754,"```python# solution```"
Mbpp/755,"```python# solution```"
Mbpp/757,"```python# solution```"
Mbpp/758,"```python# solution```"
Mbpp/759,"```python# solution```"
Mbpp/760,"```python# solution```"
Mbpp/762,"```python# solution```"
Mbpp/763,"```python# solution```"
Mbpp/764,"```python# solution```"
Mbpp/765,"```python# solution```"
Mbpp/766,"```python# solution```"
Mbpp/767,"```python# solution```"
Mbpp/769,"```python# solution```"
Mbpp/770,"```python# solution```"
Mbpp/771,"```python# solution```"
Mbpp/772,"```python# solution```"
Mbpp/773,"```python# solution```"
Mbpp/775,"```python# solution```"
Mbpp/777,"```python# solution```"
Mbpp/778,"```python# solution```"
Mbpp/780,"```python# solution```"
Mbpp/781,"```python# solution```"
Mbpp/782,"```python# solution```"
Mbpp/784,"```python# solution```"
Mbpp/785,"```python# solution```"
Mbpp/786,"```python# solution```"
Mbpp/787,"```python# solution```"
Mbpp/788,"```python# solution```"
Mbpp/790,"```python# solution```"
Mbpp/791,"```python# solution```"
Mbpp/792,"```python# solution```"
Mbpp/793,"```python# solution```"
Mbpp/794,"```python# solution```"
Mbpp/796,"```python# solution```"
Mbpp/797,"```python# solution```"
Mbpp/798,"```python# solution```"
Mbpp/799,"```python# solution```"
Mbpp/800,"```python# solution```"
Mbpp/801,"```python# solution```"
Mbpp/803,"```python# solution```"
Mbpp/804,"```python# solution```"
Mbpp/805,"```python# solution```"
Mbpp/806,"```python# solution```"
Mbpp/807,"```python# solution```"
Mbpp/808,"```python# solution```"
Mbpp/809,"```python# solution```"123version https://git-lfs.github.com/spec/v1oid sha256:92fbabbe5baa241ba2db11e2ac3ba1f14981fd24df071d459735ce14acdcc0acsize 1107237README.mdAdded+30
cc_valid/evaluator.pyAdded+697
cc_valid/sample_submission.csvAdded+352
cc_valid/validation-00000-of-00001.parquetAdded+3
codeforces/evaluator.pyAdded+689
codeforces/sample_submission.csvAdded+1225
codeforces/validation-00000-of-00001.parquetAdded+3
mbppplus/evaluator.pyAdded+177
mbppplus/sample_submission.csvAdded+1135
mbppplus/validation-00000-of-00001.parquetAdded+3