






import json
import os
import tempfile
import unittest

import numpy as np
from datasets import load_dataset

from transformers.testing_utils import require_torch, require_vision, slow
from transformers.utils import is_torch_available, is_vision_available

from ...test_image_processing_common import ImageProcessingSavingTestMixin


if is_torch_available():
   import torch

if is_vision_available():
   from PIL import Image

   from transformers import ImageGPTImageProcessor


class  SCREAMING_SNAKE_CASE			(			unittest.TestCase					):
     '''simple docstring'''


     def __init__(				self       :	List[Any]					, UpperCAmelCase_       :	Any					, UpperCAmelCase_       :	Union[str, Any]=7					, UpperCAmelCase_       :	Tuple=3					, UpperCAmelCase_       :	Optional[int]=18					, UpperCAmelCase_       :	List[str]=30					, UpperCAmelCase_       :	str=400					, UpperCAmelCase_       :	int=True					, UpperCAmelCase_       :	Dict=None					, UpperCAmelCase_       :	Dict=True					, ):
       SCREAMING_SNAKE_CASE       :      Dict							=    size if size is not None else {"height": 18, "width": 18}
       SCREAMING_SNAKE_CASE       :      Dict							=    parent
       SCREAMING_SNAKE_CASE       :      int							=    batch_size
       SCREAMING_SNAKE_CASE       :      List[Any]							=    num_channels
       SCREAMING_SNAKE_CASE       :      Tuple							=    image_size
       SCREAMING_SNAKE_CASE       :      Tuple							=    min_resolution
       SCREAMING_SNAKE_CASE       :      str							=    max_resolution
       SCREAMING_SNAKE_CASE       :      str							=    do_resize
       SCREAMING_SNAKE_CASE       :      List[Any]							=    size
       SCREAMING_SNAKE_CASE       :      Optional[int]							=    do_normalize






     def 				_A       (				self       :	str      ):
       return {
           # here we create 2 clusters for the sake of simplicity
           "clusters": np.asarray(
               [
                   [0.8_866_443_634_033_203, 0.6_618_829_369_544_983, 0.3_891_746_401_786_804],
                   [-0.6_042_559_146_881_104, -0.02_295_008_860_528_469, 0.5_423_797_369_003_296],
               ]      ),
           "do_resize": self.do_resize,
           "size": self.size,
           "do_normalize": self.do_normalize,
       }





@require_torch
@require_vision
class  SCREAMING_SNAKE_CASE			(			lowerCAmelCase      ,		unittest.TestCase					):
     '''simple docstring'''


     UpperCamelCase_							:		Optional[Any]			=	ImageGPTImageProcessor if is_vision_available() else None


     def 				_A       (				self       :	str      ):
       SCREAMING_SNAKE_CASE       :      List[Any]							=    ImageGPTImageProcessingTester(self      )


     @property
     def 				_A       (				self       :	List[str]      ):
       return self.image_processor_tester.prepare_image_processor_dict()


     def 				_A       (				self       :	Tuple      ):
       SCREAMING_SNAKE_CASE       :      Tuple							=    self.image_processing_class(**self.image_processor_dict      )
       self.assertTrue(hasattr(UpperCAmelCase_					, "clusters"      )      )
       self.assertTrue(hasattr(UpperCAmelCase_					, "do_resize"      )      )
       self.assertTrue(hasattr(UpperCAmelCase_					, "size"      )      )
       self.assertTrue(hasattr(UpperCAmelCase_					, "do_normalize"      )      )


     def 				_A       (				self       :	Tuple      ):
       SCREAMING_SNAKE_CASE       :      List[str]							=    self.image_processing_class.from_dict(self.image_processor_dict      )
       self.assertEqual(image_processor.size					, {"height": 18, "width": 18}      )

       SCREAMING_SNAKE_CASE       :      List[str]							=    self.image_processing_class.from_dict(self.image_processor_dict					, size=42      )
       self.assertEqual(image_processor.size					, {"height": 42, "width": 42}      )


     def 				_A       (				self       :	str      ):
       SCREAMING_SNAKE_CASE       :      Tuple							=    self.image_processing_class(**self.image_processor_dict      )
       SCREAMING_SNAKE_CASE       :      Optional[Any]							=    json.loads(image_processor.to_json_string()      )
       for key, value in self.image_processor_dict.items():
         if key == "clusters":
           self.assertTrue(np.array_equal(UpperCAmelCase_					, obj[key]      )      )
         else:
           self.assertEqual(obj[key]					, UpperCAmelCase_      )


     def 				_A       (				self       :	int      ):
       SCREAMING_SNAKE_CASE       :      Dict							=    self.image_processing_class(**self.image_processor_dict      )

       with tempfile.TemporaryDirectory() as tmpdirname:
         SCREAMING_SNAKE_CASE       :      List[Any]							=    os.path.join(UpperCAmelCase_					, "image_processor.json"      )
         image_processor_first.to_json_file(UpperCAmelCase_      )
         SCREAMING_SNAKE_CASE       :      Any							=    self.image_processing_class.from_json_file(UpperCAmelCase_      ).to_dict()

       SCREAMING_SNAKE_CASE       :      Optional[Any]							=    image_processor_first.to_dict()
       for key, value in image_processor_first.items():
         if key == "clusters":
           self.assertTrue(np.array_equal(UpperCAmelCase_					, image_processor_second[key]      )      )
         else:
           self.assertEqual(image_processor_first[key]					, UpperCAmelCase_      )


     def 				_A       (				self       :	Any      ):
       SCREAMING_SNAKE_CASE       :      Optional[Any]							=    self.image_processing_class(**self.image_processor_dict      )

       with tempfile.TemporaryDirectory() as tmpdirname:
         image_processor_first.save_pretrained(UpperCAmelCase_      )
         SCREAMING_SNAKE_CASE       :      Optional[Any]							=    self.image_processing_class.from_pretrained(UpperCAmelCase_      ).to_dict()

       SCREAMING_SNAKE_CASE       :      Any							=    image_processor_first.to_dict()
       for key, value in image_processor_first.items():
         if key == "clusters":
           self.assertTrue(np.array_equal(UpperCAmelCase_					, image_processor_second[key]      )      )
         else:
           self.assertEqual(image_processor_first[key]					, UpperCAmelCase_      )






     @unittest.skip("ImageGPT requires clusters at initialization"      )
     def 				_A       (				self       :	Optional[int]      ):
       pass





def   lowerCamelCase__			(     ):

  """simple docstring"""






  SCREAMING_SNAKE_CASE       :      List[Any]							=    load_dataset("hf-internal-testing/fixtures_image_utils"						,     split="test"				)

  SCREAMING_SNAKE_CASE       :      Union[str, Any]							=    Image.open(dataset[4]["file"]				)
  SCREAMING_SNAKE_CASE       :      int							=    Image.open(dataset[5]["file"]				)

  SCREAMING_SNAKE_CASE       :      Optional[int]							=    [imagea, imagea]

  return images


@require_vision
@require_torch
class  SCREAMING_SNAKE_CASE			(			unittest.TestCase					):
     '''simple docstring'''


     @slow
     def 				_A       (				self       :	str      ):
       SCREAMING_SNAKE_CASE       :      Union[str, Any]							=    ImageGPTImageProcessor.from_pretrained("openai/imagegpt-small"      )

       SCREAMING_SNAKE_CASE       :      List[str]							=    prepare_images()

       # test non-batched
       SCREAMING_SNAKE_CASE       :      Optional[Any]							=    image_processing(images[0]					, return_tensors="pt"      )

       self.assertIsInstance(encoding.input_ids					, torch.LongTensor      )
       self.assertEqual(encoding.input_ids.shape					, (1, 1024)      )

       SCREAMING_SNAKE_CASE       :      int							=    [306, 191, 191]
       self.assertEqual(encoding.input_ids[0, :3].tolist()					, UpperCAmelCase_      )

       # test batched
       SCREAMING_SNAKE_CASE       :      Optional[Any]							=    image_processing(UpperCAmelCase_					, return_tensors="pt"      )

       self.assertIsInstance(encoding.input_ids					, torch.LongTensor      )
       self.assertEqual(encoding.input_ids.shape					, (2, 1024)      )

       SCREAMING_SNAKE_CASE       :      Optional[Any]							=    [303, 13, 13]
       self.assertEqual(encoding.input_ids[1, -3:].tolist()					, UpperCAmelCase_      )














from __future__ import annotations


def   lowerCamelCase__			(     lowercase				):

  """simple docstring"""






  SCREAMING_SNAKE_CASE       :      Optional[Any]							=    str(lowercase				)
  return n == n[::-1]


def   lowerCamelCase__			(     lowercase = 1000000				):

  """simple docstring"""






  SCREAMING_SNAKE_CASE       :      int							=    0

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


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






