def pow2_ru(n):
    """Given an integer >= 1, return the next power of 2 >= to n."""
    assert n <= 2 ** 31
    n -= 1
    n |= n >> 1
    n |= n >> 2
    n |= n >> 4
    n |= n >> 8
    n |= n >> 16
    n += 1
    return n