def next_pow2(n):
 if (n <= 0):
  return 1
 n2 = (1 << n.bit_length())
 if ((n2 >> 1) == n):
  return n
 else:
  return n2

def next_pow2 ( n ) : if ( n <= 0 ) : return 1 n2 = ( 1 << n . bit_length ( ) ) if ( ( n2 >> 1 ) == n ) : return n else : return n2
return first power of 2 >= n .