


from collections import Counter
from timeit import timeit






def 	__lowerCamelCase						(							lowerCamelCase__		:						str = ""  ,							):





			'''simple docstring'''




			return sum(c % 2 for c in Counter(input_str.replace(""" """  ,							""""""      ).lower()      ).values()      ) < 2






def 	__lowerCamelCase						(							lowerCamelCase__		:						str = ""      ):





			'''simple docstring'''




			if len(lowerCamelCase__      ) == 0:
						return True
			lowerCamelCase    		=  input_str.replace(""" """  ,							""""""      ).lower()
			# character_freq_dict: Stores the frequency of every character in the input string
			lowerCamelCase    		=  {}

			for character in lower_case_input_str:
						lowerCamelCase    		=  character_freq_dict.get(lowerCamelCase__  ,							0      ) + 1
			lowerCamelCase    		=  0

			for character_count in character_freq_dict.values():
						if character_count % 2:
									odd_char += 1
			if odd_char > 1:
						return False
			return True






def 	__lowerCamelCase						(							lowerCamelCase__		:						str = ""      ):





			'''simple docstring'''




			print("""\nFor string = """  ,							lowerCamelCase__  ,							""":"""      )
			print(
			    """> can_string_be_rearranged_as_palindrome_counter()"""  ,							"""\tans ="""  ,							can_string_be_rearranged_as_palindrome_counter(lowerCamelCase__      )  ,							"""\ttime ="""  ,							timeit(
			        """z.can_string_be_rearranged_as_palindrome_counter(z.check_str)"""  ,							setup="""import __main__ as z"""  ,							)  ,							"""seconds"""  ,							)
			print(
			    """> can_string_be_rearranged_as_palindrome()"""  ,							"""\tans ="""  ,							can_string_be_rearranged_as_palindrome(lowerCamelCase__      )  ,							"""\ttime ="""  ,							timeit(
			        """z.can_string_be_rearranged_as_palindrome(z.check_str)"""  ,							setup="""import __main__ as z"""  ,							)  ,							"""seconds"""  ,							)


if __name__ == "__main__":
		UpperCAmelCase   :    List[Any]     =		input(
		    "Enter string to determine if it can be rearranged as a palindrome or not: "
		).strip()
		benchmark(check_str)
		UpperCAmelCase   :    Optional[Any]     =		can_string_be_rearranged_as_palindrome_counter(check_str)
		print(f"""{check_str} can {"" if status else "not "}be rearranged as a palindrome""")








"""simple docstring"""





class 						lowercase   :





      def __init__(			self					)						->	Any:
            lowerCAmelCase    		=			""""""
            lowerCAmelCase    		=			""""""
            lowerCAmelCase    		=			[]





      def        _snake_case     (			self ,		lowercase ,		lowercase					)						->	int:
            if m == -1:
                  return n + 1
            elif n == -1:
                  return m + 1
            elif self.dp[m][n] > -1:
                  return self.dp[m][n]
            else:
                  if self.worda[m] == self.worda[n]:
                        lowerCAmelCase    		=			self.__min_dist_top_down_dp(m - 1 ,		n - 1					)
                  else:
                        lowerCAmelCase    		=			self.__min_dist_top_down_dp(lowercase ,		n - 1					)
                        lowerCAmelCase    		=			self.__min_dist_top_down_dp(m - 1 ,		lowercase					)
                        lowerCAmelCase    		=			self.__min_dist_top_down_dp(m - 1 ,		n - 1					)
                        lowerCAmelCase    		=			1 + min(lowercase ,		lowercase ,		lowercase					)

                  return self.dp[m][n]





      def        _snake_case     (			self ,		lowercase ,		lowercase					)						->	int:
            lowerCAmelCase    		=			worda
            lowerCAmelCase    		=			worda
            lowerCAmelCase    		=			[[-1 for _ in range(len(lowercase					)					)] for _ in range(len(lowercase					)					)]

            return self.__min_dist_top_down_dp(len(lowercase					) - 1 ,		len(lowercase					) - 1					)





      def        _snake_case     (			self ,		lowercase ,		lowercase					)						->	int:
            lowerCAmelCase    		=			worda
            lowerCAmelCase    		=			worda
            lowerCAmelCase    		=			len(lowercase					)
            lowerCAmelCase    		=			len(lowercase					)
            lowerCAmelCase    		=			[[0 for _ in range(n + 1					)] for _ in range(m + 1					)]

            for i in range(m + 1					):
                  for j in range(n + 1					):
                        if i == 0:  # first string is empty
                              lowerCAmelCase    		=			j
                        elif j == 0:  # second string is empty
                              lowerCAmelCase    		=			i
                        elif worda[i - 1] == worda[j - 1]:  # last characters are equal
                              lowerCAmelCase    		=			self.dp[i - 1][j - 1]
                        else:
                              lowerCAmelCase    		=			self.dp[i][j - 1]
                              lowerCAmelCase    		=			self.dp[i - 1][j]
                              lowerCAmelCase    		=			self.dp[i - 1][j - 1]
                              lowerCAmelCase    		=			1 + min(lowercase ,		lowercase ,		lowercase					)
            return self.dp[m][n]


if __name__ == "__main__":
       SCREAMING_SNAKE_CASE__   =  EditDistance()

       print("****************** Testing Edit Distance DP Algorithm ******************")
       print()

       SCREAMING_SNAKE_CASE__   =  input("Enter the first string: ").strip()
       SCREAMING_SNAKE_CASE__   =  input("Enter the second string: ").strip()

       print()
       print(f'The minimum edit distance is: {solver.min_dist_top_down(Sa, Sa)}')
       print(f'The minimum edit distance is: {solver.min_dist_bottom_up(Sa, Sa)}')
       print()
       print("*************** End of Testing Edit Distance DP Algorithm ***************")






