
"""simple docstring"""






import timeit

class 				__a    :



							'''simple docstring'''







							def __init__(    self     ,						_lowerCamelCase					) ->       Optional[int]:




										'''simple docstring'''
										if isinstance(_lowerCamelCase     ,						_lowerCamelCase					):  # Initializes a matrix identical to the one provided.
													__lowercase						      =					arg
													__lowercase						      =					len(_lowerCamelCase					)
										else:  # Initializes a square matrix of the given size and set values to zero.
													__lowercase						      =					arg
													__lowercase						      =					[[0 for _ in range(self.n					)] for _ in range(self.n					)]





							def __mul__(    self     ,						_lowerCamelCase					) ->       List[str]:




										'''simple docstring'''
										__lowercase						      =					Matrix(self.n					)
										for i in range(self.n					):
													for j in range(self.n					):
																for k in range(self.n					):
																			matrix.t[i][j] += self.t[i][k] * b.t[k][j]
										return matrix





def     lowerCAmelCase__ (		__magic_name__ ,      __magic_name__			)	->Tuple:
			__lowercase						      =					Matrix([[1, 0], [0, 1]]			)
			while b > 0:
						if b & 1:
									matrix *= a
						a *= a
						b >>= 1
			return matrix





def     lowerCAmelCase__ (		__magic_name__ ,      __magic_name__ ,      __magic_name__			)	->int:
			# Trivial Cases
			if n == 1:
						return fa
			elif n == 2:
						return fa
			__lowercase						      =					Matrix([[1, 1], [1, 0]]			)
			__lowercase						      =					modular_exponentiation(__magic_name__ ,      n - 2			)
			return fa * matrix.t[0][0] + fa * matrix.t[0][1]





def     lowerCAmelCase__ (		__magic_name__ ,      __magic_name__ ,      __magic_name__			)	->int:
			# Trivial Cases
			if n == 1:
						return fa
			elif n == 2:
						return fa

			__lowercase						      =					fa
			__lowercase						      =					fa
			n -= 2

			while n > 0:
						__lowercase      ,				__lowercase						      =					fn_a + fn_a, fn_a
						n -= 1

			return fn_a





def     lowerCAmelCase__ (		)	->str:
			__lowercase						      =					"\nfrom random import randint\nfrom __main__ import fibonacci_with_matrix_exponentiation\n"
			__lowercase						      =					"fibonacci_with_matrix_exponentiation(randint(1,70000), 1, 1)"
			__lowercase						      =					timeit.timeit(setup=__magic_name__ ,      stmt=__magic_name__ ,      number=1_0_0			)
			print("With matrix exponentiation the average execution time is " ,      exec_time / 1_0_0			)
			return exec_time





def     lowerCAmelCase__ (		)	->Optional[Any]:
			__lowercase						      =					"\nfrom random import randint\nfrom __main__ import simple_fibonacci\n"
			__lowercase						      =					"simple_fibonacci(randint(1,70000), 1, 1)"
			__lowercase						      =					timeit.timeit(setup=__magic_name__ ,      stmt=__magic_name__ ,      number=1_0_0			)
			print(
			    "Without matrix exponentiation the average execution time is " ,      exec_time / 1_0_0			)
			return exec_time





def     lowerCAmelCase__ (		)	->Optional[int]:
			matrix_exponentiation_time()
			simple_fibonacci_time()


if __name__ == "__main__":
					main()







"""simple docstring"""






import os



def     lowerCAmelCase__ (		)	->Tuple:
			__lowercase						      =					0
			__lowercase						      =					0
			with open(os.path.dirname(__magic_name__			) + "/p022_names.txt"			) as file:
						__lowercase						      =					str(file.readlines()[0]			)
						__lowercase						      =					name.replace("\"" ,      ""			).split(","			)

			name.sort()
			for i in range(len(__magic_name__			)			):
						for j in name[i]:
									temp_sum += ord(__magic_name__			) - ord("A"			) + 1
						total_sum += (i + 1) * temp_sum
						__lowercase						      =					0
			return total_sum


if __name__ == "__main__":
					print(solution())





