


"""simple docstring"""




lowercase_	   =     {}
def 				UpperCamelCase__					(  SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__      ,	SCREAMING_SNAKE_CASE__						):

 # if we are absent twice, or late 3 consecutive days,
 # no further prize strings are possible
 if late == 3 or absent == 2:
  return 0

 # if we have no days left, and have not failed any other rules,
 # we have a prize string
 if days == 0:
  return 1

 # No easy solution, so now we need to do the recursive calculation

 # First, check if the combination is already in the cache, and
 # if yes, return the stored value from there since we already
 # know the number of possible prize strings from this point on
 __lowerCamelCase		:							Optional[int]		 =						(days, absent, late)
 if key in cache:
  return cache[key]

 # now we calculate the three possible ways that can unfold from
 # this point on, depending on our attendance today

 # 1) if we are late (but not absent), the "absent" counter stays as
 # it is, but the "late" counter increases by one
 __lowerCamelCase		:							Tuple		 =						_calculate(days - 1      ,	SCREAMING_SNAKE_CASE__      ,	late + 1						)

 # 2) if we are absent, the "absent" counter increases by 1, and the
 # "late" counter resets to 0
 __lowerCamelCase		:							Tuple		 =						_calculate(days - 1      ,	absent + 1      ,	0						)

 # 3) if we are on time, this resets the "late" counter and keeps the
 # absent counter
 __lowerCamelCase		:							Union[str, Any]		 =						_calculate(days - 1      ,	SCREAMING_SNAKE_CASE__      ,	0						)

 __lowerCamelCase		:							int		 =						state_late + state_absent + state_ontime

 __lowerCamelCase		:							List[str]		 =						prizestrings
 return prizestrings
def 				UpperCamelCase__					(  SCREAMING_SNAKE_CASE__ = 30						):
 return _calculate(SCREAMING_SNAKE_CASE__      ,	absent=0      ,	late=0						)


if __name__ == "__main__":
       print(solution())





from dataclasses import dataclass, field
from typing import Tuple

from ..utils import cached_property, is_torch_available, is_torch_tpu_available, logging, requires_backends
from .benchmark_args_utils import BenchmarkArguments


if is_torch_available():
       import torch

if is_torch_tpu_available(check_device=False):
       import torch_xla.core.xla_model as xm


lowercase_	   =     logging.get_logger(__name__)


@dataclass
class 	A_ (	__UpperCamelCase   ):




      '''simple docstring'''


      __snake_case 	=       [
          """no_inference""",
          """no_cuda""",
          """no_tpu""",
          """no_speed""",
          """no_memory""",
          """no_env_print""",
          """no_multi_process""",
      ]




      def __init__(    self:	Any						,				**a:	Optional[Any]    ):
       for deprecated_arg in self.deprecated_args:
        if deprecated_arg in kwargs:
         __lowerCamelCase		:							str		 =						deprecated_arg[3:]
         setattr(self						,				a						,				not kwargs.pop(a    )    )
         logger.warning(
             F'{deprecated_arg} is depreciated. Please use --no_{positive_arg} or'
             F' {positive_arg}={kwargs[positive_arg]}'    )

       __lowerCamelCase		:							str		 =						kwargs.pop('torchscript'						,				self.torchscript    )
       __lowerCamelCase		:							int		 =						kwargs.pop('torch_xla_tpu_print_metrics'						,				self.torch_xla_tpu_print_metrics    )
       __lowerCamelCase		:							Dict		 =						kwargs.pop('fp16_opt_level'						,				self.fpaa_opt_level    )
       super().__init__(**a    )

      __snake_case 	=       field(default=__UpperCamelCase ,				metadata={"""help""": """Trace the models using torchscript"""}   )
      __snake_case 	=       field(default=__UpperCamelCase ,				metadata={"""help""": """Print Xla/PyTorch tpu metrics"""}   )
      __snake_case 	=       field(
          default="""O1""" ,				metadata={
              """help""": (
                  """For fp16: Apex AMP optimization level selected in ['O0', 'O1', 'O2', and 'O3']. """
                  """See details at https://nvidia.github.io/apex/amp.html"""
              )
          } ,				)




      @cached_property
      def 					_snake_case     (    self:	Dict    ):
       requires_backends(self						,				['torch']    )
       logger.info('PyTorch: setting up devices'    )
       if not self.cuda:
        __lowerCamelCase		:							Dict		 =						torch.device('cpu'    )
        __lowerCamelCase		:							str		 =						0
       elif is_torch_tpu_available():
        __lowerCamelCase		:							Optional[int]		 =						xm.xla_device()
        __lowerCamelCase		:							Dict		 =						0
       else:
        __lowerCamelCase		:							Any		 =						torch.device('cuda' if torch.cuda.is_available() else 'cpu'    )
        __lowerCamelCase		:							Union[str, Any]		 =						torch.cuda.device_count()
       return device, n_gpu




      @property
      def 					_snake_case     (    self:	Optional[Any]    ):
       return is_torch_tpu_available() and self.tpu




      @property
      def 					_snake_case     (    self:	Union[str, Any]    ):
       requires_backends(self						,				['torch']    )
       # TODO(PVP): currently only single GPU is supported
       return torch.cuda.current_device()




      @property
      def 					_snake_case     (    self:	int    ):
       requires_backends(self						,				['torch']    )
       return self._setup_devices[0]




      @property
      def 					_snake_case     (    self:	Union[str, Any]    ):
       requires_backends(self						,				['torch']    )
       return self._setup_devices[1]




      @property
      def 					_snake_case     (    self:	List[Any]    ):
       return self.n_gpu > 0

