



'''simple docstring'''





# Lint as: python3
import dataclasses
import re
from dataclasses import dataclass
from functools import total_ordering
from typing import Optional, Union


_lowerCAmelCase      						=	re.compile(R'''^(?P<major>\d+)''' R'''\.(?P<minor>\d+)''' R'''\.(?P<patch>\d+)$''')






@total_ordering
@dataclass
class        lowerCAmelCase_:
  '''simple docstring'''




  __lowercase							:      str
  __lowercase							:      Optional[str]				=      None
  __lowercase							:      Optional[Union[str, int]]				=      None
  __lowercase							:      Optional[Union[str, int]]				=      None
  __lowercase							:      Optional[Union[str, int]]				=      None




  def 							UpperCAmelCase_	(    self      )    ->		List[Any]:
      lowerCAmelCase__      ,   lowerCAmelCase__      ,   lowerCAmelCase__ :  Dict							      =					_str_to_version_tuple(self.version_str      )




  def __repr__(    self      )    ->		List[Any]:
      return F"""{self.tuple[0]}.{self.tuple[1]}.{self.tuple[2]}"""




  @property
  def 							UpperCAmelCase_	(    self      )    ->		Optional[int]:
      return self.major, self.minor, self.patch




  def 							UpperCAmelCase_	(    self  ,__UpperCAmelCase      )    ->		Dict:
      if isinstance(__UpperCAmelCase  ,__UpperCAmelCase      ):
          return Version(__UpperCAmelCase      )
      elif isinstance(__UpperCAmelCase  ,__UpperCAmelCase      ):
          return other
      raise TypeError(F"""{other} (type {type(__UpperCAmelCase      )}) cannot be compared to version."""      )




  def __eq__(    self  ,__UpperCAmelCase      )    ->		str:
      try:
          lowerCAmelCase__ :  Union[str, Any]							      =					self._validate_operand(__UpperCAmelCase      )
      except (TypeError, ValueError):
          return False
      else:
          return self.tuple == other.tuple




  def __lt__(    self  ,__UpperCAmelCase      )    ->		Any:
      lowerCAmelCase__ :  Optional[Any]							      =					self._validate_operand(__UpperCAmelCase      )
      return self.tuple < other.tuple




  def __hash__(    self      )    ->		List[str]:
      return hash(_version_tuple_to_str(self.tuple      )      )




  @classmethod
  def 							UpperCAmelCase_	(    cls  ,__UpperCAmelCase      )    ->		Optional[Any]:
      lowerCAmelCase__ :  List[str]							      =					{f.name for f in dataclasses.fields(cls      )}
      return cls(**{k: v for k, v in dic.items() if k in field_names}      )






  def 							UpperCAmelCase_	(    self      )    ->		str:
      return self.version_str







def    _SCREAMING_SNAKE_CASE  (       UpperCamelCase			):



    """simple docstring"""





    lowerCAmelCase__ :  Any							      =					_VERSION_REG.match(UpperCamelCase			)
    if not res:
        raise ValueError(f"""Invalid version '{version_str}'. Format should be x.y.z with {{x,y,z}} being digits."""			)
    return tuple(int(UpperCamelCase			) for v in [res.group("""major"""			), res.group("""minor"""			), res.group("""patch"""			)]			)




def    _SCREAMING_SNAKE_CASE  (       UpperCamelCase			):



    """simple docstring"""





    return ".".join(str(UpperCamelCase			) for v in version_tuple			)







'''simple docstring'''





def    _SCREAMING_SNAKE_CASE  (       UpperCamelCase			):



    """simple docstring"""





    lowerCAmelCase__ :  Tuple							      =					abs(UpperCamelCase			)
    lowerCAmelCase__ :  List[Any]							      =					0
    while n > 0:
        res += n % 10
        n //= 10
    return res
def    _SCREAMING_SNAKE_CASE  (       UpperCamelCase			):



    """simple docstring"""





    lowerCAmelCase__ :  Union[str, Any]							      =					abs(UpperCamelCase			)
    return n if n < 10 else n % 10 + sum_of_digits(n // 10			)
def    _SCREAMING_SNAKE_CASE  (       UpperCamelCase			):



    """simple docstring"""





    return sum(int(UpperCamelCase			) for c in str(abs(UpperCamelCase			)			)			)
def    _SCREAMING_SNAKE_CASE  (       ):



    """simple docstring"""





    from collections.abc import Callable
    from timeit import timeit

    def benchmark_a_function(UpperCamelCase							,    UpperCamelCase			) -> None:
        lowerCAmelCase__ :  str							      =					f"""{func.__name__}({value})"""
        lowerCAmelCase__ :  str							      =					timeit(f"""__main__.{call}"""							,    setup="""import __main__"""			)
        print(f"""{call:56} = {func(UpperCamelCase			)} -- {timing:.4f} seconds"""			)

    for value in (262144, 1125899906842624, 1267650600228229401496703205376):
        for func in (sum_of_digits, sum_of_digits_recursion, sum_of_digits_compact):
            benchmark_a_function(UpperCamelCase							,    UpperCamelCase			)
        print()


if __name__ == "__main__":
 import doctest

 doctest.testmod()
 benchmark()


