




'''simple docstring'''

import torch

from diffusers import EulerDiscreteScheduler
from diffusers.utils import torch_device

from .test_schedulers import SchedulerCommonTest
class   SCREAMING_SNAKE_CASE			(						__lowercase):







		"""simple docstring"""
		lowercase   :      List[str]       =							(EulerDiscreteScheduler,)
		lowercase   :      Optional[Any]       =							10






		def 		UpperCamelCase__       (   self		,						**__A				) ->     Union[str, Any]:
								_lowerCAmelCase										={
								    'num_train_timesteps': 1100,
								    'beta_start': 0.0_001,
								    'beta_end': 0.02,
								    'beta_schedule': 'linear',
								}

								config.update(**__A				)
								return config






		def 		UpperCamelCase__       (   self				) ->     Any:
								for timesteps in [10, 50, 100, 1000]:
														self.check_over_configs(num_train_timesteps=__A				)






		def 		UpperCamelCase__       (   self				) ->     List[Any]:
								for beta_start, beta_end in zip([0.00_001, 0.0_001, 0.001]		,						[0.0_002, 0.002, 0.02]				):
														self.check_over_configs(beta_start=__A		,						beta_end=__A				)






		def 		UpperCamelCase__       (   self				) ->     List[Any]:
								for schedule in ["linear", "scaled_linear"]:
														self.check_over_configs(beta_schedule=__A				)






		def 		UpperCamelCase__       (   self				) ->     str:
								for prediction_type in ["epsilon", "v_prediction"]:
														self.check_over_configs(prediction_type=__A				)






		def 		UpperCamelCase__       (   self				) ->     List[str]:
								_lowerCAmelCase										=self.scheduler_classes[0]
								_lowerCAmelCase										=self.get_scheduler_config()
								_lowerCAmelCase										=scheduler_class(**__A				)

								scheduler.set_timesteps(self.num_inference_steps				)

								_lowerCAmelCase										=torch.manual_seed(0				)

								_lowerCAmelCase										=self.dummy_model()
								_lowerCAmelCase										=self.dummy_sample_deter * scheduler.init_noise_sigma
								_lowerCAmelCase										=sample.to(__A				)

								for i, t in enumerate(scheduler.timesteps				):
														_lowerCAmelCase										=scheduler.scale_model_input(__A		,						__A				)

														_lowerCAmelCase										=model(__A		,						__A				)

														_lowerCAmelCase										=scheduler.step(__A		,						__A		,						__A		,						generator=__A				)
														_lowerCAmelCase										=output.prev_sample

								_lowerCAmelCase										=torch.sum(torch.abs(__A				)				)
								_lowerCAmelCase										=torch.mean(torch.abs(__A				)				)

								assert abs(result_sum.item() - 10.0_807				) < 1E-2
								assert abs(result_mean.item() - 0.0_131				) < 1E-3






		def 		UpperCamelCase__       (   self				) ->     int:
								_lowerCAmelCase										=self.scheduler_classes[0]
								_lowerCAmelCase										=self.get_scheduler_config(prediction_type='v_prediction'				)
								_lowerCAmelCase										=scheduler_class(**__A				)

								scheduler.set_timesteps(self.num_inference_steps				)

								_lowerCAmelCase										=torch.manual_seed(0				)

								_lowerCAmelCase										=self.dummy_model()
								_lowerCAmelCase										=self.dummy_sample_deter * scheduler.init_noise_sigma
								_lowerCAmelCase										=sample.to(__A				)

								for i, t in enumerate(scheduler.timesteps				):
														_lowerCAmelCase										=scheduler.scale_model_input(__A		,						__A				)

														_lowerCAmelCase										=model(__A		,						__A				)

														_lowerCAmelCase										=scheduler.step(__A		,						__A		,						__A		,						generator=__A				)
														_lowerCAmelCase										=output.prev_sample

								_lowerCAmelCase										=torch.sum(torch.abs(__A				)				)
								_lowerCAmelCase										=torch.mean(torch.abs(__A				)				)

								assert abs(result_sum.item() - 0.0_002				) < 1E-2
								assert abs(result_mean.item() - 2.26_76E-06				) < 1E-3






		def 		UpperCamelCase__       (   self				) ->     List[str]:
								_lowerCAmelCase										=self.scheduler_classes[0]
								_lowerCAmelCase										=self.get_scheduler_config()
								_lowerCAmelCase										=scheduler_class(**__A				)

								scheduler.set_timesteps(self.num_inference_steps		,						device=__A				)

								_lowerCAmelCase										=torch.manual_seed(0				)

								_lowerCAmelCase										=self.dummy_model()
								_lowerCAmelCase										=self.dummy_sample_deter * scheduler.init_noise_sigma.cpu()
								_lowerCAmelCase										=sample.to(__A				)

								for t in scheduler.timesteps:
														_lowerCAmelCase										=scheduler.scale_model_input(__A		,						__A				)

														_lowerCAmelCase										=model(__A		,						__A				)

														_lowerCAmelCase										=scheduler.step(__A		,						__A		,						__A		,						generator=__A				)
														_lowerCAmelCase										=output.prev_sample

								_lowerCAmelCase										=torch.sum(torch.abs(__A				)				)
								_lowerCAmelCase										=torch.mean(torch.abs(__A				)				)

								assert abs(result_sum.item() - 10.0_807				) < 1E-2
								assert abs(result_mean.item() - 0.0_131				) < 1E-3






		def 		UpperCamelCase__       (   self				) ->     str:
								_lowerCAmelCase										=self.scheduler_classes[0]
								_lowerCAmelCase										=self.get_scheduler_config()
								_lowerCAmelCase										=scheduler_class(**__A		,						use_karras_sigmas=__A				)

								scheduler.set_timesteps(self.num_inference_steps		,						device=__A				)

								_lowerCAmelCase										=torch.manual_seed(0				)

								_lowerCAmelCase										=self.dummy_model()
								_lowerCAmelCase										=self.dummy_sample_deter * scheduler.init_noise_sigma.cpu()
								_lowerCAmelCase										=sample.to(__A				)

								for t in scheduler.timesteps:
														_lowerCAmelCase										=scheduler.scale_model_input(__A		,						__A				)

														_lowerCAmelCase										=model(__A		,						__A				)

														_lowerCAmelCase										=scheduler.step(__A		,						__A		,						__A		,						generator=__A				)
														_lowerCAmelCase										=output.prev_sample

								_lowerCAmelCase										=torch.sum(torch.abs(__A				)				)
								_lowerCAmelCase										=torch.mean(torch.abs(__A				)				)

								assert abs(result_sum.item() - 124.52_299_499_511_719				) < 1E-2
								assert abs(result_mean.item() - 0.16_213_932_633_399_963				) < 1E-3






'''simple docstring'''

def 							UpperCamelCase__			(			a__ = 1_0_0_0      ):


						'''simple docstring'''






						_lowerCAmelCase										=2**power
						_lowerCAmelCase										=0
						while n:
												_lowerCAmelCase						,				_lowerCAmelCase										=r + n % 1_0, n // 1_0
						return r


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





