'''python
from qiskit import QuantumCircuit
import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.x(0)
    if 8 < n:
        theta = math.atan(math.sqrt((n-8)/(8)))*2
        qc.cry(theta, 0, 8)
        qc.cx(8, 0)
    if 12 < n:
        theta = math.atan(math.sqrt((n-12)/(4)))*2
        qc.cry(theta, 8, 12)
        qc.cx(12, 8)
    if 4 < n:
        theta = math.atan(math.sqrt(min(4,n-4)/(4)))*2
        qc.cry(theta, 0, 4)
        qc.cx(4, 0)
    if 14 < n:
        theta = math.atan(math.sqrt((n-14)/(2)))*2
        qc.cry(theta, 12, 14)
        qc.cx(14, 12)
    if 10 < n:
        theta = math.atan(math.sqrt(min(2,n-10)/(2)))*2
        qc.cry(theta, 8, 10)
        qc.cx(10, 8)
    if 6 < n:
        theta = math.atan(math.sqrt(min(2,n-6)/(2)))*2
        qc.cry(theta, 4, 6)
        qc.cx(6, 4)
    if 2 < n:
        theta = math.atan(math.sqrt(min(2,n-2)/(2)))*2
        qc.cry(theta, 0, 2)
        qc.cx(2, 0)
    for i in range(1,15,2):
        if i < n:
            theta = math.atan(1)*2
            qc.cry(theta, i-1, i)
            qc.cx(i-1, i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n:int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.x(0)
    if 8 < n:
        theta = math.atan(math.sqrt((n-8)/(8)))*2
        qc.cry(theta, 0, 8)
        qc.cx(8, 0)
    if 12 < n:
        theta = math.atan(math.sqrt((n-12)/(4)))*2
        qc.cry(theta, 8, 12)
        qc.cx(12, 8)
    if 4 < n:
        theta = math.atan(math.sqrt(min(4,n-4)/(4)))*2
        qc.cry(theta, 0, 4)
        qc.cx(4, 0)
    if 14 < n:
        theta = math.atan(math.sqrt((n-14)/(2)))*2
        qc.cry(theta, 12, 14)
        qc.cx(14, 12)
    if 10 < n:
        theta = math.atan(math.sqrt(min(2,n-10)/(2)))*2
        qc.cry(theta, 8, 10)
        qc.cx(10, 8)
    if 6 < n:
        theta = math.atan(math.sqrt(min(2,n-6)/(2)))*2
        qc.cry(theta, 4, 6)
        qc.cx(6, 4)
    if 2 < n:
        theta = math.atan(math.sqrt(min(2,n-2)/(2)))*2
        qc.cry(theta, 0, 2)
        qc.cx(2, 0)
    for i in range(1,15,2):
        if i < n:
            theta = math.atan(1)*2
            qc.cry(theta, i-1, i)
            qc.cx(i-1, i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.x(0)
    for i,j in [(0,8),(0,4),(8,12),(0,2),(4,6),(8,10),(12,14),(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13)]:
        if j >= n:
            continue
        theta = math.atan(math.sqrt(min(j-i,n-j)/(j-i)))*2
        qc.cry(theta, i, j)
        qc.cx(j,i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import acos, pi, sqrt

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

    for i in range(n - 1):
        theta = 2 * acos(1 / sqrt(n - i))
        qc.cry(theta, i, i + 1)
        qc.cx(i + 1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import acos, pi, sqrt

def func(qc, l:int, r:int) -> QuantumCircuit:
    m = (l + r) // 2
    theta = 2 * acos(sqrt((m - l)/(r - l)))
    qc.cry(theta, l, m)
    qc.cx(m, l)
    if m - l > 1:
        func(qc, l, m)
    if r - m > 1:
         func(qc, m, r)

    return qc

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.x(0)
    func(qc, 0, n)

    return qc
'''


'''python
import math
from qiskit import QuantumCircuit

def theta(k: int) -> float:
    return math.asin(math.sqrt((k-1)/k)) * 2

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.x(0)
    qc.cry(theta(n), 0, 1)
    for i in range(2, n):
        qc.cry(theta(n-i+1), i-1, i)
        qc.cx(i-1, i-2)
    qc.cx(n-1, n-2)
    return qc

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


'''python
from math import (
    pi,
    # degrees,
    # radians,
    asin,
    acos,
    # atan2,
    sqrt,
    # sin,
    # cos,
    # tan
)
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(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.x(0)
    for i in range(1, n):
        qc.cry(asin(sqrt((n - i) / (n - i + 1))) * 2, i - 1, i)
    for i in range(1, n):
        qc.cx(i, i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

import math

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(4)  # We need 4 qubits for this state

    # Calculate the rotation angle for the initial Ry gate
    theta = 4 * math.atan(math.sqrt(6) / (3 + math.sqrt(3)))

    # Apply the RY rotation to the first qubit
    qc.ry(theta, 0)

    # Apply controlled-Hadamard (CH) gates to create superposition
    qc.ch(0, 1)  # Control from qubit 0 to 1
    qc.cx(1, 0)
    qc.ch(1, 2)  # Control from qubit 1 to 2
    qc.cx(2, 1)
    qc.ch(2, 3)  # Control from qubit 2 to 3
    qc.cx(3, 2)

    # Apply X gates to prepare for the multi-control Toffoli gate (CCX)
    qc.x(0)
    qc.x(1)
    qc.x(2)

    # Apply Toffoli gate to flip the last qubit if the first three are all |1>
    qc.mcx([0, 1, 2], 3)  # Multi-controlled X gate (CCX equivalent for 3 controls)

    # Revert the X gates to return the state to the desired form
    qc.x(0)
    qc.x(1)
    qc.x(2)

    return qc
'''


'''python
from qiskit import QuantumCircuit

import math

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

    count = 1

    # queue = [(a, b, control bit of CRy), ...]
    queue = [(n // 2, n, 0)]

    # breadth first search
    while len(queue):
        a, b, control = queue.pop(0)

        if a == 0:
            continue

        theta = 2 * math.atan(math.sqrt((b - a) / a))

        qc.cry(theta, control, count)
        qc.cx(count, control)

        queue.append(((b // 2) // 2, b // 2, control))
        queue.append((math.ceil(b / 2) // 2, math.ceil(b / 2), count))

        count += 1

    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import asin

def move(qc, f, t, ratio):
    theta = 2 * asin(ratio**0.5)
    qc.cry(theta, f, t)
    qc.cx(t, f)

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

    qc.x(0)

    parent = [None]
    for i in range(1, n):
        for r in (8, 4, 2, 1):
            if i & r:
                parent.append(i - r)
                break

    # print(parent)

    ww = [0] * n
    for i in range(n - 1, -1, -1):
        ww[i] += 1 / n
        if parent[i] is not None:
            ww[parent[i]] += ww[i]

    # print(ww)

    xx = [0] * n
    xx[0] = 1

    for i in range(1, n):
        p = parent[i]
        move(qc, p, i, ww[i] / xx[p])
        xx[p] -= ww[i]
        xx[i] = ww[i]

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.x(0)
    for _ in range(n - 1):
        qc.cry(2 * math.atan(math.sqrt(n - _ - 1)), _, _ + 1)
    for _ in range(n - 1):
        qc.cx(_ + 1, _)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math
import numpy

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

    qc.x(0)
    for i in range(n - 1):
        theta = 2 * numpy.arccos(math.sqrt(1/(n - i)))
        qc.cry(theta, i, i + 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math
import numpy

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

    qc.x(0)
    for i in range(n - 1):
        theta = 2 * numpy.arccos(math.sqrt(1/(n - i)))
        qc.cry(theta, i, i + 1)

    for i in range(n - 1):
        qc.cx(i + 1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    # Step 1: Apply Hadamard to the first qubit
    qc.h(0)

    # Step 2: Apply CNOT gates to create the desired superposition
    for i in range(1, n):
        qc.cx(0, i)  # CNOT from qubit 0 to qubit i

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    theta = 2 * math.atan(math.sqrt(n-1))
    qc.ry(theta,0)

    for i in range(n-2):
        theta = 2 * math.atan(math.sqrt(n-i-2))
        qc.cry(theta,i,i+1)

    qc.cx(n-2,n-1)
    for i in range(n-2)[::-1]:
        qc.cx(i,i+1)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    #l,rに分ける
    u = n//2
    l = (n+1)//2
    theta = 2 * math.atan(math.sqrt(u)/math.sqrt(l))
    qc.ry(theta,l)

    #u側
    theta = 2 * math.atan(math.sqrt(u-2))
    qc.cry(theta,l,l+1)
    qc.x(l)
    qc.cx(l,0)

    #u側
    for i in range(1,u-2):
        theta = 2 * math.atan(math.sqrt(u-i-2))
        qc.cry(theta,l+i,l+i+1)

    qc.cx(n-2,n-1)
    for i in range(n-2)[::-1]:
        qc.cx(i,i+1)

    #l側
    for i in range(l-2):
        theta = 2 * math.atan(math.sqrt(l-i-2))
        qc.cry(theta,i,i+1)

    qc.cx(l-2,l-1)
    for i in range(l-2)[::-1]:
        qc.cx(i,i+1)

    qc.x(l)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    #l,rに分ける
    u = n//2
    l = (n+1)//2
    theta = 2 * math.atan(math.sqrt(u)/math.sqrt(l))
    qc.ry(theta,l)

    #u側
    theta = 2 * math.atan(math.sqrt(u-2))
    qc.cry(theta,l,l+1)
    qc.x(l)
    qc.cx(l,0)

    #u側
    for i in range(1,u-2):
        theta = 2 * math.atan(math.sqrt(u-i-2))
        qc.cry(theta,l+i,l+i+1)

    qc.cx(n-2,n-1)
    for i in range(u-2)[::-1]:
        qc.cx(l+i,l+i+1)

    #l側
    for i in range(l-2):
        theta = 2 * math.atan(math.sqrt(l-i-2))
        qc.cry(theta,i,i+1)

    qc.cx(l-2,l-1)
    for i in range(l-2)[::-1]:
        qc.cx(i,i+1)

    qc.x(l)

    return qc
'''


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

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

    for i in range(n-1):
        theta = 2 * np.arccos(np.sqrt(1 / (n - i)))
        qc.cry(theta,i, i+1)
        qc.cx(i+1,i)

    return qc
'''


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

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

    for i in range(1, n):
        theta = 2 * np.arccos(np.sqrt(1 / (i + 1)))
        qc.cry(theta, i - 1, i)

    return qc
'''


'''python
from math import ceil,floor,acos,sqrt
from qiskit import QuantumCircuit

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

    qc.x(0)

    cnt=1

    que=[(n,0)]

    while len(que):
        a,ctrl=que.pop(0)

        if a == 0 or a==1:
            continue
        b=ceil(a/2)
        c=floor(a/2)
        t=2*acos(sqrt(b/a))

        qc.cry(t,ctrl,cnt)
        qc.cx(cnt,ctrl)

        if b>1:
            que.append((b,ctrl))
        if c>1:
            que.append((c,cnt))

        cnt+=1

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.x(0)
    n0 = n-n//2
    n1 = n//2
    qc.cry(2*math.acos(math.sqrt(n0/n)),0,1)
    qc.cx(1,0)
    for i in range(n0-1):
        qc.cry(2*math.acos(1/math.sqrt(n0-i)),2*i, 2*i+2)
        qc.cx(2*i+2, 2*i)
    for i in range(n1-1):
        qc.cry(2*math.acos(1/math.sqrt(n1-i)),2*i+1, 2*i+3)
        qc.cx(2*i+3, 2*i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.ry(2*math.acos(1/math.sqrt(n)),0)
    for i in range(1,n-1):
        qc.cry(2*math.acos(1/math.sqrt(n-i)),i-1,i)
    for i in range(n-1,0,-1):
        qc.cx(i-1,i)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import pi, sqrt, atan

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

    theta = 2 * atan(sqrt(n - 1))
    qc.ry(theta, 0)

    for i in range(1, n):
        theta = 2 * atan(sqrt(n - i - 1))
        qc.cry(theta, i - 1, i)

    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import pi, sqrt, atan

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

    qc.x(0)

    for i in range(1, n):
        theta = 2 * acos(1.0 / sqrt(n - i + 1))
        qc.cry(theta, i - 1, i)

    for i in range(1, n):
        qc.cx(i, i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    qc.x(0)

    for i in range(1, n):
        theta = 2 * math.acos(1.0 / sqrt(n - i + 1))
        qc.cry(theta, i - 1, i)

    for i in range(1, n):
        qc.cx(i, i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    qc.x(0)

    for i in range(1, n):
        theta = 2 * math.acos(1.0 / math.sqrt(n - i + 1))
        qc.cry(theta, i - 1, i)

    for i in range(1, n):
        qc.cx(i, i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.x(0)
    for i in range(n-1):
        theta = 2 * math.atan(math.sqrt(n - i - 1))
        qc.cry(theta, i, i+1)

    for i in range(n-1):
        qc.cx(i+1, i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    def theta(n: int, m: int) -> float:
        return 2 * math.acos(math.sqrt(m/n))

    a = 1
    while a*2 < n:
        a *= 2

    qc.x(0)
    while a > 0:
        j = 0
        while j + a < n:
            # print(j, j+a)
            qc.cry(theta(min(2*a, n), a), j, j+a)
            qc.cx(j+a,j)
            j += a+1
        a //= 2

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def theta(n: int, m: int) -> float:
    return 2 * math.acos(math.sqrt(m/n))

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

    a = 1
    while a*2 < n:
        a *= 2

    qc.x(0)
    while a > 0:
        j = 0
        while j + a < n:
            qc.cry(theta(min(2*a, n), a), j, j+a)
            qc.cx(j+a,j)
            j += a+1
        a //= 2

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def theta(n: int, m: int) -> float:
    return 2 * math.acos(math.sqrt(m/n))

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

    a = 1
    while a*2 < n:
        a *= 2

    qc.x(0)
    while a > 0:
        j = 0
        while j + a < n:
            qc.cry(theta(min(2*a, n-j), a), j, j+a)
            qc.cx(j+a, j)
            j += 2*a
        a //= 2

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    for i in range(n-1):
        theta = 2*math.acos(math.sqrt((n-i-1)/(n-i)))
        qc.cry(theta, 0, i+1)
        qc.cx(i+1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    if n<=9:
        qc.x(0)

        for i in range(n-1):
            theta = 2*math.acos(math.sqrt((n-i-1)/(n-i)))
            qc.cry(theta, 0, i+1)
            qc.cx(i+1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    if n <= 9:
        qc.x(0)

        for i in range(n-1):
            theta = 2*math.acos(math.sqrt((n-i-1)/(n-i)))
            qc.cry(theta, 0, i+1)
            qc.cx(i+1, 0)
    else:
        qc.x(0)
        qc.x(n//2)

        for i in range(n//2-1):
            theta = 2*math.acos(math.sqrt((n-i-1)/(n-i)))
            qc.cry(theta, 0, i+1)
            qc.cx(i+1, 0)
            qc.cx(i+1, n//2)

        for i in range(n//2, n-1):
            theta = 2*math.acos(math.sqrt((n-i-1)/(n-i)))
            qc.cry(theta, n//2, i+1)
            qc.cx(i+1, n//2)
            qc.cx(i+1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    for i in range(n-1):
        theta = 2*math.acos(math.sqrt((n-i-1)/(n-i)))
        qc.cry(theta, 0, i+1)
    for i in range(n-1):
        qc.cx(i+1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    for i in range(n-1):
        theta = 2*math.acos(math.sqrt((n-i-1)/(n-i)))
        qc.cry(theta, i, i+1)
    for i in range(n-1):
        qc.cx(i+1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    for i in range(n-1):
        theta = 2*math.acos(math.sqrt(1/n-i))
        qc.cry(theta, i, i+1)
    for i in range(n-1):
        qc.cx(i+1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    qc.x(0)
    for i in range(n-1):
        theta = 2 * math.acos((n-i)**-0.5)
        qc.cry(theta, i, i+1)
        qc.cx(i+1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for i in range(0, n-1):
        theta = math.atan(math.sqrt(n-i-1)) * 2
        qc.cry(theta, i, i+1)
        qc.cx(i+1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    # theta = []
    # for i in range(n-1):
    #     theta.append(math.atan(math.sqrt(n-i-1))*2)

    qc.x(0)

    for i in range(0, n-1):
        theta = math.atan(math.sqrt(n-i-1)) * 2
        qc.cry(theta, i, i+1)
        qc.cx(i+1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    qc.x(0)

    for i in range(n-1):
        theta = math.atan(math.sqrt(n-1-i)) * 2
        qc.cry(theta, i, i+1)
        qc.cx(i+1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    qc.x(0)

    for i in range(n-1):
        theta = math.atan(math.sqrt(n-1-i)) * 2
        qc.cry(theta, i, i+1)

    for i in range(n-1):

        qc.cx(i+1, i)

    return qc
'''


'''python
import math

from qiskit import QuantumCircuit

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

    theta = [2 * math.atan(math.sqrt(i)) for i in range(n - 1, 0, -1)]

    qc.x(0)

    for i in range(n-1):
        qc.cry(theta[i], i, i + 1)

    for i in range(n - 1):

        qc.cx(i + 1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    theta = [2 * math.atan(math.sqrt(i)) for i in range(n - 1, 0, -1)]
    qc.x(0)
    for i in range(n - 1):
        qc.cry(theta[i], i, i + 1)
    for i in range(n - 1):
        qc.cx(i + 1,i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    theta = [2 * math.atan(math.sqrt(i)) for i in range(n - 1, 0, -1)]
    qc.x(0)
    for i in range(n - 1):
        qc.cry(theta[i], i, i + 1)
    for i in range(n - 1):
        qc.cx(i + 1,i)
    return qc
'''


'''python
from qiskit import QuantumCircuit, QuantumRegister
from qiskit.circuit.library import CXGate, ZGate
from math import sqrt, acos, pi

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

	def solve_for(l, r):
		if r - l == 1:
			return
		m = l + r >> 1
		theta = 2 * acos(sqrt(m - l) / sqrt(r - l))
		qc.cry(theta, l, m)
		qc.cx(m, l)
		solve_for(l, m)
		solve_for(m, r)

	solve_for(0, n)
	return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    theta=[2*math.atan(math.sqrt(i)) for i in range(n-1,0,-1)]
    qc.x(0)
    for i in range(n-1):
        qc.cry(theta[i],i,i+1)
        qc.cx(i+1,i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    theta=[2*math.atan(math.sqrt(i)) for i in range(n-1,0,-1)]
    qc.x(0)
    for i in range(n-1):
        qc.cry(theta[i],i,i+1)
        qc.cx(i+1,i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    theta=[2*math.atan(math.sqrt(i)) for i in range(n-1,0,-1)]
    qc.x(0)
    for i in range(n-1):
        qc.cry(theta[i],i,i+1)
    for i in range(n-1):
        qc.cx(i+1,i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range( n - 1 ):
        x =  math.sqrt(1/ (n-i))
        y =  math.sqrt((n-i-1)/(n-i))
        theta = 2 * math.atan(y/x)
        if i == 0:
            qc.ry(theta, i)
        else:
            qc.cry(theta, i-1, i)

    qc.x(n-1)
    qc.cx(0,n-1)
    for i in range(n-2):
        qc.cx(i+1,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    qc.ry(2*math.arccos(1/math.sqrt(n)))
    for target in range(1, n-1):
        qc.ch(target-1, target)

    for target in range(n-1, 0, -1):
        qc.cx(target-1, target)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    qc.ry(2*math.acos(1/math.sqrt(n)), 0)
    for target in range(1, n-1):
        qc.ch(target-1, target)

    for target in range(n-1, 0, -1):
        qc.cx(target-1, target)
    qc.x(0)
'''


'''python
from qiskit import QuantumCircuit
import math

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

    qc.ry(2*math.acos(1/math.sqrt(n)), 0)
    for target in range(1, n-1):
        qc.ch(target-1, target)

    for target in range(n-1, 0, -1):
        qc.cx(target-1, target)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    # Hゲートを各量子ビットに適用して、均等な重ね合わせを作成
    for i in range(n):
        qc.h(i)

    # 各量子ビットが1つだけ1となる状態の測定を行う
    return qc

# n の値を指定
n = 4  # 例として n = 4 の場合
qc = solve(n)
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.x(0)
    a = [[0]*n for _ in range(5)]
    for i in range(n):
        a[4][i] = 1
    for i in range(3, -1, -1):
        for j in range(n):
            a[i][j] = a[i+1][j]
            if j+2**i<n:
                a[i][j] += a[i+1][j+2**i]
    for i in range(4):
        if 2**i>=n:
            break
        for j in range(0, 2**i):
            if j+2**i<n:
                qc.cry(math.acos(math.sqrt(a[i+1][j]/a[i][j]))*2, j, j+2**i)
                qc.cx(j+2**i, j)
    # print(qc.depth())
    return qc

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


'''python
from math import (
    pi,
    # degrees,
    # radians,
    asin,
    acos,
    # atan2,
    sqrt,
    # sin,
    # cos,
    # tan
)
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 split_state(qc: QuantumCircuit, targets: list[int], proportions: list[float]):
    sum_p = sum(proportions)
    proportions = [p / sum_p for p in proportions]
    for i in range(1, len(targets)):
        qc.cry(
            asin(sqrt((1 - sum(proportions[:i])) / (1 - sum(proportions[: i - 1]))))
            * 2,
            targets[i - 1],
            targets[i],
        )
    for i in range(1, len(targets)):
        qc.cx(targets[i], targets[i - 1])

def solve_main(qc: QuantumCircuit, i0: int, i1: int):
    if i1 - i0 <= 1:
        return
    i = (i0 + i1) // 2
    split_state(qc, [i0, i], [len(range(i0, i)), len(range(i, i1))])
    solve_main(qc, i0, i)
    solve_main(qc, i, i1)

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.x(0)
    solve_main(qc, 0, n)

    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    levels = int(np.ceil(np.log2(n)))
    qc.x(0)

    box = [0 for _ in range(n)]
    box[0] = n

    for level in range(levels):
        tmp = 2**level
        for i in range(tmp):
            parent = box[i]
            if parent == 1:
                continue

            left = parent//2
            right = parent - left

            prob_amp = np.sqrt(left / parent)
            rot_ang = 2 * np.arccos(prob_amp)

            for j in range(tmp, n):
                if box[j] == 0:
                    bridge = j
                    break

            qc.cry(rot_ang, i, bridge)
            qc.cx(bridge, i)

            box[i] = left
            box[bridge] = right

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    n_code = bin(n)[2:]
    m = [0]
    for i in range(len(n_code)):
        if n_code[i] == "1":
            m.append(m[-1]+2**(len(n_code)-i-1))
    qc.x(0)
    for i in range(1,len(m)-1):
        print(i,m[i-1],m[i],(m[i]-m[i-1])/(n-m[i-1]))
        split_one_hot(qc,m[i-1],m[i],(m[i]-m[i-1])/(n-m[i-1]))
    for j in range(1,len(m)):
        for k in range(1,m[j]-m[j-1]):
            split_one_hot(qc,m[j-1]+k-2**int(math.log2(k)),m[j-1]+k,1/2)

    return qc
def split_one_hot(qc,m1,m2,l):
    print(m1,m2,l)
    qc.cry(2*math.acos(math.sqrt(l)),m1,m2)
    qc.cx(m2,m1)
'''


'''python
from qiskit import QuantumCircuit
from math import acos, pi, sqrt

def func(qc, l:int, r:int) -> QuantumCircuit:
    m = (l + r) // 2
    theta = 2 * acos(sqrt((m - l)/(r - l)))
    qc.cry(theta, l, m)
    qc.cx(m, l)
    if m - l > 1:
        func(qc, l, m)
    if r - m > 1:
         func(qc, m, r)

    return qc

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.x(0)
    func(qc, 0, n)

    return qc
'''


'''python
from qiskit import QuantumCircuit, QuantumRegister
from qiskit.circuit.library import ZGate, XGate, HGate, SwapGate
import math

"""
You can apply oracle as follows:
qc.compose(o, inplace=True)
"""

def diffusion_oracle(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n):
        qc.h(i)
        qc.x(i)
    qc.append(ZGate().control(n - 1), range(n))
    for i in range(n):
        qc.x(i)
        qc.h(i)
    return qc

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

    count = 1

    # queue = [(a, b, control bit of CRy), ...]
    queue = [(n // 2, n, 0)]

    # breadth first search
    while len(queue):
        a, b, control = queue.pop(0)

        if a == 0:
            continue

        theta = 2 * math.atan(math.sqrt((b - a) / a))

        qc.cry(theta, control, count)
        qc.cx(count, control)

        queue.append(((b // 2) // 2, b // 2, control))
        queue.append((math.ceil(b / 2) // 2, math.ceil(b / 2), count))

        count += 1

    return qc

# if __name__ == "__main__":
#     from qiskit.quantum_info import Statevector
#     import numpy as np

#     n = 3
#     qc = solve(n)
#     sv = Statevector(qc)
#     print(sv)
#     print(qc)
#     print(f"{qc.depth() = }")
#     # sv = Statevector.from_label('01000')
#     # print(sv.evolve(qc))
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    levels = int(np.ceil(np.log2(n)))
    qc.x(0)

    box = [0 for _ in range(n)]
    box[0] = n

    for level in range(levels):
        tmp = 2**level
        for i in range(tmp):
            parent = box[i]
            if parent == 1:
                continue
            left = parent//2
            right = parent - left
            prob_amp = np.sqrt(left / parent)
            rot_ang = 2 * np.arccos(prob_amp)
            for j in range(tmp, n):
                if box[j] == 0:
                    bridge = j
                    break
            qc.cry(rot_ang, i, bridge)
            qc.cx(bridge, i)
            box[i] = left
            box[bridge] = right

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    # Apply Hadamard to the first qubit to create superposition
    qc.h(0)

    # Apply controlled NOT gates to create the desired states
    for i in range(1, n):
        qc.cx(0, i)  # Control on qubit 0, target on qubit i

    # Apply a normalization factor (not explicitly in the circuit, but conceptually)
    # The state is already normalized due to the structure of the circuit.

    return qc
'''


'''python
import math

from qiskit import QuantumCircuit

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

    count = 1

    # queue = [(a, b, control bit of CRy), ...]
    queue = [(n // 2, n, 0)]

    # breadth first search
    while len(queue):
        a, b, control = queue.pop(0)

        if a == 0:
            continue

        theta = 2 * math.atan(math.sqrt((b - a) / a))

        qc.cry(theta, control, count)
        qc.cx(count, control)

        queue.append(((b // 2) // 2, b // 2, control))
        queue.append((math.ceil(b / 2) // 2, math.ceil(b / 2), count))

        count += 1

    return qc
'''


'''python
from math import *
from qiskit import QuantumCircuit

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

    qc.x(0)

    cnt=1

    que=[(n,0)]

    while len(que):
        a,ctrl=que.pop(0)

        if a == 0 or a==1:
            continue
        b=ceil(a/2)
        c=floor(a/2)
        t=2*acos(sqrt(b/a))

        qc.cry(t,ctrl,cnt)
        qc.cx(cnt,ctrl)

        que.append((b,ctrl))
        que.append((c,cnt))

        cnt+=1

    return qc
'''


'''python
from math import ceil,floor,acos,sqrt
from qiskit import QuantumCircuit

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

    qc.x(0)

    cnt=1

    que=[(n,0)]

    while len(que):
        a,ctrl=que.pop(0)

        if a == 0 or a==1:
            continue
        b=ceil(a/2)
        c=floor(a/2)
        t=2*acos(sqrt(b/a))

        qc.cry(t,ctrl,cnt)
        qc.cx(cnt,ctrl)

        que.append((b,ctrl))
        que.append((c,cnt))

        cnt+=1

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.x(0)
    count = 1
    queue = [(n//2, n, 0)]
    while len(queue):
        a,b,control = queue.pop()
        if a == 0:
            continue;
        qc.cry(2 * math.atan(math.sqrt((b - a) / a)),control,count)
        qc.cx(count,control)
        qc.append(((b // 2) // 2,b // 2, control))
        qc.append((math.ceil(b / 2) // 2,math.ceil(b / 2), count))
        count += 1
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.x(0)
    count = 1
    queue = [(n//2, n, 0)]
    while len(queue):
        a,b,control = queue.pop(0)
        if a == 0:
            continue;
        qc.cry(2 * math.atan(math.sqrt((b - a) / a)),control,count)
        qc.cx(count,control)
        qc.append(((b // 2) // 2,b // 2, control))
        qc.append((math.ceil(b / 2) // 2,math.ceil(b / 2), count))
        count += 1
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc = QuantumCircuit(n)
    qc.x(0)
    count = 1
    queue = [(n//2, n, 0)]
    while len(queue):
        a,b,control = queue.pop(0)
            continue;
        if a > 0 and b > a:
            qc.cry(2 * math.atan(math.sqrt((b - a) / a)),control,count)
            qc.cx(count,control)
        if b // 2 > 0:
            qc.cx(control, count)
            queue.append(((b // 2) // 2, b // 2, control))
        if math.ceil(b / 2) // 2 > 0:
            qc.cx(count, control)
            queue.append((math.ceil(b / 2) // 2, math.ceil(b / 2), count))
        count += 1
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc = QuantumCircuit(n)
    qc.x(0)
    count = 1
    queue = [(n//2, n, 0)]
    while len(queue):
        a,b,control = queue.pop(0)
        if a == 0:
            continue;
        if a > 0 and b > a:
            qc.cry(2 * math.atan(math.sqrt((b - a) / a)),control,count)
            qc.cx(count,control)
        if b // 2 > 0:
            qc.cx(control, count)
            queue.append(((b // 2) // 2, b // 2, control))
        if math.ceil(b / 2) // 2 > 0:
            qc.cx(count, control)
            queue.append((math.ceil(b / 2) // 2, math.ceil(b / 2), count))
        count += 1
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.x(0)
    count = 1
    queue = [(n//2, n, 0)]
    while len(queue):
        a,b,control = queue.pop(0)
        if a == 0:
            continue;
        qc.cry(2 * math.atan(math.sqrt((b - a) / a)),control,count)
        qc.cx(count,control)
        queue.append(((b // 2) // 2, b // 2, control))
        queue.append((math.ceil(b / 2) // 2, math.ceil(b / 2), count))
        count += 1
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    keep = [n]
    qc.x(0)
    for i in range(int(math.log2(n)) + 1):
        for j in range(2**i):
            if 2**i + j < n:
                x = keep.pop(0)
                a = (x + 1) // 2
                b = x // 2
                keep.append(a)
                keep.append(b)
                theta = 2 * math.atan(math.sqrt(b / a))
                qc.cry(theta, j, j + 2**i)
            print(keep)
        for k in range(2**i):
            if 2 ** i + k < n:
                qc.cx(k + 2**i, k)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    keep = [n]
    qc.x(0)
    for i in range(int(math.log2(n)) + 1):
        for j in range(2**i):
            if 2**i + j < n:
                x = keep.pop(0)
                a = (x + 1) // 2
                b = x // 2
                keep.append(a)
                keep.append(b)
                theta = 2 * math.atan(math.sqrt(b / a))
                qc.cry(theta, j, j + 2**i)
        for k in range(2**i):
            if 2 ** i + k < n:
                qc.cx(k + 2**i, k)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    keep = [n]
    qc.x(0)
    for i in range(int(math.log2(n)) + 1):
        for j in range(2**i):
            # print(2**i + j)
            if 2**i + j < n:
                x = keep.pop(0)
                a = (x + 1) // 2
                b = x // 2
                if a > 1:
                    keep.append(a)
                if b > 1:
                    keep.append(b)
                theta = 2 * math.atan(math.sqrt(b / a))
                qc.cry(theta, j, j + 2**i)

            # print(keep)
        for k in range(2**i):
            if 2 ** i + k < n:
                qc.cx(k + 2**i, k)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    keep = {0:n}
    qc.x(0)
    for i in range(int(math.log2(n)) + 1):
        for j in range(2**i):
            # print(2**i + j)
            if 2**i + j < n:
                x = keep.pop(j)
                a = (x + 1) // 2
                b = x // 2
                # print(a, b)
                if a > 1:
                    keep[j] = a
                if b > 1:
                    keep[j + 2**i] = b
                theta = 2 * math.atan(math.sqrt(b / a))
                qc.cry(theta, j, j + 2**i)

            # print(keep)
        for k in range(2**i):
            if 2 ** i + k < n:
                qc.cx(k + 2**i, k)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range( n - 1 ):
        x =  math.sqrt(1/ (n-i))
        y =  math.sqrt((n-i-1)/(n-i))
        theta = 2 * math.atan(y/x)
        if i == 0:
            qc.ry(theta, i)
        else:
            qc.cry(theta, i-1, i)

    qc.x(n-1)
    qc.cx(0,n-1)
    for i in range(n-2):
        qc.cx(i+1,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    if n < 6:
      qc.ry(2*math.acos(1.0/math.sqrt(n)), 0)
      for i in range(n-2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-i-1)), i, i+1)
      for i in range(n-1):
        qc.cry(-math.pi, n-2-i, n-1-i)
      qc.ry(-math.pi, 0)
    elif n < 10:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      for i in range(n-6):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(n-6):
        qc.cry(-math.pi, i+6, i+5)
    elif n < 13:
      qc.x(0)
      qc.cry(2*math.acos(math.sqrt(5.0/n)), 0, 5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      qc.cry(2*math.acos(math.sqrt(4.0/(n-5))), 5, 9)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(3):
        qc.cry(-math.pi, i+6, i+5)
      for i in range(n-10):
        qc.cry(2*math.acos(1.0/math.sqrt(n-9-i)), i+9, i+10)
      for i in range(n-10):
        qc.cry(-math.pi, i+10, i+9)
    elif n < 15:
      qc.x(0)
      qc.cry(2*math.acos(math.sqrt(5.0/n)), 0, 5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      qc.cry(2*math.acos(math.sqrt(4.0/(n-5))), 5, 9)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(3):
        qc.cry(-math.pi, i+6, i+5)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-9))), 9, 12)
      for i in range(2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-9-i)), i+9, i+10)
      for i in range(2):
        qc.cry(-math.pi, i+10, i+9)
      for i in range(n-13):
        qc.cry(2*math.acos(1.0/math.sqrt(n-13-i)), i+12, i+13)
      for i in range(n-13):
        qc.cry(-math.pi, i+13, i+12)
    else:
      qc.x(0)
      qc.cry(2*math.acos(math.sqrt(5.0/n)), 0, 5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      qc.cry(2*math.acos(math.sqrt(4.0/(n-5))), 5, 9)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(3):
        qc.cry(-math.pi, i+6, i+5)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-9))), 9, 12)
      for i in range(2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-9-i)), i+9, i+10)
      for i in range(2):
        qc.cry(-math.pi, i+10, i+9)
      qc.cry(2*math.acos(math.sqrt(2.0/(n-12))), 12, 14)
      for i in range(1):
        qc.cry(2*math.acos(1.0/math.sqrt(n-13-i)), i+12, i+13)
      for i in range(1):
        qc.cry(-math.pi, i+13, i+12)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    if n < 6:
      qc.ry(2*math.acos(1.0/math.sqrt(n)), 0)
      for i in range(n-2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-i-1)), i, i+1)
      for i in range(n-1):
        qc.cry(-math.pi, n-2-i, n-1-i)
      qc.ry(-math.pi, 0)
    elif n < 10:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      for i in range(n-6):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(n-6):
        qc.cry(-math.pi, i+6, i+5)
    elif n < 13:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      qc.cry(2*math.acos(math.sqrt(4.0/(n-5))), 5, 9)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(3):
        qc.cry(-math.pi, i+6, i+5)
      for i in range(n-10):
        qc.cry(2*math.acos(1.0/math.sqrt(n-9-i)), i+9, i+10)
      for i in range(n-10):
        qc.cry(-math.pi, i+10, i+9)
    elif n < 15:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      qc.cry(2*math.acos(math.sqrt(4.0/(n-5))), 5, 9)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(3):
        qc.cry(-math.pi, i+6, i+5)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-9))), 9, 12)
      for i in range(2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-9-i)), i+9, i+10)
      for i in range(2):
        qc.cry(-math.pi, i+10, i+9)
      for i in range(n-13):
        qc.cry(2*math.acos(1.0/math.sqrt(n-13-i)), i+12, i+13)
      for i in range(n-13):
        qc.cry(-math.pi, i+13, i+12)
    else:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      qc.cry(2*math.acos(math.sqrt(4.0/(n-5))), 5, 9)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(3):
        qc.cry(-math.pi, i+6, i+5)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-9))), 9, 12)
      for i in range(2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-9-i)), i+9, i+10)
      for i in range(2):
        qc.cry(-math.pi, i+10, i+9)
      qc.cry(2*math.acos(math.sqrt(2.0/(n-12))), 12, 14)
      for i in range(1):
        qc.cry(2*math.acos(1.0/math.sqrt(n-13-i)), i+12, i+13)
      for i in range(1):
        qc.cry(-math.pi, i+13, i+12)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    if n < 6:
      qc.ry(2*math.acos(1.0/math.sqrt(n)), 0)
      for i in range(n-2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-i-1)), i, i+1)
      for i in range(n-1):
        qc.cry(-math.pi, n-2-i, n-1-i)
      qc.ry(-math.pi, 0)
    elif n < 10:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      for i in range(n-6):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(n-6):
        qc.cry(-math.pi, i+6, i+5)
    elif n < 13:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      qc.cry(2*math.acos(math.sqrt(4.0/(n-5))), 5, 9)
      qc.cx(9, 5)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(3):
        qc.cry(-math.pi, i+6, i+5)
      for i in range(n-10):
        qc.cry(2*math.acos(1.0/math.sqrt(n-9-i)), i+9, i+10)
      for i in range(n-10):
        qc.cry(-math.pi, i+10, i+9)
    elif n < 15:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      qc.cry(2*math.acos(math.sqrt(4.0/(n-5))), 5, 9)
      qc.cx(9, 5)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(3):
        qc.cry(-math.pi, i+6, i+5)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-9))), 9, 12)
      qc.cx(12, 9)
      for i in range(2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-9-i)), i+9, i+10)
      for i in range(2):
        qc.cry(-math.pi, i+10, i+9)
      for i in range(n-13):
        qc.cry(2*math.acos(1.0/math.sqrt(n-13-i)), i+12, i+13)
      for i in range(n-13):
        qc.cry(-math.pi, i+13, i+12)
    else:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      qc.cry(2*math.acos(math.sqrt(4.0/(n-5))), 5, 9)
      qc.cx(9, 5)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(3):
        qc.cry(-math.pi, i+6, i+5)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-9))), 9, 12)
      qc.cx(12, 9)
      for i in range(2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-9-i)), i+9, i+10)
      for i in range(2):
        qc.cry(-math.pi, i+10, i+9)
      qc.cry(2*math.acos(math.sqrt(2.0/(n-12))), 12, 14)
      qc.cx(14, 12)
      for i in range(1):
        qc.cry(2*math.acos(1.0/math.sqrt(n-13-i)), i+12, i+13)
      for i in range(1):
        qc.cry(-math.pi, i+13, i+12)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    if n < 6:
      qc.ry(2*math.acos(1.0/math.sqrt(n)), 0)
      for i in range(n-2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-i-1)), i, i+1)
      for i in range(n-1):
        qc.cry(-math.pi, n-2-i, n-1-i)
      qc.ry(-math.pi, 0)
    elif n < 10:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      for i in range(n-6):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(n-6):
        qc.cry(-math.pi, i+6, i+5)
    elif n < 12:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.cry(2*math.acos(math.sqrt(0.5), 0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      for i in range(n-9):
        qc.cry(2*math.acos(1.0/math.sqrt(n-8-i)), i+8, i+9)
      for i in range(n-9):
        qc.cry(-math.pi, i+9, i+8)
    elif n < 15:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.cry(2*math.acos(math.sqrt(0.5), 0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8)), 8, 11)
      qc.cx(11, 8)
      for i in range(2):
        qc.cry(2*math.acos(1.0/math.sqrt(3-i)), i+8, i+9)
      for i in range(2):
        qc.cry(-math.pi, i+9, i+8)
      for i in range(n-12):
        qc.cry(2*math.acos(1.0/math.sqrt(n-11-i)), i+11, i+12)
      for i in range(n-12):
        qc.cry(-math.pi, i+12, i+11)
    else:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.cry(2*math.acos(math.sqrt(0.5), 0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8)), 8, 11)
      qc.cx(11, 8)
      qc.cry(2*math.acos(math.sqrt(0.5), 11, 13)
      qc.cx(13, 11)
      qc.ch(11, 12)
      qc.ch(13, 14)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    if n < 6:
      qc.ry(2*math.acos(1.0/math.sqrt(n)), 0)
      for i in range(n-2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-i-1)), i, i+1)
      for i in range(n-1):
        qc.cry(-math.pi, n-2-i, n-1-i)
      qc.ry(-math.pi, 0)
    elif n < 10:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      for i in range(n-6):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(n-6):
        qc.cry(-math.pi, i+6, i+5)
    elif n < 12:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.cry(2*math.acos(math.sqrt(0.5), 0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      for i in range(n-9):
        qc.cry(2*math.acos(1.0/math.sqrt(n-8-i)), i+8, i+9)
      for i in range(n-9):
        qc.cry(-math.pi, i+9, i+8)
    elif n < 15:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.cry(2*math.acos(math.sqrt(0.5), 0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8)), 8, 11)
      qc.cx(11, 8)
      for i in range(2):
        qc.cry(2*math.acos(1.0/math.sqrt(3-i)), i+8, i+9)
      for i in range(2):
        qc.cry(-math.pi, i+9, i+8)
      for i in range(n-12):
        qc.cry(2*math.acos(1.0/math.sqrt(n-11-i)), i+11, i+12)
      for i in range(n-12):
        qc.cry(-math.pi, i+12, i+11)
    else:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.cry(2*math.acos(math.sqrt(0.5), 0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8)), 8, 11)
      qc.cx(11, 8)
      qc.ch(11, 13)
      qc.cx(13, 11)
      qc.ch(11, 12)
      qc.ch(13, 14)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    if n < 6:
      qc.ry(2*math.acos(1.0/math.sqrt(n)), 0)
      for i in range(n-2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-i-1)), i, i+1)
      for i in range(n-1):
        qc.cry(-math.pi, n-2-i, n-1-i)
      qc.ry(-math.pi, 0)
    elif n < 10:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      for i in range(n-6):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(n-6):
        qc.cry(-math.pi, i+6, i+5)
    elif n < 12:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      for i in range(n-9):
        qc.cry(2*math.acos(1.0/math.sqrt(n-8-i)), i+8, i+9)
      for i in range(n-9):
        qc.cry(-math.pi, i+9, i+8)
    elif n < 15:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8)), 8, 11)
      qc.cx(11, 8)
      for i in range(2):
        qc.cry(2*math.acos(1.0/math.sqrt(3-i)), i+8, i+9)
      for i in range(2):
        qc.cry(-math.pi, i+9, i+8)
      for i in range(n-12):
        qc.cry(2*math.acos(1.0/math.sqrt(n-11-i)), i+11, i+12)
      for i in range(n-12):
        qc.cry(-math.pi, i+12, i+11)
    else:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8)), 8, 11)
      qc.cx(11, 8)
      qc.ch(11, 13)
      qc.cx(13, 11)
      qc.ch(11, 12)
      qc.ch(13, 14)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    if n < 6:
      qc.ry(2*math.acos(1.0/math.sqrt(n)), 0)
      for i in range(n-2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-i-1)), i, i+1)
      for i in range(n-1):
        qc.cry(-math.pi, n-2-i, n-1-i)
      qc.ry(-math.pi, 0)
    elif n < 10:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      for i in range(n-6):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(n-6):
        qc.cry(-math.pi, i+6, i+5)
    elif n < 12:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      for i in range(n-9):
        qc.cry(2*math.acos(1.0/math.sqrt(n-8-i)), i+8, i+9)
      for i in range(n-9):
        qc.cry(-math.pi, i+9, i+8)
    elif n < 15:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8)), 8, 11)
      qc.cx(11, 8)
      for i in range(2):
        qc.cry(2*math.acos(1.0/math.sqrt(3-i)), i+8, i+9)
      for i in range(2):
        qc.cry(-math.pi, i+9, i+8)
      for i in range(n-12):
        qc.cry(2*math.acos(1.0/math.sqrt(n-11-i)), i+11, i+12)
      for i in range(n-12):
        qc.cry(-math.pi, i+12, i+11)
    else:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8))), 8, 11)
      qc.cx(11, 8)
      qc.ch(11, 13)
      qc.cx(13, 11)
      qc.ch(11, 12)
      qc.ch(13, 14)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    if n < 6:
      qc.ry(2*math.acos(1.0/math.sqrt(n)), 0)
      for i in range(n-2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-i-1)), i, i+1)
      for i in range(n-1):
        qc.cry(-math.pi, n-2-i, n-1-i)
      qc.ry(-math.pi, 0)
    elif n < 10:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      for i in range(n-6):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(n-6):
        qc.cry(-math.pi, i+6, i+5)
    elif n < 12:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      for i in range(n-9):
        qc.cry(2*math.acos(1.0/math.sqrt(n-8-i)), i+8, i+9)
      for i in range(n-9):
        qc.cry(-math.pi, i+9, i+8)
    elif n < 15:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8))), 8, 11)
      qc.cx(11, 8)
      for i in range(2):
        qc.cry(2*math.acos(1.0/math.sqrt(3-i)), i+8, i+9)
      for i in range(2):
        qc.cry(-math.pi, i+9, i+8)
      for i in range(n-12):
        qc.cry(2*math.acos(1.0/math.sqrt(n-11-i)), i+11, i+12)
      for i in range(n-12):
        qc.cry(-math.pi, i+12, i+11)
    else:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8))), 8, 11)
      qc.cx(11, 8)
      qc.ch(11, 13)
      qc.cx(13, 11)
      qc.ch(11, 12)
      qc.ch(13, 14)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    if n < 6:
      qc.ry(2*math.acos(1.0/math.sqrt(n)), 0)
      for i in range(n-2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-i-1)), i, i+1)
      for i in range(n-1):
        qc.cry(-math.pi, n-2-i, n-1-i)
      qc.ry(-math.pi, 0)
    elif n < 10:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      for i in range(n-6):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(n-6):
        qc.cry(-math.pi, i+6, i+5)
    elif n < 12:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.cry(2*math.acos(math.sqrt(0.5)), 0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      for i in range(n-9):
        qc.cry(2*math.acos(1.0/math.sqrt(n-8-i)), i+8, i+9)
      for i in range(n-9):
        qc.cry(-math.pi, i+9, i+8)
    elif n < 15:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.cry(2*math.acos(math.sqrt(0.5)), 0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8))), 8, 11)
      qc.cx(11, 8)
      for i in range(2):
        qc.cry(2*math.acos(1.0/math.sqrt(3-i)), i+8, i+9)
      for i in range(2):
        qc.cry(-math.pi, i+9, i+8)
      for i in range(n-12):
        qc.cry(2*math.acos(1.0/math.sqrt(n-11-i)), i+11, i+12)
      for i in range(n-12):
        qc.cry(-math.pi, i+12, i+11)
    else:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.cry(2*math.acos(math.sqrt(0.5)), 0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8))), 8, 11)
      qc.cx(11, 8)
      qc.cry(2*math.acos(math.sqrt(0.5)), 11, 13)
      qc.cx(13, 11)
      qc.cry(2*math.acos(math.sqrt(0.5)), 11, 12)
      qc.cry(-math.pi, 12, 11)
      qc.cry(2*math.acos(math.sqrt(0.5)), 13, 14)
      qc.cry(-math.pi, 14, 13)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    if n < 6:
      qc.ry(2*math.acos(1.0/math.sqrt(n)), 0)
      for i in range(n-2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-i-1)), i, i+1)
      for i in range(n-1):
        qc.cry(-math.pi, n-2-i, n-1-i)
      qc.ry(-math.pi, 0)
    elif n < 10:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      for i in range(n-6):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(n-6):
        qc.cry(-math.pi, i+6, i+5)
    elif n < 12:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.cry(2*math.acos(math.sqrt(0.5)), 0, 4)
      qc.cry(-math.pi, 4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      for i in range(n-9):
        qc.cry(2*math.acos(1.0/math.sqrt(n-8-i)), i+8, i+9)
      for i in range(n-9):
        qc.cry(-math.pi, i+9, i+8)
    elif n < 15:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.cry(2*math.acos(math.sqrt(0.5)), 0, 4)
      qc.cry(-math.pi, 4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8))), 8, 11)
      qc.cry(-math.pi, 11, 8)
      for i in range(2):
        qc.cry(2*math.acos(1.0/math.sqrt(3-i)), i+8, i+9)
      for i in range(2):
        qc.cry(-math.pi, i+9, i+8)
      for i in range(n-12):
        qc.cry(2*math.acos(1.0/math.sqrt(n-11-i)), i+11, i+12)
      for i in range(n-12):
        qc.cry(-math.pi, i+12, i+11)
    else:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.cry(2*math.acos(math.sqrt(0.5)), 0, 4)
      qc.cry(-math.pi, 4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8))), 8, 11)
      qc.cry(-math.pi, 11, 8)
      qc.cry(2*math.acos(math.sqrt(0.5)), 11, 13)
      qc.cry(-math.pi, 13, 11)
      qc.cry(2*math.acos(math.sqrt(0.5)), 11, 12)
      qc.cry(-math.pi, 12, 11)
      qc.cry(2*math.acos(math.sqrt(0.5)), 13, 14)
      qc.cry(-math.pi, 14, 13)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    if n < 6:
      qc.ry(2*math.acos(1.0/math.sqrt(n)), 0)
      for i in range(n-2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-i-1)), i, i+1)
      for i in range(n-1):
        qc.cry(-math.pi, n-2-i, n-1-i)
      qc.ry(-math.pi, 0)
    elif n < 10:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      for i in range(n-6):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(n-6):
        qc.cry(-math.pi, i+6, i+5)
    elif n < 12:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(, 0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      for i in range(n-9):
        qc.cry(2*math.acos(1.0/math.sqrt(n-8-i)), i+8, i+9)
      for i in range(n-9):
        qc.cry(-math.pi, i+9, i+8)
    elif n < 15:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(, 0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8))), 8, 11)
      qc.cry(-math.pi, 11, 8)
      for i in range(2):
        qc.cry(2*math.acos(1.0/math.sqrt(3-i)), i+8, i+9)
      for i in range(2):
        qc.cry(-math.pi, i+9, i+8)
      for i in range(n-12):
        qc.cry(2*math.acos(1.0/math.sqrt(n-11-i)), i+11, i+12)
      for i in range(n-12):
        qc.cry(-math.pi, i+12, i+11)
    else:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(, 0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8))), 8, 11)
      qc.cry(-math.pi, 11, 8)
      qc.cry(2*math.acos(math.sqrt(0.5)), 11, 13)
      qc.cry(-math.pi, 13, 11)
      qc.cry(2*math.acos(math.sqrt(0.5)), 11, 12)
      qc.cry(-math.pi, 12, 11)
      qc.cry(2*math.acos(math.sqrt(0.5)), 13, 14)
      qc.cry(-math.pi, 14, 13)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    if n < 6:
      qc.ry(2*math.acos(1.0/math.sqrt(n)), 0)
      for i in range(n-2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-i-1)), i, i+1)
      for i in range(n-1):
        qc.cry(-math.pi, n-2-i, n-1-i)
      qc.ry(-math.pi, 0)
    elif n < 10:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      for i in range(n-6):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(n-6):
        qc.cry(-math.pi, i+6, i+5)
    elif n < 12:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      for i in range(n-9):
        qc.cry(2*math.acos(1.0/math.sqrt(n-8-i)), i+8, i+9)
      for i in range(n-9):
        qc.cry(-math.pi, i+9, i+8)
    elif n < 15:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8))), 8, 11)
      qc.cry(-math.pi, 11, 8)
      for i in range(2):
        qc.cry(2*math.acos(1.0/math.sqrt(3-i)), i+8, i+9)
      for i in range(2):
        qc.cry(-math.pi, i+9, i+8)
      for i in range(n-12):
        qc.cry(2*math.acos(1.0/math.sqrt(n-11-i)), i+11, i+12)
      for i in range(n-12):
        qc.cry(-math.pi, i+12, i+11)
    else:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8))), 8, 11)
      qc.cry(-math.pi, 11, 8)
      qc.cry(2*math.acos(math.sqrt(0.5)), 11, 13)
      qc.cry(-math.pi, 13, 11)
      qc.cry(2*math.acos(math.sqrt(0.5)), 11, 12)
      qc.cry(-math.pi, 12, 11)
      qc.cry(2*math.acos(math.sqrt(0.5)), 13, 14)
      qc.cry(-math.pi, 14, 13)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    if n < 6:
      qc.ry(2*math.acos(1.0/math.sqrt(n)), 0)
      for i in range(n-2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-i-1)), i, i+1)
      for i in range(n-1):
        qc.cry(-math.pi, n-2-i, n-1-i)
      qc.ry(-math.pi, 0)
    elif n < 10:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      for i in range(n-6):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(n-6):
        qc.cry(-math.pi, i+6, i+5)
    elif n < 12:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i, i+1)
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      for i in range(n-9):
        qc.cry(2*math.acos(1.0/math.sqrt(n-8-i)), i+8, i+9)
      for i in range(n-9):
        qc.cry(-math.pi, i+9, i+8)
    elif n < 15:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i, i+1)
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8))), 8, 11)
      qc.cry(-math.pi, 11, 8)
      for i in range(2):
        qc.cry(2*math.acos(1.0/math.sqrt(3-i)), i+8, i+9)
      for i in range(2):
        qc.cry(-math.pi, i+9, i+8)
      for i in range(n-12):
        qc.cry(2*math.acos(1.0/math.sqrt(n-11-i)), i+11, i+12)
      for i in range(n-12):
        qc.cry(-math.pi, i+12, i+11)
    else:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i, i+1)
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8))), 8, 11)
      qc.cry(-math.pi, 11, 8)
      qc.cry(2*math.acos(math.sqrt(0.5)), 11, 13)
      qc.cry(-math.pi, 13, 11)
      qc.cry(2*math.acos(math.sqrt(0.5)), 11, 12)
      qc.cry(-math.pi, 12, 11)
      qc.cry(2*math.acos(math.sqrt(0.5)), 13, 14)
      qc.cry(-math.pi, 14, 13)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    if n < 6:
      qc.ry(2*math.acos(1.0/math.sqrt(n)), 0)
      for i in range(n-2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-i-1)), i, i+1)
      for i in range(n-1):
        qc.cry(-math.pi, n-2-i, n-1-i)
      qc.ry(-math.pi, 0)
    elif n < 10:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      for i in range(n-6):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(n-6):
        qc.cry(-math.pi, i+6, i+5)
    elif n < 12:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i, i+1)
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      for i in range(n-9):
        qc.cry(2*math.acos(1.0/math.sqrt(n-8-i)), i+8, i+9)
      for i in range(n-9):
        qc.cry(-math.pi, i+9, i+8)
    elif n < 15:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i, i+1)
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8))), 8, 11)
      qc.cry(-math.pi, 11, 8)
      for i in range(2):
        qc.cry(2*math.acos(1.0/math.sqrt(3-i)), i+8, i+9)
      for i in range(2):
        qc.cry(-math.pi, i+9, i+8)
      for i in range(n-12):
        qc.cry(2*math.acos(1.0/math.sqrt(n-11-i)), i+11, i+12)
      for i in range(n-12):
        qc.cry(-math.pi, i+12, i+11)
    else:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i, i+1)
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8))), 8, 11)
      qc.cx(11, 8)
      qc.ch(11, 13)
      qc.cx(13, 11)
      qc.ch(11, 12)
      qc.cx(12, 11)
      qc.ch(13, 14)
      qc.cx(14, 13)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    if n < 6:
      qc.ry(2*math.acos(1.0/math.sqrt(n)), 0)
      for i in range(n-2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-i-1)), i, i+1)
      for i in range(n-1):
        qc.cry(-math.pi, n-2-i, n-1-i)
      qc.ry(-math.pi, 0)
    elif n < 10:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      for i in range(n-6):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(n-6):
        qc.cry(-math.pi, i+6, i+5)
    elif n < 12:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i, i+1)
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      for i in range(n-9):
        qc.cry(2*math.acos(1.0/math.sqrt(n-8-i)), i+8, i+9)
      for i in range(n-9):
        qc.cry(-math.pi, i+9, i+8)
    elif n < 15:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i, i+1)
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8))), 8, 11)
      qc.cry(-math.pi, 11, 8)
      for i in range(2):
        qc.cry(2*math.acos(1.0/math.sqrt(3-i)), i+8, i+9)
      for i in range(2):
        qc.cry(-math.pi, i+9, i+8)
      for i in range(n-12):
        qc.cry(2*math.acos(1.0/math.sqrt(n-11-i)), i+11, i+12)
      for i in range(n-12):
        qc.cry(-math.pi, i+12, i+11)
    else:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i, i+1)
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8))), 8, 11)
      qc.cry(-math.pi, 11, 8)
      qc.ch(11, 13)
      qc.cx(13, 11)
      qc.ch(11, 12)
      qc.cx(12, 11)
      qc.ch(13, 14)
      qc.cx(14, 13)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    if n < 6:
      qc.ry(2*math.acos(1.0/math.sqrt(n)), 0)
      for i in range(n-2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-i-1)), i, i+1)
      for i in range(n-1):
        qc.cry(-math.pi, n-2-i, n-1-i)
      qc.ry(-math.pi, 0)
    elif n < 10:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      for i in range(n-6):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(n-6):
        qc.cry(-math.pi, i+6, i+5)
    elif n < 12:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i, i+1)
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      for i in range(n-9):
        qc.cry(2*math.acos(1.0/math.sqrt(n-8-i)), i+8, i+9)
      for i in range(n-9):
        qc.cry(-math.pi, i+9, i+8)
    elif n < 15:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i, i+1)
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8))), 8, 11)
      qc.cry(-math.pi, 11, 8)
      for i in range(2):
        qc.cry(2*math.acos(1.0/math.sqrt(3-i)), i+8, i+9)
      for i in range(2):
        qc.cry(-math.pi, i+9, i+8)
      for i in range(n-12):
        qc.cry(2*math.acos(1.0/math.sqrt(n-11-i)), i+11, i+12)
      for i in range(n-12):
        qc.cry(-math.pi, i+12, i+11)
    elif n < 12:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i, i+1)
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8))), 8, 11)
      qc.cry(-math.pi, 11, 8)
      qc.ch(11, 13)
      qc.cx(13, 11)
      qc.ch(11, 12)
      qc.cx(12, 11)
      qc.ch(13, 14)
      qc.cx(14, 13)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    if n < 6:
      qc.ry(2*math.acos(1.0/math.sqrt(n)), 0)
      for i in range(n-2):
        qc.cry(2*math.acos(1.0/math.sqrt(n-i-1)), i, i+1)
      for i in range(n-1):
        qc.cry(-math.pi, n-2-i, n-1-i)
      qc.ry(-math.pi, 0)
    elif n < 10:
      qc.ry(2*math.acos(math.sqrt((n-5.0)/n)), 5)
      qc.cx(5, 0)
      qc.x(5)
      for i in range(4):
        qc.cry(2*math.acos(1.0/math.sqrt(5-i)), i, i+1)
      for i in range(4):
        qc.cry(-math.pi, i+1, i)
      for i in range(n-6):
        qc.cry(2*math.acos(1.0/math.sqrt(n-5-i)), i+5, i+6)
      for i in range(n-6):
        qc.cry(-math.pi, i+6, i+5)
    elif n < 12:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i, i+1)
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      for i in range(n-9):
        qc.cry(2*math.acos(1.0/math.sqrt(n-8-i)), i+8, i+9)
      for i in range(n-9):
        qc.cry(-math.pi, i+9, i+8)
    elif n < 15:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i, i+1)
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8))), 8, 11)
      qc.cry(-math.pi, 11, 8)
      for i in range(2):
        qc.cry(2*math.acos(1.0/math.sqrt(3-i)), i+8, i+9)
      for i in range(2):
        qc.cry(-math.pi, i+9, i+8)
      for i in range(n-12):
        qc.cry(2*math.acos(1.0/math.sqrt(n-11-i)), i+11, i+12)
      for i in range(n-12):
        qc.cry(-math.pi, i+12, i+11)
    else:
      qc.ry(2*math.acos(math.sqrt((n-8.0)/n)), 8)
      qc.cx(8, 0)
      qc.x(8)
      qc.ch(0, 4)
      qc.cx(4, 0)
      for i in range(3):
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i, i+1)
        qc.cry(2*math.acos(1.0/math.sqrt(4-i)), i+4, i+5)
      for i in range(3):
        qc.cry(-math.pi, i+1, i)
        qc.cry(-math.pi, i+5, i+4)
      qc.cry(2*math.acos(math.sqrt(3.0/(n-8))), 8, 11)
      qc.cry(-math.pi, 11, 8)
      for i in range(2):
        qc.cry(2*math.acos(1.0/math.sqrt(3-i)), i+8, i+9)
      for i in range(2):
        qc.cry(-math.pi, i+9, i+8)
      qc.ch(11, 13)
      qc.cx(13, 11)
      qc.ch(11, 12)
      qc.cx(12, 11)
      qc.ch(13, 14)
      qc.cx(14, 13)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.x(0)
    count = 1
    queue = [(n // 2, n, 0)]
    while len(quque):
        a, b, control = queue.pop(0)
        if a == 0:
            continue
        theta = 2 * math.atan(math.sqrt((b - a) / a))
        qc.cry(theta, control, count)
        qc.cx(count, control)
        queue.append(((b // 2) // 2, b // 2, control))
        queue.append((math.ceil(b / 2) // 2, math.ceil(b / 2), count))
        count += 1
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.x(0)
    count = 1
    queue = [(n // 2, n, 0)]
    while len(quque):
        a, b, control = queue.pop(0)
        if a == 0:
            continue
        theta = 2 * math.atan(math.sqrt((b - a) / a))
        qc.cry(theta, control, count)
        qc.cx(count, control)
        queue.append(((b // 2) // 2, b // 2, control))
        queue.append((math.ceil(b / 2) // 2, math.ceil(b / 2), count))
        count += 1
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    count = 1

    queue = [(n // 2, n, 0)]

    while len(queue):
        a, b, control = queue.pop(0)

        if a == 0:
            continue

        theta = 2 * math.atan(math.sqrt((b - a) / a))

        qc.cry(theta, control, count)
        qc.cx(count, control)

        queue.append(((b // 2) // 2, b // 2, control))
        queue.append((math.ceil(b / 2) // 2, math.ceil(b / 2), count))

        count += 1
    return qc
'''


'''python
from qiskit import QuantumCircuit

import math

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

    count = 1

    # queue = [(a, b, control bit of CRy), ...]
    queue = [(n // 2, n, 0)]

    # breadth first search
    while len(queue):
        a, b, control = queue.pop(0)

        if a == 0:
            continue

        theta = 2 * math.atan(math.sqrt((b - a) / a))

        qc.cry(theta, control, count)
        qc.cx(count, control)

        queue.append(((b // 2) // 2, b // 2, control))
        queue.append((math.ceil(b / 2) // 2, math.ceil(b / 2), count))

        count += 1

    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import pi, acos, sqrt

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

    qc.x(0)
    def f(l: int, r: int) -> None:
        if r - l == 1:
            return
        mid = (l + r) // 2
        qc.cry(2 * acos(sqrt((mid-l)/(r-l))), l, mid)
        qc.cx(mid, l)
        f(l, mid)
        f(mid, r)
    f(0, n)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import asin

def move(qc, f, t, ratio):
    theta = 2 * asin(ratio**0.5)
    qc.cry(theta, f, t)
    qc.cx(t, f)

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

    qc.x(0)

    parent = [None]
    for i in range(1, n):
        for r in (8, 4, 2, 1):
            if i & r:
                parent.append(i - r)
                break

    # print(parent)

    ww = [0] * n
    for i in range(n - 1, -1, -1):
        ww[i] += 1 / n
        if parent[i] is not None:
            ww[parent[i]] += ww[i]

    # print(ww)

    xx = [0] * n
    xx[0] = 1

    for i in range(1, n):
        p = parent[i]
        move(qc, p, i, ww[i] / xx[p])
        xx[p] -= ww[i]
        xx[i] = ww[i]

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def theta(n: int, m: int) -> float:
    return 2 * math.acos(math.sqrt(m/n))

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

    a = 1
    while a*2 < n:
        a *= 2

    qc.x(0)
    while a > 0:
        j = 0
        while j + a <= n:
            print(j, j+a)
            qc.cry(theta(min(2*a,n), a), j, j+a)
            qc.cx(j+a,j)
            j += a+1
        a //= 2

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    def theta(n: int, m: int) -> float:
        return 2 * math.acos(math.sqrt(m/n))

    a = 1
    while a*2 < n:
        a *= 2

    qc.x(0)
    while a > 0:
        j = 0
        while j + a <= n:
            print(j, j+a)
            qc.cry(theta(min(2*a,n), a), j, j+a)
            qc.cx(j+a,j)
            j += a+1
        a //= 2

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    def theta(n: int, m: int) -> float:
        return 2 * math.acos(math.sqrt(m/n))

    a = 1
    while a*2 < n:
        a *= 2

    qc.x(0)
    while a > 0:
        j = 0
        while j + a < n:
            # print(j, j+a)
            qc.cry(theta(min(2*a, n), a), j, j+a)
            qc.cx(j+a,j)
            j += a+1
        a //= 2

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def theta(n: int, m: int) -> float:
    return 2 * math.acos(math.sqrt(m/n))

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

    a = 1
    while a*2 < n:
        a *= 2

    qc.x(0)
    while a > 0:
        j = 0
        while j + a < n:
            qc.cry(theta(min(2*a, n-j), a), j, j+a)
            qc.cx(j+a, j)
            j += 2*a
        a //= 2

    return qc
'''


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

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

    qc.x(0)
    split(qc, 0, n)

    return qc

def split(qc, stIncl, edExcl):
    if stIncl + 1 == edExcl:
        return

    mid = (stIncl + edExcl) // 2
    left = mid - stIncl
    right = edExcl - mid
    print(f'{left=} {right=}')

    angle = 2*math.atan(math.sqrt(right/left))
    qc.cry(angle, stIncl, mid)
    qc.cx(mid, stIncl)

    split(qc, stIncl, mid)
    split(qc, mid, edExcl)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.x(0)
    for i,j in [(0,8),(0,4),(8,12),(0,2),(4,6),(8,10),(12,14),(0,1),(2,3),(4,5),(6,7),(8,9),(10,11),(12,13)]:
        if j >= n:
            continue
        theta = math.atan(math.sqrt(min(j-i,n-j)/(j-i)))*2
        qc.cry(theta, i, j)
        qc.cx(j,i)
    return qc
'''


'''python
import math
from qiskit import QuantumCircuit

def theta(l: int, k: int) -> float:
    return math.asin(math.sqrt(l/k)) * 2

def solve_inner(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    if n == 1:
        return qc
    else:
        half = n // 2
        qc_l = solve_inner(half)
        qc_r = solve_inner(n - half)
        qc.cry(theta(n-half, n), 0, half)
        qc.cx(half, 0)
        qc.append(qc_l, range(half))
        qc.append(qc_r, range(half, n))
        return qc

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    qc.x(0)
    qc.append(solve_inner(n), range(n))
    return qc

if __name__ == "__main__":
    qc = solve_inner(3)
    print(qc)
'''


'''python
import math
from qiskit import QuantumCircuit

def theta(l: int, k: int) -> float:
    return math.asin(math.sqrt(l/k)) * 2

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    qc.x(0)
    def solve_inner(k: int, l: int, qc_l: QuantumCircuit) -> QuantumCircuit:
        if k == 1:
            return qc_l
        else:
            half = k // 2
            qc_l.cry(theta(k-half, k), l, l + half)
            qc_l.cx(l + half, l)
            qc_l = solve_inner(half, l, qc_l)
            qc_l = solve_inner(k - half, l + half, qc_l)
            return qc_l
    qc = solve_inner(n, 0, qc)
    return qc

if __name__ == "__main__":
    qc = solve(3)
    print(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)
    # Write your code here:
    qc.cx(0,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(0)

    return qc
'''


'''python
import numpy as np
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.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np
# from qiskit.quantum_info import Statevector

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

    return qc

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


'''python
from qiskit import QuantumCircuit
from math import pi, acos, sqrt

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

    qc.x(0)

    return qc
'''


'''python
import math
from qiskit import QuantumCircuit

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


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates import GlobalPhaseGate
import math
# from qiskit.quantum_info import Statevector

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    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.h(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    return qc

qc = solve()
'''


'''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)

    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.extensions import UnitaryGate

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

    A = np.array([[0, 1], [1, 0]])  # 例としてパウリXゲートを使用

    # カスタムゲートを作成
    custom_gate = UnitaryGate(A, label='A')
    qc.append(custom_gate, [0])
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.extensions import UnitaryGate
import numpy as np

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

    A = np.array([[0, 1], [1, 0]])  # 例としてパウリXゲートを使用

    # カスタムゲートを作成
    custom_gate = UnitaryGate(A, label='A')
    qc.append(custom_gate, [0])
    return qc
'''


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

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    matrix = [[[0, 1], [1, 0]]]
    gate = UnitaryGate(matrix)

    circuit = QuantumCircuit(2)
    circuit.append(gate, [0, 1])

    return qc
'''


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

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    matrix = [[[0, 1], [1, 0]]]
    gate = UnitaryGate(matrix)

    circuit = QuantumCircuit(1)
    circuit.append(gate, [0, 1])

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.quantum_info.operators.operator import Operator
import numpy as np

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

    # ユニタリー行列を用意(今回は適当に単位行列)
    unitary = np.array([[0, 1], [1, 0]])

    # ユニタリー行列からオペレーターを作成
    operator = Operator(unitary)

    # 量子回路(qubit0番と1番)にオペレーターを作用(ユニタリーでなかった場合はエラーが出る)
    qc.append(operator, [0])
'''


'''python
from qiskit import QuantumCircuit
from qiskit.quantum_info.operators.operator import Operator

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

    # ユニタリー行列を用意(今回は適当に単位行列)
    unitary = [[0, 1], [1, 0]]

    # ユニタリー行列からオペレーターを作成
    operator = Operator(unitary)

    # 量子回路(qubit0番と1番)にオペレーターを作用(ユニタリーでなかった場合はエラーが出る)
    qc.append(operator, [0])
'''


'''python
from qiskit import QuantumCircuit
from qiskit.quantum_info.operators.operator import Operator

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

    # ユニタリー行列を用意(今回は適当に単位行列)
    unitary = [[0, 1], [1, 0]]

    # ユニタリー行列からオペレーターを作成
    operator = Operator(unitary)

    # 量子回路(qubit0番と1番)にオペレーターを作用(ユニタリーでなかった場合はエラーが出る)
    qc.append(operator, [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
from qiskit.circuit.library.standard_gates import XGate, HGate, CXGate, MCPhaseGate
import math

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)
    # Write your code here:
    qc.cx(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.swap(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)
    qc.z(0)

    return qc
'''


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

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:
    # Aplicamos la compuerta X
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Apply the Pauli-X gate to the qubit
    qc.x(0)  # This applies the NOT operation on the qubit at index 0
    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    qc.x(0)

    return qc
'''