import random
import unittest

import torch

from diffusers import IFInpaintingSuperResolutionPipeline
from diffusers.utils import floats_tensor
from diffusers.utils.import_utils import is_xformers_available
from diffusers.utils.testing_utils import skip_mps, torch_device

from ..pipeline_params import (
    TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS,
    TEXT_GUIDED_IMAGE_INPAINTING_PARAMS,
)
from ..test_pipelines_common import PipelineTesterMixin
from . import IFPipelineTesterMixin





@skip_mps
class 					A							(    __lowercase		,    __lowercase		,    unittest.TestCase					):
   __UpperCAmelCase			:			Any              =      IFInpaintingSuperResolutionPipeline
   __UpperCAmelCase			:			Tuple              =      TEXT_GUIDED_IMAGE_INPAINTING_PARAMS - {'''width''', '''height'''}
   __UpperCAmelCase			:			str              =      TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS.union({'original_image'}					)
   __UpperCAmelCase			:			List[str]              =      PipelineTesterMixin.required_optional_params - {'''latents'''}


   def       lowercase_				(self					:						Any		)						->    Dict:
         """simple docstring"""



         return self._get_superresolution_dummy_components()


   def       lowercase_				(self					:						List[str]	,  __UpperCAmelCase					:						Union[str, Any]	,  __UpperCAmelCase					:						List[str]=0		)						->    Tuple:
         """simple docstring"""



         if str(UpperCAmelCase__		).startswith("mps"		):
               UpperCAmelCase__								=  torch.manual_seed(UpperCAmelCase__		)
         else:
               UpperCAmelCase__								=  torch.Generator(device=UpperCAmelCase__		).manual_seed(UpperCAmelCase__		)

         UpperCAmelCase__								=  floats_tensor((1, 3, 1_6, 1_6)	,  rng=random.Random(UpperCAmelCase__		)		).to(UpperCAmelCase__		)
         UpperCAmelCase__								=  floats_tensor((1, 3, 3_2, 3_2)	,  rng=random.Random(UpperCAmelCase__		)		).to(UpperCAmelCase__		)
         UpperCAmelCase__								=  floats_tensor((1, 3, 3_2, 3_2)	,  rng=random.Random(UpperCAmelCase__		)		).to(UpperCAmelCase__		)

         UpperCAmelCase__								=  {
             "prompt": "A painting of a squirrel eating a burger",
             "image": image,
             "original_image": original_image,
             "mask_image": mask_image,
             "generator": generator,
             "num_inference_steps": 2,
             "output_type": "numpy",
         }

         return inputs


   @unittest.skipIf(
       torch_device != "cuda" or not is_xformers_available()	,  reason="XFormers attention is only available with CUDA and `xformers` installed"	,  )
   def       lowercase_				(self					:						Optional[Any]		)						->    List[str]:
         """simple docstring"""



         self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1E-3		)


   def       lowercase_				(self					:						Dict		)						->    Tuple:
         """simple docstring"""



         self._test_save_load_optional_components()


   @unittest.skipIf(torch_device != "cuda"	,  reason="float16 requires CUDA"		)
   def       lowercase_				(self					:						Any		)						->    int:
         """simple docstring"""



         super().test_save_load_floataa(expected_max_diff=1E-1		)


   def       lowercase_				(self					:						List[Any]		)						->    Dict:
         """simple docstring"""



         self._test_attention_slicing_forward_pass(expected_max_diff=1E-2		)


   def       lowercase_				(self					:						Union[str, Any]		)						->    Any:
         """simple docstring"""



         self._test_save_load_local()





   def       lowercase_				(self					:						Tuple		)						->    str:
         """simple docstring"""



         self._test_inference_batch_single_identical(
             expected_max_diff=1E-2	,  )
from __future__ import annotations




def        lowerCAmelCase_			(					__A							)					->    bool:







      '''simple docstring'''


      UpperCAmelCase__								=  str(__A							)
      return n == n[::-1]




def        lowerCAmelCase_			(					__A = 1_000_000							)					->    Optional[int]:







      '''simple docstring'''


      UpperCAmelCase__								=  0

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


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



