import subprocess import sys from pathlib import Path cases = [{'input': '5\n5 -3 3 -1 1\n', 'output': '8 7\n'}, {'input': '10\n4 2 -4 3 1 2 -4 3 2 3\n', 'output': '28 27\n'}, {'input': '5\n-1 -2 -3 -4 -5\n', 'output': '9 6\n'}, {'input': '1\n1761402\n', 'output': '0 1\n'}, {'input': '1\n1\n', 'output': '0 1\n'}, {'input': '1\n-648613522\n', 'output': '1 0\n'}, {'input': '2\n-837247075 -925321573\n', 'output': '2 1\n'}, {'input': '2\n1 -42205445\n', 'output': '2 1\n'}, {'input': '2\n1 1\n', 'output': '0 3\n'}, {'input': '2\n-703630698 870277542\n', 'output': '2 1\n'}, {'input': '2\n1 753393670\n', 'output': '0 3\n'}, {'input': '2\n665876657 284761489\n', 'output': '0 3\n'}, {'input': '10\n-27433367 -21216390 1 303383863 -799030648 -1 160141051 -1 -342089574 -215298491\n', 'output': '28 27\n'}, {'input': '2\n1000000000 -1000000000\n', 'output': '2 1\n'}, {'input': '5\n1 1 1 1 1\n', 'output': '0 15\n'}, {'input': '3\n1 1000000000 -1\n', 'output': '3 3\n'}, {'input': '3\n-1000000000 2 -2\n', 'output': '4 2\n'}, {'input': '1\n-11\n', 'output': '1 0\n'}, {'input': '2\n-1 1\n', 'output': '2 1\n'}, {'input': '2\n3 -1\n', 'output': '2 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')