import subprocess import sys from pathlib import Path cases = [{'input': '5\n1 1 1 1\n1 -1 -1 -1 -1\n', 'output': '1\n'}, {'input': '5\n1 2 3 1\n1 -1 2 -1 -1\n', 'output': '2\n'}, {'input': '3\n1 2\n2 -1 1\n', 'output': '-1\n'}, {'input': '2\n1\n0 -1\n', 'output': '0\n'}, {'input': '2\n1\n1 -1\n', 'output': '1\n'}, {'input': '5\n1 2 2 3\n1 -1 2 3 -1\n', 'output': '3\n'}, {'input': '5\n1 2 3 4\n5 -1 5 -1 7\n', 'output': '7\n'}, {'input': '10\n1 1 1 1 2 3 4 5 1\n3 -1 -1 -1 -1 3 3 3 3 -1\n', 'output': '3\n'}, {'input': '10\n1 1 2 4 4 5 6 3 3\n0 -1 -1 0 -1 -1 1 2 3 4\n', 'output': '7\n'}, {'input': '10\n1 2 3 4 4 3 3 8 8\n1 -1 1 -1 1 1 -1 -1 2 2\n', 'output': '2\n'}, {'input': '25\n1 2 1 4 4 4 1 2 8 5 1 8 1 6 9 6 10 10 7 10 8 17 14 6\n846 -1 941 -1 1126 1803 988 -1 1352 1235 -1 -1 864 -1 -1 -1 -1 -1 -1 -1 -1 1508 1802 1713 -1\n', 'output': '-1\n'}] solution = Path(__file__).with_name("solution.py") for index, case in enumerate(cases): proc = subprocess.run( [sys.executable, str(solution)], input=case["input"], text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=10, ) if proc.returncode != 0: raise AssertionError(f"case {index} exited {proc.returncode}: {proc.stderr}") got = proc.stdout.strip() expected = case["output"].strip() if got.split() != expected.split(): raise AssertionError( f"case {index} output mismatch\nexpected={expected!r}\ngot={got!r}\nstderr={proc.stderr}" ) print('deepcoder_primeintellect_io')