





def 							lowerCAmelCase_				(    A_):

    # validate:
    if not isinstance(A_  ,A_) or not all(
        isinstance(A_  ,A_) and item >= 0 for item in citations):
        raise ValueError("The citations should be a list of non negative integers.")

    citations.sort()
    UpperCamelCase__:					str												=      len(A_)

    for i in range(A_):
        if citations[len_citations - 1 - i] <= i:
            return i

    return len_citations


if __name__ == "__main__":
   import doctest

   doctest.testmod()








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()

