
'''simple docstring'''







from __future__ import annotations

from PIL import Image

# Define the first generation of cells
# fmt: off
_lowercase				:						List[str]												= [[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       snake_case_	(       __SCREAMING_SNAKE_CASE      :				int							):



						"""simple docstring"""





						return [int(__SCREAMING_SNAKE_CASE							) for c in F'''{ruleset:08}'''[:8]]
def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				list[list[int]]   ,   __SCREAMING_SNAKE_CASE      :				list[int]   ,   __SCREAMING_SNAKE_CASE      :				int							):



						"""simple docstring"""





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



						"""simple docstring"""





						lowercase_			:  Tuple									= Image.new('''RGB'''   ,   (len(cells[0]							), len(__SCREAMING_SNAKE_CASE							))							)
						lowercase_			:  List[str]									= img.load()
						# Generates image
						for w in range(img.width							):
												for h in range(img.height							):
																		lowercase_			:  Tuple									= 255 - int(255 * cells[h][w]							)
																		lowercase_			:  Optional[Any]									= (color, color, color)
						return img


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





'''simple docstring'''







from itertools import combinations, product
def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				int   ,   __SCREAMING_SNAKE_CASE      :				int   ,   __SCREAMING_SNAKE_CASE      :				int   ,   __SCREAMING_SNAKE_CASE      :				int							):



						"""simple docstring"""





						if xa == ya == 0 or xa == ya == 0:
												return False
						lowercase_			:  Optional[Any]									= xa * xa + ya * ya
						lowercase_			:  List[str]									= xa * xa + ya * ya
						lowercase_			:  Any									= (xa - xa) * (xa - xa) + (ya - ya) * (ya - ya)
						return (
						    a_square + b_square == c_square
						    or a_square + c_square == b_square
						    or b_square + c_square == a_square
						)
def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				int = 50							):



						"""simple docstring"""





						return sum(
						    1
						    for pta, pta in combinations(product(range(limit + 1							)   ,   repeat=2							)   ,   2							)
						    if is_right(*__SCREAMING_SNAKE_CASE   ,   *__SCREAMING_SNAKE_CASE							)							)


if __name__ == "__main__":
							print(f"""{solution() = }""")



