import random
import unittest

import torch

from diffusers import IFInpaintingPipeline
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   lowerCamelCase					(SCREAMING_SNAKE_CASE__  ,      SCREAMING_SNAKE_CASE__  ,      unittest.TestCase					):
  """simple docstring"""







  lowerCamelCase__     =						IFInpaintingPipeline
  lowerCamelCase__     =						TEXT_GUIDED_IMAGE_INPAINTING_PARAMS - {'''width''', '''height'''}
  lowerCamelCase__     =						TEXT_GUIDED_IMAGE_INPAINTING_BATCH_PARAMS
  lowerCamelCase__     =						PipelineTesterMixin.required_optional_params - {'''latents'''}







  def    __A     (							self :       Tuple   )  ->	List[str]:
        return self._get_dummy_components()







  def    __A     (							self :       int  ,     __magic_name__ :       Any  ,     __magic_name__ :       Optional[Any]=0   )  ->	Dict:
        if str(__magic_name__   ).startswith("mps"   ):
              SCREAMING_SNAKE_CASE_          =  torch.manual_seed(__magic_name__   )
        else:
              SCREAMING_SNAKE_CASE_          =  torch.Generator(device=__magic_name__   ).manual_seed(__magic_name__   )

        SCREAMING_SNAKE_CASE_          =  floats_tensor((1, 3, 32, 32)  ,     rng=random.Random(__magic_name__   )   ).to(__magic_name__   )
        SCREAMING_SNAKE_CASE_          =  floats_tensor((1, 3, 32, 32)  ,     rng=random.Random(__magic_name__   )   ).to(__magic_name__   )

        SCREAMING_SNAKE_CASE_          =  {
            "prompt": "A painting of a squirrel eating a burger",
            "image": 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    __A     (							self :       Dict   )  ->	str:
        self._test_xformers_attention_forwardGenerator_pass(expected_max_diff=1e-3   )







  def    __A     (							self :       Optional[Any]   )  ->	List[Any]:
        self._test_save_load_optional_components()







  @unittest.skipIf(torch_device != "cuda"  ,     reason="float16 requires CUDA"   )
  def    __A     (							self :       List[Any]   )  ->	List[Any]:
        # Due to non-determinism in save load of the hf-internal-testing/tiny-random-t5 text encoder
        super().test_save_load_floataa(expected_max_diff=1e-1   )







  def    __A     (							self :       Optional[Any]   )  ->	Dict:
        self._test_attention_slicing_forward_pass(expected_max_diff=1e-2   )







  def    __A     (							self :       Union[str, Any]   )  ->	Dict:
        self._test_save_load_local()







  def    __A     (							self :       Optional[Any]   )  ->	Tuple:
        self._test_inference_batch_single_identical(
            expected_max_diff=1e-2  ,     )



from __future__ import annotations


def      a__ (		__UpperCamelCase				):
      SCREAMING_SNAKE_CASE_          =  str(__UpperCamelCase				)
      return n == n[::-1]


def      a__ (		__UpperCamelCase = 1_0_0_0_0_0_0				):
      SCREAMING_SNAKE_CASE_          =  0

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


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


