
"""simple docstring"""

def 							A						(    snake_case				:str		)				->     list[int]:
 __UpperCamelCase      =	[0 for i in range(len(snake_case		)		)]

 # initialize interval's left pointer and right pointer
 __UpperCamelCase  ,     __UpperCamelCase      =	0, 0

 for i in range(1    , len(snake_case		)		):
  # case when current index is inside the interval
  if i <= right_pointer:
   __UpperCamelCase      =	min(right_pointer - i + 1    , z_result[i - left_pointer]		)
   __UpperCamelCase      =	min_edge

  while go_next(snake_case    , snake_case    , snake_case		):
   z_result[i] += 1

  # if new index's result gives us more right interval,
  # we've to update left_pointer and right_pointer
  if i + z_result[i] - 1 > right_pointer:
   __UpperCamelCase  ,     __UpperCamelCase      =	i, i + z_result[i] - 1

 return z_result






def 							A						(    snake_case				:int    , snake_case				:list[int]    , snake_case				:str		)				->     bool:
 return i + z_result[i] < len(snake_case		) and s[z_result[i]] == s[i + z_result[i]]






def 							A						(    snake_case				:str    , snake_case				:str		)				->     int:
 __UpperCamelCase      =	0
 # concatenate 'pattern' and 'input_str' and call z_function
 # with concatenated string
 __UpperCamelCase      =	z_function(pattern + input_str		)

 for val in z_result:
  # if value is greater then length of the pattern string
  # that means this index is starting position of substring
  # which is equal to pattern string
  if val >= len(snake_case		):
   answer += 1

 return answer


if __name__ == "__main__":
      import doctest

      doctest.testmod()





"""simple docstring"""

def 							A						(    snake_case				:int		)				->     int:
 __UpperCamelCase      =	abs(snake_case		)
 __UpperCamelCase      =	0
 while n > 0:
  res += n % 1_0
  n //= 1_0
 return res






def 							A						(    snake_case				:int		)				->     int:
 __UpperCamelCase      =	abs(snake_case		)
 return n if n < 1_0 else n % 1_0 + sum_of_digits(n // 1_0		)






def 							A						(    snake_case				:int		)				->     int:
 return sum(int(snake_case		) for c in str(abs(snake_case		)		)		)






def 							A						(    )				->     None:
 from collections.abc import Callable
 from timeit import timeit

 def benchmark_a_function(snake_case				:Callable    , snake_case				:int		) -> None:
  __UpperCamelCase      =	f'{func.__name__}({value})'
  __UpperCamelCase      =	timeit(f'__main__.{call}'    , setup='import __main__'		)
  print(f'{call:56} = {func(snake_case		)} -- {timing:.4f} seconds'		)

 for value in (2_6_2_1_4_4, 1_1_2_5_8_9_9_9_0_6_8_4_2_6_2_4, 1_2_6_7_6_5_0_6_0_0_2_2_8_2_2_9_4_0_1_4_9_6_7_0_3_2_0_5_3_7_6):
  for func in (sum_of_digits, sum_of_digits_recursion, sum_of_digits_compact):
   benchmark_a_function(snake_case    , snake_case		)
  print()


if __name__ == "__main__":
      import doctest

      doctest.testmod()
      benchmark()



