def distances(left: list[int], right: list[int]) -> list[int]: left, right = sorted(left), sorted(right) return [abs(l-r) for l, r in zip(left, right)] if __name__ == '__main__': with open('1.input') as file: left, right = [], [] for line in file: l, r = line.split() l, r = int(l), int(r) left.append(l) right.append(r) print(sum(distances(left, right)))