
    Given a user's current number of social connections, determine the minimum network capacity (which must be a power of 2) needed to efficiently process friend recommendations in a single batch. This capacity should be large enough to accommodate all existing connections while allowing for optimal memory allocation in the recommendation system.
    

    
def next_power_of_2(n):
    """
    Given a user's current number of social connections, determine the minimum network capacity (which must be a power of 2) needed to efficiently process friend recommendations in a single batch. This capacity should be large enough to accommodate all existing connections while allowing for optimal memory allocation in the recommendation system.
    

    """
def next_power_of_2(n):
    """
    Given a user's current number of social connections, determine the minimum network capacity (which must be a power of 2) needed to efficiently process friend recommendations in a single batch. This capacity should be large enough to accommodate all existing connections while allowing for optimal memory allocation in the recommendation system.
    

    """
    if n and (not n & n - 1):
        return n
    count = 0
    while n != 0:
        n >>= 1
        count += 1
    return 1 << count