

'''simple docstring'''
import tempfile

import torch

from diffusers import (
    DEISMultistepScheduler,
    DPMSolverMultistepScheduler,
    DPMSolverSinglestepScheduler,
    UniPCMultistepScheduler,
)

from .test_schedulers import SchedulerCommonTest


class        a__  (							lowerCamelCase_  ):
   _SCREAMING_SNAKE_CASE   :					Optional[Any]     	=							(DPMSolverSinglestepScheduler,)
   _SCREAMING_SNAKE_CASE   :					Optional[Any]     	=							(('num_inference_steps', 25),)


   def 						_lowerCamelCase       (			self      ,    **_UpperCamelCase  ):





      """simple docstring"""





      _lowercase      :				List[str]      					=       {
          "num_train_timesteps": 1000,
          "beta_start": 0.0_0_0_1,
          "beta_end": 0.0_2,
          "beta_schedule": "linear",
          "solver_order": 2,
          "prediction_type": "epsilon",
          "thresholding": False,
          "sample_max_value": 1.0,
          "algorithm_type": "dpmsolver++",
          "solver_type": "midpoint",
          "lambda_min_clipped": -float("inf"  ),
          "variance_type": None,
      }

      config.update(**_UpperCamelCase  )
      return config


   def 						_lowerCamelCase       (			self      ,    _UpperCamelCase=0      ,    **_UpperCamelCase  ):





      """simple docstring"""





      _lowercase      :				int      					=       dict(self.forward_default_kwargs  )
      _lowercase      :				str      					=       kwargs.pop("num_inference_steps"      ,    _UpperCamelCase  )
      _lowercase      :				List[str]      					=       self.dummy_sample
      _lowercase      :				List[Any]      					=       0.1 * sample
      _lowercase      :				Optional[Any]      					=       [residual + 0.2, residual + 0.1_5, residual + 0.1_0]

      for scheduler_class in self.scheduler_classes:
         _lowercase      :				int      					=       self.get_scheduler_config(**_UpperCamelCase  )
         _lowercase      :				Union[str, Any]      					=       scheduler_class(**_UpperCamelCase  )
         scheduler.set_timesteps(_UpperCamelCase  )
         # copy over dummy past residuals
         _lowercase      :				List[str]      					=       dummy_past_residuals[: scheduler.config.solver_order]

         with tempfile.TemporaryDirectory() as tmpdirname:
            scheduler.save_config(_UpperCamelCase  )
            _lowercase      :				Dict      					=       scheduler_class.from_pretrained(_UpperCamelCase  )
            new_scheduler.set_timesteps(_UpperCamelCase  )
            # copy over dummy past residuals
            _lowercase      :				List[str]      					=       dummy_past_residuals[: new_scheduler.config.solver_order]

         _lowercase      :				Optional[int]      					=       sample, sample
         for t in range(_UpperCamelCase      ,    time_step + scheduler.config.solver_order + 1  ):
            _lowercase      :				str      					=       scheduler.step(_UpperCamelCase      ,    _UpperCamelCase      ,    _UpperCamelCase      ,    **_UpperCamelCase  ).prev_sample
            _lowercase      :				int      					=       new_scheduler.step(_UpperCamelCase      ,    _UpperCamelCase      ,    _UpperCamelCase      ,    **_UpperCamelCase  ).prev_sample

            assert torch.sum(torch.abs(output - new_output  )  ) < 1E-5, "Scheduler outputs are not identical"


   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      pass


   def 						_lowerCamelCase       (			self      ,    _UpperCamelCase=0      ,    **_UpperCamelCase  ):





      """simple docstring"""





      _lowercase      :				Dict      					=       dict(self.forward_default_kwargs  )
      _lowercase      :				int      					=       kwargs.pop("num_inference_steps"      ,    _UpperCamelCase  )
      _lowercase      :				Optional[Any]      					=       self.dummy_sample
      _lowercase      :				Union[str, Any]      					=       0.1 * sample
      _lowercase      :				List[Any]      					=       [residual + 0.2, residual + 0.1_5, residual + 0.1_0]

      for scheduler_class in self.scheduler_classes:
         _lowercase      :				int      					=       self.get_scheduler_config()
         _lowercase      :				List[Any]      					=       scheduler_class(**_UpperCamelCase  )
         scheduler.set_timesteps(_UpperCamelCase  )

         # copy over dummy past residuals (must be after setting timesteps)
         _lowercase      :				str      					=       dummy_past_residuals[: scheduler.config.solver_order]

         with tempfile.TemporaryDirectory() as tmpdirname:
            scheduler.save_config(_UpperCamelCase  )
            _lowercase      :				List[str]      					=       scheduler_class.from_pretrained(_UpperCamelCase  )
            # copy over dummy past residuals
            new_scheduler.set_timesteps(_UpperCamelCase  )

            # copy over dummy past residual (must be after setting timesteps)
            _lowercase      :				Union[str, Any]      					=       dummy_past_residuals[: new_scheduler.config.solver_order]

         _lowercase      :				Optional[Any]      					=       scheduler.step(_UpperCamelCase      ,    _UpperCamelCase      ,    _UpperCamelCase      ,    **_UpperCamelCase  ).prev_sample
         _lowercase      :				Optional[int]      					=       new_scheduler.step(_UpperCamelCase      ,    _UpperCamelCase      ,    _UpperCamelCase      ,    **_UpperCamelCase  ).prev_sample

         assert torch.sum(torch.abs(output - new_output  )  ) < 1E-5, "Scheduler outputs are not identical"


   def 						_lowerCamelCase       (			self      ,    _UpperCamelCase=None      ,    **_UpperCamelCase  ):





      """simple docstring"""





      if scheduler is None:
         _lowercase      :				int      					=       self.scheduler_classes[0]
         _lowercase      :				List[str]      					=       self.get_scheduler_config(**_UpperCamelCase  )
         _lowercase      :				Union[str, Any]      					=       scheduler_class(**_UpperCamelCase  )

      _lowercase      :				str      					=       self.scheduler_classes[0]
      _lowercase      :				Union[str, Any]      					=       self.get_scheduler_config(**_UpperCamelCase  )
      _lowercase      :				Optional[int]      					=       scheduler_class(**_UpperCamelCase  )

      _lowercase      :				int      					=       10
      _lowercase      :				Union[str, Any]      					=       self.dummy_model()
      _lowercase      :				Union[str, Any]      					=       self.dummy_sample_deter
      scheduler.set_timesteps(_UpperCamelCase  )

      for i, t in enumerate(scheduler.timesteps  ):
         _lowercase      :				Any      					=       model(_UpperCamelCase      ,    _UpperCamelCase  )
         _lowercase      :				Tuple      					=       scheduler.step(_UpperCamelCase      ,    _UpperCamelCase      ,    _UpperCamelCase  ).prev_sample

      return sample


   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      _lowercase      :				List[str]      					=       DPMSolverSinglestepScheduler(**self.get_scheduler_config()  )
      _lowercase      :				Dict      					=       50
      _lowercase      :				Tuple      					=       self.dummy_model()
      _lowercase      :				Tuple      					=       self.dummy_sample_deter
      scheduler.set_timesteps(_UpperCamelCase  )

      # make sure that the first t is uneven
      for i, t in enumerate(scheduler.timesteps[3:]  ):
         _lowercase      :				List[Any]      					=       model(_UpperCamelCase      ,    _UpperCamelCase  )
         _lowercase      :				Union[str, Any]      					=       scheduler.step(_UpperCamelCase      ,    _UpperCamelCase      ,    _UpperCamelCase  ).prev_sample

      _lowercase      :				Any      					=       torch.mean(torch.abs(_UpperCamelCase  )  )

      assert abs(result_mean.item() - 0.2_5_7_4  ) < 1E-3


   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      for timesteps in [25, 50, 100, 999, 1000]:
         self.check_over_configs(num_train_timesteps=_UpperCamelCase  )


   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      _lowercase      :				Dict      					=       DPMSolverSinglestepScheduler(**self.get_scheduler_config()  )
      _lowercase      :				Dict      					=       self.full_loop(scheduler=_UpperCamelCase  )
      _lowercase      :				Dict      					=       torch.mean(torch.abs(_UpperCamelCase  )  )

      assert abs(result_mean.item() - 0.2_7_9_1  ) < 1E-3

      _lowercase      :				List[Any]      					=       DEISMultistepScheduler.from_config(scheduler.config  )
      _lowercase      :				List[Any]      					=       DPMSolverMultistepScheduler.from_config(scheduler.config  )
      _lowercase      :				Union[str, Any]      					=       UniPCMultistepScheduler.from_config(scheduler.config  )
      _lowercase      :				List[Any]      					=       DPMSolverSinglestepScheduler.from_config(scheduler.config  )

      _lowercase      :				List[Any]      					=       self.full_loop(scheduler=_UpperCamelCase  )
      _lowercase      :				Any      					=       torch.mean(torch.abs(_UpperCamelCase  )  )

      assert abs(result_mean.item() - 0.2_7_9_1  ) < 1E-3


   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      self.check_over_configs(thresholding=_UpperCamelCase  )
      for order in [1, 2, 3]:
         for solver_type in ["midpoint", "heun"]:
            for threshold in [0.5, 1.0, 2.0]:
               for prediction_type in ["epsilon", "sample"]:
                  self.check_over_configs(
                      thresholding=_UpperCamelCase      ,    prediction_type=_UpperCamelCase      ,    sample_max_value=_UpperCamelCase      ,    algorithm_type="dpmsolver++"      ,    solver_order=_UpperCamelCase      ,    solver_type=_UpperCamelCase      ,    )


   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      for prediction_type in ["epsilon", "v_prediction"]:
         self.check_over_configs(prediction_type=_UpperCamelCase  )


   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      for algorithm_type in ["dpmsolver", "dpmsolver++"]:
         for solver_type in ["midpoint", "heun"]:
            for order in [1, 2, 3]:
               for prediction_type in ["epsilon", "sample"]:
                  self.check_over_configs(
                      solver_order=_UpperCamelCase      ,    solver_type=_UpperCamelCase      ,    prediction_type=_UpperCamelCase      ,    algorithm_type=_UpperCamelCase      ,    )
                  _lowercase      :				str      					=       self.full_loop(
                      solver_order=_UpperCamelCase      ,    solver_type=_UpperCamelCase      ,    prediction_type=_UpperCamelCase      ,    algorithm_type=_UpperCamelCase      ,    )
                  assert not torch.isnan(_UpperCamelCase  ).any(), "Samples have nan numbers"


   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      self.check_over_configs(lower_order_final=_UpperCamelCase  )
      self.check_over_configs(lower_order_final=_UpperCamelCase  )


   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      self.check_over_configs(lambda_min_clipped=-float("inf"  )  )
      self.check_over_configs(lambda_min_clipped=-5.1  )


   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      self.check_over_configs(variance_type=_UpperCamelCase  )
      self.check_over_configs(variance_type="learned_range"  )


   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      for num_inference_steps in [1, 2, 3, 5, 10, 50, 100, 999, 1000]:
         self.check_over_forward(num_inference_steps=_UpperCamelCase      ,    time_step=0  )


   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      _lowercase      :				List[str]      					=       self.full_loop()
      _lowercase      :				str      					=       torch.mean(torch.abs(_UpperCamelCase  )  )

      assert abs(result_mean.item() - 0.2_7_9_1  ) < 1E-3


   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      _lowercase      :				List[Any]      					=       self.full_loop(use_karras_sigmas=_UpperCamelCase  )
      _lowercase      :				Tuple      					=       torch.mean(torch.abs(_UpperCamelCase  )  )

      assert abs(result_mean.item() - 0.2_2_4_8  ) < 1E-3


   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      _lowercase      :				Union[str, Any]      					=       self.full_loop(prediction_type="v_prediction"  )
      _lowercase      :				Tuple      					=       torch.mean(torch.abs(_UpperCamelCase  )  )

      assert abs(result_mean.item() - 0.1_4_5_3  ) < 1E-3


   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      _lowercase      :				List[Any]      					=       self.full_loop(prediction_type="v_prediction"      ,    use_karras_sigmas=_UpperCamelCase  )
      _lowercase      :				Optional[Any]      					=       torch.mean(torch.abs(_UpperCamelCase  )  )

      assert abs(result_mean.item() - 0.0_6_4_9  ) < 1E-3






   def 						_lowerCamelCase       (			self  ):





      """simple docstring"""





      _lowercase      :				str      					=       self.scheduler_classes[0]
      _lowercase      :				Optional[int]      					=       self.get_scheduler_config(thresholding=_UpperCamelCase      ,    dynamic_thresholding_ratio=0  )
      _lowercase      :				List[str]      					=       scheduler_class(**_UpperCamelCase  )

      _lowercase      :				Optional[Any]      					=       10
      _lowercase      :				Dict      					=       self.dummy_model()
      _lowercase      :				Union[str, Any]      					=       self.dummy_sample_deter.half()
      scheduler.set_timesteps(_UpperCamelCase  )

      for i, t in enumerate(scheduler.timesteps  ):
         _lowercase      :				Tuple      					=       model(_UpperCamelCase      ,    _UpperCamelCase  )
         _lowercase      :				Tuple      					=       scheduler.step(_UpperCamelCase      ,    _UpperCamelCase      ,    _UpperCamelCase  ).prev_sample

      assert sample.dtype == torch.floataa









'''simple docstring'''
from math import sqrt







def  _A		(     snake_case					)      ->     int:
   _lowercase      :				str      					=       0
   for i in range(1		,							int(sqrt(snake_case					) + 1					)					):
      if n % i == 0 and i != sqrt(snake_case					):
         total += i + n // i
      elif i == sqrt(snake_case					):
         total += i
   return total - n







def  _A		(     snake_case = 1_00_00					)      ->     int:
   _lowercase      :				List[Any]      					=       sum(
       i
       for i in range(1		,							snake_case					)
       if sum_of_divisors(sum_of_divisors(snake_case					)					) == i and sum_of_divisors(snake_case					) != i					)
   return total


if __name__ == "__main__":
    print(solution(int(str(input()).strip())))






