def optimize_delete(s): stack = [] for char in s: if not stack or stack[-1] != char: stack.append(char) else: stack.pop() return '0' if not stack else ''.join(stack) s = input() print(optimize_delete(s))
def optimize_delete(s): stack = [] for char in s: if not stack or stack[-1] != char: stack.append(char) else: stack.pop() return '0' if not stack else ''.join(stack) s = input() print(optimize_delete(s))