





from __future__ import annotations



def 							lowerCAmelCase_				(    A_  ,A_):
    UpperCamelCase__:					List[str]												=      0
    UpperCamelCase__:					Optional[int]												=      len(A_) - 1
    while left <= right:
        UpperCamelCase__:					List[str]												=      (left + right) // 2
        if left == right:
            if sorted_list[middle] < item:
                UpperCamelCase__:					Optional[Any]												=      middle + 1
            break
        elif sorted_list[middle] < item:
            UpperCamelCase__:					Any												=      middle + 1
        else:
            UpperCamelCase__:					List[Any]												=      middle - 1
    sorted_list.insert(A_  ,A_)
    return sorted_list



def 							lowerCAmelCase_				(    A_  ,A_):
    UpperCamelCase__:					List[str]												=      []
    while left and right:
        if left[0][0] < right[0][0]:
            result.append(left.pop(0))
        else:
            result.append(right.pop(0))
    return result + left + right



def 							lowerCAmelCase_				(    A_):
    UpperCamelCase__:					Any												=      len(A_)
    if length <= 1:
        return list_ad
    UpperCamelCase__:					Optional[Any]												=      length // 2
    return merge(sortlist_ad(list_ad[:middle])  ,sortlist_ad(list_ad[middle:]))



def 							lowerCAmelCase_				(    A_):

    if len(A_) <= 1:
        return collection
    UpperCamelCase__:					Tuple												=      []
    UpperCamelCase__:					Tuple												=      False
    for i in range(0  ,len(A_)  ,2):
        if i == len(A_) - 1:
            UpperCamelCase__:					Any												=      True
        else:
            if collection[i] < collection[i + 1]:
                two_paired_list.append([collection[i], collection[i + 1]])
            else:
                two_paired_list.append([collection[i + 1], collection[i]])
    UpperCamelCase__:					str												=      sortlist_ad(A_)
    UpperCamelCase__:					Tuple												=      [i[0] for i in sorted_list_ad]
    result.append(sorted_list_ad[-1][1])
    if has_last_odd_item:
        UpperCamelCase__:					int												=      collection[-1]
        UpperCamelCase__:					Union[str, Any]												=      binary_search_insertion(A_  ,A_)
    UpperCamelCase__:					int												=      False
    for i in range(len(A_) - 1):
        if result[i] == collection[-1] and has_last_odd_item:
            UpperCamelCase__:					List[str]												=      True
        UpperCamelCase__:					Union[str, Any]												=      sorted_list_ad[i][1]
        # If last_odd_item is inserted before the item's index,
        # you should forward index one more.
        if is_last_odd_item_inserted_before_this_index:
            UpperCamelCase__:					Optional[int]												=      result[: i + 2] + binary_search_insertion(result[i + 2 :]  ,A_)
        else:
            UpperCamelCase__:					Union[str, Any]												=      result[: i + 1] + binary_search_insertion(result[i + 1 :]  ,A_)

    return result


if __name__ == "__main__":
      A__:  str       					=					input('''Enter numbers separated by a comma:\n''').strip()
      A__:  Dict       					=					[int(item) for item in user_input.split(''',''')]
      print(merge_insertion_sort(unsorted))








from __future__ import annotations

from PIL import Image

# Define the first generation of cells
# fmt: off
A__:  Tuple       					=					[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]



def 							lowerCAmelCase_				(    A_):
    return [int(A_) for c in F"{ruleset:08}"[:8]]



def 							lowerCAmelCase_				(    A_  ,A_  ,A_):
    UpperCamelCase__:					List[str]												=      len(cells[0])  # 31
    UpperCamelCase__:					Union[str, Any]												=      []
    for i in range(A_):
        # Get the neighbors of each cell
        # Handle neighbours outside bounds by using 0 as their value
        UpperCamelCase__:					str												=      0 if i == 0 else cells[time][i - 1]
        UpperCamelCase__:					Union[str, Any]												=      0 if i == population - 1 else cells[time][i + 1]
        # Define a new cell and add it to the new generation
        UpperCamelCase__:					List[Any]												=      7 - int(F"{left_neighbor}{cells[time][i]}{right_neighbor}"  ,2)
        next_generation.append(rule[situation])
    return next_generation



def 							lowerCAmelCase_				(    A_):
    UpperCamelCase__:					int												=      Image.new("RGB"  ,(len(cells[0]), len(A_)))
    UpperCamelCase__:					Dict												=      img.load()
    # Generates image
    for w in range(img.width):
        for h in range(img.height):
            UpperCamelCase__:					List[str]												=      2_55 - int(2_55 * cells[h][w])
            UpperCamelCase__:					Union[str, Any]												=      (color, color, color)
    return img


if __name__ == "__main__":
   A__:  Any       					=					bin(int(input('''Rule:\n''').strip()))[2:]
   A__:  Dict       					=					format_ruleset(int(rule_num))
   for time in range(16):
      CELLS.append(new_generation(CELLS, rule, time))
   A__:  int       					=					generate_image(CELLS)
   # Uncomment to save the image
   # img.save(f"rule_{rule_num}.png")
   img.show()

