





"""simple docstring"""


import qiskit
from qiskit.providers import Backend





def 				a__      (	_UpperCAmelCase						,  _UpperCAmelCase						)     ->	tuple[qiskit.QuantumCircuit, str, str]:

 '''simple docstring'''






 snake_case__				, snake_case__     				=					bin(_UpperCAmelCase						)[2:], bin(_UpperCAmelCase						)[2:]  # Remove leading '0b'

 # Ensure that both strings are of the same length
 if len(_UpperCAmelCase						) > len(_UpperCAmelCase						):
  snake_case__     				=					y.zfill(len(_UpperCAmelCase						)						)
 else:
  snake_case__     				=					x.zfill(len(_UpperCAmelCase						)						)

 # We need (3 * number of bits in the larger number)+1 qBits
 # The second parameter is the number of classical registers, to measure the result
 snake_case__     				=					qiskit.QuantumCircuit((len(_UpperCAmelCase						) * 3) + 1						,  len(_UpperCAmelCase						) + 1						)

 # We are essentially "not-ing" the bits that are 1
 # Reversed because it's easier to perform ops on more significant bits
 for i in range(len(_UpperCAmelCase						)						):
  if x[::-1][i] == "1":
   circuit.x(_UpperCAmelCase						)
 for j in range(len(_UpperCAmelCase						)						):
  if y[::-1][j] == "1":
   circuit.x(len(_UpperCAmelCase						) + j						)

 return circuit, x, y





def 				a__      (	_UpperCAmelCase						,  _UpperCAmelCase						,  _UpperCAmelCase						,  _UpperCAmelCase						,  _UpperCAmelCase						,  )     ->	int:

 '''simple docstring'''






 circuit.ccx(_UpperCAmelCase						,  _UpperCAmelCase						,  _UpperCAmelCase						)
 circuit.cx(_UpperCAmelCase						,  _UpperCAmelCase						)
 circuit.ccx(_UpperCAmelCase						,  _UpperCAmelCase						,  _UpperCAmelCase						)
 circuit.cx(_UpperCAmelCase						,  _UpperCAmelCase						)
 circuit.cx(_UpperCAmelCase						,  _UpperCAmelCase						)





def 				a__      (	_UpperCAmelCase						,  _UpperCAmelCase						,  _UpperCAmelCase = qiskit.Aer.get_backend("aer_simulator"						)						,  )     ->	int:

 '''simple docstring'''






 if vala < 0 or vala < 0:
  raise ValueError("Both Integers must be positive!"						)

 # Store the Integers
 snake_case__				, snake_case__				, snake_case__     				=					store_two_classics(_UpperCAmelCase						,  _UpperCAmelCase						)
 for i in range(len(_UpperCAmelCase						)						):
  full_adder(_UpperCAmelCase						,  _UpperCAmelCase						,  len(_UpperCAmelCase						) + i						,  len(_UpperCAmelCase						) + len(_UpperCAmelCase						) + i						,  len(_UpperCAmelCase						) + len(_UpperCAmelCase						) + i + 1						)
  circuit.barrier()  # Optional, just for aesthetics

 # Measure the resultant qBits
 for i in range(len(_UpperCAmelCase						) + 1						):
  circuit.measure([(len(_UpperCAmelCase						) * 2) + i]						,  [i]						)

 snake_case__     				=					qiskit.execute(_UpperCAmelCase						,  _UpperCAmelCase						,  shots=1						).result()

 # The result is in binary. Convert it back to int
 return int(list(res.get_counts()						)[0]						,  2						)


if __name__ == "__main__":
   import doctest

   doctest.testmod()








"""simple docstring"""


from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available


a__       :  List[Any]       		=					{
    """configuration_realm""": ["""REALM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """RealmConfig"""],
    """tokenization_realm""": ["""RealmTokenizer"""],
}

try:
   if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   a__       :  Union[str, Any]       		=					["""RealmTokenizerFast"""]

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   a__       :  Dict       		=					[
       """REALM_PRETRAINED_MODEL_ARCHIVE_LIST""",
       """RealmEmbedder""",
       """RealmForOpenQA""",
       """RealmKnowledgeAugEncoder""",
       """RealmPreTrainedModel""",
       """RealmReader""",
       """RealmScorer""",
       """load_tf_weights_in_realm""",
   ]
   a__       :  Any       		=					["""RealmRetriever"""]


if TYPE_CHECKING:
   from .configuration_realm import REALM_PRETRAINED_CONFIG_ARCHIVE_MAP, RealmConfig
   from .tokenization_realm import RealmTokenizer

   try:
      if not is_tokenizers_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_realm import RealmTokenizerFast

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_realm import (
          REALM_PRETRAINED_MODEL_ARCHIVE_LIST,
          RealmEmbedder,
          RealmForOpenQA,
          RealmKnowledgeAugEncoder,
          RealmPreTrainedModel,
          RealmReader,
          RealmScorer,
          load_tf_weights_in_realm,
      )
      from .retrieval_realm import RealmRetriever


else:
   import sys

   a__       :  Any       		=					_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)

