






"""simple docstring"""
from typing import Any, Callable, Dict, List, Optional, Union

import PIL.Image
import torch
from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    DiffusionPipeline,
    LMSDiscreteScheduler,
    PNDMScheduler,
    StableDiffusionImgaImgPipeline,
    StableDiffusionInpaintPipelineLegacy,
    StableDiffusionPipeline,
    UNetaDConditionModel,
)
from diffusers.configuration_utils import FrozenDict
from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
from diffusers.utils import deprecate, logging


A_			: Dict				=			logging.get_logger(__name__)  # pylint: disable=invalid-name



class 		a_      (	snake_case_ ):







      '''simple docstring'''

      lowerCamelCase__       :				Optional[Any] =	['safety_checker', 'feature_extractor']




      def __init__(self,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_ = True,     ):

       '''simple docstring'''



       super().__init__()
       if hasattr(scheduler.config,     'steps_offset'					) and scheduler.config.steps_offset != 1:
        lowerCamelCase__     :			Tuple     				=						(
            f'''The configuration file of this scheduler: {scheduler} is outdated. `steps_offset`'''
            f''' should be set to 1 instead of {scheduler.config.steps_offset}. Please make sure '''
            'to update the config accordingly as leaving `steps_offset` might led to incorrect results'
            ' in future versions. If you have downloaded this checkpoint from the Hugging Face Hub,'
            ' it would be very nice if you could open a Pull request for the `scheduler/scheduler_config.json`'
            ' file'
        )
        deprecate('steps_offset!=1',     '1.0.0',     lowerCamelCase_,     standard_warn=lowerCamelCase_					)
        lowerCamelCase__     :			Optional[Any]     				=						dict(scheduler.config					)
        lowerCamelCase__     :			Any     				=						1
        lowerCamelCase__     :			List[Any]     				=						FrozenDict(lowerCamelCase_					)

       self.register_modules(
           vae=lowerCamelCase_,     text_encoder=lowerCamelCase_,     tokenizer=lowerCamelCase_,     unet=lowerCamelCase_,     scheduler=lowerCamelCase_,     safety_checker=lowerCamelCase_,     feature_extractor=lowerCamelCase_,     )
       self.register_to_config(requires_safety_checker=lowerCamelCase_					)




      @property
      def 			a__							(self					):

       '''simple docstring'''



       return {k: getattr(self,     lowerCamelCase_					) for k in self.config.keys() if not k.startswith('_'					)}




      def 			a__							(self,     lowerCamelCase_ = "auto"					):

       '''simple docstring'''



       if slice_size == "auto":
        # half the attention head size is usually a good trade-off between
        # speed and memory
        lowerCamelCase__     :			Optional[int]     				=						self.unet.config.attention_head_dim // 2
       self.unet.set_attention_slice(lowerCamelCase_					)




      def 			a__							(self					):

       '''simple docstring'''



       self.enable_attention_slicing(lowerCamelCase_					)




      @torch.no_grad()
      def 			a__							(self,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_ = 0.8,     lowerCamelCase_ = 5_0,     lowerCamelCase_ = 7.5,     lowerCamelCase_ = None,     lowerCamelCase_ = 1,     lowerCamelCase_ = 0.0,     lowerCamelCase_ = None,     lowerCamelCase_ = "pil",     lowerCamelCase_ = True,     lowerCamelCase_ = None,     lowerCamelCase_ = 1,     ):

       '''simple docstring'''



       return StableDiffusionInpaintPipelineLegacy(**self.components					)(
           prompt=lowerCamelCase_,     image=lowerCamelCase_,     mask_image=lowerCamelCase_,     strength=lowerCamelCase_,     num_inference_steps=lowerCamelCase_,     guidance_scale=lowerCamelCase_,     negative_prompt=lowerCamelCase_,     num_images_per_prompt=lowerCamelCase_,     eta=lowerCamelCase_,     generator=lowerCamelCase_,     output_type=lowerCamelCase_,     return_dict=lowerCamelCase_,     callback=lowerCamelCase_,     )




      @torch.no_grad()
      def 			a__							(self,     lowerCamelCase_,     lowerCamelCase_,     lowerCamelCase_ = 0.8,     lowerCamelCase_ = 5_0,     lowerCamelCase_ = 7.5,     lowerCamelCase_ = None,     lowerCamelCase_ = 1,     lowerCamelCase_ = 0.0,     lowerCamelCase_ = None,     lowerCamelCase_ = "pil",     lowerCamelCase_ = True,     lowerCamelCase_ = None,     lowerCamelCase_ = 1,     **lowerCamelCase_,     ):

       '''simple docstring'''



       return StableDiffusionImgaImgPipeline(**self.components					)(
           prompt=lowerCamelCase_,     image=lowerCamelCase_,     strength=lowerCamelCase_,     num_inference_steps=lowerCamelCase_,     guidance_scale=lowerCamelCase_,     negative_prompt=lowerCamelCase_,     num_images_per_prompt=lowerCamelCase_,     eta=lowerCamelCase_,     generator=lowerCamelCase_,     output_type=lowerCamelCase_,     return_dict=lowerCamelCase_,     callback=lowerCamelCase_,     callback_steps=lowerCamelCase_,     )





      @torch.no_grad()
      def 			a__							(self,     lowerCamelCase_,     lowerCamelCase_ = 5_1_2,     lowerCamelCase_ = 5_1_2,     lowerCamelCase_ = 5_0,     lowerCamelCase_ = 7.5,     lowerCamelCase_ = None,     lowerCamelCase_ = 1,     lowerCamelCase_ = 0.0,     lowerCamelCase_ = None,     lowerCamelCase_ = None,     lowerCamelCase_ = "pil",     lowerCamelCase_ = True,     lowerCamelCase_ = None,     lowerCamelCase_ = 1,     ):

       '''simple docstring'''



       return StableDiffusionPipeline(**self.components					)(
           prompt=lowerCamelCase_,     height=lowerCamelCase_,     width=lowerCamelCase_,     num_inference_steps=lowerCamelCase_,     guidance_scale=lowerCamelCase_,     negative_prompt=lowerCamelCase_,     num_images_per_prompt=lowerCamelCase_,     eta=lowerCamelCase_,     generator=lowerCamelCase_,     latents=lowerCamelCase_,     output_type=lowerCamelCase_,     return_dict=lowerCamelCase_,     callback=lowerCamelCase_,     callback_steps=lowerCamelCase_,     )









"""simple docstring"""
import os






def        lowerCamelCase_  (						):
 lowerCamelCase__     :			List[Any]     				=						os.path.dirname(os.path.realpath(_lowerCamelCase				)				)
 lowerCamelCase__     :			Any     				=						os.path.join(_lowerCamelCase			,   'triangle.txt'				)

 with open(_lowerCamelCase				) as in_file:
  lowerCamelCase__     :			Dict     				=						[[int(_lowerCamelCase				) for i in line.split()] for line in in_file]

 while len(_lowerCamelCase				) != 1:
  lowerCamelCase__     :			Dict     				=						triangle.pop()
  lowerCamelCase__     :			Optional[Any]     				=						triangle[-1]
  for j in range(len(_lowerCamelCase				) - 1				):
   curr_row[j] += max(last_row[j]			,   last_row[j + 1]				)
 return triangle[0][0]


if __name__ == "__main__":
      print(solution())

