






import math

import qiskit







def     a_   (__A = 1				,       __A = 1				,       __A = 1      )				->						qiskit.result.counts.Counts:



					"""simple docstring"""
					if (
					    isinstance(__UpperCAmelCase				,       __UpperCAmelCase      )
					    or isinstance(__UpperCAmelCase				,       __UpperCAmelCase      )
					    or isinstance(__UpperCAmelCase				,       __UpperCAmelCase      )
					):
										raise TypeError("inputs must be integers."      )

					if (input_a < 0) or (input_a < 0) or (carry_in < 0):
										raise ValueError("inputs must be positive."      )

					if (
					    (math.floor(__UpperCAmelCase      ) != input_a)
					    or (math.floor(__UpperCAmelCase      ) != input_a)
					    or (math.floor(__UpperCAmelCase      ) != carry_in)
					):
										raise ValueError("inputs must be exact integers."      )

					if (input_a > 2) or (input_a > 2) or (carry_in > 2):
										raise ValueError("inputs must be less or equal to 2."      )

					# build registers
					__a					:						Optional[int]      =					qiskit.QuantumRegister(4				,       "qr"      )
					__a					:						int      =					qiskit.ClassicalRegister(2				,       "cr"      )
					# list the entries
					__a					:						Optional[int]      =					[input_a, input_a, carry_in]

					__a					:						str      =					qiskit.QuantumCircuit(__UpperCAmelCase				,       __UpperCAmelCase      )

					for i in range(0				,       3      ):
										if entry[i] == 2:
															quantum_circuit.h(__UpperCAmelCase      )  # for hadamard entries
										elif entry[i] == 1:
															quantum_circuit.x(__UpperCAmelCase      )  # for 1 entries
										elif entry[i] == 0:
															quantum_circuit.i(__UpperCAmelCase      )  # for 0 entries

    # build the circuit
					quantum_circuit.ccx(0				,       1				,       3      )  # ccx = toffoli gate
					quantum_circuit.cx(0				,       1      )
					quantum_circuit.ccx(1				,       2				,       3      )
					quantum_circuit.cx(1				,       2      )
					quantum_circuit.cx(0				,       1      )

					quantum_circuit.measure([2, 3]				,       __UpperCAmelCase      )  # measure the last two qbits

					__a					:						Any      =					qiskit.Aer.get_backend("aer_simulator"      )
					__a					:						Union[str, Any]      =					qiskit.execute(__UpperCAmelCase				,       __UpperCAmelCase				,       shots=1_000      )

					return job.result().get_counts(__UpperCAmelCase      )


if __name__ == "__main__":
			print(F"Total sum count for state is: {quantum_full_adder(1, 1, 1)}")











from __future__ import annotations

from typing import TypedDict





class 			lowerCamelCase_				( _SCREAMING_SNAKE_CASE   ):


 '''simple docstring'''







 lowercase_							       =       42
 lowercase_							       =       42


def    UpperCAmelCase_				( __UpperCAmelCase		:      str				)   ->					list[str]:
      if not isinstance(__UpperCAmelCase     ,     __UpperCAmelCase				):
            raise TypeError('The parameter s type must be str.'				)

      return [s[i:] + s[:i] for i in range(len(__UpperCAmelCase				)				)]

def    UpperCAmelCase_				( __UpperCAmelCase		:      str				)   ->					BWTTransformDict:
      if not isinstance(__UpperCAmelCase     ,     __UpperCAmelCase				):
            raise TypeError('The parameter s type must be str.'				)
      if not s:
            raise ValueError('The parameter s must not be empty.'				)

      SCREAMING_SNAKE_CASE_      		=     all_rotations(__UpperCAmelCase				)
      rotations.sort()  # sort the list of rotations in alphabetically order
      # make a string composed of the last char of each rotation
      SCREAMING_SNAKE_CASE_      		=     {
          "bwt_string": "".join([word[-1] for word in rotations]				),
          "idx_original_string": rotations.index(__UpperCAmelCase				),
      }
      return response

def    UpperCAmelCase_				( __UpperCAmelCase		:      str     ,     __UpperCAmelCase		:      int				)   ->					str:
      if not isinstance(__UpperCAmelCase     ,     __UpperCAmelCase				):
            raise TypeError('The parameter bwt_string type must be str.'				)
      if not bwt_string:
            raise ValueError('The parameter bwt_string must not be empty.'				)
      try:
            SCREAMING_SNAKE_CASE_      		=     int(__UpperCAmelCase				)
      except ValueError:
            raise TypeError(
                'The parameter idx_original_string type must be int or passive'
                ' of cast to int.'				)
      if idx_original_string < 0:
            raise ValueError('The parameter idx_original_string must not be lower than 0.'				)
      if idx_original_string >= len(__UpperCAmelCase				):
            raise ValueError(
                'The parameter idx_original_string must be lower than' ' len(bwt_string).'				)

      SCREAMING_SNAKE_CASE_      		=     [''] * len(__UpperCAmelCase				)
      for _ in range(len(__UpperCAmelCase				)				):
            for i in range(len(__UpperCAmelCase				)				):
                  SCREAMING_SNAKE_CASE_      		=     bwt_string[i] + ordered_rotations[i]
            ordered_rotations.sort()
      return ordered_rotations[idx_original_string]


if __name__ == "__main__":
   lowerCamelCase__					:  Optional[int]      							=				'Provide a string that I will generate its BWT transform: '
   lowerCamelCase__					:  List[str]      							=				input(entry_msg).strip()
   lowerCamelCase__					:  int      							=				bwt_transform(s)
   print(
       f'''Burrows Wheeler transform for string \'{s}\' results '''
       f'''in \'{result['bwt_string']}\''''
   )
   lowerCamelCase__					:  Dict      							=				reverse_bwt(result['bwt_string'], result['idx_original_string'])
   print(
       f'''Reversing Burrows Wheeler transform for entry \'{result['bwt_string']}\' '''
       f'''we get original string \'{original_string}\''''
   )