


from __future__ import annotations

import os







class       _lowercase			:


       """simple docstring"""




       A__ 						=      (
           "High card",
           "One pair",
           "Two pairs",
           "Three of a kind",
           "Straight",
           "Flush",
           "Full house",
           "Four of a kind",
           "Straight flush",
           "Royal flush",
       )

       A__ 						=      (
           "",  # placeholder as tuples are zero-indexed
           "One",
           "Two",
           "Three",
           "Four",
           "Five",
           "Six",
           "Seven",
           "Eight",
           "Nine",
           "Ten",
           "Jack",
           "Queen",
           "King",
           "Ace",
       )





       def __init__(       self							:      Optional[Any] ,				__lowerCamelCase							:      str	):


             '''simple docstring'''



             if not isinstance(__lowerCamelCase ,				__lowerCamelCase	):
                   lowerCamelCase__		:    List[Any]   =  f"Hand should be of type 'str': {hand!r}"
                   raise TypeError(__lowerCamelCase	)
             # split removes duplicate whitespaces so no need of strip
             if len(hand.split(" "	)	) != 5:
                   lowerCamelCase__		:    Any   =  f"Hand should contain only 5 cards: {hand!r}"
                   raise ValueError(__lowerCamelCase	)
             lowerCamelCase__		:    List[str]   =  hand
             lowerCamelCase__		:    List[str]   =  0
             lowerCamelCase__		:    int   =  0
             lowerCamelCase__   ,       lowerCamelCase__		:    Optional[Any]   =  self._internal_state()
             lowerCamelCase__		:    str   =  self._get_hand_type()
             lowerCamelCase__		:    Optional[Any]   =  self._card_values[0]





       @property
       def 						lowerCAmelCase					(       self							:      List[str]	):


             '''simple docstring'''



             return self._hand





       def 						lowerCAmelCase					(       self							:      int ,				__lowerCamelCase							:      PokerHand	):


             '''simple docstring'''



             if self._hand_type > other._hand_type:
                   return "Win"
             elif self._hand_type < other._hand_type:
                   return "Loss"
             elif self._first_pair == other._first_pair:
                   if self._second_pair == other._second_pair:
                         return self._compare_cards(__lowerCamelCase	)
                   else:
                         return "Win" if self._second_pair > other._second_pair else "Loss"
             return "Win" if self._first_pair > other._first_pair else "Loss"





       def 						lowerCAmelCase					(       self							:      List[str]	):


             '''simple docstring'''



             lowerCamelCase__		:    Optional[int]   =  PokerHand._HAND_NAME[self._hand_type - 14]
             lowerCamelCase__		:    Tuple   =  PokerHand._CARD_NAME[self._high_card]
             lowerCamelCase__		:    Any   =  PokerHand._CARD_NAME[self._first_pair]
             lowerCamelCase__		:    Optional[int]   =  PokerHand._CARD_NAME[self._second_pair]
             if self._hand_type in [22, 19, 18]:
                   return name + f", {high}-high"
             elif self._hand_type in [21, 17, 15]:
                   return name + f", {paira}s"
             elif self._hand_type in [20, 16]:
                   lowerCamelCase__		:    List[str]   =  "over" if self._hand_type == 20 else "and"
                   return name + f", {paira}s {join} {paira}s"
             elif self._hand_type == 23:
                   return name
             else:
                   return name + f", {high}"





       def 						lowerCAmelCase					(       self							:      List[str] ,				__lowerCamelCase							:      PokerHand	):


             '''simple docstring'''



             for index, card_value in enumerate(self._card_values	):
                   if card_value != other._card_values[index]:
                         return "Win" if card_value > other._card_values[index] else "Loss"
             return "Tie"





       def 						lowerCAmelCase					(       self							:      Any	):


             '''simple docstring'''



             if self._is_flush():
                   if self._is_five_high_straight() or self._is_straight():
                         return 23 if sum(self._card_values	) == 60 else 22
                   return 19
             elif self._is_five_high_straight() or self._is_straight():
                   return 18
             return 14 + self._is_same_kind()





       def 						lowerCAmelCase					(       self							:      Tuple	):


             '''simple docstring'''



             return len(self._card_suit	) == 1





       def 						lowerCAmelCase					(       self							:      List[Any]	):


             '''simple docstring'''



             if sorted(self._card_values	) == [2, 3, 4, 5, 14]:
                   if self._card_values[0] == 14:
                         # Remember, our list is sorted in reverse order
                         lowerCamelCase__		:    str   =  self._card_values.pop(0	)
                         self._card_values.append(__lowerCamelCase	)
                   return True
             return False





       def 						lowerCAmelCase					(       self							:      List[Any]	):


             '''simple docstring'''



             for i in range(4	):
                   if self._card_values[i] - self._card_values[i + 1] != 1:
                         return False
             return True





       def 						lowerCAmelCase					(       self							:      Union[str, Any]	):


             '''simple docstring'''



             lowerCamelCase__		:    Any   =  0
             for i in range(4	):
                   # Compare two cards at a time, if they are same increase 'kind',
                   # add the value of the card to val1, if it is repeating again we
                   # will add 2 to 'kind' as there are now 3 cards with same value.
                   # If we get card of different value than val1, we will do the same
                   # thing with val2
                   if self._card_values[i] == self._card_values[i + 1]:
                         if not vala:
                               lowerCamelCase__		:    List[Any]   =  self._card_values[i]
                               kind += 1
                         elif vala == self._card_values[i]:
                               kind += 2
                         elif not vala:
                               lowerCamelCase__		:    str   =  self._card_values[i]
                               kind += 1
                         elif vala == self._card_values[i]:
                               kind += 2
        # For consistency in hand type (look at note in _get_hand_type function)
             lowerCamelCase__		:    Any   =  kind + 2 if kind in [4, 5] else kind
             # first meaning first pair to compare in 'compare_with'
             lowerCamelCase__		:    Optional[int]   =  max(__lowerCamelCase ,				__lowerCamelCase	)
             lowerCamelCase__		:    str   =  min(__lowerCamelCase ,				__lowerCamelCase	)
             # If it's full house (three count pair + two count pair), make sure
             # first pair is three count and if not then switch them both.
             if kind == 6 and self._card_values.count(__lowerCamelCase	) != 3:
                   lowerCamelCase__   ,       lowerCamelCase__		:    Dict   =  second, first
             lowerCamelCase__		:    Any   =  first
             lowerCamelCase__		:    str   =  second
             return kind





       def 						lowerCAmelCase					(       self							:      Tuple	):


             '''simple docstring'''



             lowerCamelCase__		:    dict   =  {"T": "10", "J": "11", "Q": "12", "K": "13", "A": "14"}
             lowerCamelCase__		:    str   =  self._hand.translate(str.maketrans(__lowerCamelCase	)	).split()
             lowerCamelCase__		:    List[Any]   =  [int(card[:-1]	) for card in new_hand]
             lowerCamelCase__		:    Any   =  {card[-1] for card in new_hand}
             return sorted(__lowerCamelCase ,				reverse=__lowerCamelCase	), card_suit





       def __repr__(       self							:      List[Any]	):


             '''simple docstring'''



             return f"{self.__class__}(\"{self._hand}\")"





       def __str__(       self							:      List[str]	):


             '''simple docstring'''



             return self._hand





       def __eq__(       self							:      Optional[Any] ,				__lowerCamelCase							:      Any	):


             '''simple docstring'''



             if isinstance(__lowerCamelCase ,				__lowerCamelCase	):
                   return self.compare_with(__lowerCamelCase	) == "Tie"
             return NotImplemented





       def __lt__(       self							:      Dict ,				__lowerCamelCase							:      Any	):


             '''simple docstring'''



             if isinstance(__lowerCamelCase ,				__lowerCamelCase	):
                   return self.compare_with(__lowerCamelCase	) == "Loss"
             return NotImplemented





       def __le__(       self							:      int ,				__lowerCamelCase							:      Any	):


             '''simple docstring'''



             if isinstance(__lowerCamelCase ,				__lowerCamelCase	):
                   return self < other or self == other
             return NotImplemented





       def __gt__(       self							:      str ,				__lowerCamelCase							:      Tuple	):


             '''simple docstring'''



             if isinstance(__lowerCamelCase ,				__lowerCamelCase	):
                   return not self < other and self != other
             return NotImplemented





       def __ge__(       self							:      List[str] ,				__lowerCamelCase							:      int	):


             '''simple docstring'''



             if isinstance(__lowerCamelCase ,				__lowerCamelCase	):
                   return not self < other
             return NotImplemented





       def __hash__(       self							:      Optional[int]	):


             '''simple docstring'''



             return object.__hash__(self	)



def 				lowercase_		(		):

      """simple docstring"""




      lowerCamelCase__		:    str   =  0
      lowerCamelCase__		:    Union[str, Any]   =  os.path.abspath(os.path.dirname(_A						)						)
      lowerCamelCase__		:    Tuple   =  os.path.join(_A   , "poker_hands.txt"						)
      with open(_A						) as file_hand:
            for line in file_hand:
                  lowerCamelCase__		:    Optional[int]   =  line[:14].strip()
                  lowerCamelCase__		:    Union[str, Any]   =  line[15:].strip()
                  lowerCamelCase__   ,       lowerCamelCase__		:    Any   =  PokerHand(_A						), PokerHand(_A						)
                  lowerCamelCase__		:    int   =  player.compare_with(_A						)
                  if output == "Win":
                        answer += 1
      return answer


if __name__ == "__main__":
    solution()






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				:   str		= logging.get_logger(__name__)  # pylint: disable=invalid-name







class       _lowercase			(							lowercase__):


       """simple docstring"""




       A__ 						=      ["safety_checker", "feature_extractor"]





       def __init__(       self							:      Optional[Any] ,				__lowerCamelCase							:      AutoencoderKL ,				__lowerCamelCase							:      CLIPTextModel ,				__lowerCamelCase							:      CLIPTokenizer ,				__lowerCamelCase							:      UNetaDConditionModel ,				__lowerCamelCase							:      Union[DDIMScheduler, PNDMScheduler, LMSDiscreteScheduler] ,				__lowerCamelCase							:      StableDiffusionSafetyChecker ,				__lowerCamelCase							:      CLIPImageProcessor ,				__lowerCamelCase							:      bool = True ,				):


             '''simple docstring'''



             super().__init__()
             if hasattr(scheduler.config ,				"steps_offset"	) and scheduler.config.steps_offset != 1:
                   lowerCamelCase__		:    List[str]   =  (
                       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__		:    List[str]   =  dict(scheduler.config	)
                   lowerCamelCase__		:    Optional[Any]   =  1
                   lowerCamelCase__		:    Union[str, 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 						lowerCAmelCase					(       self							:      List[Any]	):


             '''simple docstring'''



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





       def 						lowerCAmelCase					(       self							:      List[Any] ,				__lowerCamelCase							:      Optional[Union[str, int]] = "auto"	):


             '''simple docstring'''



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





       def 						lowerCAmelCase					(       self							:      Optional[Any]	):


             '''simple docstring'''



             self.enable_attention_slicing(__lowerCamelCase	)





       @torch.no_grad()
       def 						lowerCAmelCase					(       self							:      Any ,				__lowerCamelCase							:      Union[str, List[str]] ,				__lowerCamelCase							:      Union[torch.FloatTensor, PIL.Image.Image] ,				__lowerCamelCase							:      Union[torch.FloatTensor, PIL.Image.Image] ,				__lowerCamelCase							:      float = 0.8 ,				__lowerCamelCase							:      Optional[int] = 50 ,				__lowerCamelCase							:      Optional[float] = 7.5 ,				__lowerCamelCase							:      Optional[Union[str, List[str]]] = None ,				__lowerCamelCase							:      Optional[int] = 1 ,				__lowerCamelCase							:      Optional[float] = 0.0 ,				__lowerCamelCase							:      Optional[torch.Generator] = None ,				__lowerCamelCase							:      Optional[str] = "pil" ,				__lowerCamelCase							:      bool = True ,				__lowerCamelCase							:      Optional[Callable[[int, int, torch.FloatTensor], None]] = None ,				__lowerCamelCase							:      int = 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 						lowerCAmelCase					(       self							:      Optional[int] ,				__lowerCamelCase							:      Union[str, List[str]] ,				__lowerCamelCase							:      Union[torch.FloatTensor, PIL.Image.Image] ,				__lowerCamelCase							:      float = 0.8 ,				__lowerCamelCase							:      Optional[int] = 50 ,				__lowerCamelCase							:      Optional[float] = 7.5 ,				__lowerCamelCase							:      Optional[Union[str, List[str]]] = None ,				__lowerCamelCase							:      Optional[int] = 1 ,				__lowerCamelCase							:      Optional[float] = 0.0 ,				__lowerCamelCase							:      Optional[torch.Generator] = None ,				__lowerCamelCase							:      Optional[str] = "pil" ,				__lowerCamelCase							:      bool = True ,				__lowerCamelCase							:      Optional[Callable[[int, int, torch.FloatTensor], None]] = None ,				__lowerCamelCase							:      int = 1 ,				**__lowerCamelCase							:      List[str] ,				):


             '''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 						lowerCAmelCase					(       self							:      List[Any] ,				__lowerCamelCase							:      Union[str, List[str]] ,				__lowerCamelCase							:      int = 512 ,				__lowerCamelCase							:      int = 512 ,				__lowerCamelCase							:      int = 50 ,				__lowerCamelCase							:      float = 7.5 ,				__lowerCamelCase							:      Optional[Union[str, List[str]]] = None ,				__lowerCamelCase							:      Optional[int] = 1 ,				__lowerCamelCase							:      float = 0.0 ,				__lowerCamelCase							:      Optional[torch.Generator] = None ,				__lowerCamelCase							:      Optional[torch.FloatTensor] = None ,				__lowerCamelCase							:      Optional[str] = "pil" ,				__lowerCamelCase							:      bool = True ,				__lowerCamelCase							:      Optional[Callable[[int, int, torch.FloatTensor], None]] = None ,				__lowerCamelCase							:      int = 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 ,				)


