

'''simple docstring'''





def 							_lowerCAmelCase (      __magic_name__	:    Any      ,   __magic_name__	:    Optional[int]      ,   __magic_name__	:    List[str]      ,   __magic_name__	:    str	)							->     str:
						global f  # a global dp table for knapsack
						if f[i][j] < 0:
												if j < wt[i - 1]:
																		lowercase   :       Tuple								=mf_knapsack(i - 1      ,   __magic_name__      ,   __magic_name__      ,   __magic_name__	)
												else:
																		lowercase   :       Optional[Any]								=max(
																		    mf_knapsack(i - 1      ,   __magic_name__      ,   __magic_name__      ,   __magic_name__	)      ,   mf_knapsack(i - 1      ,   __magic_name__      ,   __magic_name__      ,   j - wt[i - 1]	) + val[i - 1]      ,   )
												lowercase   :       Union[str, Any]								=val
						return f[i][j]






def 							_lowerCAmelCase (      __magic_name__	:    str      ,   __magic_name__	:    List[Any]      ,   __magic_name__	:    Optional[Any]      ,   __magic_name__	:    Dict	)							->     int:
						lowercase   :       str								=[[0] * (w + 1) for _ in range(n + 1	)]

						for i in range(1      ,   n + 1	):
												for w_ in range(1      ,   w + 1	):
																		if wt[i - 1] <= w_:
																								lowercase   :       Dict								=max(val[i - 1] + dp[i - 1][w_ - wt[i - 1]]      ,   dp[i - 1][w_]	)
																		else:
																								lowercase   :       Optional[int]								=dp[i - 1][w_]

						return dp[n][w_], dp






def 							_lowerCAmelCase (      __magic_name__	:    int      ,   __magic_name__	:    list      ,   __magic_name__	:    list	)							->     List[str]:
						if not (isinstance(__magic_name__      ,   (list, tuple)	) and isinstance(__magic_name__      ,   (list, tuple)	)):
												raise ValueError(
												    '''Both the weights and values vectors must be either lists or tuples'''	)

						lowercase   :       Any								=len(__magic_name__	)
						if num_items != len(__magic_name__	):
												lowercase   :       Dict								=(
												    '''The number of weights must be the same as the number of values.\n'''
												    f'''But got {num_items} weights and {len(__magic_name__	)} values'''
												)
												raise ValueError(__magic_name__	)
						for i in range(__magic_name__	):
												if not isinstance(wt[i]      ,   __magic_name__	):
																		lowercase   :       str								=(
																		    '''All weights must be integers but got weight of '''
																		    f'''type {type(wt[i]	)} at index {i}'''
																		)
																		raise TypeError(__magic_name__	)

						lowercase		,  lowercase   :       Tuple								=knapsack(__magic_name__      ,   __magic_name__      ,   __magic_name__      ,   __magic_name__	)
						lowercase   :       set								=set()
						_construct_solution(__magic_name__      ,   __magic_name__      ,   __magic_name__      ,   __magic_name__      ,   __magic_name__	)

						return optimal_val, example_optional_set






def 							_lowerCAmelCase (      __magic_name__	:    list      ,   __magic_name__	:    list      ,   __magic_name__	:    int      ,   __magic_name__	:    int      ,   __magic_name__	:    set	)							->     Optional[Any]:
						# for the current item i at a maximum weight j to be part of an optimal subset,
						# the optimal value at (i, j) must be greater than the optimal value at (i-1, j).
						# where i - 1 means considering only the previous items at the given maximum weight
						if i > 0 and j > 0:
												if dp[i - 1][j] == dp[i][j]:
																		_construct_solution(__magic_name__      ,   __magic_name__      ,   i - 1      ,   __magic_name__      ,   __magic_name__	)
												else:
																		optimal_set.add(__magic_name__	)
																		_construct_solution(__magic_name__      ,   __magic_name__      ,   i - 1      ,   j - wt[i - 1]      ,   __magic_name__	)


if __name__ == "__main__":
							UpperCamelCase_							=					[3, 2, 4, 4]
							UpperCamelCase_							=					[4, 3, 2, 3]
							UpperCamelCase_							=					4
							UpperCamelCase_							=					6
							UpperCamelCase_							=					[[0] * (w + 1)] + [[0] + [-1] * (w + 1) for _ in range(n + 1)]
							UpperCamelCase_	,      UpperCamelCase_							=					knapsack(w, wt, val, n)
							print(optimal_solution)
							print(mf_knapsack(n, wt, val, w))  # switched the n and w

							# testing the dynamic programming problem with example
							# the optimal subset for the above example are items 3 and 4
							UpperCamelCase_	,      UpperCamelCase_							=					knapsack_with_example_solution(w, wt, val)
							assert optimal_solution == 8
							assert optimal_subset == {3, 4}
							print("""optimal_value = """, optimal_solution)
							print("""An optimal subset corresponding to the optimal value""", optimal_subset)








'''simple docstring'''





from collections import defaultdict






def 							_lowerCAmelCase (      __magic_name__	:    str      ,   __magic_name__	:    str	)							->     bool:
						lowercase   :       Optional[int]								=first_str.lower().strip()
						lowercase   :       Union[str, Any]								=second_str.lower().strip()

						# Remove whitespace
						lowercase   :       Optional[int]								=first_str.replace(''' '''      ,   ''''''	)
						lowercase   :       Optional[Any]								=second_str.replace(''' '''      ,   ''''''	)

						# Strings of different lengths are not anagrams
						if len(__magic_name__	) != len(__magic_name__	):
												return False

						# Default values for count should be 0
						lowercase   :       defaultdict[str, int]								=defaultdict(__magic_name__	)

						# For each character in input strings,
						# increment count in the corresponding
						for i in range(len(__magic_name__	)	):
												count[first_str[i]] += 1
												count[second_str[i]] -= 1

						return all(_count == 0 for _count in count.values()	)


if __name__ == "__main__":
							from doctest import testmod

							testmod()
							UpperCamelCase_							=					input("""Enter the first string """).strip()
							UpperCamelCase_							=					input("""Enter the second string """).strip()

							UpperCamelCase_							=					check_anagrams(input_a, input_b)
							print(f'''{input_a} and {input_b} are {'' if status else 'not '}anagrams.''')





