from collections import defaultdict def part_1(data): regs = defaultdict(int) allmax = 0 for line in data.splitlines(): match line.split(): case [reg_a, op, value, "if", reg_c, cmp, val_c]: value, val_c = int(value), int(val_c) reg_val = regs[reg_c] if eval(f"{reg_val} {cmp} {val_c}"): value = value if op == "inc" else -value regs[reg_a] += value case _: assert False allmax = max(max(regs.values()), allmax) print(max(regs.values())) print(allmax) def main(): data = open(0).read().strip() part_1(data) if __name__ == "__main__": main()