

import argparse
import hashlib  # hashlib is only used inside the Test class
import struct





class        lowerCAmelCase__  :



       '''simple docstring'''







       def __init__(							self ,   lowercase__     ):







             '''simple docstring'''



             __A    =data
             __A    =[0X67452301, 0XEFCDAB89, 0X98BADCFE, 0X10325476, 0XC3D2E1F0]

       @staticmethod
       def     __UpperCamelCase     (							lowercase__ ,   lowercase__     ):







             '''simple docstring'''



             return ((n << b) | (n >> (3_2 - b))) & 0XFFFFFFFF

       def     __UpperCamelCase     (							self     ):







             '''simple docstring'''



             __A    =b'''\x80''' + b'''\x00''' * (6_3 - (len(self.data     ) + 8) % 6_4)
             __A    =self.data + padding + struct.pack('''>Q''' ,   8 * len(self.data     )     )
             return padded_data

       def     __UpperCamelCase     (							self     ):







             '''simple docstring'''



             return [
                 self.padded_data[i : i + 6_4] for i in range(0 ,   len(self.padded_data     ) ,   6_4     )
             ]

       def     __UpperCamelCase     (							self ,   lowercase__     ):







             '''simple docstring'''



             __A    =list(struct.unpack('''>16L''' ,   lowercase__     )     ) + [0] * 6_4
             for i in range(1_6 ,   8_0     ):
                   __A    =self.rotate((w[i - 3] ^ w[i - 8] ^ w[i - 1_4] ^ w[i - 1_6]) ,   1     )
             return w


       def     __UpperCamelCase     (							self     ):







             '''simple docstring'''



             __A    =self.padding()
             __A    =self.split_blocks()
             for block in self.blocks:
                   __A    =self.expand_block(lowercase__     )
                   __A    ,		__A    ,		__A    ,		__A    ,		__A    =self.h
                   for i in range(0 ,   8_0     ):
                         if 0 <= i < 2_0:
                               __A    =(b & c) | ((~b) & d)
                               __A    =0X5A827999
                         elif 2_0 <= i < 4_0:
                               __A    =b ^ c ^ d
                               __A    =0X6ED9EBA1
                         elif 4_0 <= i < 6_0:
                               __A    =(b & c) | (b & d) | (c & d)
                               __A    =0X8F1BBCDC
                         elif 6_0 <= i < 8_0:
                               __A    =b ^ c ^ d
                               __A    =0XCA62C1D6
                         __A    ,		__A    ,		__A    ,		__A    ,		__A    =(
                             self.rotate(lowercase__ ,   5     ) + f + e + k + expanded_block[i] & 0XFFFFFFFF,
                             a,
                             self.rotate(lowercase__ ,   3_0     ),
                             c,
                             d,
                         )
                   __A    =(
                       self.h[0] + a & 0XFFFFFFFF,
                       self.h[1] + b & 0XFFFFFFFF,
                       self.h[2] + c & 0XFFFFFFFF,
                       self.h[3] + d & 0XFFFFFFFF,
                       self.h[4] + e & 0XFFFFFFFF,
                   )
             return ("{:08x}" * 5).format(*self.h     )





def      A__					(			)					->Tuple:
      __A    =b'''Test String'''
      assert SHAaHash(A__			).final_hash() == hashlib.shaa(A__			).hexdigest()  # noqa: S324





def      A__					(			)					->str:
      __A    =argparse.ArgumentParser(description='''Process some strings or files'''			)
      parser.add_argument(
          '''--string'''     ,				dest='''input_string'''     ,				default='''Hello World!! Welcome to Cryptography'''     ,				help='''Hash the string'''     ,				)
      parser.add_argument('''--file'''     ,				dest='''input_file'''     ,				help='''Hash contents of a file'''			)
      __A    =parser.parse_args()
      __A    =args.input_string
      # In any case hash input should be a bytestring
      if args.input_file:
            with open(args.input_file     ,				'''rb'''			) as f:
                  __A    =f.read()
      else:
            __A    =bytes(A__     ,				'''utf-8'''			)
      print(SHAaHash(A__			).final_hash()			)


if __name__ == "__main__":
   main()
   import doctest

   doctest.testmod()





from __future__ import annotations

from statistics import mean
def 	a (     A__      :  list[int] ,  A__      :  list[int] ,  A__      :  int	)       -> list[int]:





      """simple docstring"""



      _lowercase      			=[0] * no_of_processes
      _lowercase      			=[0] * no_of_processes

      # Initialize remaining_time to waiting_time.

      for i in range(A__	):
            _lowercase      			=burst_time[i]
      _lowercase      			=[]

      _lowercase      			=0
      _lowercase      			=0

      # When processes are not completed,
      # A process whose arrival time has passed \
      # and has remaining execution time is put into the ready_process.
      # The shortest process in the ready_process, target_process is executed.

      while completed != no_of_processes:
            _lowercase      			=[]
            _lowercase      			=-1

            for i in range(A__	):
                  if (arrival_time[i] <= total_time) and (remaining_time[i] > 0):
                        ready_process.append(A__	)

            if len(A__	) > 0:
                  _lowercase      			=ready_process[0]
                  for i in ready_process:
                        if remaining_time[i] < remaining_time[target_process]:
                              _lowercase      			=i
                  total_time += burst_time[target_process]
                  completed += 1
                  _lowercase      			=0
                  _lowercase      			=(
                      total_time - arrival_time[target_process] - burst_time[target_process]
                  )
            else:
                  total_time += 1

      return waiting_time
def 	a (     A__      :  list[int] ,  A__      :  int ,  A__      :  list[int]	)       -> list[int]:





      """simple docstring"""



      _lowercase      			=[0] * no_of_processes
      for i in range(A__	):
            _lowercase      			=burst_time[i] + waiting_time[i]
      return turn_around_time


if __name__ == "__main__":
  print('[TEST CASE 01]')

  lowercase_   							=  4
  lowercase_   							=  [2, 5, 3, 7]
  lowercase_   							=  [0, 0, 0, 0]
  lowercase_   							=  calculate_waitingtime(arrival_time, burst_time, no_of_processes)
  lowercase_   							=  calculate_turnaroundtime(
      burst_time, no_of_processes, waiting_time
  )

  # Printing the Result
  print('PID\tBurst Time\tArrival Time\tWaiting Time\tTurnaround Time')
  for i, process_id in enumerate(list(range(1, 5))):
    print(
        f"{process_id}\t{burst_time[i]}\t\t\t{arrival_time[i]}\t\t\t\t"
        f"{waiting_time[i]}\t\t\t\t{turn_around_time[i]}"
    )
  print(f"\nAverage waiting time = {mean(waiting_time):.5f}")
  print(f"Average turnaround time = {mean(turn_around_time):.5f}")


