'''simple docstring'''

from typing import List, Optional, Tuple, Union

import torch

from ...models import UNetaDModel
from ...schedulers import ScoreSdeVeScheduler
from ...utils import randn_tensor
from ..pipeline_utils import DiffusionPipeline, ImagePipelineOutput





class 							lowercase						(						__lowerCamelCase ):
   lowerCamelCase_    					=42
   lowerCamelCase_    					=42


   def __init__(   self				:	int   ,		__lowerCAmelCase				:	UNetaDModel   ,		__lowerCAmelCase				:	ScoreSdeVeScheduler)      ->					Optional[int]:
         super().__init__()
         self.register_modules(unet=__lowerCAmelCase   ,		scheduler=__lowerCAmelCase)


   @torch.no_grad()
   def __call__(   self				:	Optional[Any]   ,		__lowerCAmelCase				:	int = 1   ,		__lowerCAmelCase				:	int = 2000   ,		__lowerCAmelCase				:	Optional[Union[torch.Generator, List[torch.Generator]]] = None   ,		__lowerCAmelCase				:	Optional[str] = "pil"   ,		__lowerCAmelCase				:	bool = True   ,		**__lowerCAmelCase				:	str   ,		)      ->					Union[ImagePipelineOutput, Tuple]:
         lowercase_     =      self.unet.config.sample_size
         lowercase_     =      (batch_size, 3, img_size, img_size)

         lowercase_     =      self.unet

         lowercase_     =      randn_tensor(__lowerCAmelCase   ,		generator=__lowerCAmelCase) * self.scheduler.init_noise_sigma
         lowercase_     =      sample.to(self.device)

         self.scheduler.set_timesteps(__lowerCAmelCase)
         self.scheduler.set_sigmas(__lowerCAmelCase)

         for i, t in enumerate(self.progress_bar(self.scheduler.timesteps)):
               lowercase_     =      self.scheduler.sigmas[i] * torch.ones(shape[0]   ,		device=self.device)

               # correction step
               for _ in range(self.scheduler.config.correct_steps):
                     lowercase_     =      self.unet(__lowerCAmelCase   ,		__lowerCAmelCase).sample
                     lowercase_     =      self.scheduler.step_correct(__lowerCAmelCase   ,		__lowerCAmelCase   ,		generator=__lowerCAmelCase).prev_sample

               # prediction step
               lowercase_     =      model(__lowerCAmelCase   ,		__lowerCAmelCase).sample
               lowercase_     =      self.scheduler.step_pred(__lowerCAmelCase   ,		__lowerCAmelCase   ,		__lowerCAmelCase   ,		generator=__lowerCAmelCase)

               lowercase_ ,							lowercase_     =      output.prev_sample, output.prev_sample_mean

         lowercase_     =      sample_mean.clamp(0   ,		1)
         lowercase_     =      sample.cpu().permute(0   ,		2   ,		3   ,		1).numpy()
         if output_type == "pil":
               lowercase_     =      self.numpy_to_pil(__lowerCAmelCase)

         if not return_dict:
               return (sample,)

         return ImagePipelineOutput(images=__lowerCAmelCase)







'''simple docstring'''

from __future__ import annotations


def __a (	__lowerCamelCase			:						int | str				)	->							bool:
      '''simple docstring'''


      lowercase_     =      str(__lowerCamelCase				)
      return n == n[::-1]


def __a (	__lowerCamelCase			:						int = 1_000_000				)	->							Optional[int]:
      '''simple docstring'''


      lowercase_     =      0

      for i in range(1 ,		__lowerCamelCase				):
            if is_palindrome(__lowerCamelCase				) and is_palindrome(bin(__lowerCamelCase				).split("b"				)[1]				):
                  total += i
      return total


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






