def next_power_of_two(n):
    """
    Return next power of 2 greater than or equal to n
    """
    n -= 1
    shift = 1
    while n + 1 & n:
        n |= n >> shift
        shift *= 2
    return n + 1
