Tommysha commited on
Commit
1600342
·
verified ·
1 Parent(s): 054e580

DeepCoder CF 408 independent val

Browse files
README.md ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ configs:
4
+ - config_name: default
5
+ data_files:
6
+ - split: validation
7
+ path: data/validation-*.parquet
8
+ ---
9
+ DeepCoder Codeforces test 408 independent val for zero-code-l1. Source agentica-org/DeepCoder-Preview-Dataset codeforces/test plus id. See also Tommysha/zero-code-l1-val.
data/validation-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:186fdac5b30ff50b3122ebbdf1728aef48960457cd3ab852f8993e3381127b00
3
+ size 306700
evaluator.py ADDED
@@ -0,0 +1,689 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Zevo custom evaluator for DeepCoder Codeforces val (408), pass@1.
3
+
4
+ Hub: Tommysha/zero-code-l1-val config codeforces split validation.
5
+ Rows: id, problem, tests (JSON list of {input, output} stdin cases).
6
+
7
+ Usage: python3 evaluator.py PREDICTIONS_CSV SCORING_SET METRICS_JSON
8
+ Stdlib only (pyarrow only if SCORING_SET is parquet). Timeout 6 s per test.
9
+ """
10
+ # ---------------- vendored: lcb_runner/evaluation/testing_util.py @ 28fef95 ----------------
11
+ import ast
12
+ import json
13
+ import sys
14
+ import faulthandler
15
+ import platform
16
+
17
+ # used for debugging to time steps
18
+ from datetime import datetime
19
+
20
+ # to run the solution files we're using a timing based approach
21
+ import signal
22
+
23
+
24
+ from io import StringIO
25
+
26
+ # used for testing the code that reads from input
27
+ from unittest.mock import patch, mock_open
28
+
29
+ # from pyext import RuntimeModule
30
+ from types import ModuleType
31
+
32
+ from enum import Enum
33
+ from decimal import Decimal
34
+ import time
35
+
36
+ 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"
37
+
38
+
39
+ def truncatefn(s, length=300):
40
+ if isinstance(s, str):
41
+ pass
42
+ else:
43
+ s = str(s)
44
+ if len(s) <= length:
45
+ return s
46
+
47
+ return s[: length // 2] + "...(truncated) ..." + s[-length // 2 :]
48
+
49
+
50
+ class CODE_TYPE(Enum):
51
+ call_based = 0
52
+ standard_input = 1
53
+
54
+
55
+ # stuff for setting up signal timer
56
+ class TimeoutException(Exception):
57
+ pass
58
+
59
+
60
+ def timeout_handler(signum, frame):
61
+ print("timeout occured: alarm went off")
62
+ raise TimeoutException
63
+
64
+
65
+ # used to capture stdout as a list
66
+ # from https://stackoverflow.com/a/16571630/6416660
67
+ # alternative use redirect_stdout() from contextlib
68
+ class Capturing(list):
69
+ def __enter__(self):
70
+ self._stdout = sys.stdout
71
+ sys.stdout = self._stringio = StringIO()
72
+ # Make closing the StringIO a no-op
73
+ self._stringio.close = lambda x: 1
74
+ return self
75
+
76
+ def __exit__(self, *args):
77
+ self.append(self._stringio.getvalue())
78
+ del self._stringio # free up some memory
79
+ sys.stdout = self._stdout
80
+
81
+
82
+ # Custom mock for sys.stdin that supports buffer attribute
83
+ class MockStdinWithBuffer:
84
+ def __init__(self, inputs: str):
85
+ self.inputs = inputs
86
+ self._stringio = StringIO(inputs)
87
+ self.buffer = MockBuffer(inputs)
88
+
89
+ def read(self, *args):
90
+ return self.inputs
91
+
92
+ def readline(self, *args):
93
+ return self._stringio.readline(*args)
94
+
95
+ def readlines(self, *args):
96
+ return self.inputs.split("\n")
97
+
98
+ def __getattr__(self, name):
99
+ # Delegate other attributes to StringIO
100
+ return getattr(self._stringio, name)
101
+
102
+
103
+ class MockBuffer:
104
+ def __init__(self, inputs: str):
105
+ self.inputs = inputs.encode("utf-8") # Convert to bytes
106
+
107
+ def read(self, *args):
108
+ # Return as byte strings that can be split
109
+ return self.inputs
110
+
111
+ def readline(self, *args):
112
+ return self.inputs.split(b"\n")[0] + b"\n"
113
+
114
+
115
+ def clean_if_name(code: str) -> str:
116
+ try:
117
+ astree = ast.parse(code)
118
+ last_block = astree.body[-1]
119
+ if isinstance(last_block, ast.If):
120
+ condition = last_block.test
121
+ if ast.unparse(condition).strip() == "__name__ == '__main__'":
122
+ code = (
123
+ ast.unparse(astree.body[:-1]) + "\n" + ast.unparse(last_block.body) # type: ignore
124
+ )
125
+ except:
126
+ pass
127
+
128
+ return code
129
+
130
+
131
+ def make_function(code: str) -> str:
132
+ try:
133
+ import_stmts = []
134
+ all_other_stmts = []
135
+ astree = ast.parse(code)
136
+ for stmt in astree.body:
137
+ if isinstance(stmt, (ast.Import, ast.ImportFrom)):
138
+ import_stmts.append(stmt)
139
+ else:
140
+ all_other_stmts.append(stmt)
141
+
142
+ function_ast = ast.FunctionDef(
143
+ name="wrapped_function",
144
+ args=ast.arguments(
145
+ posonlyargs=[], args=[], kwonlyargs=[], kw_defaults=[], defaults=[]
146
+ ),
147
+ body=all_other_stmts,
148
+ decorator_list=[],
149
+ lineno=-1,
150
+ )
151
+ main_code = (
152
+ import_string
153
+ + "\n"
154
+ + ast.unparse(import_stmts) # type: ignore
155
+ + "\n"
156
+ + ast.unparse(function_ast) # type: ignore
157
+ )
158
+ return main_code
159
+ except Exception as e:
160
+ return code
161
+
162
+
163
+ def call_method(method, inputs):
164
+
165
+ if isinstance(inputs, list):
166
+ inputs = "\n".join(inputs)
167
+
168
+ inputs_line_iterator = iter(inputs.split("\n"))
169
+
170
+ # Create custom stdin mock with buffer support
171
+ mock_stdin = MockStdinWithBuffer(inputs)
172
+
173
+ # sys.setrecursionlimit(10000)
174
+
175
+ # @patch('builtins.input', side_effect=inputs.split("\n"))
176
+ @patch("builtins.open", mock_open(read_data=inputs))
177
+ @patch("sys.stdin", mock_stdin) # Use our custom mock instead of StringIO
178
+ @patch("sys.stdin.readline", lambda *args: next(inputs_line_iterator))
179
+ @patch("sys.stdin.readlines", lambda *args: inputs.split("\n"))
180
+ @patch("sys.stdin.read", lambda *args: inputs)
181
+ # @patch('sys.stdout.write', print)
182
+ def _inner_call_method(_method):
183
+ try:
184
+ return _method()
185
+ except SystemExit as e:
186
+ pass
187
+ finally:
188
+ pass
189
+
190
+ return _inner_call_method(method)
191
+
192
+
193
+ def get_function(compiled_sol, fn_name: str): # type: ignore
194
+ try:
195
+ assert hasattr(compiled_sol, fn_name)
196
+ return getattr(compiled_sol, fn_name)
197
+ except Exception as e:
198
+ return
199
+
200
+
201
+ def compile_code(code: str, timeout: int):
202
+ signal.alarm(timeout)
203
+ try:
204
+ tmp_sol = ModuleType("tmp_sol", "")
205
+ exec(code, tmp_sol.__dict__)
206
+ if "class Solution" in code:
207
+ # leetcode wraps solutions in `Solution`
208
+ # this is a hack to check if it is leetcode solution or not
209
+ # currently livecodebench only supports LeetCode but
210
+ # else condition allows future extensibility to other platforms
211
+ compiled_sol = tmp_sol.Solution()
212
+ else:
213
+ # do nothing in the other case since function is accesible
214
+ compiled_sol = tmp_sol
215
+
216
+ assert compiled_sol is not None
217
+ finally:
218
+ signal.alarm(0)
219
+
220
+ return compiled_sol
221
+
222
+
223
+ def convert_line_to_decimals(line: str) -> tuple[bool, list[Decimal]]:
224
+ try:
225
+ decimal_line = [Decimal(elem) for elem in line.split()]
226
+ except:
227
+ return False, []
228
+ return True, decimal_line
229
+
230
+
231
+ def get_stripped_lines(val: str):
232
+ ## you don't want empty lines to add empty list after splitlines!
233
+ val = val.strip()
234
+
235
+ return [val_line.strip() for val_line in val.split("\n")]
236
+
237
+
238
+ def grade_call_based(
239
+ code: str, all_inputs: list, all_outputs: list, fn_name: str, timeout: int
240
+ ):
241
+ # call-based clean up logic
242
+ # need to wrap in try-catch logic after to catch the correct errors, but for now this is fine.
243
+ code = import_string + "\n\n" + code
244
+ compiled_sol = compile_code(code, timeout)
245
+
246
+ if compiled_sol is None:
247
+ return
248
+
249
+ method = get_function(compiled_sol, fn_name)
250
+
251
+ if method is None:
252
+ return
253
+
254
+ all_inputs = [
255
+ [json.loads(line) for line in inputs.split("\n")] for inputs in all_inputs
256
+ ]
257
+
258
+ all_outputs = [json.loads(output) for output in all_outputs]
259
+
260
+ total_execution = 0
261
+ all_results = []
262
+ for idx, (gt_inp, gt_out) in enumerate(zip(all_inputs, all_outputs)):
263
+ signal.alarm(timeout)
264
+ faulthandler.enable()
265
+ try:
266
+ # can lock here so time is useful
267
+ start = time.time()
268
+ prediction = method(*gt_inp)
269
+ total_execution += time.time() - start
270
+ signal.alarm(0)
271
+
272
+ # don't penalize model if it produces tuples instead of lists
273
+ # ground truth sequences are not tuples
274
+ if isinstance(prediction, tuple):
275
+ prediction = list(prediction)
276
+
277
+ tmp_result = prediction == gt_out
278
+
279
+ # handle floating point comparisons
280
+
281
+ all_results.append(tmp_result)
282
+
283
+ if not tmp_result:
284
+ return all_results, {
285
+ "output": truncatefn(prediction),
286
+ "inputs": truncatefn(gt_inp),
287
+ "expected": truncatefn(gt_out),
288
+ "error_code": -2,
289
+ "error_message": "Wrong Answer",
290
+ }
291
+ except Exception as e:
292
+ signal.alarm(0)
293
+ if "timeoutexception" in repr(e).lower():
294
+ all_results.append(-3)
295
+ return all_results, {
296
+ "error": repr(e),
297
+ "error_code": -3,
298
+ "error_message": "Time Limit Exceeded",
299
+ "inputs": truncatefn(gt_inp),
300
+ "expected": truncatefn(gt_out),
301
+ }
302
+ else:
303
+ all_results.append(-4)
304
+ return all_results, {
305
+ "error": repr(e),
306
+ "error_code": -4,
307
+ "error_message": "Runtime Error",
308
+ "inputs": truncatefn(gt_inp),
309
+ "expected": truncatefn(gt_out),
310
+ }
311
+
312
+ finally:
313
+ signal.alarm(0)
314
+ faulthandler.disable()
315
+
316
+ return all_results, {"execution time": total_execution}
317
+
318
+
319
+ def grade_stdio(
320
+ code: str,
321
+ all_inputs: list,
322
+ all_outputs: list,
323
+ timeout: int,
324
+ ):
325
+ ## runtime doesn't interact well with __name__ == '__main__'
326
+ code = clean_if_name(code)
327
+
328
+ ## we wrap the given code inside another function
329
+ code = make_function(code)
330
+
331
+ compiled_sol = compile_code(code, timeout)
332
+ if compiled_sol is None:
333
+ return
334
+
335
+ method = get_function(compiled_sol, "wrapped_function")
336
+
337
+ if method is None:
338
+ return
339
+
340
+ all_results = []
341
+ total_execution_time = 0
342
+ for idx, (gt_inp, gt_out) in enumerate(zip(all_inputs, all_outputs)):
343
+ signal.alarm(timeout)
344
+ faulthandler.enable()
345
+
346
+ signal.alarm(timeout)
347
+ with Capturing() as captured_output:
348
+ try:
349
+ start = time.time()
350
+ call_method(method, gt_inp)
351
+ total_execution_time += time.time() - start
352
+ # reset the alarm
353
+ signal.alarm(0)
354
+ except Exception as e:
355
+ signal.alarm(0)
356
+ if "timeoutexception" in repr(e).lower():
357
+ all_results.append(-3)
358
+ return all_results, {
359
+ "error": repr(e),
360
+ "error_code": -3,
361
+ "error_message": "Time Limit Exceeded",
362
+ "inputs": truncatefn(gt_inp),
363
+ "expected": truncatefn(gt_out),
364
+ }
365
+ else:
366
+ all_results.append(-4)
367
+ return all_results, {
368
+ "error": repr(e),
369
+ "error_code": -4,
370
+ "error_message": "Runtime Error",
371
+ "inputs": truncatefn(gt_inp),
372
+ "expected": truncatefn(gt_out),
373
+ }
374
+
375
+ finally:
376
+ signal.alarm(0)
377
+ faulthandler.disable()
378
+
379
+ prediction = captured_output[0]
380
+
381
+ stripped_prediction_lines = get_stripped_lines(prediction)
382
+ stripped_gt_out_lines = get_stripped_lines(gt_out)
383
+
384
+ ## WA happens in multiple circumstances
385
+ ## so cache the return to make it clean!
386
+ WA_send_args = {
387
+ "output": truncatefn(prediction),
388
+ "inputs": truncatefn(gt_inp),
389
+ "expected": truncatefn(gt_out),
390
+ "error_code": -2,
391
+ }
392
+
393
+ if len(stripped_prediction_lines) != len(stripped_gt_out_lines):
394
+ all_results.append(-2)
395
+ WA_send_args["error_message"] = "Wrong answer: mismatched output length"
396
+ return all_results, WA_send_args
397
+
398
+ for output_line_idx, (
399
+ stripped_prediction_line,
400
+ stripped_gt_out_line,
401
+ ) in enumerate(zip(stripped_prediction_lines, stripped_gt_out_lines)):
402
+ WA_send_args["error_message"] = (
403
+ f"Wrong answer at {output_line_idx=}: {truncatefn(stripped_prediction_line)} != {truncatefn(stripped_gt_out_line)}"
404
+ )
405
+
406
+ ## CASE 1: exact match
407
+ if stripped_prediction_line == stripped_gt_out_line:
408
+ continue
409
+
410
+ ## CASE 2: element-wise comparision
411
+ ## if there are floating elements
412
+ ## use `decimal` library for good floating point comparision
413
+ ## otherwise gotcha: np.isclose(50000000000000000, 50000000000000001) = True
414
+ ## note that we should always be able to convert to decimals
415
+
416
+ success, decimal_prediction_line = convert_line_to_decimals(
417
+ stripped_prediction_line
418
+ )
419
+ if not success:
420
+ all_results.append(-2)
421
+ return all_results, WA_send_args
422
+ success, decimal_gtout_line = convert_line_to_decimals(stripped_gt_out_line)
423
+ if not success:
424
+ all_results.append(-2)
425
+ return all_results, WA_send_args
426
+
427
+ if decimal_prediction_line == decimal_gtout_line:
428
+ continue
429
+
430
+ all_results.append(-2)
431
+ return all_results, WA_send_args
432
+ all_results.append(True)
433
+
434
+ return all_results, {"execution time": total_execution_time}
435
+
436
+
437
+ def run_test(sample, test=None, debug=False, timeout=6):
438
+ """
439
+ if test(generated_code) is not None it'll try to run the code.
440
+ otherwise it'll just return an input and output pair.
441
+ """
442
+ signal.signal(signal.SIGALRM, timeout_handler)
443
+
444
+ # Disable functionalities that can make destructive changes to the test.
445
+ # max memory is set to 4GB
446
+ reliability_guard()
447
+
448
+ if debug:
449
+ print(f"start = {datetime.now().time()}")
450
+
451
+ try:
452
+ in_outs = json.loads(sample["input_output"])
453
+ except ValueError as e:
454
+ raise e
455
+ in_outs = None
456
+
457
+ if in_outs:
458
+ if in_outs.get("fn_name") is None:
459
+ which_type = CODE_TYPE.standard_input # Standard input
460
+ method_name = None
461
+
462
+ else:
463
+ which_type = CODE_TYPE.call_based # Call-based
464
+ method_name = in_outs["fn_name"]
465
+
466
+ if debug:
467
+ print(f"loaded input_output = {datetime.now().time()}")
468
+
469
+ if test is None:
470
+ assert False, "should not happen: test code is none"
471
+ return in_outs, {"error": "no test code provided"}
472
+ elif test is not None:
473
+ results = []
474
+ sol = import_string
475
+ if debug:
476
+ print(f"loading test code = {datetime.now().time()}")
477
+
478
+ if which_type == CODE_TYPE.call_based:
479
+ signal.alarm(timeout)
480
+ try:
481
+ results, metadata = grade_call_based(
482
+ code=test,
483
+ all_inputs=in_outs["inputs"],
484
+ all_outputs=in_outs["outputs"],
485
+ fn_name=method_name,
486
+ timeout=timeout,
487
+ )
488
+ return results, metadata
489
+ except Exception as e:
490
+ return [-4], {
491
+ "error_code": -4,
492
+ "error_message": f"Error during testing: {e}",
493
+ }
494
+ finally:
495
+ signal.alarm(0)
496
+ elif which_type == CODE_TYPE.standard_input:
497
+ # sol
498
+ # if code has if __name__ == "__main__": then remove it
499
+
500
+ signal.alarm(timeout)
501
+ try:
502
+ results, metadata = grade_stdio(
503
+ code=test,
504
+ all_inputs=in_outs["inputs"],
505
+ all_outputs=in_outs["outputs"],
506
+ timeout=timeout,
507
+ )
508
+ return results, metadata
509
+ except Exception as e:
510
+ return [-4], {
511
+ "error_code": -4,
512
+ "error_message": f"Error during testing: {e}",
513
+ }
514
+ finally:
515
+ signal.alarm(0)
516
+
517
+
518
+ def reliability_guard(maximum_memory_bytes=None):
519
+ """
520
+ This disables various destructive functions and prevents the generated code
521
+ from interfering with the test (e.g. fork bomb, killing other processes,
522
+ removing filesystem files, etc.)
523
+ WARNING
524
+ This function is NOT a security sandbox. Untrusted code, including, model-
525
+ generated code, should not be blindly executed outside of one. See the
526
+ Codex paper for more information about OpenAI's code sandbox, and proceed
527
+ with caution.
528
+ """
529
+
530
+ if maximum_memory_bytes is not None:
531
+ import resource
532
+
533
+ resource.setrlimit(
534
+ resource.RLIMIT_AS, (maximum_memory_bytes, maximum_memory_bytes)
535
+ )
536
+ resource.setrlimit(
537
+ resource.RLIMIT_DATA, (maximum_memory_bytes, maximum_memory_bytes)
538
+ )
539
+ if not platform.uname().system == "Darwin":
540
+ resource.setrlimit(
541
+ resource.RLIMIT_STACK, (maximum_memory_bytes, maximum_memory_bytes)
542
+ )
543
+
544
+ faulthandler.disable()
545
+
546
+ import builtins
547
+
548
+ # builtins.exit = None
549
+ builtins.quit = None
550
+
551
+ import os
552
+
553
+ os.environ["OMP_NUM_THREADS"] = "1"
554
+
555
+ os.kill = None
556
+ os.system = None
557
+ os.putenv = None
558
+ os.remove = None
559
+ os.removedirs = None
560
+ os.rmdir = None
561
+ os.fchdir = None
562
+ os.setuid = None
563
+ os.fork = None
564
+ os.forkpty = None
565
+ os.killpg = None
566
+ os.rename = None
567
+ os.renames = None
568
+ os.truncate = None
569
+ os.replace = None
570
+ os.unlink = None
571
+ os.fchmod = None
572
+ os.fchown = None
573
+ os.chmod = None
574
+ os.chown = None
575
+ os.chroot = None
576
+ os.fchdir = None
577
+ os.lchflags = None
578
+ os.lchmod = None
579
+ os.lchown = None
580
+ os.getcwd = None
581
+ os.chdir = None
582
+
583
+ import shutil
584
+
585
+ shutil.rmtree = None
586
+ shutil.move = None
587
+ shutil.chown = None
588
+
589
+ import subprocess
590
+
591
+ subprocess.Popen = None # type: ignore
592
+
593
+ # run as __main__ (Zevo), __builtins__ is the module, not its dict
594
+ (__builtins__ if isinstance(__builtins__, dict) else __builtins__.__dict__)["help"] = None
595
+
596
+ import sys
597
+
598
+ sys.modules["ipdb"] = None
599
+ sys.modules["joblib"] = None
600
+ sys.modules["resource"] = None
601
+ sys.modules["psutil"] = None
602
+ sys.modules["tkinter"] = None
603
+
604
+ # ---------------- Zevo entry point ----------------
605
+ import base64, csv, multiprocessing, pickle, zlib, os
606
+ from concurrent.futures import ProcessPoolExecutor
607
+
608
+
609
+ def extract_code(output: str) -> str:
610
+ lines = output.split("\n")
611
+ idx = [i for i, line in enumerate(lines) if "```" in line]
612
+ if len(idx) >= 2:
613
+ return "\n".join(lines[idx[-2] + 1: idx[-1]])
614
+ return (output or "").strip()
615
+
616
+
617
+ def decode_tests(row):
618
+ ts = row["tests"]
619
+ if isinstance(ts, str):
620
+ ts = json.loads(ts)
621
+ ts = ts or []
622
+ return {"input_output": json.dumps({
623
+ "inputs": [t.get("input", "") for t in ts],
624
+ "outputs": [t.get("output", "") for t in ts],
625
+ "fn_name": None,
626
+ })}
627
+
628
+
629
+ def _run(sample, code, result, timeout):
630
+ res, _ = run_test(sample, test=code, debug=False, timeout=timeout)
631
+ result.append(res)
632
+
633
+
634
+ def check(args):
635
+ # LCB check_correctness: run in a child process with a global timeout.
636
+ sample, code, timeout = args
637
+ if not code.strip():
638
+ return False
639
+ manager = multiprocessing.Manager()
640
+ result = manager.list()
641
+ p = multiprocessing.Process(target=_run, args=(sample, code, result, timeout))
642
+ p.start()
643
+ n = len(json.loads(sample["input_output"])["inputs"])
644
+ p.join(timeout=(timeout + 1) * n + 5)
645
+ if p.is_alive():
646
+ p.kill()
647
+ if not result:
648
+ return False
649
+ res = result[0]
650
+ return bool(res) and all(r is True or (not isinstance(r, bool) and r == 1) for r in res)
651
+
652
+
653
+ def load_rows(path):
654
+ ext = os.path.splitext(path)[1].lower()
655
+ if ext == ".parquet":
656
+ import pyarrow.parquet as pq
657
+ return pq.read_table(path).to_pylist()
658
+ if ext == ".jsonl":
659
+ return [json.loads(l) for l in open(path, encoding="utf-8") if l.strip()]
660
+ if ext == ".json":
661
+ d = json.load(open(path, encoding="utf-8"))
662
+ return d if isinstance(d, list) else d.get("data", d.get("rows"))
663
+ csv.field_size_limit(sys.maxsize)
664
+ return list(csv.DictReader(open(path, newline="", encoding="utf-8")))
665
+
666
+
667
+ def main():
668
+ pred_path, set_path, out_path = sys.argv[1:4]
669
+ csv.field_size_limit(sys.maxsize)
670
+ preds = {r["id"]: r.get("prediction") or "" for r in csv.DictReader(open(pred_path, newline="", encoding="utf-8"))}
671
+ rows = load_rows(set_path)
672
+ jobs = [(decode_tests(r), extract_code(preds.get(str(r["id"]), "")), 6) for r in rows]
673
+ workers = int(os.environ.get("LCB_EVAL_WORKERS", min(16, os.cpu_count() or 1)))
674
+ with ProcessPoolExecutor(max_workers=workers) as ex:
675
+ ok = list(ex.map(check, jobs))
676
+ by = {}
677
+ for r, k in zip(rows, ok):
678
+ d = by.setdefault(r.get("difficulty", "all"), [0, 0])
679
+ d[0] += k; d[1] += 1
680
+ total = len(rows); correct = sum(ok)
681
+ out = {"score": correct / total if total else 0.0, "correct": correct, "total": total,
682
+ "missing_predictions": sum(str(r["id"]) not in preds for r in rows),
683
+ "by_difficulty": {k: round(v[0] / v[1], 4) for k, v in by.items()}}
684
+ json.dump(out, open(out_path, "w", encoding="utf-8"))
685
+ print(json.dumps(out))
686
+
687
+
688
+ if __name__ == "__main__":
689
+ main()
sample_submission.csv ADDED
@@ -0,0 +1,1225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ id,prediction
2
+ cf-7523ff0de46ffb62,"```python
3
+ # solution
4
+ ```"
5
+ cf-c02443ec23f88353,"```python
6
+ # solution
7
+ ```"
8
+ cf-7ac66687aa5eab54,"```python
9
+ # solution
10
+ ```"
11
+ cf-e76762ee2f865346,"```python
12
+ # solution
13
+ ```"
14
+ cf-8a7b37d147fff9f2,"```python
15
+ # solution
16
+ ```"
17
+ cf-d64ea36c259258bd,"```python
18
+ # solution
19
+ ```"
20
+ cf-71cdab7c3ed2a9e3,"```python
21
+ # solution
22
+ ```"
23
+ cf-d5bc0040e507c601,"```python
24
+ # solution
25
+ ```"
26
+ cf-c9dc2fe6951af63c,"```python
27
+ # solution
28
+ ```"
29
+ cf-f022f97a83aecd81,"```python
30
+ # solution
31
+ ```"
32
+ cf-03989708ba80f434,"```python
33
+ # solution
34
+ ```"
35
+ cf-6b96f12da81e3aa6,"```python
36
+ # solution
37
+ ```"
38
+ cf-27257141f88d7919,"```python
39
+ # solution
40
+ ```"
41
+ cf-0c54c4db17b4a002,"```python
42
+ # solution
43
+ ```"
44
+ cf-d269d3c95353659a,"```python
45
+ # solution
46
+ ```"
47
+ cf-2846ab5c0f8efc0a,"```python
48
+ # solution
49
+ ```"
50
+ cf-7ae26c5706fd4fd1,"```python
51
+ # solution
52
+ ```"
53
+ cf-3a92d2c8dbf1ac59,"```python
54
+ # solution
55
+ ```"
56
+ cf-d894a01fb8ac77eb,"```python
57
+ # solution
58
+ ```"
59
+ cf-6d4279adcb1fad9f,"```python
60
+ # solution
61
+ ```"
62
+ cf-d0e6b6fcda95bed7,"```python
63
+ # solution
64
+ ```"
65
+ cf-aa9efedb39810f70,"```python
66
+ # solution
67
+ ```"
68
+ cf-2900b66654b363c3,"```python
69
+ # solution
70
+ ```"
71
+ cf-d3d645b73b59c21d,"```python
72
+ # solution
73
+ ```"
74
+ cf-5500d3fcb5e5722a,"```python
75
+ # solution
76
+ ```"
77
+ cf-1aa2747d93916bb1,"```python
78
+ # solution
79
+ ```"
80
+ cf-faae40af5e76d60b,"```python
81
+ # solution
82
+ ```"
83
+ cf-5bdc7b104350f60f,"```python
84
+ # solution
85
+ ```"
86
+ cf-4dcb5afc4dd0896d,"```python
87
+ # solution
88
+ ```"
89
+ cf-eb141c5086038eac,"```python
90
+ # solution
91
+ ```"
92
+ cf-56bd4e1044a4fc5a,"```python
93
+ # solution
94
+ ```"
95
+ cf-241362537a821837,"```python
96
+ # solution
97
+ ```"
98
+ cf-2504211e2da6bf85,"```python
99
+ # solution
100
+ ```"
101
+ cf-fe72bd8119780ec8,"```python
102
+ # solution
103
+ ```"
104
+ cf-1ca08b48bd892578,"```python
105
+ # solution
106
+ ```"
107
+ cf-7f5b6e4b96fcd311,"```python
108
+ # solution
109
+ ```"
110
+ cf-79fa4a4184718719,"```python
111
+ # solution
112
+ ```"
113
+ cf-11cfb743bc719098,"```python
114
+ # solution
115
+ ```"
116
+ cf-80c6887ef976a83f,"```python
117
+ # solution
118
+ ```"
119
+ cf-0ca0714ae890d497,"```python
120
+ # solution
121
+ ```"
122
+ cf-ee1166e86da8a5bc,"```python
123
+ # solution
124
+ ```"
125
+ cf-01dda202b0218b62,"```python
126
+ # solution
127
+ ```"
128
+ cf-94ba82d61a989906,"```python
129
+ # solution
130
+ ```"
131
+ cf-686973a2ba447968,"```python
132
+ # solution
133
+ ```"
134
+ cf-1087f5de081a27de,"```python
135
+ # solution
136
+ ```"
137
+ cf-bf629747f8647fbd,"```python
138
+ # solution
139
+ ```"
140
+ cf-200064be45810647,"```python
141
+ # solution
142
+ ```"
143
+ cf-978389c1f63e8c56,"```python
144
+ # solution
145
+ ```"
146
+ cf-53bbfadfc69af54a,"```python
147
+ # solution
148
+ ```"
149
+ cf-b15b42ca21d6498c,"```python
150
+ # solution
151
+ ```"
152
+ cf-09d4b3eee7968b29,"```python
153
+ # solution
154
+ ```"
155
+ cf-97100ad837e06861,"```python
156
+ # solution
157
+ ```"
158
+ cf-cc1dd97084442fd7,"```python
159
+ # solution
160
+ ```"
161
+ cf-61505319ac981d75,"```python
162
+ # solution
163
+ ```"
164
+ cf-2e5b5d04f1d95a7f,"```python
165
+ # solution
166
+ ```"
167
+ cf-336a44a84724d94f,"```python
168
+ # solution
169
+ ```"
170
+ cf-1bc44fec8f5fbeb5,"```python
171
+ # solution
172
+ ```"
173
+ cf-4857ca2b46ac76e5,"```python
174
+ # solution
175
+ ```"
176
+ cf-83c9c92eee2f2fad,"```python
177
+ # solution
178
+ ```"
179
+ cf-546e2bfd848ad791,"```python
180
+ # solution
181
+ ```"
182
+ cf-c5781db3fd9b0c93,"```python
183
+ # solution
184
+ ```"
185
+ cf-6b1da5c26358bb68,"```python
186
+ # solution
187
+ ```"
188
+ cf-bc5062c8c3e0ab6e,"```python
189
+ # solution
190
+ ```"
191
+ cf-d0c531ba295dc35b,"```python
192
+ # solution
193
+ ```"
194
+ cf-7ab2686a86e7e11b,"```python
195
+ # solution
196
+ ```"
197
+ cf-46b5d0f266fb5973,"```python
198
+ # solution
199
+ ```"
200
+ cf-575a7dd3dacefcac,"```python
201
+ # solution
202
+ ```"
203
+ cf-62950c42317da0ea,"```python
204
+ # solution
205
+ ```"
206
+ cf-4035efd555f39da9,"```python
207
+ # solution
208
+ ```"
209
+ cf-71583b418f5b422f,"```python
210
+ # solution
211
+ ```"
212
+ cf-d9a92f5b1ca467a7,"```python
213
+ # solution
214
+ ```"
215
+ cf-ee148c8d94fef8f0,"```python
216
+ # solution
217
+ ```"
218
+ cf-12ded724e7b4e8ce,"```python
219
+ # solution
220
+ ```"
221
+ cf-e3b3e78d8d33ea08,"```python
222
+ # solution
223
+ ```"
224
+ cf-6948ecd6286e913c,"```python
225
+ # solution
226
+ ```"
227
+ cf-5fdd0e04ea336294,"```python
228
+ # solution
229
+ ```"
230
+ cf-50b61b3d8c1fef5e,"```python
231
+ # solution
232
+ ```"
233
+ cf-895ee117276fc985,"```python
234
+ # solution
235
+ ```"
236
+ cf-b9be4f453fa811fd,"```python
237
+ # solution
238
+ ```"
239
+ cf-35558baff322d158,"```python
240
+ # solution
241
+ ```"
242
+ cf-39dc6d797ec012dc,"```python
243
+ # solution
244
+ ```"
245
+ cf-26164dd358b25b03,"```python
246
+ # solution
247
+ ```"
248
+ cf-85d614b42c653847,"```python
249
+ # solution
250
+ ```"
251
+ cf-3b24035b37b7e3d0,"```python
252
+ # solution
253
+ ```"
254
+ cf-5f489f6285179bc0,"```python
255
+ # solution
256
+ ```"
257
+ cf-4d8452a6dc8692ee,"```python
258
+ # solution
259
+ ```"
260
+ cf-3210cc15125b1902,"```python
261
+ # solution
262
+ ```"
263
+ cf-68791d88924e8208,"```python
264
+ # solution
265
+ ```"
266
+ cf-d81d9c8ba952a505,"```python
267
+ # solution
268
+ ```"
269
+ cf-5fa3fb3b49dbd702,"```python
270
+ # solution
271
+ ```"
272
+ cf-a7fa9759eff61255,"```python
273
+ # solution
274
+ ```"
275
+ cf-5118104022fa64fe,"```python
276
+ # solution
277
+ ```"
278
+ cf-7d90be3588221da2,"```python
279
+ # solution
280
+ ```"
281
+ cf-650d93f12b4cd5ba,"```python
282
+ # solution
283
+ ```"
284
+ cf-2034d12ca0220544,"```python
285
+ # solution
286
+ ```"
287
+ cf-8a750ad6391674a9,"```python
288
+ # solution
289
+ ```"
290
+ cf-1f0b89e27db09b4b,"```python
291
+ # solution
292
+ ```"
293
+ cf-f90a85e39db3bde3,"```python
294
+ # solution
295
+ ```"
296
+ cf-9474cceabd190d0e,"```python
297
+ # solution
298
+ ```"
299
+ cf-10c296908f2b0a5f,"```python
300
+ # solution
301
+ ```"
302
+ cf-221072dc36214997,"```python
303
+ # solution
304
+ ```"
305
+ cf-8f39e6c702501551,"```python
306
+ # solution
307
+ ```"
308
+ cf-669639e067f94619,"```python
309
+ # solution
310
+ ```"
311
+ cf-b3cdd9336cdbad21,"```python
312
+ # solution
313
+ ```"
314
+ cf-5e9d0047aca5fcd3,"```python
315
+ # solution
316
+ ```"
317
+ cf-50a8c0c707c1b907,"```python
318
+ # solution
319
+ ```"
320
+ cf-5bae67e9f7e11a8b,"```python
321
+ # solution
322
+ ```"
323
+ cf-09fb79acee3ca230,"```python
324
+ # solution
325
+ ```"
326
+ cf-a5588da658a1be0c,"```python
327
+ # solution
328
+ ```"
329
+ cf-f82bf3ec8a29e0fa,"```python
330
+ # solution
331
+ ```"
332
+ cf-c5eb57e3cf07b61f,"```python
333
+ # solution
334
+ ```"
335
+ cf-30ba13a749db8bc7,"```python
336
+ # solution
337
+ ```"
338
+ cf-a7e1dfb8e3b12bc1,"```python
339
+ # solution
340
+ ```"
341
+ cf-f798fd88bad8fc48,"```python
342
+ # solution
343
+ ```"
344
+ cf-e7510edf5c14124e,"```python
345
+ # solution
346
+ ```"
347
+ cf-0aab0be1d320d720,"```python
348
+ # solution
349
+ ```"
350
+ cf-b8b2a08f1a3286a6,"```python
351
+ # solution
352
+ ```"
353
+ cf-dffe1fc7a37fd6bc,"```python
354
+ # solution
355
+ ```"
356
+ cf-8ee59b3823b970d0,"```python
357
+ # solution
358
+ ```"
359
+ cf-77f4f41be4eba94f,"```python
360
+ # solution
361
+ ```"
362
+ cf-3748298c6fa84b8d,"```python
363
+ # solution
364
+ ```"
365
+ cf-0c93176b7ce4364f,"```python
366
+ # solution
367
+ ```"
368
+ cf-03c511813008a86d,"```python
369
+ # solution
370
+ ```"
371
+ cf-b09aec76d1837c24,"```python
372
+ # solution
373
+ ```"
374
+ cf-391bac3dfdc536db,"```python
375
+ # solution
376
+ ```"
377
+ cf-46174ab40f15f729,"```python
378
+ # solution
379
+ ```"
380
+ cf-7fcf6af9ecb30c92,"```python
381
+ # solution
382
+ ```"
383
+ cf-9efc6692005e91ce,"```python
384
+ # solution
385
+ ```"
386
+ cf-2943e7e34664e8c5,"```python
387
+ # solution
388
+ ```"
389
+ cf-d69c116dbaad1972,"```python
390
+ # solution
391
+ ```"
392
+ cf-d01ce37257534804,"```python
393
+ # solution
394
+ ```"
395
+ cf-7e9f19df18c2ba41,"```python
396
+ # solution
397
+ ```"
398
+ cf-0309babcf9dda96c,"```python
399
+ # solution
400
+ ```"
401
+ cf-006d0934620370cc,"```python
402
+ # solution
403
+ ```"
404
+ cf-2a52cabaf43650dc,"```python
405
+ # solution
406
+ ```"
407
+ cf-c9f48f65ee0d3d5b,"```python
408
+ # solution
409
+ ```"
410
+ cf-59cd2c8e2e10e192,"```python
411
+ # solution
412
+ ```"
413
+ cf-70f7ff90284b48c2,"```python
414
+ # solution
415
+ ```"
416
+ cf-9f97358eb1d62bec,"```python
417
+ # solution
418
+ ```"
419
+ cf-5567773d14325bc8,"```python
420
+ # solution
421
+ ```"
422
+ cf-13aef844372c5001,"```python
423
+ # solution
424
+ ```"
425
+ cf-b14e6b9c9dcf66b9,"```python
426
+ # solution
427
+ ```"
428
+ cf-cbbcd7f62b037500,"```python
429
+ # solution
430
+ ```"
431
+ cf-a321048f5888ef51,"```python
432
+ # solution
433
+ ```"
434
+ cf-397118f1dab2c7fb,"```python
435
+ # solution
436
+ ```"
437
+ cf-98130539ebad9e70,"```python
438
+ # solution
439
+ ```"
440
+ cf-ff3ec5fb2b0cc895,"```python
441
+ # solution
442
+ ```"
443
+ cf-624a4450163844ef,"```python
444
+ # solution
445
+ ```"
446
+ cf-cf90f5c1db71888e,"```python
447
+ # solution
448
+ ```"
449
+ cf-d67c6cc0447e5f8c,"```python
450
+ # solution
451
+ ```"
452
+ cf-44618e82f0098b93,"```python
453
+ # solution
454
+ ```"
455
+ cf-7d2a5031279c6736,"```python
456
+ # solution
457
+ ```"
458
+ cf-4ed3d1f699f7dddc,"```python
459
+ # solution
460
+ ```"
461
+ cf-25c02b9bea693993,"```python
462
+ # solution
463
+ ```"
464
+ cf-3619874544e5ccea,"```python
465
+ # solution
466
+ ```"
467
+ cf-12dc8eda8f35fdfa,"```python
468
+ # solution
469
+ ```"
470
+ cf-a984e5ceced107d1,"```python
471
+ # solution
472
+ ```"
473
+ cf-61cbafb0ef257ccc,"```python
474
+ # solution
475
+ ```"
476
+ cf-4cc55667fe935a5a,"```python
477
+ # solution
478
+ ```"
479
+ cf-a4f027f8e14a0af2,"```python
480
+ # solution
481
+ ```"
482
+ cf-04727798f98b4a4c,"```python
483
+ # solution
484
+ ```"
485
+ cf-b2ff548846ed597d,"```python
486
+ # solution
487
+ ```"
488
+ cf-eaab552d285cde6c,"```python
489
+ # solution
490
+ ```"
491
+ cf-365ba03e7f5b85b7,"```python
492
+ # solution
493
+ ```"
494
+ cf-8b79081aebc62bc7,"```python
495
+ # solution
496
+ ```"
497
+ cf-a302895c661ba29f,"```python
498
+ # solution
499
+ ```"
500
+ cf-75772844aa9cad85,"```python
501
+ # solution
502
+ ```"
503
+ cf-99080af17eb1bf1c,"```python
504
+ # solution
505
+ ```"
506
+ cf-e8e17264de612d6e,"```python
507
+ # solution
508
+ ```"
509
+ cf-6f4343760a24ac63,"```python
510
+ # solution
511
+ ```"
512
+ cf-ad0962212fea178b,"```python
513
+ # solution
514
+ ```"
515
+ cf-8362c209625003cf,"```python
516
+ # solution
517
+ ```"
518
+ cf-a2c4cb90b1253c45,"```python
519
+ # solution
520
+ ```"
521
+ cf-c125dbf9485fd3ed,"```python
522
+ # solution
523
+ ```"
524
+ cf-84a3c25300a6786d,"```python
525
+ # solution
526
+ ```"
527
+ cf-07f17213c5153858,"```python
528
+ # solution
529
+ ```"
530
+ cf-ee48ac1d46404f98,"```python
531
+ # solution
532
+ ```"
533
+ cf-5e6dca6776327096,"```python
534
+ # solution
535
+ ```"
536
+ cf-3d117b411889e077,"```python
537
+ # solution
538
+ ```"
539
+ cf-76bcb693a884b96a,"```python
540
+ # solution
541
+ ```"
542
+ cf-613410f2f2802e71,"```python
543
+ # solution
544
+ ```"
545
+ cf-9a28ec78eb695a72,"```python
546
+ # solution
547
+ ```"
548
+ cf-c920adb1f14fead4,"```python
549
+ # solution
550
+ ```"
551
+ cf-1c2348462e0ffb5b,"```python
552
+ # solution
553
+ ```"
554
+ cf-5a56f3b6d7d96629,"```python
555
+ # solution
556
+ ```"
557
+ cf-b403ad23f9df01b5,"```python
558
+ # solution
559
+ ```"
560
+ cf-8a01dee6edff6646,"```python
561
+ # solution
562
+ ```"
563
+ cf-36dd48709d4c6cec,"```python
564
+ # solution
565
+ ```"
566
+ cf-e5b32d29e5e18804,"```python
567
+ # solution
568
+ ```"
569
+ cf-a55eb159ec9f7c5e,"```python
570
+ # solution
571
+ ```"
572
+ cf-3038f57f582b92b7,"```python
573
+ # solution
574
+ ```"
575
+ cf-dd14fb3b657481f5,"```python
576
+ # solution
577
+ ```"
578
+ cf-4ee06e376cf46d6d,"```python
579
+ # solution
580
+ ```"
581
+ cf-25416861a5241d3c,"```python
582
+ # solution
583
+ ```"
584
+ cf-daf5280b3d547cdc,"```python
585
+ # solution
586
+ ```"
587
+ cf-dcd26549d309c08f,"```python
588
+ # solution
589
+ ```"
590
+ cf-de92f4a76c782ead,"```python
591
+ # solution
592
+ ```"
593
+ cf-a61cf5630d697657,"```python
594
+ # solution
595
+ ```"
596
+ cf-e75d947160f43f48,"```python
597
+ # solution
598
+ ```"
599
+ cf-19a2223b29a4e32b,"```python
600
+ # solution
601
+ ```"
602
+ cf-8d9c2ecd53154735,"```python
603
+ # solution
604
+ ```"
605
+ cf-fae8a3c0ea1ddda9,"```python
606
+ # solution
607
+ ```"
608
+ cf-56d0d66fd32f536a,"```python
609
+ # solution
610
+ ```"
611
+ cf-b6ae539aa0ece0b5,"```python
612
+ # solution
613
+ ```"
614
+ cf-89c6dc80bc6e178e,"```python
615
+ # solution
616
+ ```"
617
+ cf-82930680859be479,"```python
618
+ # solution
619
+ ```"
620
+ cf-bdc784eca7e75ac8,"```python
621
+ # solution
622
+ ```"
623
+ cf-85d6865110fbdf3d,"```python
624
+ # solution
625
+ ```"
626
+ cf-10527c7c686d8515,"```python
627
+ # solution
628
+ ```"
629
+ cf-4c4b8d8245f50929,"```python
630
+ # solution
631
+ ```"
632
+ cf-9c0469c0fcf57c19,"```python
633
+ # solution
634
+ ```"
635
+ cf-9ef290c1a24d9496,"```python
636
+ # solution
637
+ ```"
638
+ cf-431573f1d7bb301d,"```python
639
+ # solution
640
+ ```"
641
+ cf-6509e4f0d2d3100d,"```python
642
+ # solution
643
+ ```"
644
+ cf-5bdb7848972b5212,"```python
645
+ # solution
646
+ ```"
647
+ cf-8221d090c4c1cba5,"```python
648
+ # solution
649
+ ```"
650
+ cf-959ea79f76be5608,"```python
651
+ # solution
652
+ ```"
653
+ cf-9b1e3b8346a5605b,"```python
654
+ # solution
655
+ ```"
656
+ cf-415b4a43628643f6,"```python
657
+ # solution
658
+ ```"
659
+ cf-c9470bcbb7ff7c74,"```python
660
+ # solution
661
+ ```"
662
+ cf-e252fafef16e86e1,"```python
663
+ # solution
664
+ ```"
665
+ cf-08e76c4162c3d5d6,"```python
666
+ # solution
667
+ ```"
668
+ cf-7e7d615540984d8a,"```python
669
+ # solution
670
+ ```"
671
+ cf-7473fec259254b1c,"```python
672
+ # solution
673
+ ```"
674
+ cf-a57c0f59d3211ae9,"```python
675
+ # solution
676
+ ```"
677
+ cf-bb8f0c3d3c490a16,"```python
678
+ # solution
679
+ ```"
680
+ cf-48ed90584336d45b,"```python
681
+ # solution
682
+ ```"
683
+ cf-af0cc196db1195da,"```python
684
+ # solution
685
+ ```"
686
+ cf-ccab0ea22013d32a,"```python
687
+ # solution
688
+ ```"
689
+ cf-62aff2d5503b50d8,"```python
690
+ # solution
691
+ ```"
692
+ cf-251153bc63e3b74c,"```python
693
+ # solution
694
+ ```"
695
+ cf-37283be4276e6343,"```python
696
+ # solution
697
+ ```"
698
+ cf-ad009460a07112af,"```python
699
+ # solution
700
+ ```"
701
+ cf-4141bfa06ec30e04,"```python
702
+ # solution
703
+ ```"
704
+ cf-0757720cc194cf68,"```python
705
+ # solution
706
+ ```"
707
+ cf-373d6eae4d68b10f,"```python
708
+ # solution
709
+ ```"
710
+ cf-066d7b94a8ba2f5e,"```python
711
+ # solution
712
+ ```"
713
+ cf-a91e4148a27de25b,"```python
714
+ # solution
715
+ ```"
716
+ cf-ef4740448ba278f7,"```python
717
+ # solution
718
+ ```"
719
+ cf-ccc3594c0c1b5c2c,"```python
720
+ # solution
721
+ ```"
722
+ cf-dedaaf5226c93873,"```python
723
+ # solution
724
+ ```"
725
+ cf-46fd459513a94580,"```python
726
+ # solution
727
+ ```"
728
+ cf-4fdc1ced5ae60f9b,"```python
729
+ # solution
730
+ ```"
731
+ cf-bf4e0736612c9400,"```python
732
+ # solution
733
+ ```"
734
+ cf-d87021af5ddc9f8b,"```python
735
+ # solution
736
+ ```"
737
+ cf-349680720454272a,"```python
738
+ # solution
739
+ ```"
740
+ cf-0526124d47568401,"```python
741
+ # solution
742
+ ```"
743
+ cf-91f7b911644f0970,"```python
744
+ # solution
745
+ ```"
746
+ cf-8fedf6fe29ad244c,"```python
747
+ # solution
748
+ ```"
749
+ cf-af684689a8afbcf6,"```python
750
+ # solution
751
+ ```"
752
+ cf-8ee03fd4c2b09cb3,"```python
753
+ # solution
754
+ ```"
755
+ cf-510311b247c2a19e,"```python
756
+ # solution
757
+ ```"
758
+ cf-e7ae750c92c8e0f5,"```python
759
+ # solution
760
+ ```"
761
+ cf-af009a97dd4077c8,"```python
762
+ # solution
763
+ ```"
764
+ cf-9f6e7573a17c06b7,"```python
765
+ # solution
766
+ ```"
767
+ cf-c0f526bb96097552,"```python
768
+ # solution
769
+ ```"
770
+ cf-b7147a313054c784,"```python
771
+ # solution
772
+ ```"
773
+ cf-17d6a269c86fedc9,"```python
774
+ # solution
775
+ ```"
776
+ cf-680e009b3b57c60e,"```python
777
+ # solution
778
+ ```"
779
+ cf-f07bcf245f7c6329,"```python
780
+ # solution
781
+ ```"
782
+ cf-0877e2b8639e3e16,"```python
783
+ # solution
784
+ ```"
785
+ cf-dbe9ec8bfe54400e,"```python
786
+ # solution
787
+ ```"
788
+ cf-3ef1867eaeef3d80,"```python
789
+ # solution
790
+ ```"
791
+ cf-fdcc0441621400eb,"```python
792
+ # solution
793
+ ```"
794
+ cf-e0db689e88ac0b62,"```python
795
+ # solution
796
+ ```"
797
+ cf-6e18c7a2f8068bd1,"```python
798
+ # solution
799
+ ```"
800
+ cf-40f91b03df8c336b,"```python
801
+ # solution
802
+ ```"
803
+ cf-1dad6e6e625a63cf,"```python
804
+ # solution
805
+ ```"
806
+ cf-5d662d4b78832aff,"```python
807
+ # solution
808
+ ```"
809
+ cf-7ea47ac04494131d,"```python
810
+ # solution
811
+ ```"
812
+ cf-3ab136690610c574,"```python
813
+ # solution
814
+ ```"
815
+ cf-290abc7279c8a39e,"```python
816
+ # solution
817
+ ```"
818
+ cf-7f0558cfec9091ee,"```python
819
+ # solution
820
+ ```"
821
+ cf-97ab4138236f1ad7,"```python
822
+ # solution
823
+ ```"
824
+ cf-7519982cbe364897,"```python
825
+ # solution
826
+ ```"
827
+ cf-bb72f5fc8c85820f,"```python
828
+ # solution
829
+ ```"
830
+ cf-ef9780f611bdc70e,"```python
831
+ # solution
832
+ ```"
833
+ cf-1747e3b07ad42b08,"```python
834
+ # solution
835
+ ```"
836
+ cf-56826b2758490b0f,"```python
837
+ # solution
838
+ ```"
839
+ cf-7fb65d4554f7be7b,"```python
840
+ # solution
841
+ ```"
842
+ cf-a671a8189b7eee8f,"```python
843
+ # solution
844
+ ```"
845
+ cf-afe72577721c1c8a,"```python
846
+ # solution
847
+ ```"
848
+ cf-d73f65b6c744baaf,"```python
849
+ # solution
850
+ ```"
851
+ cf-ac1d78d8afe1b4d5,"```python
852
+ # solution
853
+ ```"
854
+ cf-a5fcf217bcab67d1,"```python
855
+ # solution
856
+ ```"
857
+ cf-0adfcf12b9b5542a,"```python
858
+ # solution
859
+ ```"
860
+ cf-20b67af882fa6c9e,"```python
861
+ # solution
862
+ ```"
863
+ cf-864d08c8ea8064b6,"```python
864
+ # solution
865
+ ```"
866
+ cf-ba65a57637e12845,"```python
867
+ # solution
868
+ ```"
869
+ cf-85a8951962050b3c,"```python
870
+ # solution
871
+ ```"
872
+ cf-2fcacee04da27b58,"```python
873
+ # solution
874
+ ```"
875
+ cf-1c9e12b94ae11466,"```python
876
+ # solution
877
+ ```"
878
+ cf-3d0b086e89aea455,"```python
879
+ # solution
880
+ ```"
881
+ cf-3a59d9bb53941e81,"```python
882
+ # solution
883
+ ```"
884
+ cf-0fd4c8078bb81537,"```python
885
+ # solution
886
+ ```"
887
+ cf-aa2d4497db2db3d5,"```python
888
+ # solution
889
+ ```"
890
+ cf-e3147c5900e6cc63,"```python
891
+ # solution
892
+ ```"
893
+ cf-676fd6d86ea858b3,"```python
894
+ # solution
895
+ ```"
896
+ cf-b060389d148d7399,"```python
897
+ # solution
898
+ ```"
899
+ cf-165031e106d9579e,"```python
900
+ # solution
901
+ ```"
902
+ cf-927ef5ee37abb90f,"```python
903
+ # solution
904
+ ```"
905
+ cf-7353ae3e3d5f3d0b,"```python
906
+ # solution
907
+ ```"
908
+ cf-ea1f1541b5c8454f,"```python
909
+ # solution
910
+ ```"
911
+ cf-15e45b1911b3e4e7,"```python
912
+ # solution
913
+ ```"
914
+ cf-6fef6d1056feef04,"```python
915
+ # solution
916
+ ```"
917
+ cf-94b6b03e91be2643,"```python
918
+ # solution
919
+ ```"
920
+ cf-6ab0ad36a045292b,"```python
921
+ # solution
922
+ ```"
923
+ cf-76d6ed3b05e44cc5,"```python
924
+ # solution
925
+ ```"
926
+ cf-ccc86e312b9a72b6,"```python
927
+ # solution
928
+ ```"
929
+ cf-e46f5d10f4f6b9e2,"```python
930
+ # solution
931
+ ```"
932
+ cf-e80ee4f1bd66e00c,"```python
933
+ # solution
934
+ ```"
935
+ cf-3ff70330e9bd5851,"```python
936
+ # solution
937
+ ```"
938
+ cf-66b44d18bf3f1229,"```python
939
+ # solution
940
+ ```"
941
+ cf-436f82981620c033,"```python
942
+ # solution
943
+ ```"
944
+ cf-89eea5f86fb6ebb4,"```python
945
+ # solution
946
+ ```"
947
+ cf-706e3e333b48079e,"```python
948
+ # solution
949
+ ```"
950
+ cf-d54a1d5f15855120,"```python
951
+ # solution
952
+ ```"
953
+ cf-843c7943207d0df5,"```python
954
+ # solution
955
+ ```"
956
+ cf-5fbb4804b2415192,"```python
957
+ # solution
958
+ ```"
959
+ cf-71cf2d6283f94dfd,"```python
960
+ # solution
961
+ ```"
962
+ cf-67aa378e15b57d64,"```python
963
+ # solution
964
+ ```"
965
+ cf-43fb67e72853e2e5,"```python
966
+ # solution
967
+ ```"
968
+ cf-3ce83ec5e0603ae5,"```python
969
+ # solution
970
+ ```"
971
+ cf-19a38180e0e87858,"```python
972
+ # solution
973
+ ```"
974
+ cf-df0dc437c0fbbdeb,"```python
975
+ # solution
976
+ ```"
977
+ cf-73e865e4391e99f0,"```python
978
+ # solution
979
+ ```"
980
+ cf-7e8845d65ed86a24,"```python
981
+ # solution
982
+ ```"
983
+ cf-d512d677498083dd,"```python
984
+ # solution
985
+ ```"
986
+ cf-a4dc6a5905b6f0a7,"```python
987
+ # solution
988
+ ```"
989
+ cf-9f6d0188dbcd667c,"```python
990
+ # solution
991
+ ```"
992
+ cf-ad3dd8ea8e119aa8,"```python
993
+ # solution
994
+ ```"
995
+ cf-281938abb20c7d61,"```python
996
+ # solution
997
+ ```"
998
+ cf-d667316e2d79898f,"```python
999
+ # solution
1000
+ ```"
1001
+ cf-f95b769319395f3e,"```python
1002
+ # solution
1003
+ ```"
1004
+ cf-07291d50bf76371a,"```python
1005
+ # solution
1006
+ ```"
1007
+ cf-aefaed1c66d42f67,"```python
1008
+ # solution
1009
+ ```"
1010
+ cf-2efb650f65bf54c1,"```python
1011
+ # solution
1012
+ ```"
1013
+ cf-eb056907043004f5,"```python
1014
+ # solution
1015
+ ```"
1016
+ cf-69860e572ae76e65,"```python
1017
+ # solution
1018
+ ```"
1019
+ cf-f167a4c521d758ef,"```python
1020
+ # solution
1021
+ ```"
1022
+ cf-04ab4db50fee9878,"```python
1023
+ # solution
1024
+ ```"
1025
+ cf-a20b0f12afdb98d1,"```python
1026
+ # solution
1027
+ ```"
1028
+ cf-096ac99dd6272319,"```python
1029
+ # solution
1030
+ ```"
1031
+ cf-76e6da6b6bf3d9eb,"```python
1032
+ # solution
1033
+ ```"
1034
+ cf-7ef1f384d514abab,"```python
1035
+ # solution
1036
+ ```"
1037
+ cf-16bd8fc76704aa81,"```python
1038
+ # solution
1039
+ ```"
1040
+ cf-dc923558da033b1c,"```python
1041
+ # solution
1042
+ ```"
1043
+ cf-7c13dfa0ef352a16,"```python
1044
+ # solution
1045
+ ```"
1046
+ cf-c98fee3bc1536f4e,"```python
1047
+ # solution
1048
+ ```"
1049
+ cf-d65b9cb01a214927,"```python
1050
+ # solution
1051
+ ```"
1052
+ cf-9de31a6b4b6c49e1,"```python
1053
+ # solution
1054
+ ```"
1055
+ cf-4af7a96237e05e2b,"```python
1056
+ # solution
1057
+ ```"
1058
+ cf-a4f2e07ca1096000,"```python
1059
+ # solution
1060
+ ```"
1061
+ cf-13dfdd9a1d14bc2f,"```python
1062
+ # solution
1063
+ ```"
1064
+ cf-25378698aa2a5f89,"```python
1065
+ # solution
1066
+ ```"
1067
+ cf-536c180a69717c33,"```python
1068
+ # solution
1069
+ ```"
1070
+ cf-045a216da08d07f3,"```python
1071
+ # solution
1072
+ ```"
1073
+ cf-f64a6806bfedd6a7,"```python
1074
+ # solution
1075
+ ```"
1076
+ cf-8b1215cf044e376e,"```python
1077
+ # solution
1078
+ ```"
1079
+ cf-8ab490bf85751d6a,"```python
1080
+ # solution
1081
+ ```"
1082
+ cf-f0a263534d579fe0,"```python
1083
+ # solution
1084
+ ```"
1085
+ cf-f533054f83e34460,"```python
1086
+ # solution
1087
+ ```"
1088
+ cf-1668e0321983a6ae,"```python
1089
+ # solution
1090
+ ```"
1091
+ cf-8720db27d7cd975a,"```python
1092
+ # solution
1093
+ ```"
1094
+ cf-292ab5a75e2207ef,"```python
1095
+ # solution
1096
+ ```"
1097
+ cf-61b2729dbba80f00,"```python
1098
+ # solution
1099
+ ```"
1100
+ cf-d5deaceac78834a9,"```python
1101
+ # solution
1102
+ ```"
1103
+ cf-03d5b1dd2e52eb5b,"```python
1104
+ # solution
1105
+ ```"
1106
+ cf-8f8bd06f486e8d1c,"```python
1107
+ # solution
1108
+ ```"
1109
+ cf-20b318abdf7ae6d9,"```python
1110
+ # solution
1111
+ ```"
1112
+ cf-32977146b46780d6,"```python
1113
+ # solution
1114
+ ```"
1115
+ cf-c7d80a8a8df85cd6,"```python
1116
+ # solution
1117
+ ```"
1118
+ cf-e51817fc02f9f753,"```python
1119
+ # solution
1120
+ ```"
1121
+ cf-45e99b03d772395c,"```python
1122
+ # solution
1123
+ ```"
1124
+ cf-246910d3d3940676,"```python
1125
+ # solution
1126
+ ```"
1127
+ cf-deb17639a6b2b215,"```python
1128
+ # solution
1129
+ ```"
1130
+ cf-6658c2b63bd7a06b,"```python
1131
+ # solution
1132
+ ```"
1133
+ cf-bc8d0c3f3a71c6b8,"```python
1134
+ # solution
1135
+ ```"
1136
+ cf-fb6a192dbcaa9a01,"```python
1137
+ # solution
1138
+ ```"
1139
+ cf-af2def7b035bf294,"```python
1140
+ # solution
1141
+ ```"
1142
+ cf-ed181f91c348aa5d,"```python
1143
+ # solution
1144
+ ```"
1145
+ cf-f5920212ad402b18,"```python
1146
+ # solution
1147
+ ```"
1148
+ cf-2a0e1ce2ca1fc740,"```python
1149
+ # solution
1150
+ ```"
1151
+ cf-2915154b1688e74a,"```python
1152
+ # solution
1153
+ ```"
1154
+ cf-4e32f442e57c2a77,"```python
1155
+ # solution
1156
+ ```"
1157
+ cf-010ecd306c4e0a9f,"```python
1158
+ # solution
1159
+ ```"
1160
+ cf-ce04106a30b8ac00,"```python
1161
+ # solution
1162
+ ```"
1163
+ cf-957b94809727ae81,"```python
1164
+ # solution
1165
+ ```"
1166
+ cf-ad33e1233cd4c342,"```python
1167
+ # solution
1168
+ ```"
1169
+ cf-d5491a1f34bd4b65,"```python
1170
+ # solution
1171
+ ```"
1172
+ cf-bc4af4d11e791351,"```python
1173
+ # solution
1174
+ ```"
1175
+ cf-0de916666c619ddf,"```python
1176
+ # solution
1177
+ ```"
1178
+ cf-2b49b989c0a12b12,"```python
1179
+ # solution
1180
+ ```"
1181
+ cf-a8b24e975163e76d,"```python
1182
+ # solution
1183
+ ```"
1184
+ cf-355edd46e49305a6,"```python
1185
+ # solution
1186
+ ```"
1187
+ cf-5f35ca6cc5422f64,"```python
1188
+ # solution
1189
+ ```"
1190
+ cf-86515d2a498d71a5,"```python
1191
+ # solution
1192
+ ```"
1193
+ cf-56de34d27bf720f6,"```python
1194
+ # solution
1195
+ ```"
1196
+ cf-173f76cf8bfaef3b,"```python
1197
+ # solution
1198
+ ```"
1199
+ cf-996e5eed51fcd7b6,"```python
1200
+ # solution
1201
+ ```"
1202
+ cf-17e1fa836091feb2,"```python
1203
+ # solution
1204
+ ```"
1205
+ cf-c59ddc4c20e3d5e6,"```python
1206
+ # solution
1207
+ ```"
1208
+ cf-fe1630ecb3faa5a3,"```python
1209
+ # solution
1210
+ ```"
1211
+ cf-b5ce86eaa1b00bf4,"```python
1212
+ # solution
1213
+ ```"
1214
+ cf-0ad302842053c28d,"```python
1215
+ # solution
1216
+ ```"
1217
+ cf-e48325d6d4340252,"```python
1218
+ # solution
1219
+ ```"
1220
+ cf-becab5c5e88a3441,"```python
1221
+ # solution
1222
+ ```"
1223
+ cf-554cbdf43b3fb726,"```python
1224
+ # solution
1225
+ ```"