

import unittest

import pytest

from transformers import (
    MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING,
    TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING,
    MBartaaTokenizerFast,
    MBartConfig,
    MBartForConditionalGeneration,
    TranslationPipeline,
    pipeline,
)
from transformers.testing_utils import is_pipeline_test, require_tf, require_torch, slow

from .test_pipelines_common import ANY






@is_pipeline_test
class 							A_			(		unittest.TestCase ):
     _lowercase      :					Any       =     MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING
     _lowercase      :					Optional[Any]       =     TF_MODEL_FOR_SEQ_TO_SEQ_CAUSAL_LM_MAPPING


     def   UpperCAmelCase  (							self      :		str      ,  UpperCAmelCase      :		List[Any]      ,  UpperCAmelCase      :		List[str]      ,  UpperCAmelCase      :		List[Any] )							->     int:
      if isinstance(model.config      ,  UpperCAmelCase ):
       __lowerCAmelCase:       Any            =				list(tokenizer.lang_code_to_id.keys() )[:2]
       __lowerCAmelCase:       Optional[Any]            =				TranslationPipeline(model=UpperCAmelCase      ,  tokenizer=UpperCAmelCase      ,  src_lang=UpperCAmelCase      ,  tgt_lang=UpperCAmelCase )
      else:
       __lowerCAmelCase:       List[str]            =				TranslationPipeline(model=UpperCAmelCase      ,  tokenizer=UpperCAmelCase )
      return translator, ["Some string", "Some other text"]


     def   UpperCAmelCase  (							self      :		Optional[Any]      ,  UpperCAmelCase      :		int      ,  UpperCAmelCase      :		int )							->     Optional[Any]:
      __lowerCAmelCase:       List[Any]            =				translator('Some string' )
      self.assertEqual(UpperCAmelCase      ,  [{'translation_text': ANY(UpperCAmelCase )}] )

      __lowerCAmelCase:       Union[str, Any]            =				translator(['Some string'] )
      self.assertEqual(UpperCAmelCase      ,  [{'translation_text': ANY(UpperCAmelCase )}] )

      __lowerCAmelCase:       int            =				translator(['Some string', 'other string'] )
      self.assertEqual(UpperCAmelCase      ,  [{'translation_text': ANY(UpperCAmelCase )}, {'translation_text': ANY(UpperCAmelCase )}] )


     @require_torch
     def   UpperCAmelCase  (							self      :		Any )							->     Any:
      __lowerCAmelCase:       Union[str, Any]            =				pipeline('translation_en_to_ro'      ,  model='patrickvonplaten/t5-tiny-random'      ,  framework='pt' )
      __lowerCAmelCase:       Optional[int]            =				translator('This is a test string'      ,  max_length=2_0 )
      self.assertEqual(
          UpperCAmelCase      ,  [
              {
                  'translation_text': (
                      'Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide'
                      ' Beide Beide'
                  )
              }
          ]      ,  )


     @require_tf
     def   UpperCAmelCase  (							self      :		List[str] )							->     Tuple:
      __lowerCAmelCase:       Optional[Any]            =				pipeline('translation_en_to_ro'      ,  model='patrickvonplaten/t5-tiny-random'      ,  framework='tf' )
      __lowerCAmelCase:       str            =				translator('This is a test string'      ,  max_length=2_0 )
      self.assertEqual(
          UpperCAmelCase      ,  [
              {
                  'translation_text': (
                      'Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide Beide'
                      ' Beide Beide'
                  )
              }
          ]      ,  )


     @require_torch
     def   UpperCAmelCase  (							self      :		Optional[int] )							->     Optional[int]:
      __lowerCAmelCase:       Optional[Any]            =				pipeline('translation_en_to_de'      ,  model='patrickvonplaten/t5-tiny-random'      ,  framework='pt' )
      __lowerCAmelCase:       Dict            =				translator('This is a test string'      ,  max_length=2_0 )
      self.assertEqual(
          UpperCAmelCase      ,  [
              {
                  'translation_text': (
                      'monoton monoton monoton monoton monoton monoton monoton monoton monoton monoton urine urine'
                      ' urine urine urine urine urine urine urine'
                  )
              }
          ]      ,  )


     @require_tf
     def   UpperCAmelCase  (							self      :		Union[str, Any] )							->     str:
      __lowerCAmelCase:       Optional[int]            =				pipeline('translation_en_to_de'      ,  model='patrickvonplaten/t5-tiny-random'      ,  framework='tf' )
      __lowerCAmelCase:       Optional[Any]            =				translator('This is a test string'      ,  max_length=2_0 )
      self.assertEqual(
          UpperCAmelCase      ,  [
              {
                  'translation_text': (
                      'monoton monoton monoton monoton monoton monoton monoton monoton monoton monoton urine urine'
                      ' urine urine urine urine urine urine urine'
                  )
              }
          ]      ,  )







class 							A_			(		unittest.TestCase ):


     @require_torch
     @slow
     def   UpperCAmelCase  (							self      :		Optional[Any] )							->     str:
      # We don't provide a default for this pair
      with self.assertRaises(UpperCAmelCase ):
       pipeline(task='translation_cn_to_ar' )

      # but we do for this one
      __lowerCAmelCase:       Optional[int]            =				pipeline(task='translation_en_to_de' )
      self.assertEqual(translator._preprocess_params['src_lang']      ,  'en' )
      self.assertEqual(translator._preprocess_params['tgt_lang']      ,  'de' )


     @require_torch
     @slow
     def   UpperCAmelCase  (							self      :		Optional[Any] )							->     Union[str, Any]:
      __lowerCAmelCase:       List[Any]            =				MBartForConditionalGeneration.from_pretrained('facebook/mbart-large-50-many-to-many-mmt' )
      __lowerCAmelCase:       List[str]            =				MBartaaTokenizerFast.from_pretrained('facebook/mbart-large-50-many-to-many-mmt' )

      __lowerCAmelCase:       Any            =				pipeline(task='translation'      ,  model=UpperCAmelCase      ,  tokenizer=UpperCAmelCase )
      # Missing src_lang, tgt_lang
      with self.assertRaises(UpperCAmelCase ):
       translator('This is a test' )

      __lowerCAmelCase:       Union[str, Any]            =				translator('This is a test'      ,  src_lang='en_XX'      ,  tgt_lang='ar_AR' )
      self.assertEqual(UpperCAmelCase      ,  [{'translation_text': 'هذا إختبار'}] )

      __lowerCAmelCase:       Optional[int]            =				translator('This is a test'      ,  src_lang='en_XX'      ,  tgt_lang='hi_IN' )
      self.assertEqual(UpperCAmelCase      ,  [{'translation_text': 'यह एक परीक्षण है'}] )

      # src_lang, tgt_lang can be defined at pipeline call time
      __lowerCAmelCase:       int            =				pipeline(task='translation'      ,  model=UpperCAmelCase      ,  tokenizer=UpperCAmelCase      ,  src_lang='en_XX'      ,  tgt_lang='ar_AR' )
      __lowerCAmelCase:       Optional[Any]            =				translator('This is a test' )
      self.assertEqual(UpperCAmelCase      ,  [{'translation_text': 'هذا إختبار'}] )


     @require_torch
     def   UpperCAmelCase  (							self      :		Optional[Any] )							->     int:
      __lowerCAmelCase:       Optional[int]            =				'patrickvonplaten/t5-tiny-random'
      __lowerCAmelCase:       Union[str, Any]            =				pipeline(task='translation_cn_to_ar'      ,  model=UpperCAmelCase )
      self.assertEqual(translator._preprocess_params['src_lang']      ,  'cn' )
      self.assertEqual(translator._preprocess_params['tgt_lang']      ,  'ar' )


     @require_torch
     def   UpperCAmelCase  (							self      :		Optional[int] )							->     Union[str, Any]:
      __lowerCAmelCase:       List[str]            =				'patrickvonplaten/t5-tiny-random'
      with pytest.warns(UpperCAmelCase      ,  match=R'.*translation_en_to_de.*' ):
       __lowerCAmelCase:       int            =				pipeline(task='translation'      ,  model=UpperCAmelCase )
      self.assertEqual(translator.task      ,  'translation_en_to_de' )
      self.assertEqual(translator._preprocess_params['src_lang']      ,  'en' )
      self.assertEqual(translator._preprocess_params['tgt_lang']      ,  'de' )


     @require_torch
     def   UpperCAmelCase  (							self      :		int )							->     str:
      with self.assertRaises(UpperCAmelCase ):
       pipeline(task='translation' )








def _a			(	SCREAMING_SNAKE_CASE		:      int = 10_00		)   ->   int:

 """simple docstring"""






 __lowerCAmelCase:       Union[str, Any]            =				[0, 3, 3, 5, 4, 4, 3, 5, 5, 4, 3, 6, 6, 8, 8, 7, 7, 9, 8, 8]
 # number of letters in twenty, thirty, ..., ninety (0 for numbers less than
 # 20 due to inconsistency in teens)
 __lowerCAmelCase:       Union[str, Any]            =				[0, 0, 6, 6, 5, 5, 5, 7, 6, 6]

 __lowerCAmelCase:       Optional[int]            =				0

 for i in range(1   , n + 1		):
  if i < 10_00:
   if i >= 1_00:
    # add number of letters for "n hundred"
    count += ones_counts[i // 1_00] + 7

    if i % 1_00 != 0:
     # add number of letters for "and" if number is not multiple
     # of 100
     count += 3

   if 0 < i % 1_00 < 20:
    # add number of letters for one, two, three, ..., nineteen
    # (could be combined with below if not for inconsistency in
    # teens)
    count += ones_counts[i % 1_00]
   else:
    # add number of letters for twenty, twenty one, ..., ninety
    # nine
    count += ones_counts[i % 10]
    count += tens_counts[(i % 1_00 - i % 10) // 10]
  else:
   count += ones_counts[i // 10_00] + 8
 return count


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





