


import random
import sys

import numpy as np
from matplotlib import pyplot as plt
from matplotlib.colors import ListedColormap

lowerCAmelCase	=							'Usage of script: script_name <size_of_canvas:int>'

lowerCAmelCase	=							[0] * 100 + [1] * 10
random.shuffle(choice)
def       _a			(				SCREAMING_SNAKE_CASE					):


		"""simple docstring"""




		lowercase__						=				[[False for i in range(SCREAMING_SNAKE_CASE					)] for j in range(SCREAMING_SNAKE_CASE					)]
		return canvas
def       _a			(				SCREAMING_SNAKE_CASE					):


		"""simple docstring"""




		for i, row in enumerate(SCREAMING_SNAKE_CASE					):
				for j, _ in enumerate(SCREAMING_SNAKE_CASE					):
						lowercase__						=				bool(random.getrandbits(1					)					)
def       _a			(				SCREAMING_SNAKE_CASE					):


		"""simple docstring"""




		lowercase__						=				np.array(SCREAMING_SNAKE_CASE					)
		lowercase__						=				np.array(create_canvas(current_canvas.shape[0]					)					)
		for r, row in enumerate(SCREAMING_SNAKE_CASE					):
				for c, pt in enumerate(SCREAMING_SNAKE_CASE					):
						lowercase__						=				__judge_point(
						    SCREAMING_SNAKE_CASE						,    current_canvas[r - 1 : r + 2, c - 1 : c + 2]					)

		lowercase__						=				next_gen_canvas
		del next_gen_canvas  # cleaning memory as we move on.
		lowercase__						=				current_canvas.tolist()
		return return_canvas
def       _a			(				SCREAMING_SNAKE_CASE						,    SCREAMING_SNAKE_CASE					):


		"""simple docstring"""




		lowercase__						=				0
		lowercase__						=				0
		# finding dead or alive neighbours count.
		for i in neighbours:
				for status in i:
						if status:
								alive += 1
						else:
								dead += 1

    # handling duplicate entry for focus pt.
		if pt:
				alive -= 1
		else:
				dead -= 1

		# running the rules of game here.
		lowercase__						=				pt
		if pt:
				if alive < 2:
						lowercase__						=				False
				elif alive == 2 or alive == 3:
						lowercase__						=				True
				elif alive > 3:
						lowercase__						=				False
		else:
				if alive == 3:
						lowercase__						=				True

		return state


if __name__ == "__main__":
			if len(sys.argv) != 2:
						raise Exception(usage_doc)

			lowerCAmelCase	=							int(sys.argv[1])
			# main working structure of this module.
			lowerCAmelCase	=							create_canvas(canvas_size)
			seed(c)
			lowerCAmelCase,						lowerCAmelCase	=							plt.subplots()
			fig.show()
			lowerCAmelCase	=							ListedColormap(['w', 'k'])
			try:
						while True:
									lowerCAmelCase	=							run(c)
									ax.matshow(c, cmap=cmap)
									fig.canvas.draw()
									ax.cla()
			except KeyboardInterrupt:
						# do nothing.
						pass






lowerCAmelCase	=							[sum(int(c, 10) ** 2 for c in i.__str__()) for i in range(10_0000)]
def       _a			(				SCREAMING_SNAKE_CASE					):


		"""simple docstring"""




		lowercase__						=				0
		while number:
				# Increased Speed Slightly by checking every 5 digits together.
				sum_of_digits_squared += DIGITS_SQUARED[number % 10_00_00]
				number //= 10_00_00

		return sum_of_digits_squared


# There are 2 Chains made,
# One ends with 89 with the chain member 58 being the one which when declared first,
# there will be the least number of iterations for all the members to be checked.

# The other one ends with 1 and has only one element 1.

# So 58 and 1 are chosen to be declared at the starting.

# Changed dictionary to an array to quicken the solution
lowerCAmelCase	=							[None] * 1000_0000
lowerCAmelCase	=							True
lowerCAmelCase	=							False
def       _a			(				SCREAMING_SNAKE_CASE					):


		"""simple docstring"""




		if CHAINS[number - 1] is not None:
				return CHAINS[number - 1]  # type: ignore

		lowercase__						=				chain(next_number(SCREAMING_SNAKE_CASE					)					)
		lowercase__						=				number_chain

		while number < 10_00_00_00:
				lowercase__						=				number_chain
				number *= 10

		return number_chain
def       _a			(				SCREAMING_SNAKE_CASE = 10_00_00_00					):


		"""simple docstring"""




		for i in range(1						,    SCREAMING_SNAKE_CASE					):
				if CHAINS[i] is None:
						chain(i + 1					)

		return CHAINS[:number].count(SCREAMING_SNAKE_CASE					)


if __name__ == "__main__":
			import doctest

			doctest.testmod()
			print(f"""{solution() = }""")


