def bin_search(ok, ng, is_ok): while abs(ok-ng) > 1: mid = (ok+ng)//2 if is_ok(mid): ok = mid else: ng = mid return ok def solve(N, X, C): INF = float("INF") def is_good(range_, C): start, stop = range_ for c in C: m = start + ((1<>c)&1 == 0 and stop <= m: return False return True S = set(C) pos = X tovisit = [] while True: found = [] for c in S: if pos&(1<