for A in range(1, 1_000): ok = True for x in range(1_000): for y in range(1_000): f = (3*x + y < A) or (x < y) or (16 <= x) if not f: ok = False break if not ok: break if ok: print(A) break