'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates import RYGate
import math

def solve(n: int, L: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # 量子ビットの番号は 0～n-1，
    # リトルエンディアンでは整数値は ∑_{j=0}^{n-1} 2^j * (qubit j の値) として読む

    # ここでは，最も重みの大きい qubit（番号 n-1）から順に回転を設定する
    for k in range(n-1, -1, -1):
        # 上位ビットとして制御する qubit の集合は {q_{k+1},...,q_{n-1}}
        control_indices = list(range(k+1, n))
        # 制御対象の上位ビットの割り当て（分岐）をすべて走査
        for prefix in itertools.product([0, 1], repeat=len(control_indices)):
            # prefix に対応して，上位ビットが取る値により整数値への寄与は
            # P = ∑_{j in control_indices} (bit_j * 2^j)
            P = 0
            for ctrl, bit in zip(control_indices, prefix):
                P += bit * (2 ** ctrl)
            # 現在決定する qubitは q_k の重み 2^k で寄与する
            # 下位（q_{0}～q_{k-1}）で作れる状態数は 2^k 個
            # よって，q_k に 0 を割り当てた場合の有効状態数は
            if P >= L:
                N0 = 0
            else:
                N0 = min(2 ** k, L - P)
            # q_k に 1 を割り当てた場合は，寄与が 2^k 加わるので
            if P + (2 ** k) >= L:
                N1 = 0
            else:
                N1 = min(2 ** k, L - (P + (2 ** k)))
            N_total = N0 + N1
            # もしこの分岐で有効な状態がなければスキップ
            if N_total == 0:
                continue
            # 回転角は，理想的には
            # cos(θ/2) = √(N0/(N0+N1))，すなわち θ = 2·arccos(√(N0/N_total))
            # ただし，N0=0 のときは θ = π，また N1=0 のときは θ = 0 とする
            if N0 == 0:
                theta = math.pi
            elif N1 == 0:
                theta = 0.0
            else:
                theta = 2 * math.acos(math.sqrt(N0 / N_total))
            # 角度が 0 ならゲート不要
            if abs(theta) < 1e-10:
                continue

            # 制御付き RY ゲートを作成
            base_gate = RYGate(theta)
            num_controls = len(control_indices)
            if num_controls > 0:
                controlled_gate = base_gate.control(num_controls)
                # デフォルトでは制御は「|1>」の場合に作用するため，
                # 制御すべき値が 0 のときは X ゲートで反転させる
                for ctrl, bit in zip(control_indices, prefix):
                    if bit == 0:
                        qc.x(ctrl)
                # 制御 qubit（上位ビット）＋対象 qubit q_k の順番で追加
                qc.append(controlled_gate, control_indices + [k])
                for ctrl, bit in zip(control_indices, prefix):
                    if bit == 0:
                        qc.x(ctrl)
            else:
                # 制御 qubitがない場合は単純に RY ゲートを適用
                qc.append(base_gate, [k])
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates import RYGate
import math

def solve(n: int, L: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # リトルエンディアン：整数は q_0 が最下位ビットとして解釈される

    # k: 現在制御対象とする qubit（重み 2^k）のインデックス．
    # 上位ビットは q_{k+1}, ..., q_{n-1} となるため，k は n-1 から 0 まで走査する
    for k in range(n-1, -1, -1):
        # 上位ビットのインデックス
        control_indices = list(range(k+1, n))
        num_controls = len(control_indices)
        # control_indices に対応する全割り当て（ビット列）を生成する．
        # itertools.product を使わず，0 から 2^(num_controls)-1 までの整数の2進数表現を用いる
        if num_controls == 0:
            prefixes = [[]]
        else:
            prefixes = []
            for x in range(2 ** num_controls):
                prefix = []
                # 桁数は num_controls．
                # 制御ビットの順序は control_indices の順序と合わせるため，
                # 最上位桁から順に取り出す
                for i in range(num_controls):
                    # i = 0 で最上位ビット，i = num_controls-1 で最下位ビットとなるようにする
                    bit = (x >> (num_controls - 1 - i)) & 1
                    prefix.append(bit)
                prefixes.append(prefix)
        # 各分岐（上位ビットの特定の割り当て）ごとに，
        # q_k に適用する制御付き RY ゲートを決定する
        for prefix in prefixes:
            # 上位ビットが与える整数値 P = sum_{j in control_indices} (bit_j * 2^j)
            P = 0
            for ctrl, bit in zip(control_indices, prefix):
                P += bit * (2 ** ctrl)
            # q_k の重みは 2^k
            # q_k に 0 を割り当てた場合の，有効な状態数 N0:
            if P >= L:
                N0 = 0
            else:
                N0 = min(2 ** k, L - P)
            # q_k に 1 を割り当てた場合の，有効な状態数 N1:
            if P + (2 ** k) >= L:
                N1 = 0
            else:
                N1 = min(2 ** k, L - (P + (2 ** k)))
            N_total = N0 + N1
            if N_total == 0:
                continue
            # 回転角 θ を決定する．
            # 特に，N0 == 0 のときは θ = π，N1 == 0 のときは θ = 0 とする．
            if N0 == 0:
                theta = math.pi
            elif N1 == 0:
                theta = 0.0
            else:
                theta = 2 * math.acos(math.sqrt(N0 / N_total))
            # 角度が 0 に近ければゲートを省略
            if abs(theta) < 1e-10:
                continue
            base_gate = RYGate(theta)
            if num_controls > 0:
                # 制御付きゲートを作成
                controlled_gate = base_gate.control(num_controls)
                # 標準では制御が |1⟩ のときに作用するため，
                # 制御すべき値が 0 の場合は前後に X ゲートを挿入する
                for ctrl, bit in zip(control_indices, prefix):
                    if bit == 0:
                        qc.x(ctrl)
                qc.append(controlled_gate, control_indices + [k])
                for ctrl, bit in zip(control_indices, prefix):
                    if bit == 0:
                        qc.x(ctrl)
            else:
                # 制御ビットがなければ，そのまま RY ゲートを適用
                qc.append(base_gate, [k])
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates import RYGate, HGate
import math

# 補助関数：サブ回路の各命令を「制御付き」にしてメイン回路 qc に追加する
def add_controlled_subcircuit(qc, subcircuit, control_qubit, target_qubits, control_value):
    # 制御すべき値が 0 の場合は、前後に X を入れて反転制御とする
    if control_value == 0:
        qc.x(control_qubit)
    # サブ回路に含まれる各命令について
    for instr, qargs, _ in subcircuit.data:
        # サブ回路内の量子ビットの位置を target_qubits に対応付ける
        new_qargs = []
        for q in qargs:
            idx = subcircuit.qubits.index(q)
            new_qargs.append(target_qubits[idx])
        # 制御付き版のゲートを作成（1 つの制御を追加）
        controlled_gate = instr.control(1)
        # 制御 qubit を先頭に、対象 qubit をその後に指定して追加
        qc.append(controlled_gate, [control_qubit] + new_qargs)
    if control_value == 0:
        qc.x(control_qubit)

# 再帰的に、指定された量子ビット集合 q_list 上で
# 状態 |ψ⟩ = 1/√L ∑_{i=0}^{L-1} |i⟩ (リトルエンディアン) を作る回路を返す
def prepare_state(q_list, L):
    n = len(q_list)
    qc = QuantumCircuit(n)
    if n == 0:
        return qc
    # 1量子ビットの場合
    if n == 1:
        if L == 1:
            # 状態 |0⟩ のままでよい
            return qc
        elif L == 2:
            # (|0⟩+|1⟩)/√2 を作る → H ゲート
            qc.h(q_list[0])
            return qc
    # もし L = 2^n なら全状態に均一振幅 → 各 qubit に H
    if L == 2**n:
        for q in q_list:
            qc.h(q)
        return qc

    # n ≥ 2 かつ L < 2^n の場合
    # q_list の最後の量子ビットを MSB (q_m)、残りを下位 (Q_low) とする
    N_low = 2**(n-1)
    if L <= N_low:
        # 下位側だけに状態が存在する → q_m は |0⟩ のまま、
        # 下位 n-1 量子ビットで問題を再帰的に解く
        sub_qc = prepare_state(q_list[:-1], L)
        qc.compose(sub_qc, qubits=range(n-1), inplace=True)
        return qc
    else:
        # L > N_low なら、ブロック分割
        L0 = N_low         # q_m=0 側に対応する状態数（0～2^(n-1)-1）
        L1 = L - N_low     # q_m=1 側（残り）の状態数
        # q_m に対して、以下を満たすよう RY 回転を適用
        #   cos(θ/2)=√(L0/L), sin(θ/2)=√(L1/L)
        theta = 2 * math.acos(math.sqrt(L0 / L))
        qc.ry(theta, q_list[-1])
        # --- 下位側の回路を条件付きで適用 ---
        # branch 0 (q_m = 0)：下位側は「全状態（2^(n-1) 個）」＝ uniform
        uniform = QuantumCircuit(n-1)
        for i in range(n-1):
            uniform.h(uniform.qubits[i])
        # branch 1 (q_m = 1)：下位側を再帰的に L1 個の状態に準備
        rec = prepare_state(list(range(n-1)), L1)
        # controlled subcircuit を追加
        # まず、q_m が 1 のときに rec を適用
        add_controlled_subcircuit(qc, rec, control_qubit=q_list[-1], target_qubits=q_list[:-1], control_value=1)
        # 次に、q_m が 0 のときに uniform を適用
        add_controlled_subcircuit(qc, uniform, control_qubit=q_list[-1], target_qubits=q_list[:-1], control_value=0)
        return qc

def solve(n: int, L: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # 特別ケース：もし L = 2^n なら全状態に均一 →各 qubitに H を適用
    if L == 2**n:
        for q in range(n):
            qc.h(q)
        return qc
    # 再帰的状態準備回路を作成（リトルエンディアン：qubit 0 が LSB，qubit n-1 が MSB）
    prep = prepare_state(list(range(n)), L)
    qc.compose(prep, qubits=range(n), inplace=True)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates import RYGate, HGate
import math

# サブ回路を一括で制御付き化する補助関数
def add_controlled_subcircuit(qc, subcircuit, control_qubit, target_qubits, control_value):
    # subcircuit をゲート化して一括制御付きゲートに変換
    gate = subcircuit.to_gate()
    controlled_gate = gate.control(1)
    if control_value == 0:
        qc.x(control_qubit)
    qc.append(controlled_gate, [control_qubit] + target_qubits)
    if control_value == 0:
        qc.x(control_qubit)

# memo[(n, L)] に対して既に作成した回路を記憶する
memo = {}

# n 量子ビット上で、状態 |ψ⟩ = 1/√L ∑_{i=0}^{L-1} |i⟩ を作る回路（ローカル回路）を返す関数
def prepare_state(n, L):
    if (n, L) in memo:
        return memo[(n, L)]
    qc = QuantumCircuit(n)
    if n == 0:
        memo[(n, L)] = qc
        return qc
    # 1量子ビットの場合
    if n == 1:
        if L == 1:
            memo[(n, L)] = qc  # |0⟩ のままでよい
            return qc
        elif L == 2:
            qc.h(0)         # (|0⟩+|1⟩)/√2
            memo[(n, L)] = qc
            return qc
    # すべての状態が有効なら、各 qubit に H を適用
    if L == 2**n:
        for i in range(n):
            qc.h(i)
        memo[(n, L)] = qc
        return qc

    # n ≥ 2 かつ L < 2^n の場合
    # ※ローカル回路では qubit 0～n-2 を下位、qubit n-1 を MSB とする（リトルエンディアン）
    if L <= 2**(n-1):
        # 有効な状態は下位側にすべて含まれる：MSBは |0⟩ のまま
        sub = prepare_state(n-1, L)
        qc.compose(sub, qubits=list(range(n-1)), inplace=True)
        memo[(n, L)] = qc
        return qc
    else:
        # L > 2^(n-1)
        L0 = 2**(n-1)        # branch q_{n-1} = 0 側の状態数
        L1 = L - L0          # branch q_{n-1} = 1 側の状態数
        # q_{n-1} に対して RY 回転： cos(θ/2)=√(L0/L), sin(θ/2)=√(L1/L)
        theta = 2 * math.acos(math.sqrt(L0 / L))
        qc.ry(theta, n-1)
        # branch 1 (q_{n-1} = 1)：下位 n-1 量子ビットで再帰的に L1 個の状態を作る
        rec = prepare_state(n-1, L1)
        add_controlled_subcircuit(qc, rec, control_qubit=n-1, target_qubits=list(range(n-1)), control_value=1)
        # branch 0 (q_{n-1} = 0)：下位 n-1 量子ビットで全状態（2^(n-1) 個）を均一に作る
        uniform = QuantumCircuit(n-1)
        for i in range(n-1):
            uniform.h(i)
        add_controlled_subcircuit(qc, uniform, control_qubit=n-1, target_qubits=list(range(n-1)), control_value=0)
        memo[(n, L)] = qc
        return qc

def solve(n: int, L: int) -> QuantumCircuit:
    global memo
    memo = {}  # 各呼び出しでメモをリセット
    # 特別ケース：全状態が有効なら各 qubit に H を適用
    if L == 2**n:
        qc = QuantumCircuit(n)
        for i in range(n):
            qc.h(i)
        return qc
    # 再帰的状態準備回路（ローカル回路）をそのまま返す
    qc = prepare_state(n, L)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates import RYGate
import math

def solve(n: int, L: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # controlled_gate_cache のキーは (num_controls, rounded_theta) で、
    # 値は対応する controlled-RY ゲート
    controlled_gate_cache = {}
    # 事前に 2^i を計算しておく（i=0,...,n）
    pows = [1 << i for i in range(n+1)]  # 1<<i は 2^i

    # 量子ビットの番号は 0～n-1（リトルエンディアン：qubit 0 が最下位）
    # k を MSB側からLSB側へ（n-1 から 0）順に処理
    for k in range(n-1, -1, -1):
        # 上位（MSB側）の qubit のリスト（制御に使う）
        control_indices = list(range(k+1, n))
        num_controls = len(control_indices)
        # 上位ビットの全割り当てを作成（itertools を使わずに 0～2^(num_controls)-1 でループ）
        if num_controls == 0:
            prefixes = [[]]
        else:
            num_prefixes = 1 << num_controls
            prefixes = []
            for x in range(num_prefixes):
                prefix = []
                for i in range(num_controls):
                    # 上位桁から順に取り出す
                    bit = (x >> (num_controls - 1 - i)) & 1
                    prefix.append(bit)
                prefixes.append(prefix)
        # 各分岐について回転角を計算し、controlled-RY ゲートを追加
        for prefix in prefixes:
            # 上位ビット（control_indices）の割り当てから整数 P を計算
            # P = ∑_{ctrl in control_indices} (bit × 2^(ctrl))
            P = 0
            for ctrl, bit in zip(control_indices, prefix):
                P += bit * (1 << ctrl)
            # 現在対象とする qubit k の重みは 2^k
            if P >= L:
                N0 = 0
            else:
                N0 = min(pows[k], L - P)
            if P + pows[k] >= L:
                N1 = 0
            else:
                N1 = min(pows[k], L - (P + pows[k]))
            N_total = N0 + N1
            if N_total == 0:
                continue
            # 回転角 θ を決定
            # ・もし N0 == 0 なら、θ = π（必ず 1 を選ぶ）
            # ・もし N1 == 0 なら、θ = 0（変化なし）
            # ・それ以外なら、cos(θ/2) = √(N0/N_total)
            if N0 == 0:
                theta = math.pi
            elif N1 == 0:
                theta = 0.0
            else:
                ratio = N0 / N_total
                # 浮動小数点の誤差対策
                if ratio < 0: ratio = 0
                if ratio > 1: ratio = 1
                theta = 2 * math.acos(math.sqrt(ratio))
            if abs(theta) < 1e-10:
                continue
            # controlled-RY ゲートのキャッシュキー
            key = (num_controls, round(theta, 12))
            if key in controlled_gate_cache:
                controlled_gate = controlled_gate_cache[key]
            else:
                controlled_gate = RYGate(theta).control(num_controls)
                controlled_gate_cache[key] = controlled_gate
            # 制御付きの場合、標準では制御が |1⟩ で作用するため、
            # 制御すべきビットが 0 の場合は X ゲートを前後に挿入して反転制御とする
            if num_controls > 0:
                for ctrl, bit in zip(control_indices, prefix):
                    if bit == 0:
                        qc.x(ctrl)
                qc.append(controlled_gate, control_indices + [k])
                for ctrl, bit in zip(control_indices, prefix):
                    if bit == 0:
                        qc.x(ctrl)
            else:
                qc.append(RYGate(theta), [k])
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def prepare_uniform(n, L):
    """
    n 量子ビット上で、状態
      |ψ⟩ = 1/√L ∑_{i=0}^{L-1} |i⟩
    （リトルエンディアン: qubit 0 が LSB, qubit n-1 が MSB）
    を作る QuantumCircuit を返す。
    """
    qc = QuantumCircuit(n)
    if n == 0:
        return qc
    # 1量子ビットの場合
    if n == 1:
        if L == 1:
            return qc  # |0⟩ のまま
        elif L == 2:
            qc.h(0)   # (|0⟩+|1⟩)/√2
            return qc
    # 全状態が有効なら、すべての qubit に H を適用
    if L == 2**n:
        for i in range(n):
            qc.h(i)
        return qc

    # ここから n ≥ 2 かつ L < 2^n の場合
    m = 2**(n-1)  # 下位 n-1 量子ビットで作れる状態数
    if L <= m:
        # 有効な状態は MSB = 0 側にのみ存在
        sub = prepare_uniform(n-1, L)
        qc.compose(sub, qubits=list(range(n-1)), inplace=True)
        # MSB (qubit n-1) はそのまま |0⟩ のまま
        return qc
    else:
        # L > m の場合
        L0 = m         # MSB = 0 側の状態数（全ての状態）
        L1 = L - m     # MSB = 1 側の状態数
        # MSB (qubit n-1) に対して RY 回転を適用
        theta = 2 * math.acos(math.sqrt(L0 / L))
        qc.ry(theta, n-1)
        # branch for MSB = 0: 下位 n-1 量子ビットに対して「全状態の均一状態」
        qc0 = QuantumCircuit(n-1)
        for i in range(n-1):
            qc0.h(i)
        # branch for MSB = 1: 下位 n-1 量子ビットに対して再帰的に L1 個の状態を作る
        qc1 = prepare_uniform(n-1, L1)
        # 制御付きゲートとしてまとめる（.to_gate() を用いて一括で制御付きに）
        gate1 = qc1.to_gate()
        cgate1 = gate1.control(1)
        gate0 = qc0.to_gate()
        cgate0 = gate0.control(1)
        # branch 1: MSB が |1⟩ のときに下位に qc1 を適用（制御が |1⟩ でそのまま作用）
        qc.append(cgate1, [n-1] + list(range(n-1)))
        # branch 0: MSB が |0⟩ のときに下位に qc0 を適用（制御が |0⟩ となるよう、前後に X を挿入）
        qc.x(n-1)
        qc.append(cgate0, [n-1] + list(range(n-1)))
        qc.x(n-1)
        return qc

def solve(n: int, L: int) -> QuantumCircuit:
    """
    入力:
      n: 量子ビット数
      L: 有効な状態数（1 ≤ L ≤ 2^n）
    出力:
      測定時に状態 |0⟩, |1⟩, ..., |L-1⟩ が等確率で観測される状態
      |ψ⟩ = 1/√L ∑_{i=0}^{L-1} |i⟩ を作り出す QuantumCircuit
    """
    qc = QuantumCircuit(n)
    # 特別ケース：全状態が有効なら各 qubit に H を適用
    if L == 2**n:
        for i in range(n):
            qc.h(i)
        return qc
    # 再帰的状態準備回路を生成し、メイン回路に合成
    prep = prepare_uniform(n, L)
    qc.compose(prep, qubits=range(n), inplace=True)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates import RYGate
import math

def solve(n: int, L: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # controlled_gate_cache のキーは (num_controls, rounded_theta)
    controlled_gate_cache = {}
    # 事前に 2^(i) を計算（i=0,...,n）
    pows = [1 << i for i in range(n+1)]

    # レベル k = 0,...,n-1 について処理する
    # ※レベル 0 →接頭辞は空（1 通り）：このときターゲットは qubit n-1（MSB）
    # レベル k のとき、接頭辞の長さは k、対象の qubitは q_{n-1-k}、制御 qubitは q_{n-1},…,q_{n-k}
    for k in range(0, n):
        target = n - 1 - k
        num_controls = k  # 接頭辞の長さ
        num_prefixes = 1 << k  # 2^k 通り
        for b in range(num_prefixes):
            # ノードの offset = b * 2^(n-k)
            offset = b * (1 << (n - k))
            if offset >= L:
                continue  # この枝は全て零
            width = 1 << (n - k)
            half = 1 << (n - k - 1)  # 2^(n-k-1)
            # 左側の非零葉数
            left_count = min(half, L - offset) if offset < L else 0
            # 右側の非零葉数
            if offset + half < L:
                right_count = min(half, L - (offset + half))
            else:
                right_count = 0
            # 回転角の決定
            if left_count == 0:
                theta = math.pi
            elif right_count == 0:
                theta = 0.0
            else:
                theta = 2 * math.atan(math.sqrt(right_count / left_count))
            if abs(theta) < 1e-10:
                continue  # わずかな回転ならスキップ

            if num_controls == 0:
                # 制御が不要の場合：単にターゲット qubitに RY を適用
                qc.ry(theta, target)
            else:
                key = (num_controls, round(theta, 12))
                if key in controlled_gate_cache:
                    controlled_ry = controlled_gate_cache[key]
                else:
                    base_gate = RYGate(theta)
                    controlled_ry = base_gate.control(num_controls)
                    controlled_gate_cache[key] = controlled_ry
                # 制御 qubitのリスト（順序は: q_{n-1}, q_{n-2}, …, q_{n-k}）
                controls = [n - 1 - i for i in range(num_controls)]
                # 接頭辞 b の各桁（長さ k）のうち、値が 0 の場合は X ゲートで反転
                for i in range(num_controls):
                    desired = (b >> (k - 1 - i)) & 1
                    if desired == 0:
                        qc.x(controls[i])
                # 制御付きゲートを追加
                qc.append(controlled_ry, controls + [target])
                # 反転用の X ゲートを元に戻す
                for i in range(num_controls):
                    desired = (b >> (k - 1 - i)) & 1
                    if desired == 0:
                        qc.x(controls[i])
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def prepare_state_be(n: int, L: int) -> QuantumCircuit:
    """
    大端（big‐endian）表現で、n 量子ビット上に
      |ψ⟩ = (1/√L) ∑_{i=0}^{L-1} |i⟩
    （ただし、i は 0～2^n-1 のうち、i < L のものにのみ非零振幅）
    を作る回路を再帰的に構成する。
    ※ここでは、量子回路の 0 番目の qubit を MSB として扱う。
    """
    qc = QuantumCircuit(n)
    if n == 0:
        return qc
    # 1量子ビットの場合
    if n == 1:
        if L == 1:
            # |0>
            return qc
        elif L == 2:
            # (|0>+|1>)/√2
            qc.h(0)
            return qc

    # 2^({n-1}) を T とする
    T = 1 << (n - 1)  # 2^(n-1)
    L0 = L if L < T else T         # 数は min(L, 2^(n-1))
    L1 = L - L0                   # 残り（L1 は 0 の場合もあり）
    p0 = L0 / L
    # R_y 回転の角度 θ で、cos(θ/2)=√p0, sin(θ/2)=√(1-p0)
    theta = 2 * math.acos(math.sqrt(p0))
    qc.ry(theta, 0)  # 0 番目（MSB）に適用

    # 残り n-1 量子ビットは、qubits 1...n-1
    if L0 > 0:
        # branch for MSB = 0 : 対象は下位部分で i in {0, ..., L0-1}
        sub0 = prepare_state_be(n - 1, L0)
        # 制御が 0 で作用するようにする：X を前後に入れる
        qc.x(0)
        qc.append(sub0.to_gate().control(1), [0] + list(range(1, n)))
        qc.x(0)
    if L1 > 0:
        # branch for MSB = 1 : 対象は下位部分で i in {0, ..., L1-1}
        sub1 = prepare_state_be(n - 1, L1)
        qc.append(sub1.to_gate().control(1), [0] + list(range(1, n)))
    return qc

def reverse_qubits(qc: QuantumCircuit) -> QuantumCircuit:
    """
    量子回路 qc の qubit の順序を反転（SWAP を用いてリトルエンディアンにする）。
    ここでは、qc.qubits[0] を最下位とするリトルエンディアンに変換する。
    """
    n = qc.num_qubits
    for i in range(n // 2):
        qc.swap(i, n - 1 - i)
    return qc

def solve(n: int, L: int) -> QuantumCircuit:
    """
    入力: 量子ビット数 n, 有効な状態数 L (1 ≤ L ≤ 2^n)
    出力: 測定時に、状態 |0>, |1>, …, |L-1> が等確率で観測され、
         かつ振幅の二乗和が 1（正規化済み）の状態 |ψ⟩ を作る回路。

    ※内部では、大端表現で状態準備を行い、最後に SWAP でリトルエンディアンに変換する。
    """
    # 特別ケース：L == 2^n なら単に各 qubit に H を適用
    if L == (1 << n):
        qc = QuantumCircuit(n)
        for i in range(n):
            qc.h(i)
        return qc

    # まず、大端表現で状態準備回路を作る
    qc_be = prepare_state_be(n, L)
    # 次に、qubit の順序を反転してリトルエンディアンにする
    qc_le = reverse_qubits(qc_be)
    return qc_le
'''


'''python
import math
from qiskit import QuantumCircuit

def solve(n: int, L: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    # まず，対象となる状態ベクトル (長さ 2^n) を
    # little–endianで「i < L なら1/sqrt(L)，それ以外は 0」と定義する．
    # しかし，uniformly–controlled rotation のアルゴリズムは
    # 回路中で big–endian順（すなわち反転した順番）の状態を作るので，
    # ここではまず psi_big[j] = 1/sqrt(L)  if bit_reverse(j) < L, else 0
    # と定義する．bit_reverse(j) は n–bit の j のビット反転．
    N = 2**n
    psi_big = [0.0] * N
    for j in range(N):
        # bit–reverse: j の n–bit 表現のビット順を反転する
        rev = 0
        temp = j
        for _ in range(n):
            rev = (rev << 1) | (temp & 1)
            temp //= 2
        if rev < L:
            psi_big[j] = 1.0 / math.sqrt(L)
        else:
            psi_big[j] = 0.0

    # uniformly–controlled Ry のアルゴリズム
    # 以下のループは，k=0,1,...,n–1 で，
    # それぞれ「対象ワイヤ target = n-k-1 に，
    # 以前に処理した（上位）ワイヤの状態 j（k–bit文字列）に対して，
    # 角度 theta(j) = 2 arccos sqrt( (sum_{l=0}^{2^(n-k-1)-1}|a_{j*2^(n-k)+l}|^2)
    #                           /(sum_{l=0}^{2^(n-k)-1}|a_{j*2^(n-k)+l}|^2 ) )
    # を用いた Ry を適用する」というものです．
    #
    # 注意: ここでは制御付きゲートは「通常制御が 1 のとき作動する」ので，
    # もし制御ビットに対応する j のビットが 0 であれば，
    # そのビットに対して X–ゲートを前後に適用しています．
    for k in range(n):
        step = 2 ** (n - k)      # ブロックの長さ
        half = 2 ** (n - k - 1)    # ブロック前半の長さ
        # k 進段では，j = 0,...,2^k - 1 の各制御パターンに対して
        for j in range(2 ** k):
            base = j * step
            # denominator = sum_{l=0}^{step-1} |psi_big[base+l]|^2
            denom = 0.0
            for l in range(step):
                denom += psi_big[base + l] ** 2
            if abs(denom) < 1e-12:
                continue  # このブロックはゼロベクトルなのでスキップ
            num = 0.0
            for l in range(half):
                num += psi_big[base + l] ** 2
            ratio = num / denom
            # 浮動小数点誤差対策：ratio ∈ [0,1]に
            ratio = min(max(ratio, 0.0), 1.0)
            theta = 2 * math.acos(math.sqrt(ratio))
            if abs(theta) < 1e-12:
                continue  # 回転角がほぼ 0 なら省略

            target = n - k - 1  # この段の対象ワイヤ
            if k == 0:
                # 制御ビットがない場合は通常の Ry
                qc.ry(theta, target)
            else:
                # 制御ビットは，これまでに処理済みの上位ワイヤ（big–endian順）
                # ここでは，制御ワイヤは [n-1, n-2, …, n-k]（降順）とする．
                control_qubits = list(range(n - k, n))
                # 制御パターンは，j を k–bit の 2進数で表したもの
                bin_str = format(j, '0{}b'.format(k))
                # もし対応するビットが '0' なら X–ゲートで反転（前後に挿入）
                for idx, bit in zip(control_qubits, bin_str):
                    if bit == '0':
                        qc.x(idx)
                # 多重制御付き Ry（ancilla なしモード）
                qc.mcry(theta, control_qubits, target, None, mode='noancilla')
                for idx, bit in zip(control_qubits, bin_str):
                    if bit == '0':
                        qc.x(idx)

    # ここまでの手続きで，psi_big を作る回路ができあがっている．
    # しかし，psi_big で作られた状態は回路中では big–endian表記となっているので，
    # 最後にワイヤの順番を反転する（SWAP）ことで little–endian に合わせる．
    for i in range(n // 2):
        qc.swap(i, n - i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int, L: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    # グローバル位相は無視して良いので、全部ひっくり返す場合は何もしない
    if L == 1 << n:
        for i in range(n):
            qc.h(i)
        return qc
    # 引く
    # L2 = (1 << n) - L
    # print("L2 = ", L2)
    # for i in range(n):
    #     if L2 & (1 << (n - i - 1)) != 0:
    #         print("i = ", i)
    #         controls = []
    #         for k in range(i):
    #             controls.append(n-1-k)
    #         if len(controls) > 0:
    #             qc.mcp(math.pi, controls, n-1-i)
    #         else:
    #             qc.z(n-1-i)
    #         qc.x(n-1-i)
    # for i in reversed(range(n)):
    #     if L2 & (1 << (n - i - 1)) != 0:
    #         qc.x(n-1-i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int, L: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    # グローバル位相は無視して良いので、全部ひっくり返す場合は何もしない
    if L == 1 << n:
        for i in range(n):
            qc.h(i)
        return qc
    rem = L
    controls = []
    for i in reversed(range(n)):
        if rem >= 1 << i:
            n0 = 1 << i
            n1 = rem - n0
            print(f"i = {i}, {rem} -> {n0}, {n1}")
            r0 = math.acos(math.sqrt(n0/(n0+n1)))*2.0
            r1 = math.acos(math.sqrt(n1/(n0+n1)))*2.0
            if len(controls) > 0:
                for k in controls:
                    qc.x(k)

                qc.mcry(r0, controls, i)

                qc.x(i)
                controls.append(i)
                for k in range(i):
                    qc.ry(math.pi / 4.0, k)
                    qc.mcrz(math.pi, controls, k)
                    qc.ry(-math.pi / 4.0, k)
                controls = controls[:-1]
                qc.x(i)

                for k in controls:
                    qc.x(k)
            else:
                qc.ry(r1, i)

            rem = n1

        controls.append(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int, L: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    # グローバル位相は無視して良いので、全部ひっくり返す場合は何もしない
    if L == 1 << n:
        for i in range(n):
            qc.h(i)
        return qc
    rem = L
    controls = []
    for i in reversed(range(n)):
        if rem >= 1 << i:
            n0 = 1 << i
            n1 = rem - n0
            print(f"i = {i}, {rem} -> {n0}, {n1}")
            r0 = math.acos(math.sqrt(n0/(n0+n1)))*2.0
            r1 = math.acos(math.sqrt(n1/(n0+n1)))*2.0
            if len(controls) > 0:
                for k in controls:
                    qc.x(k)

                qc.mcry(r0, controls, i)

                qc.x(i)
                controls.append(i)
                for k in range(i):
                    qc.ry(math.pi / 4.0, k)
                    # qc.mcrz(math.pi, controls, k)
                    qc.ry(-math.pi / 4.0, k)
                controls = controls[:-1]
                qc.x(i)

                for k in controls:
                    qc.x(k)
            else:
                qc.ry(r1, i)

            rem = n1

        controls.append(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int, L: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    # グローバル位相は無視して良いので、全部ひっくり返す場合は何もしない
    if L == 1 << n:
        for i in range(n):
            qc.h(i)
        return qc
    rem = L
    controls = []
    for i in reversed(range(n)):
        if rem >= 1 << i:
            n0 = 1 << i
            n1 = rem - n0
            print(f"i = {i}, {rem} -> {n0}, {n1}")
            r0 = math.acos(math.sqrt(n0/(n0+n1)))*2.0
            r1 = math.acos(math.sqrt(n1/(n0+n1)))*2.0
            if len(controls) > 0:
                for k in controls:
                    qc.x(k)

                # qc.mcry(r0, controls, i)

                qc.x(i)
                controls.append(i)
                for k in range(i):
                    qc.ry(math.pi / 4.0, k)
                    # qc.mcrz(math.pi, controls, k)
                    qc.ry(-math.pi / 4.0, k)
                controls = controls[:-1]
                qc.x(i)

                for k in controls:
                    qc.x(k)
            else:
                qc.ry(r1, i)

            rem = n1

        controls.append(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int, L: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    # グローバル位相は無視して良いので、全部ひっくり返す場合は何もしない
    if L == 1 << n:
        for i in range(n):
            qc.h(i)
        return qc
    rem = L
    controls = []
    for i in reversed(range(n)):
        if rem >= 1 << i:
            n0 = 1 << i
            n1 = rem - n0
            print(f"i = {i}, {rem} -> {n0}, {n1}")
            r0 = math.acos(math.sqrt(n0/(n0+n1)))*2.0
            r1 = math.acos(math.sqrt(n1/(n0+n1)))*2.0
            if len(controls) > 0:
                for k in controls:
                    qc.x(k)

                #qc.mcry(r0, controls, i)

                qc.x(i)
                controls.append(i)
                for k in range(i):
                    qc.ry(math.pi / 4.0, k)
                    qc.mcrz(math.pi, controls, k)
                    qc.ry(-math.pi / 4.0, k)
                controls = controls[:-1]
                qc.x(i)

                for k in controls:
                    qc.x(k)
            else:
                qc.ry(r1, i)

            rem = n1

        controls.append(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int, L: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    # グローバル位相は無視して良いので、全部ひっくり返す場合は何もしない
    if L == 1 << n:
        for i in range(n):
            qc.h(i)
        return qc
    rem = L
    controls = []
    for i in reversed(range(n)):
        if rem >= 1 << i:
            n0 = 1 << i
            n1 = rem - n0
            print(f"i = {i}, {rem} -> {n0}, {n1}")
            r0 = math.acos(math.sqrt(n0/(n0+n1)))*2.0
            r1 = math.acos(math.sqrt(n1/(n0+n1)))*2.0
            if len(controls) > 0:
                for k in controls:
                    qc.x(k)

                qc.mcry(r0, controls, i)

                qc.x(i)
                controls.append(i)
                for k in range(i):
                    qc.ry(math.pi / 4.0, k)
                    qc.mcp(math.pi, controls, k)
                    qc.ry(-math.pi / 4.0, k)
                controls = controls[:-1]
                qc.x(i)

                for k in controls:
                    qc.x(k)
            else:
                qc.ry(r1, i)

            rem = n1

        controls.append(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int, L: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    # グローバル位相は無視して良いので、全部ひっくり返す場合は何もしない
    if L == 1 << n:
        for i in range(n):
            qc.h(i)
        return qc
    rem = L
    controls = []
    for i in reversed(range(n)):
        if rem >= 1 << i:
            n0 = 1 << i
            n1 = rem - n0
            print(f"i = {i}, {rem} -> {n0}, {n1}")
            r0 = math.acos(math.sqrt(n0/(n0+n1)))*2.0
            r1 = math.acos(math.sqrt(n1/(n0+n1)))*2.0
            if len(controls) > 0:
                for k in controls:
                    qc.x(k)

                qc.mcry(r0, controls, i)

                qc.x(i)
                controls.append(i)
                for k in range(i):
                    qc.ry(-math.pi / 4.0, k)
                    qc.mcp(math.pi, controls, k)
                    qc.ry(math.pi / 4.0, k)
                controls = controls[:-1]
                qc.x(i)

                for k in controls:
                    qc.x(k)
            else:
                qc.ry(r1, i)

            rem = n1

        controls.append(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int, L: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    # グローバル位相は無視して良いので、全部ひっくり返す場合は何もしない
    if L == 1 << n:
        for i in range(n):
            qc.h(i)
        return qc
    rem = L
    controls = []
    for i in reversed(range(n)):
        if rem >= 1 << i:
            n0 = 1 << i
            n1 = rem - n0
            print(f"i = {i}, {rem} -> {n0}, {n1}")
            r0 = math.acos(math.sqrt(n0/(n0+n1)))*2.0
            r1 = math.acos(math.sqrt(n1/(n0+n1)))*2.0
            if len(controls) > 0:
                for k in controls:
                    qc.x(k)

                # qc.mcry(r0, controls, i)
                qc.ry(r0, i)

                qc.x(i)
                controls.append(i)
                for k in range(i):
                    print(f"k = {k}")
                    qc.ry(math.pi / 4.0, k)
                    qc.mcp(math.pi, controls, k)
                    qc.ry(-math.pi / 4.0, k)
                controls = controls[:-1]
                qc.x(i)

                for k in controls:
                    qc.x(k)
            else:
                qc.ry(r1, i)

            rem = n1

        controls.append(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.rz(3.14159, 0)
    # Write your code here:

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.i(0)  # Identit operation to maintain |0⟩ state
    qc.z(0)     # Wrte your code here:

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.rz(np.pi/2, 0)
# Wrte your code here:

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)

    qc.z(0)
# Wrte your code here:

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.rz(np.pi, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.g(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.h(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.h(-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.h(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.y(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.s(0)
    qc.s(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(1)
    qc.z(1)
    qc.x(1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)

    qc.y(0)
    qc.y(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)

    qc.x(0)
    qc.h(0)
    qc.x(0)
    qc.h(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)

    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.x(0)
    qc.z(0)
    qz.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.h(0)
    qc.x(0)
    qc.h(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(3.14159, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(1)
    qc.z(1)
    qc.x(1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    theta = 4 * math.atan(0/-1)
    qc.ry(theta, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    theta = 4 * math.atan(0/-)
    qc.ry(theta, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    theta = math.atan(0/-1)
    qc.ry(theta, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    theta = math.atan(math.pi)
    qc.ry(theta, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    theta = math.atan(2*math.pi)
    qc.rx(theta, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    theta = 2*math.pi
    qc.rx(theta, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
import math
import numpy as np
from qiskit import QuantumCircuit, QuantumRegister
from qiskit.quantum_info import Statevector
from qiskit.circuit.library.standard_gates import (
    C3XGate,
    C3SXGate,
    C4XGate,
    CCXGate,
    DCXGate,
    CHGate,
    CPhaseGate,
    CRXGate,
    CRYGate,
    CRZGate,
    CSwapGate,
    CSXGate,
    CUGate,
    CU1Gate,
    CU3Gate,
    CXGate,
    CYGate,
    CZGate,
    CCZGate,
    HGate,
    IGate,
    MCPhaseGate,
    PhaseGate,
    RCCXGate,
    RC3XGate,
    RXGate,
    RXXGate,
    RYGate,
    RYYGate,
    RZGate,
    RZZGate,
    RZXGate,
    XXMinusYYGate,
    XXPlusYYGate,
    ECRGate,
    SGate,
    SdgGate,
    CSGate,
    CSdgGate,
    SwapGate,
    iSwapGate,
    SXGate,
    SXdgGate,
    TGate,
    TdgGate,
    UGate,
    U1Gate,
    U2Gate,
    U3Gate,
    XGate,
    YGate,
    ZGate,
)

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc

if __name__ == "__main__":
    qc = solve()
    print(Statevector(qc))
'''


'''python
import math
import numpy as np
from qiskit import QuantumCircuit, QuantumRegister
from qiskit.circuit.library.standard_gates import (
    C3XGate,
    C3SXGate,
    C4XGate,
    CCXGate,
    DCXGate,
    CHGate,
    CPhaseGate,
    CRXGate,
    CRYGate,
    CRZGate,
    CSwapGate,
    CSXGate,
    CUGate,
    CU1Gate,
    CU3Gate,
    CXGate,
    CYGate,
    CZGate,
    CCZGate,
    HGate,
    IGate,
    MCPhaseGate,
    PhaseGate,
    RCCXGate,
    RC3XGate,
    RXGate,
    RXXGate,
    RYGate,
    RYYGate,
    RZGate,
    RZZGate,
    RZXGate,
    XXMinusYYGate,
    XXPlusYYGate,
    ECRGate,
    SGate,
    SdgGate,
    CSGate,
    CSdgGate,
    SwapGate,
    iSwapGate,
    SXGate,
    SXdgGate,
    TGate,
    TdgGate,
    UGate,
    U1Gate,
    U2Gate,
    U3Gate,
    XGate,
    YGate,
    ZGate,
)

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.x()
    qc.z()
    qc.x()

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    qc.z(0)
    qc.x(0)
    # Write your code here:

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.id(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import pi

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.p(pi,0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import pi

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.g(pi,0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import pi

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)

    # Write your code here:
    qc.p(pi)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import pi

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    # create -|0> state
    qc.x(0)
    qc.h(0)
    qc.rz(pi/4, 0)
    qc.h(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import pi

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.p(pi,0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.y(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.x(0)
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.x(0)
    qc.z(0)
    qc.cx(0, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.cx(0, 0)
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.z(0)
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.s(0)  # Apply the S gate (phase of π/2)
    qc.z(0)  # Apply the Z gate (phase of π)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.rz(-3.14159, 0)  # Apply a phase of -π to the qubit
    return qc
'''


'''python
from qiskit import QuantumCircuit
def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.p(-3.14159, 0)  # Apply a phase shift of -π to the qubit
    return qc
'''


'''python
from qiskit import QuantumCircuit
def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.s(0)  # Apply the S-gate
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)  # Create a quantum circuit with 1 qubit
    qc.z(0)  # Apply the Z gate to the qubit to add a phase of π
    return qc
'''


'''python
from qiskit import QuantumCircuit
from numpy import pi

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.p(pi, 0)  # Apply a phase gate with phase pi
    return qc
'''


'''python
from qiskit import QuantumCircuit
from numpy import pi

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.append(PhaseGate(pi), [0])

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    # Apply the phase shift gate with phase π to introduce a global phase of -1
    qc.p(pi, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    # Apply the phase shift gate with phase π to introduce a global phase of -1
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    # Apply the phase shift gate with phase π to introduce a global phase of -1
    qc.x(0)  # Apply X gate to the qubit
    qc.z(0)  # Apply Z gate to the qubit

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    # Apply the phase shift gate with phase π to introduce a global phase of -1

    qc.rz(pi, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    # Apply the phase shift gate with phase π to introduce a global phase of -1

    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import pi

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.p(pi,0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import pi

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.p(2*pi, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import pi

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.Z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
import numpy as np
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
import math

from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rx(2 * math.pi, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)

    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc

# if __name__ == "__main__":
#     qc = solve()
#     print(Statevector(qc))
'''


'''python
from qiskit import QuantumCircuit
# from qiskit.quantum_info import Statevector

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc

# if __name__ == "__main__":
#     qc = solve()
#     print(Statevector(qc))
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.y(1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.y(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(1)
    qc.z(1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.y(0)
    qc.y(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.s(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rx(3 * np.pi / 2, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rx(3 * np.pi / 2,0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as n

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rx(np.pi,0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rx(np.pi ,0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(-2 * np.pi ,0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(1)
    qc.z(1)
    qc.x(1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.h(0)
    qc.x(0)
    qc.h(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rx(np.pi*2)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rx(np.pi*2,0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc

ret = solve()
ret.draw("mpl")
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.g(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.h(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.reset(0)
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.y(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(0)
    # Write your code here:
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import ZGate

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.append(ZGate(), [1])

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import ZGate

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.append(ZGate(), [0])

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.y(1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z()

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.h(0)
    qc.x(0)
    qc.h(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.h(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.sdg(0)
    qc.sdg(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    # Apply the Z gate to the qubit to create the state -|0>
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.h(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.h(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.z(1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.g(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)

    qc.h(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)

    qc.h(0)
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.h(n)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.z(0)
    return qc

if __name__ == "__main__":
    qc = solve()
    print(Statevector(qc))
'''


'''python
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.z(0)
    return qc

if __name__ == "__main__":
    qc = solve()
    print(Statevector(qc))
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)

    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)

    qc.z(1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)

    qc.z(1,0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)

    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)

    qc.z(0)

    return qc

qc = solve()
qc.draw('mpl')
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.cx(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.h(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x()

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    x(qc)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.cx(0, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qiskit.x(qc)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.y(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.reset(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc * -1

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.p(pi, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import pi

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.p(pi,0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.p（）

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.p（0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.y(0)
    qc.y(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    qc.z(0)
    qc.x(0)
    # Write your code here:

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.h(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.h(0)
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:+
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    -qc.h(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.h(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.h(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.y(0)
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.zdg(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates  import GlobalPhaseGate
import math
def solve() -> QuantumCircuit:
  qc = QuantumCircuit(1)
  qc.append(GlobalPhaseGate(math.pi))
  return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.h(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.g(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.append(
    HGate(),  # New HGate instruction
    [0]       # Apply to qubit 0
)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    qc.sdg(0)
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.global_phase = 3.14159
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    qc.rz(math.pi,0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.rz(math.pi,0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.rx(2*math.pi,0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)
    qc.draw(output='mpl')
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)
    return qc
qc=solve()
qc.draw(output='mpl')
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)
    return qc
qc=solve()
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.h(1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.h(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rx(np.pi, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rx(np.pi, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import pi

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(pi, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import pi

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.u1(pi, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(np.pi, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.set_phase(np.pi, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(np.pi/2, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    k = np.pi/2
    qc.rz(k,0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    k = np.pi * 1/2
    qc.rz(k,0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    k = np.pi * 3/2
    qc.rz(k,0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    k = np.pi
    qc.rx(k,0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    k = np.pi
    qc.rz(k,0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from numpy import pi

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    k = pi
    qc.rz(k,0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from numpy import pi

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    k = pi / 2
    qc.rz(k,0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from numpy import pi

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.global_phase = pi
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.y(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    # to do a phase flip from ket(0) to -ket(0) apply pauli z gate
    # quantum_circit.z(qubit_index)
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    # to do a phase flip from ket(0) to -ket(0) apply pauli z gate
    # quantum_circit.z(qubit_index)
    qc.z(0)
    qc.x(0)
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code her
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.s(0)  # Apply phase shift gate (S gate) to change the phase to -1
    qc.x(0)  # Apply Pauli-X gate (X gate) to flip the state from |0⟩ to |1⟩
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.u1(-3.141592653589793, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)

    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(pi,0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import pi

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(pi,0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import pi

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.u1(pi,0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import pi

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
     qc.u3(pi, 0, pi, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import pi

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
     qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(3.141592653589793, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.u3(3.141592653589793, 0, 3.141592653589793, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.p(np.pi, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.global_phase = 3.141592653589793

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.z(0)  # Zゲートを量子ビット0に適用
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.g(0)  # Zゲートを量子ビット0に適用
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
import math
from qiskit import QuantumCircuit
from qiskit.circuit.library import ZGate

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc

if __name__ == "__main__":
    from qiskit.quantum_info import Statevector
    import numpy as np
    import random
    qc = solve()
    sv = Statevector(qc)
#     sv = Statevector.from_label('+++')
#     print(sv.evolve(qc))
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc

if __name__ == "__main__":
    from qiskit.quantum_info import Statevector
    import numpy as np
    import random
    qc = solve()
    sv = Statevector(qc)
#     sv = Statevector.from_label('+++')
#     print(sv.evolve(qc))
'''


'''python
import math
from qiskit import QuantumCircuit
from qiskit.circuit.library import ZGate

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc

# if __name__ == "__main__":
#     from qiskit.quantum_info import Statevector
#     import numpy as np
#     import random
#     qc = solve()
#     sv = Statevector(qc)
# #     sv = Statevector.from_label('+++')
# #     print(sv.evolve(qc))
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.-i(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.h(0)
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.z(0)
    qc.x(0)
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates import ZGate

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.z(0)
    qc.x(0)
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates import ZGate

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.rz(math.pi, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.rz(math.pi, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    qc.h(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)
    qc.measure_all()

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.ry(2.0 * math.pi, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.h(0)
    qc.z(0)
    qc.h(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.h(0)
    qc.z(0)
    qc.h(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    # qc.x(0)
    qc.g(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    # qc.x(0)
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.g(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x()
    qc.z()
    qc.x()
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(1)
    qc.z(1)
    qc.x(1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.h(0)
    qc.z(0)
    qc.h(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(2*math.pi, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.reset(0)
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(2*pi, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import pi

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(2*pi, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.y(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    return -qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc = -qc

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.y(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(i)
    qc.z(i)
    qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(1)
    qc.z(1)
    qc.x(1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit, QuantumRegister
import qiskit.circuit.library as qlib
import numpy as np

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
	qc = QuantumCircuit(1)
	qc.x(0)
	qc.z(0)
	qc.x(0)
	return qc

if __name__ == "__main__":
	from Qiskit_Library import *
	qc = solve()
	print_circuit_matrix(qc)
	print_circuit_nonzero(qc)
	print_circuit_output(qc, [1, 0])
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
	qc = QuantumCircuit(1)
	qc.x(0)
	qc.z(0)
	qc.x(0)
	return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.r(2*math.pi, 0, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    return qc.z(0)
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.x(0)
    qc.z(0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(math.pi, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(math.pi, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.rz(math.pi, 0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.g(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.g(1)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.s(0)
    qc.s(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.z(1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.y(1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.h(0)
    qc.s(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.h(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.cx(0, 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.h(0)
    qc.cx(0, 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.h(1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.h(0)
    qc.z(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.g(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.y(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.z(0)
    qc.x(0)
    return qc
'''