'''simple docstring'''




def      UpperCamelCase_							( _UpperCAmelCase  :				list[int]   ):


       """simple docstring"""







       if not isinstance(_UpperCAmelCase      ,     _UpperCAmelCase   ) or not all(
           isinstance(_UpperCAmelCase      ,     _UpperCAmelCase   ) and item >= 0 for item in citations   ):
              raise ValueError("The citations should be a list of non negative integers."   )

       citations.sort()
       _UpperCAmelCase					:  str											=   len(_UpperCAmelCase   )

       for i in range(_UpperCAmelCase   ):
              if citations[len_citations - 1 - i] <= i:
                     return i

       return len_citations


if __name__ == "__main__":
  import doctest

  doctest.testmod()


'''simple docstring'''




from __future__ import annotations

from collections.abc import Generator

def      UpperCamelCase_							( _UpperCAmelCase  :				int   )   ->   Generator[int, None, None]:


       """simple docstring"""







       if not isinstance(_UpperCAmelCase      ,     _UpperCAmelCase   ) or n < 1:
              raise Exception("Sequence only defined for positive integers"   )

       yield n
       while n != 1:
              if n % 2 == 0:
                     n //= 2
              else:
                     _UpperCAmelCase					:  Optional[Any]											=   3 * n + 1
              yield n

def      UpperCamelCase_							( )   ->   Any:


       """simple docstring"""







       _UpperCAmelCase					:  str											=   43
       _UpperCAmelCase					:  Optional[int]											=   tuple(collatz_sequence(_UpperCAmelCase   )   )
       print(_UpperCAmelCase   )
       print(F"""Collatz sequence from {n} took {len(_UpperCAmelCase   )} steps."""   )


if __name__ == "__main__":
  main()

