# Custom checker of the pair task: accepts any two distinct 1-based # positions whose values add up to the target. Exit 0 accepts, 1 rejects. import sys with open(sys.argv[1]) as stream: lines = stream.read().split("\n") with open(sys.argv[3]) as stream: answer = stream.read().split() target = int(lines[0]) values = [int(token) for token in lines[1].split()] try: first, second = (int(token) for token in answer) except ValueError: sys.exit(1) valid = 1 <= first <= len(values) and 1 <= second <= len(values) and first != second sys.exit(0 if valid and values[first - 1] + values[second - 1] == target else 1)