'''simple docstring'''

from __future__ import annotations

import unittest

from transformers import is_tf_available
from transformers.testing_utils import require_tf, slow

from ...test_configuration_common import ConfigTester
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_tf_available():
       import numpy
       import tensorflow as tf

       from transformers import (
           TF_DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
           TF_DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST,
           TF_DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST,
           BertConfig,
           DPRConfig,
           TFDPRContextEncoder,
           TFDPRQuestionEncoder,
           TFDPRReader,
       )





class 							lowercase						:


   def __init__(   self				:	Dict   ,		__lowerCAmelCase				:	Union[str, Any]   ,		__lowerCAmelCase				:	str=13   ,		__lowerCAmelCase				:	List[str]=7   ,		__lowerCAmelCase				:	Optional[Any]=True   ,		__lowerCAmelCase				:	Dict=True   ,		__lowerCAmelCase				:	List[Any]=True   ,		__lowerCAmelCase				:	Optional[Any]=True   ,		__lowerCAmelCase				:	Dict=99   ,		__lowerCAmelCase				:	str=32   ,		__lowerCAmelCase				:	Tuple=2   ,		__lowerCAmelCase				:	List[str]=4   ,		__lowerCAmelCase				:	Optional[int]=37   ,		__lowerCAmelCase				:	Dict="gelu"   ,		__lowerCAmelCase				:	str=0.1   ,		__lowerCAmelCase				:	int=0.1   ,		__lowerCAmelCase				:	Union[str, Any]=512   ,		__lowerCAmelCase				:	Optional[Any]=16   ,		__lowerCAmelCase				:	Optional[Any]=2   ,		__lowerCAmelCase				:	Any=0.02   ,		__lowerCAmelCase				:	str=3   ,		__lowerCAmelCase				:	Optional[Any]=4   ,		__lowerCAmelCase				:	int=None   ,		__lowerCAmelCase				:	Any=0   ,		)      ->					Optional[int]:
         lowercase_     =      parent
         lowercase_     =      batch_size
         lowercase_     =      seq_length
         lowercase_     =      is_training
         lowercase_     =      use_input_mask
         lowercase_     =      use_token_type_ids
         lowercase_     =      use_labels
         lowercase_     =      vocab_size
         lowercase_     =      hidden_size
         lowercase_     =      num_hidden_layers
         lowercase_     =      num_attention_heads
         lowercase_     =      intermediate_size
         lowercase_     =      hidden_act
         lowercase_     =      hidden_dropout_prob
         lowercase_     =      attention_probs_dropout_prob
         lowercase_     =      max_position_embeddings
         lowercase_     =      type_vocab_size
         lowercase_     =      type_sequence_label_size
         lowercase_     =      initializer_range
         lowercase_     =      num_labels
         lowercase_     =      num_choices
         lowercase_     =      scope
         lowercase_     =      projection_dim


   def __UpperCAmelCase       (   self				:	int)      ->					List[str]:
         lowercase_     =      ids_tensor([self.batch_size, self.seq_length]   ,		self.vocab_size)

         lowercase_     =      None
         if self.use_input_mask:
               # follow test_modeling_tf_ctrl.py
               lowercase_     =      random_attention_mask([self.batch_size, self.seq_length])

         lowercase_     =      None
         if self.use_token_type_ids:
               lowercase_     =      ids_tensor([self.batch_size, self.seq_length]   ,		self.type_vocab_size)

         lowercase_     =      None
         lowercase_     =      None
         lowercase_     =      None
         if self.use_labels:
               lowercase_     =      ids_tensor([self.batch_size]   ,		self.type_sequence_label_size)
               lowercase_     =      ids_tensor([self.batch_size, self.seq_length]   ,		self.num_labels)
               lowercase_     =      ids_tensor([self.batch_size]   ,		self.num_choices)

         lowercase_     =      BertConfig(
             vocab_size=self.vocab_size   ,		hidden_size=self.hidden_size   ,		num_hidden_layers=self.num_hidden_layers   ,		num_attention_heads=self.num_attention_heads   ,		intermediate_size=self.intermediate_size   ,		hidden_act=self.hidden_act   ,		hidden_dropout_prob=self.hidden_dropout_prob   ,		attention_probs_dropout_prob=self.attention_probs_dropout_prob   ,		max_position_embeddings=self.max_position_embeddings   ,		type_vocab_size=self.type_vocab_size   ,		is_decoder=__lowerCAmelCase   ,		initializer_range=self.initializer_range   ,		)
         lowercase_     =      DPRConfig(projection_dim=self.projection_dim   ,		**config.to_dict())

         return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels


   def __UpperCAmelCase       (   self				:	int   ,		__lowerCAmelCase				:	int   ,		__lowerCAmelCase				:	Optional[Any]   ,		__lowerCAmelCase				:	Tuple   ,		__lowerCAmelCase				:	Optional[Any]   ,		__lowerCAmelCase				:	Tuple   ,		__lowerCAmelCase				:	Optional[Any]   ,		__lowerCAmelCase				:	Union[str, Any])      ->					List[str]:
         lowercase_     =      TFDPRContextEncoder(config=__lowerCAmelCase)
         lowercase_     =      model(__lowerCAmelCase   ,		attention_mask=__lowerCAmelCase   ,		token_type_ids=__lowerCAmelCase)
         lowercase_     =      model(__lowerCAmelCase   ,		token_type_ids=__lowerCAmelCase)
         lowercase_     =      model(__lowerCAmelCase)
         self.parent.assertEqual(result.pooler_output.shape   ,		(self.batch_size, self.projection_dim or self.hidden_size))


   def __UpperCAmelCase       (   self				:	List[str]   ,		__lowerCAmelCase				:	Optional[int]   ,		__lowerCAmelCase				:	Tuple   ,		__lowerCAmelCase				:	List[Any]   ,		__lowerCAmelCase				:	str   ,		__lowerCAmelCase				:	List[str]   ,		__lowerCAmelCase				:	str   ,		__lowerCAmelCase				:	Any)      ->					List[Any]:
         lowercase_     =      TFDPRQuestionEncoder(config=__lowerCAmelCase)
         lowercase_     =      model(__lowerCAmelCase   ,		attention_mask=__lowerCAmelCase   ,		token_type_ids=__lowerCAmelCase)
         lowercase_     =      model(__lowerCAmelCase   ,		token_type_ids=__lowerCAmelCase)
         lowercase_     =      model(__lowerCAmelCase)
         self.parent.assertEqual(result.pooler_output.shape   ,		(self.batch_size, self.projection_dim or self.hidden_size))


   def __UpperCAmelCase       (   self				:	Optional[Any]   ,		__lowerCAmelCase				:	int   ,		__lowerCAmelCase				:	List[Any]   ,		__lowerCAmelCase				:	Dict   ,		__lowerCAmelCase				:	Tuple   ,		__lowerCAmelCase				:	Any   ,		__lowerCAmelCase				:	List[str]   ,		__lowerCAmelCase				:	Any)      ->					Optional[Any]:
         lowercase_     =      TFDPRReader(config=__lowerCAmelCase)
         lowercase_     =      model(__lowerCAmelCase   ,		attention_mask=__lowerCAmelCase)

         self.parent.assertEqual(result.start_logits.shape   ,		(self.batch_size, self.seq_length))
         self.parent.assertEqual(result.end_logits.shape   ,		(self.batch_size, self.seq_length))
         self.parent.assertEqual(result.relevance_logits.shape   ,		(self.batch_size,))


   def __UpperCAmelCase       (   self				:	Dict)      ->					Union[str, Any]:
         lowercase_     =      self.prepare_config_and_inputs()
         (
             (
             lowercase_
         ) ,							(
             lowercase_
         ) ,							(
             lowercase_
         ) ,							(
             lowercase_
         ) ,							(
             lowercase_
         ) ,							(
             lowercase_
         ) ,							(
             lowercase_
         ) ,							
         )     =      config_and_inputs
         lowercase_     =      {"input_ids": input_ids}
         return config, inputs_dict





@require_tf
class 							lowercase						(						__lowerCamelCase ,				__lowerCamelCase ,				unittest.TestCase ):
   lowerCamelCase_    					=(
       (
           TFDPRContextEncoder,
           TFDPRQuestionEncoder,
           TFDPRReader,
       )
       if is_tf_available()
       else ()
   )
   lowerCamelCase_    					={'feature-extraction': TFDPRQuestionEncoder} if is_tf_available() else {}

   lowerCamelCase_    					=False
   lowerCamelCase_    					=False
   lowerCamelCase_    					=False
   lowerCamelCase_    					=False
   lowerCamelCase_    					=False


   def __UpperCAmelCase       (   self				:	int)      ->					Any:
         lowercase_     =      TFDPRModelTester(self)
         lowercase_     =      ConfigTester(self   ,		config_class=__lowerCAmelCase   ,		hidden_size=37)


   def __UpperCAmelCase       (   self				:	Dict)      ->					Dict:
         self.config_tester.run_common_tests()


   def __UpperCAmelCase       (   self				:	List[str])      ->					Any:
         lowercase_     =      self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_dpr_context_encoder(*__lowerCAmelCase)


   def __UpperCAmelCase       (   self				:	Any)      ->					Any:
         lowercase_     =      self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_dpr_question_encoder(*__lowerCAmelCase)


   def __UpperCAmelCase       (   self				:	Optional[Any])      ->					Dict:
         lowercase_     =      self.model_tester.prepare_config_and_inputs()
         self.model_tester.create_and_check_dpr_reader(*__lowerCAmelCase)


   @slow
   def __UpperCAmelCase       (   self				:	int)      ->					Any:
         for model_name in TF_DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
               lowercase_     =      TFDPRContextEncoder.from_pretrained(__lowerCAmelCase)
               self.assertIsNotNone(__lowerCAmelCase)

         for model_name in TF_DPR_CONTEXT_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
               lowercase_     =      TFDPRContextEncoder.from_pretrained(__lowerCAmelCase)
               self.assertIsNotNone(__lowerCAmelCase)

         for model_name in TF_DPR_QUESTION_ENCODER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
               lowercase_     =      TFDPRQuestionEncoder.from_pretrained(__lowerCAmelCase)
               self.assertIsNotNone(__lowerCAmelCase)

         for model_name in TF_DPR_READER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
               lowercase_     =      TFDPRReader.from_pretrained(__lowerCAmelCase)
               self.assertIsNotNone(__lowerCAmelCase)





@require_tf
class 							lowercase						(						unittest.TestCase ):


   @slow
   def __UpperCAmelCase       (   self				:	int)      ->					int:
         lowercase_     =      TFDPRQuestionEncoder.from_pretrained("facebook/dpr-question_encoder-single-nq-base")

         lowercase_     =      tf.constant(
             [[101, 7592, 1010, 2003, 2026, 3899, 1_0140, 1029, 102]])  # [CLS] hello, is my dog cute? [SEP]
         lowercase_     =      model(__lowerCAmelCase)[0]  # embedding shape = (1, 768)
         # compare the actual values for a slice.
         lowercase_     =      tf.constant(
             [
                 [
                     0.0323_6253,
                     0.1275_3335,
                     0.1681_8509,
                     0.0027_9786,
                     0.389_6933,
                     0.2426_4945,
                     0.217_8971,
                     -0.0233_5227,
                     -0.0848_1959,
                     -0.1432_4117,
                 ]
             ])
         self.assertTrue(numpy.allclose(output[:, :10].numpy()   ,		expected_slice.numpy()   ,		atol=1e-4))







'''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()))))






