'''python
from qiskit import QuantumCircuit

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


'''python
from qiskit import QuantumCircuit

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

    qc.cx(0,1)
    qc.cx(1,0)
    qc.cx(0,1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

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


'''python
from qiskit import QuantumCircuit

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

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    return qc
'''


'''python
from qiskit import QuantumCircuit

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


'''python
from qiskit import QuantumCircuit

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

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

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

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

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    # a0 a1 a2 a3

    qc.cx(1, 0)
    # a0 a1 a3 a2

    qc.cx(0, 1)
    # a0 a2 a3 a1

    qc.cx(1, 0)
    # a0 a2 a1 a3

    return qc
'''


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

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

    return qc

#print(Statevector(qc)) #こことimportを消す

qc = solve()
print(qc)
#print(Statevector(qc)) #こことimportを消す
'''


'''python
from qiskit import QuantumCircuit

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

    return qc
'''


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


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


'''python
from qiskit import QuantumCircuit

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

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    return qc
'''


'''python
from qiskit import QuantumCircuit

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


'''python
from qiskit import QuantumCircuit

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


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    from qiskit.circuit.library import RZGate
    qc = QuantumCircuit(2)
    # Write your code here:
    qc.x(1)
    qc.cx(0,1)
    qc.x(0)
    qc.cx(0,1)
    qc.cx(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    from qiskit.circuit.library import RZGate
    qc = QuantumCircuit(2)
    # Write your code here:
    qc.x(1)
    qc.cx(0,1)
    qc.x(0)
    qc.cx(0,1)
    qc.x(0)
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    from qiskit.circuit.library import RZGate
    qc = QuantumCircuit(2)
    # Write your code here:
    qc.x(1)
    qc.cx(0,1)
    qc.x(0)
    qc.cx(0,1)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    from qiskit.circuit.library import RZGate
    qc = QuantumCircuit(2)
    # Write your code here:
    qc.cx(0,1)
    qc.cx(1,0)
    qc.cx(0,1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    return qc
'''


'''python
from qiskit import QuantumCircuit

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


'''python
from qiskit import QuantumCircuit

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

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

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    return qc
'''


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

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


'''python
from qiskit import QuantumCircuit

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

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

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

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(2)
    # Write your code here:
    matrix = [ [1, 0, 0, 0]
             , [0, 0, 1, 0]
             , [0, 1, 0, 0]
             , [0, 0, 0, 1]]
    qc.unitary(matrix, [0, 1])
    return qc
'''


'''python
from qiskit import QuantumCircuit

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


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

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

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


'''python
from qiskit import QuantumCircuit

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


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import CNOT, SwapGate

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

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

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

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    return qc.decompose(reps=5)
'''


'''python
from qiskit import QuantumCircuit

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

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(2)
    # Write your code here:
    # SWAP operation using three CNOT gates
    qc.cx(0, 1)  # CNOT with qubit 0 as control and qubit 1 as target
    qc.cx(1, 0)  # CNOT with qubit 1 as control and qubit 0 as target
    qc.cx(0, 1)  # CNOT with qubit 0 as control and qubit 1 as target

    return qc
'''


'''python
from qiskit import QuantumCircuit

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


'''python
from qiskit import QuantumCircuit

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

    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, -1, -1):
        qc.h(i)
        for k in range(i):
            lam = np.pi * 2.0 ** (k - i)
            qc.cu(0, 0, lam, 0)
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, -1, -1):
        qc.h(i)
        for k in range(i):
            lam = np.pi * 2.0 ** (k - i)
            qc.cu(0, 0, lam, 0, k, i)
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, -1, -1):
        qc.h(i)
        for k in range(i):
            lam = np.pi * 2.0 ** (k - i)
            qc.cu(0, 0, lam, 0, k, i)
    for i in range(n // 2):
        qc.swap(i, n - i - 1)
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, -1, -1):
        qc.h(i)
        for k in range(i):
            lam = np.pi * 2.0 ** (k - i)
            qc.cp(lam, i, k)
    for i in range(n // 2):
        qc.swap(i, n - i - 1)
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        theta = 2 * np.pi
        for j in range(i+1, n):
            qc.cz(j, i)
            theta /= 2

    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(-1, -n, -1):
        qc.h(i)
        theta = 2 * np.pi
        for j in range(i+1, n):
            qc.cz(j, i)
            theta /= 2

    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        theta = 2 * np.pi
        for j in range(i+1, n):
            qc.crz(theta, j, i)
            theta /= 2

    return qc
'''


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

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

    # Write your code here:
    for i in range(n):
        qc.h(i)
        theta = 2 * np.pi
        for j in range(i+1, n):
            qc.crz(theta, j, i)
            theta /= 2
    for i in range(n//2):
        qc.cx(i, n-i-1)
        qc.cx(n-i-1, i)
        qc.cx(i, n-i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import ZGate,XGate,CU1Gate
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n):
        qc.h(i)
        for j in range(i+1,n):
            qc.cp(2*math.pi / 2**j,j,i)
    return qc

# for n in range(5):
#     for l in range(2**(n+1)):
#         print(f"{n+1} {l+1}")
#         solve(n+1,l+1)
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import ZGate,XGate,CU1Gate
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n):
        qc.h(i)
        for j in range(i+1,n):
            qc.cp(math.pi / 2**(j-i),j,i)
    return qc

# for n in range(5):
#     for l in range(2**(n+1)):
#         print(f"{n+1} {l+1}")
#         solve(n+1,l+1)
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import ZGate,XGate,CU1Gate
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n):
        qc.h(n-1-i)
        for j in range(i+1,n):
            qc.cp(math.pi / 2**(j-i),n-1-j,n-1-i)
    return qc

# for n in range(5):
#     for l in range(2**(n+1)):
#         print(f"{n+1} {l+1}")
#         solve(n+1,l+1)
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import ZGate,XGate,CU1Gate
import math
from qiskit.quantum_info import Statevector

# def solve(n: int) -> QuantumCircuit:
#     qc = QuantumCircuit(n)
#     for i in range(n):
#         qc.h(n-1-i)
#         for j in range(i+1,n):
#             qc.cp(math.pi / 2**(j-i),n-1-j,n-1-i)
#     return qc
def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n):
        qc.h(i)
        for j in range(i+1,n):
            qc.cp(math.pi / 2**(j-i),j,i)
    return qc

# for n in range(5):
#     for l in range(2**(n+1)):
#         print(f"{n+1} {l+1}")
#         solve(n+1,l+1)
'''


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

# def solve(n: int) -> QuantumCircuit:
#     qc = QuantumCircuit(n)
#     for i in range(n):
#         qc.h(n-1-i)
#         for j in range(i+1,n):
#             qc.cp(math.pi / 2**(j-i),n-1-j,n-1-i)
#     return qc
def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n):
        qc.h(i)
        for j in range(i+1,n):
            qc.cp(math.pi / 2**(j-i),j,i)
    return qc

# for n in range(5):
#     for l in range(2**(n+1)):
#         print(f"{n+1} {l+1}")
#         solve(n+1,l+1)
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import ZGate,XGate,CU1Gate
import math
from qiskit.quantum_info import Statevector

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n):
        qc.h(n-1-i)
        for j in range(i+1,n):
            qc.cp(math.pi / 2**(j-i),n-1-j,n-1-i)
    for i in range(n//2):
        qc.swap(i,n-1-i)
    return qc
# def solve(n: int) -> QuantumCircuit:
#     qc = QuantumCircuit(n)
#     qc.x(0)
#     for i in range(n):
#         qc.h(i)
#         for j in range(i+1,n):
#             qc.cp(math.pi / 2**(j-i),j,i)
#     return qc

# for n in range(5):
#     for l in range(2**(n+1)):
#         print(f"{n+1} {l+1}")
#         solve(n+1,l+1)
# if __name__ == "__main__":
#     qc = solve(4)
#     qc.draw(output="mpl",filename="img.png")

#     print(Statevector(qc))
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import ZGate,XGate,CU1Gate
import math
#from qiskit.quantum_info import Statevector

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n):
        qc.h(n-1-i)
        for j in range(i+1,n):
            qc.cp(math.pi / 2**(j-i),n-1-j,n-1-i)
    for i in range(n//2):
        qc.swap(i,n-1-i)
    return qc
# def solve(n: int) -> QuantumCircuit:
#     qc = QuantumCircuit(n)
#     qc.x(0)
#     for i in range(n):
#         qc.h(i)
#         for j in range(i+1,n):
#             qc.cp(math.pi / 2**(j-i),j,i)
#     return qc

# for n in range(5):
#     for l in range(2**(n+1)):
#         print(f"{n+1} {l+1}")
#         solve(n+1,l+1)
# if __name__ == "__main__":
#     qc = solve(4)
#     qc.draw(output="mpl",filename="img.png")

#     print(Statevector(qc))
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.compose(QFT(n))
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
for i in range(n):
        qc.h(i)

    # Controlled phase gates
    for i in range(n-1):
        for j in range(i+1, n):
            angle = pi / (2**(j-i))
            qc.cu1(angle, j, i)

    # Swap gates (optimized)
    for i in range(n//2):
        qc.swap(i, n-i-1)    # Write your code here:

    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n):
        qc.h(i)

    # Controlled phase gates
    for i in range(n-1):
      for j in range(i+1, n):
        angle = pi / (2**(j-i))
        qc.cu1(angle, j, i)

    # Swap gates (optimized)
    for i in range(n//2):
        qc.swap(i, n-i-1)    # Write your code here:

    return qc
'''


'''python
from qiskit import QuantumCircuit

import numpy as np

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n):
        # Apply Hadamard gate to qubit i
        qc.h(i)

        # Apply controlled-phase gates
        for j in range(i + 1, n):
            # Apply the controlled phase gate with angle π / 2^(j-i)
            qc.cp(np.pi / (2 ** (j - i)), j, i)

    # Swap qubits to get the correct order
    for i in range(n // 2):
        qc.swap(i, n - i - 1)  # Write your code here:

    return qc
'''


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

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

    for i in range(n):
        qc.p(2 * pi / 2 ** (i + 1), n - 1 - i)

    return qc
'''


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

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

    for i in range(n)[::-1]:
        qc.h(i)
        for j in range(1, i + 1):
            qc.cp(pi / 2 ** j, i - j, i)

    for i in range(n // 2):
        qc.swap(i, n - i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.cp(pi/2**(n-range(n)), range(n), n)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
   # Apply Hadamard gate to the most significant qubit
    qc.h(n-1)

    # Apply controlled rotations to all qubits
    for i in range(n-1, 0, -1):
        for j in range(n-i-1):
            qc.cu1(np.pi/2**(j+1), i-j-1, i)
        qc.h(i)

    # Apply swap gates to reverse the order of the qubits
    for i in range(n//2):
        qc.swap(i, n-i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
def qft_rotations(circuit, n):
    if n == 0: # Exit function if circuit is empty
        return circuit
    n -= 1 # Indexes start from 0
    circuit.h(n) # Apply the H-gate to the most significant qubit
    for qubit in range(n):
        # For each less significant qubit, we need to do a
        # smaller-angled controlled rotation:
        circuit.cp(pi/2**(n-qubit), qubit, n)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
# Apply Hadamard gate and controlled phase gates
    for i in range(n):
        # Apply Hadamard gate to the i-th qubit
        qc.h(i)

        # Apply controlled phase gates
        for j in range(i + 1, n):
            angle = pi / (2 ** (j - i))
            qc.cp(angle, j, i)

    # Reverse the order of the qubits
    qc.swap(0, n - 1)
    for i in range(n // 2):
        qc.swap(i, n - i - 1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
# Apply Hadamard gate and controlled phase gates
import numpy as np
    for i in range(n):
        # Apply Hadamard gate to the i-th qubit
        qc.h(i)

        # Apply controlled phase gates
        for j in range(i + 1, n):
            angle = np.pi / (2 ** (j - i))
            qc.cp(angle, j, i)

    # Reverse the order of the qubits
    qc.swap(0, n - 1)
    for i in range(n // 2):
        qc.swap(i, n - i - 1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for j in range(n):
        qc.h(j)
        for k in range(j+1, n):
            qc.cp(np.pi / (2**(k-j)), k, j)

    for i in range(n // 2):
        qc.swap(i, n - i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

 for j in range(n):
        qc.h(j)
        for k in range(j+1, n):
            qc.cp(np.pi / (2 ** (k - j)), k, j)

    for i in range(n // 2):
        qc.swap(i, n - i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

  for j in range(n):
        qc.h(j)
        for k in range(j + 1, n):
            qc.cp(np.pi / (2 ** (k - j)), k, j)

    for i in range(n // 2):
        qc.swap(i, n - i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    def rotations(q):
        if q == 0:
            return
        q -= 1
        qc.h(q)
        for i in range(q):
            circuit.cp(pi/2**(q-i), i, q)

        rotations(q)

    roations(n)
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    def rotations(q):
        if q == 0:
            return
        q -= 1
        qc.h(q)
        for i in range(q):
            circuit.cp(pi/2**(q-i), i, q)

        rotations(q)

    rotations(n)
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


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

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

    def rotations(q):
        if q == 0:
            return
        q -= 1
        qc.h(q)
        for i in range(q):
            qc.cp(pi/2**(q-i), i, q)

        rotations(q)

    rotations(n)
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from numpy import p

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

    def rotations(q):
        if q == 0:
            return
        q -= 1
        qc.h(q)
        for i in range(q):
            phase = pi/2**(q-i)
            if phase > 0.0001:
                qc.cp(phase, i, q)

        rotations(q)

    rotations(n)
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from numpy import p

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

    def rotations(q):
        if q == 0:
            return
        q -= 1
        qc.h(q)
        for i in range(q):
            phase = pi/2**(q-i)
            if phase > 0.1:
                qc.cp(phase, i, q)

        rotations(q)

    rotations(n)
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


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

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

    def rotations(q):
        if q == 0:
            return
        q -= 1
        qc.h(q)
        for i in range(q):
            phase = pi/2**(q-i)
            if phase > 0.1:
                qc.cp(phase, i, q)

        rotations(q)

    rotations(n)
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


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

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

    def rotations(q):
        if q == 0:
            return
        q -= 1
        qc.h(q)
        for i in range(q):
            phase = pi/2**(q-i)
            if phase > 0.001:
                qc.cp(phase, i, q)

        rotations(q)

    rotations(n)
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


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

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

    def rotations(q):
        if q == 0:
            return
        q -= 1
        qc.h(q)
        for i in range(q):
            phase = pi/2**(q-i)
            if phase > 0.01:
                qc.cp(phase, i, q)

        rotations(q)

    rotations(n)
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


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

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

    def rotations(q):
        if q == 0:
            return
        q -= 1
        qc.h(q)
        for i in range(q):
            phase = pi/2**(q-i)
            if phase > 0.05:
                qc.cp(phase, i, q)

        rotations(q)

    rotations(n)
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


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

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

    def rotations(q):
        if q == 0:
            return
        q -= 1
        qc.h(q)
        for i in range(q):
            phase = pi/2**(q-i)
            qc.cp(phase, i, q)

        rotations(q)

    rotations(n)
    # for i in range(n//2):
    #     qc.swap(i, n-i-1)

    return qc
'''


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

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

    def rotations(q):
        if q == 0:
            return
        q -= 1
        qc.h(q)
        for i in range(q):
            phase = pi/2**(q-i)
            qc.cp(phase, i, q)

        rotations(q)

    rotations(n)
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.cp(0.5*math.pi,0,1)
    qc.x(1)
    qc.cp(0.5*math.pi,0,1)
    qc.cp(math.pi,1,0)
    qc.x(0)
    qc.cp(math.pi,1,0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(i+1,n):
            qc.cp(2*math.pi/(1<<(j-i+1)),j,i)
    return qc
'''


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

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


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for j in range(n):
        qc.h(j)
    for k in range(j+1,n):
        angle=np.pi/2**(k-j)
        qc.rz(angle,k)
    for i in range(n//2):
        qc.swap(i,n-i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1,-1,-1):
        qc.h(i)
        for j in range(i):
            qc.cp(math.pi/(2**(j+1)), i-j-1, i)

    for i in range(int(n/2)):
        qc.swap(i,n-i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.quantum_info import Operator
from qiskit.circuit.library import CU1Gate

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, -1, -1):
        qc.h(i)
        for j in range(j-1, -1, -1):
            theta = np.pi/float(2**(j-m))
            cu1 = Operator(CU1Gate(theta=theta).to_matrix())
            qc.unitary(cu1, [j, i])
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, -1, -1):
        qc.h(i)
        for j in range(j-1, -1, -1):
            theta = np.pi/float(2**(j-m))
            qc.cu1(j, i, theta)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, -1, -1):
        qc.h(i)
        for j in range(j-1, -1, -1):
            theta = np.pi/float(2**(j-i))
            qc.cu1(j, i, theta)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, -1, -1):
        qc.h(i)
        for j in range(j-1, -1, -1):
            theta = np.pi/float(2**(j-i))
            qc.cu1(theta, j, i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, -1, -1):
        qc.h(i)
        for j in range(j-1, -1, -1):
            theta = np.pi/float(2**(j-i))
            qc.cu1(theta,qc[j], qc[i])
    return qc
'''


'''python
from qiskit import QuantumCircuit

import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(i+1,n):
            theta = -2*math.pi/(2**(j+1-i))
            qc.crz(theta,i,j)
    return qc
'''


'''python
from qiskit import QuantumCircuit

import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(i+1,n):
            theta = -2*math.pi/(2**(j-i))
            qc.crz(theta,i,j)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(i+1,n):
            qc.cp(2*math.pi/2**(j-i),j,i)
    for k in range(n//2):
        qc.swap(k,n-1-k)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(i+1,n):
            qc.cp(2*math.pi/2**(j-i+1),j,i)
    for k in range(n//2):
        qc.swap(k,n-1-k)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1,-1,-1):
        qc.h(i)
        for j in range(i-1,-1,-1):
            qc.cp(2*math.pi/2**(i-j+1),j,i)
    for k in range(n//2):
        qc.swap(k,n-1-k)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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


'''python
from qiskit import QuantumCircuit
import math

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

    #Applying QFT
    for i in range(n):
        qc.h(i)
        #Apply controlled phase gate
        for j in range(i+1,n):
            qc.cp(math.pi/2**(j-i),j,i)

    #Swap qubits to reverse the order
    for i in range(n//2):
        qc.swap(i,n-i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    #Applying QFT
    for i in range(n):
        qc.h(n-i-1)
        #Apply controlled phase gate
        for j in range(1,n-1):
            qc.cp(math.pi/2**j,n-i-j-1,n-i-1)

    #Swap qubits to reverse the order
    for i in range(n//2):
        qc.swap(i,n-i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    #Applying QFT
    for i in range(n):
        qc.h(n-i-1)
        for j in range(1, n-i):
            qc.cp(math.pi/2**j, n-i-j-1, n-i-1)

    #Swap qubits to reverse the order
    for i in range(n//2):
        qc.swap(i,n-i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for i in range(n):
        qc.h(i)
        for k in range(i+1, n):
            qc.cp(pi/2**(k-i), k, i)
    return qc
'''


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

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

    for i in range(n):
        qc.h(i)
        for k in range(i+1, n):
            qc.cp(pi/2**(k-i), k, i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import p

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

    for i in range(n):
        qc.h(i)
        for k in range(i+1, n):
            qc.cp(pi/2**(k-i), k, i)
    for i in range(n//2):
        qc.swap(j, n-i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import p

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

    for i in range(n-1, 0, -1):
        qc.h(i)
        for k in range(i+1, n):
            qc.cp(pi/2**(k-i), k, i)

    for j in range(n//2):
        qc.swap(j, n-j-1)

    return qc
'''


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

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

    for i in range(n-1, 0, -1):
        qc.h(i)
        for k in range(i+1, n):
            qc.cp(pi/2**(k-i), k, i)

    for j in range(n//2):
        qc.swap(j, n-j-1)

    return qc
'''


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

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

    for i in range(n):
        qc.h(i)
        for k in range(i+1, n):
            qc.cp(2*pi/(2**(k+1)), k, i)

    for j in range(n//2):
        qc.swap(j, n-j-1)

    return qc
'''


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

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

    for i in range(n):
        qc.h(i)
        for k in range(i+1, n):
            qc.cp(2*pi/(2**(k+1)), k, i)

    return qc
'''


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

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

    for i in range(n):
        qc.h(i)
        for k in range(i+1, n):
            qc.cp(2*pi/(2**(k+1)), k, i)

    for i in range(floor(n/2)):
        qc.swap(i , n-i-1)
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        r_count = 2
        for k in range(i+1, n):
            qc.cp(2*pi/(2**r_count), k, i)
            r_count+=1

    for i in range(floor(n/2)):
        qc.swap(i , n-i-1)
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        r_count = 2
        for k in range(i+1, n):
            qc.cp(2*pi/(2**r_count), k, i)
            r_count+=1

    # for i in range(floor(n/2)):
    #     qc.swap(i , n-i-1)
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        r_count = 2
        for k in range(i+1, n):
            qc.cp(2*pi/(2**r_count), i, k)
            r_count+=1

    for i in range(floor(n/2)):
        qc.swap(i , n-i-1)
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        r_count = 2
        for k in range(i+1, n):
            qc.cp(2*pi/(2**r_count), i, k)
            r_count+=1

    # for i in range(floor(n/2)):
    #     qc.swap(i , n-i-1)
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        r_count = 2
        for k in range(i+1, n):
            qc.cp(2*pi/(2**r_count), i, k)
            r_count+=1
    if n > 1:
        qc.h(n-1)
    for i in range(floor(n/2)):
        qc.swap(i , n-i-1)
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        r_count = 2
        for k in range(i+1, n):
            qc.cp(2*pi/(2**r_count), i, k)
            r_count+=1
    if n > 1:
        qc.h(n-1)
    # for i in range(floor(n/2)):
    #     qc.swap(i , n-i-1)
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        r_count = 1
        for k in range(i+1, n):
            qc.cp(pi/(2**r_count), i, k)
            r_count+=1

    for i in range(floor(n/2)):
        qc.swap(i , n-i-1)
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        r_count = 1
        for k in range(i+1, n):
            qc.cp(pi/(2**r_count), i, k)
            r_count+=1

    # for i in range(floor(n/2)):
    #     qc.swap(i , n-i-1)
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        r_count = 1
        for k in range(i+1, n):
            qc.cp(pi/(2**r_count), i, k)
            r_count+=1

    for i in range(floor(n/2)):
        qc.swap(i , n-i-1)
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, -1, -1):
        qc.h(i)
        r_count = 1
        for k in range(i-1, -1, -1):
            qc.cp(pi/(2**r_count), k, i)
            r_count+=1

    for i in range(floor(n/2)):
        qc.swap(i , n-i-1)
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, -1, -1):
        qc.h(i)
        r_count = 1
        for k in range(i-1, -1, -1):
            qc.cp(pi/(2**r_count), k, i)
            r_count+=1

    for i in range(floor(n/2)):
        qc.swap(i , n-i-1)
    return qc
'''


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

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

    for i in range(n):
        qc.h(i)

        for j in range(i+1, n):
            qc.cp(np.pi / (2 ** (j - i)), j, i)

    for i in range(n // 2):
        qc.swap(i, n - i - 1)

    return qc
'''


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

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

    for i in range(n):
        qc.h(i)

        for j in range(i+1, n):
            qc.cp(2*np.pi / (2 ** (j - i)), j, i)

    for i in range(n // 2):
        qc.swap(i, n - i - 1)

    return qc
'''


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

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

    for i in range(n):
        qc.h(i)

        for j in range(i+1, n):
            qc.cp(2*np.pi / (2 ** (j - i)), j, i)

    return qc
'''


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

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

    for i in range(n):
        qc.h(i)

        for j in range(i+1, n):
            qc.cp(np.pi / (2 ** (j - i)), j, i)

    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        for j in range(i + 1, n):
            if not (L >> j) & 1:
                qc.x(j)
        qc.x(i)
        if i == n - 1:
            qc.z(i)
        else:
            qc.append(qlib.PhaseGate(np.pi/2).control(n - 1), range(n))
        qc.x(i)
        for j in range(i + 1, n):
            if not (L >> j) & 1:
                qc.x(j)
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        for j in range(i + 1, n):
            qc.x(j)
        qc.x(i)
        if i == n - 1:
            qc.z(i)
        else:
            qc.append(qlib.PhaseGate(np.pi/2).control(n - 1), range(n))
        qc.x(i)
        for j in range(i + 1, n):
            qc.x(j)
    return qc
'''


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

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

    for i in range(n):
        qc.h(i)

        for j in range(i+1, n):
            qc.cp(np.pi / (2 ** (j - i)), j, i)

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

    return qc
'''


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

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

    for i in range(n - 1, -1, -1):
        for j in range(n - 1, i, -1):
            qc.cp(np.pi / (2 ** (j - i)), j, i)

        qc.h(i)  # Hadamardゲートも逆順で適

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

    return qc
'''


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

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

    for i in range(n - 1, -1, -1):
        for j in range(n - 1, i, -1):
            qc.cp(np.pi / (2 ** (j - i)), j, i)

        qc.h(i)  # Hadamardゲートも逆順で適

    for i in range(n // 2):
        qc.swap(i, n - i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    #Applying QFT
    for i in range(n):
        qc.h(n-i-1)
        for j in range(1, n-i):
            qc.cp(math.pi/2**j, n-i-j-1, n-i-1)

    #Swap qubits to reverse the order
    for i in range(n//2):
        qc.swap(i,n-i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

import math

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

    #Applying QFT
    for i in range(n):
        qc.h(n-i-1)
        for j in range(1, n-i):
            qc.cp(math.pi/2**j, n-i-j-1, n-i-1)

    #Swap qubits to reverse the order
    for i in range(n//2):
        qc.swap(i,n-i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def rk(qc, qubit1, qubit2, k):
    qc.cp(2 * 3.14 / 2**k, qubit1, qubit2)

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    qc.x(1)
    for i in range(n):
        qc.h(i)
        for j in range(2, 2 + n - i - 1):
            rk(qc, i, i + j - 1, j)
    return qc
'''


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

def rk(qc, qubit1, qubit2, k):
    qc.cp(2 * pi / 2**k, qubit1, qubit2)

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # qc.x(1)
    for i in range(n):
        qc.h(i)
        for j in range(i + 1, n):
            rk(qc, i, j, j - i + 1)
        qc.barrier()
            # print(i, j, j - i + 1)
    for i in reversed(range(n // 2)):
        qc.swap(i, n - i - 1)
    return qc
'''


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

def rk(qc, qubit1, qubit2, k):
    qc.cp(2 * pi / 2**k, qubit1, qubit2)

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # qc.x(1)
    for i in reversed(range(n)):
        qc.h(i)
        for j in range(i + 1, n):
            rk(qc, i, j, j - i + 1)
        qc.barrier()
            # print(i, j, j - i + 1)
    for i in reversed(range(n // 2)):
        qc.swap(i, n - i - 1)
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for j in reversed(range(n)):
        qc.h(j)
        for k in reversed(range(0, j)):
            lam = pi * (2.0 ** (k - j))
            qc.cp(lam, j, k)

    for i in range(n // 2):
        qc.swap(i, n - i - 1)
    return qc
'''


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

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

    t = pi/(1<<n)
    for i in range(n):
        cp.p(t*(1<<i),i)

    return qc
'''


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

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

    t = pi/(1<<n)
    for i in range(n):
        qc.p(t*(1<<i),i)

    return qc
'''


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

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

    t = pi/(1<<n)
    for i in range(n):
        qc.p(t,i)

    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc = qc.compose(QFT(n))
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    data_qubits = n
    for i in range(data_qubits):
        qc.h(qr_data[-1-i])
        for j in range(i+1,data_qubits):
            qc.cp(2 * math.pi / 2**(j+1-i), qr_data[-1-j], qr_data[-1-i])
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    data_qubits = n
    for i in range(data_qubits):
        qc.h(qr_data[-1-i])
        for j in range(i+1,data_qubits):
            qc.cp(2 * math.pi / 2**(j+1-i), qr_data[-1-j], qr_data[-1-i])
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    data_qubits = n
    qr_data =qc.qubits
    for i in range(data_qubits):
        qc.h(qr_data[-1-i])
        for j in range(i+1,data_qubits):
            qc.cp(2 * math.pi / 2**(j+1-i), qr_data[-1-j], qr_data[-1-i])
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    data_qubits = n
    qr_data =qc.qubits
    for i in range(data_qubits):
        qc.h(qr_data[-1-i])
        for j in range(i+1,data_qubits):
            qc.cp(2 * math.pi / 2**(j+1-i), qr_data[-1-j], qr_data[-1-i])
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    data_qubits = n
    qr_data =qc.qubits
    for i in range(data_qubits-1,-1,-1):

        qc.h(qr_data[-1-i])
        for j in range(i+1,data_qubits):
            qc.cp(2 * math.pi / 2**(j+1-i), qr_data[-1-j], qr_data[-1-i])
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(2,i+2):
            qc.cp(2 * math.pi / 2**j, i-j+1, i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        i=-i-1
        qc.h(i)
        for j in range(2,i+2):
            j=-j-1
            qc.cp(2 * math.pi / 2**j, i-j+1, i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        i2=n-i-1
        qc.h(i2)
        for j in range(2,i+2):
            j2=n-j
            # print(i,j,i2,j2)
            qc.cp(2 * math.pi / 2**j, i2-j2+1, i2)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(2,i+2):
            qc.cp(2 * math.pi / 2**j, i-(j-1), i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(2,i+2):
            qc.cp(2 * math.pi / 2**j, i-(j-1), i)
    for i in range(n // 2):
        qc.swap(i, n - i - 1)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    # QFTのコア部分を実装
    for i in range(n):
        qc.h(i)  # Hadamard gate on qubit i

        for j in range(i + 1, n):
            # Controlled phase rotation with angle π/(2^(j-i))
            angle = math.pi / (2 ** (j - i))
            qc.cp(angle, j, i)

    # ビットの順序を反転
    for i in range(n // 2):
        qc.swap(i, n - i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    # QFTのコア部分を実装
    for i in range(n):
        qc.h(i)  # Hadamard gate on qubit i

        for j in range(i + 1, n):
            # Controlled phase rotation with angle π/(2^(j-i))
            angle = math.pi / (2 ** (j - i))
            qc.cp(angle, j, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    # QFTのコア部分を実装
    for i in range(n):
        i2=n-i-1
        qc.h(i2)  # Hadamard gate on qubit i

        for j in range(i + 1, n):
            j2=n-j-1
            # Controlled phase rotation with angle π/(2^(j-i))
            angle = math.pi / (2 ** (j - i))
            qc.cp(angle, j2, i2)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    # QFTのコア部分を実装
    for i in range(n):
        i2=n-i-1
        qc.h(i)  # Hadamard gate on qubit i

        for j in range(i + 1, n):
            j2=n-j-1
            # Controlled phase rotation with angle π/(2^(j-i))
            angle = math.pi / (2 ** (j - i))
            qc.cp(angle, j, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    i = 0
    while n-1-i>i:
        qc.swap(i,n-1-i)
        i += 1
    qc.append(QFTGate(n),range(n))
    i = 0
    while n-1-i>i:
        qc.swap(i,n-1-i)
        i += 1
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    i = 0
    while n-1-i>i:
        qc.swap(i,n-1-i)
        i += 1
    qc.append(QFTGate(n),range(n))
    i = 0
    while n-1-i>i:
        qc.swap(i,n-1-i)
        i += 1
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(n)):
        qc.h(i)
        for j in reversed(range(i)):
            qc.cp(math.pi/(1<<(i-j)),j,i)
    i = 0
    while i<n-i-1:
        qc.swap(i,n-i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(n)):
        qc.h(i)
        for j in reversed(range(i)):
            qc.cp(math.pi/(1<<(i-j)),j,i)
    i = 0
    while i<n-i-1:
        qc.swap(i,n-i-1)
        i += 1
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.h(0)
    for i in range(n-1):
        for j in range(i+1, n):
            qc.cp(2*math.pi/2**(1+j-i), j, i)
        qc.h(i+1)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for j in range(n):
        for k in range(j):
            qc.cu1(2 * np.pi / 2**(j - k), k, j)
        qc.h(j)
    return qc
    """
    qc.h(0)
    for i in range(n-1):
        for j in range(i+1, n):
            qc.cp(2*math.pi/2**(1+j-i), j, i)
        qc.h(i+1)
    return qc
    """
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for j in range(n):
        for k in range(j):
            qc.cp(2 * np.pi / 2**(j - k), k, j)
        qc.h(j)
    return qc
    """
    qc.h(0)
    for i in range(n-1):
        for j in range(i+1, n):
            qc.cp(2*math.pi/2**(1+j-i), j, i)
        qc.h(i+1)
    return qc
    """
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for j in range(n):
        for k in range(j):
            qc.cp(2 * math.pi / 2**(j - k), k, j)
        qc.h(j)
    return qc
    """
    qc.h(0)
    for i in range(n-1):
        for j in range(i+1, n):
            qc.cp(2*math.pi/2**(1+j-i), j, i)
        qc.h(i+1)
    return qc
    """
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(i+1, n):
            qc.cp(math.pi / float(2**(k-j)), j, i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(i+1, n):
            qc.cp(math.pi / float(2**(j-i)), j, i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(i+1, n):
            qc.cp(math.pi / float(2**(j-i)), j, i)
        qc.barrier()
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(i+1, n):
            qc.cu1(math.pi / float(2**(j-i)), j, i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(i+1, n):
            qc.cp(math.pi / float(2**(j-i)), j, i)
    for i in range(n//2):
        qc.swap(i, n-i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(i+1, n):
            qc.cp(math.pi / float(2**(j-i)), j, i)
    #for i in range(n//2):
    #    qc.swap(i, n-i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(i+1, n):
            qc.cp(math.pi / float(2**(j-i)), j, i)
    for i in range(n//2):
        qc.swap(i, n-i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n//2):
        qc.swap(i, n-i-1)
    for i in range(n):
        qc.h(i)
        for j in range(i+1, n):
            qc.cp(math.pi / float(2**(j-i)), j, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    def qft_rotations(circuit, n):
    """Performs qft on the first n qubits in circuit (without swaps)"""
        if n == 0:
            return circuit
        n -= 1
        circuit.h(n)
        for qubit in range(n):
            circuit.cp(pi/2**(n-qubit), qubit, n)
    # At the end of our function, we call the same function again on
    # the next qubits (we reduced n by one earlier in the function)
        qft_rotations(circuit, n)

    def swap_registers(circuit, n):
        for qubit in range(n//2):
            circuit.swap(qubit, n-qubit-1)
        return circuit

    def qft(circuit, n):
        """QFT on the first n qubits in circuit"""
        qft_rotations(circuit, n)
        swap_registers(circuit, n)
        return circuit

    qft(qc, n)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    def qft_rotations(circuit, n):
        """Performs qft on the first n qubits in circuit (without swaps)"""
        if n == 0:
            return circuit
        n -= 1
        circuit.h(n)
        for qubit in range(n):
            circuit.cp(pi/2**(n-qubit), qubit, n)
        # At the end of our function, we call the same function again on
        # the next qubits (we reduced n by one earlier in the function)
        qft_rotations(circuit, n)

    def swap_registers(circuit, n):
        for qubit in range(n//2):
            circuit.swap(qubit, n-qubit-1)
        return circuit

    def qft(circuit, n):
        """QFT on the first n qubits in circuit"""
        qft_rotations(circuit, n)
        swap_registers(circuit, n)
        return circuit

    qft(qc, n)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    circuit = QuantumCircuit(n)
    # Write your code here:
    #
    # We start with the most significant bit
    #
    for k in range(n):
        j = n - k
        # Add the Hadamard to qubit j-1
        circuit.h(q[j-1])
        #
        # there is one conditional rotation for
        # each qubit with lower significance
        for i in reversed(range(j-1)):
            circuit.cu1(2*np.pi/2**(j-i),q[i], q[j-1])
    #
    # Finally we need to swap qubits
    #
    for i in range(n//2):
        circuit.swap(q[i], q[n-i-1])
    return circuit
'''


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

def solve(n: int) -> QuantumCircuit:
    circuit = QuantumCircuit(n)
    # Write your code here:
    #
    q = [i for i in range(n)]
    # We start with the most significant bit
    #
    for k in range(n):
        j = n - k
        # Add the Hadamard to qubit j-1
        circuit.h(q[j-1])
        #
        # there is one conditional rotation for
        # each qubit with lower significance
        for i in reversed(range(j-1)):
            circuit.cp(2*np.pi/2**(j-i),q[i], q[j-1])
    #
    # Finally we need to swap qubits
    #
    for i in range(n//2):
        circuit.swap(q[i], q[n-i-1])
    return circuit
'''


'''python
from qiskit import QuantumCircuit

def solve(n) -> QuantumCircuit:
	from numpy import pi
	qc = QuantumCircuit(n)
	for i in reversed(range(n)):
		qc.h(i)
		for j in reversed(range(i)):
			qc.cp(pi / 2**(i-j), j, i)
	i, j = 0, n - 1
	while i < j:
		qc.swap(i, j)
		i, j = i + 1, j - 1
	return qc
'''


'''python
from qiskit import QuantumCircuit

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

    # Apply QFT
    for j in range(n):
        # Apply Hadamard gate to the j-th qubit
        qc.h(j)

        # Apply controlled phase rotations
        for k in range(j + 1, n):
            qc.cp(math.pi / (2 ** (k - j)), k, j)

    # Reverse the order of the qubits
    for j in range(n // 2):
        qc.swap(j, n - j - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    # Apply QFT
    for j in range(n):
        # Apply Hadamard gate to the j-th qubit
        qc.h(j)

        # Apply controlled phase rotations
        for k in range(j + 1, n):
            qc.cp(math.pi / (2 ** (k - j)), k, j)

    # Reverse the order of the qubits
    for j in range(n // 2):
        qc.swap(j, n - j - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    # Apply Hadamard gates
    for j in range(n):
        qc.h(j)

        # Apply controlled phase rotations
        for k in range(j + 1, n):
            angle = math.pi / (2 ** (k - j + 1))
            qc.cp(angle, k, j)  # Controlled phase rotation

    # Reverse the order of qubits
    for j in range(n // 2):
        qc.swap(j, n - j - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for j in range(n):
        qc.h(j)
        for k in range(j + 1, n):
            qc.crz(2 * math.pi / (2 ** (k - j + 1)), k, j)

    for j in range(n // 2):
        qc.swap(j, n - j - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for i in range(n):
        qc.h(n - 1 - i)
        for j in range(i + 1, n):
            qc.crz(2 * math.pi / (2 ** (j - i + 1)), n - j - 1, n - i - 1)

    for i in range(n // 2):
        qc.swap(i, n - i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for i in range(n):
        qc.h(n - 1 - i)
        for j in range(i + 1, n):
            qc.cp(2 * math.pi / (2 ** (j - i + 1)), n - j - 1, n - i - 1)

    for i in range(n // 2):
        qc.swap(i, n - i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    for i in range(n):
        qc.h(i)
        for j in range(i + 1, n):
            qc.crz(2 * math.pi / (2 ** (j - i + 1)), n - j - 1, n - i - 1)

    for i in range(n // 2):
        qc.swap(i, n - i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    for i in range(n):
        qc.h(i)
        for j in range(i + 1, n):
            qc.cp(2 * math.pi / (2 ** (j - i + 1)), n - j - 1, n - i - 1)

    for i in range(n // 2):
        qc.swap(i, n - i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    for i in range(n):
        qc.h(n - i - 1)
        for j in range(i + 1, n):
            qc.cp(2 * math.pi / (2 ** (j - i + 1)), n - j - 1, n - i - 1)

    for i in range(n // 2):
        qc.swap(i, n - i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for i in range(n - 1, -1, -1):
        qc.h(i)
        for j in range(i - 1, -1, -1):
            qc.cp(pi / (1 << (i - j)), j, i)

    for i in range(n // 2):
        j = n - i - 1
        qc.cx(i, j)
        qc.cx(j, i)
        qc.cx(i, j)

    return qc
'''


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

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

    for i in range(n - 1, -1, -1):
        qc.h(i)
        for j in range(i - 1, -1, -1):
            qc.cp(pi / (1 << (i - j)), j, i)

    for i in range(n // 2):
        j = n - i - 1
        qc.cx(i, j)
        qc.cx(j, i)
        qc.cx(i, j)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    n -= 1
    qc.h(n)
    for q in range(n):
        qc.cp(pi/2**(n-q),q,n)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import U1Gate, pi

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

    n -= 1
    qc.h(n)
    for q in range(n):
        qc.cp(pi/2**(n-q),q,n)

    return qc
'''


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

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

    n -= 1
    qc.append(HGate(), [n])
    for q in range(n):
        qc.append(CPGate(math.pi/2**(n-q)), [q, n])

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def r(qc: QuantumCircuit, control: int, target: int, l: int):
    qc.cp(2*math.pi/(1<<l), control, target)

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n//2):
        qc.cx(i, n-i-1)
        qc.cx(n-i-1, i)
        qc.cx(i, n-i-1)
    for i in range(0, n):
        qc.h(i)
        for j in range(1, n-i):
            r(qc, i+j, i, j+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def QFT(qc):
    n = qc.num_qubits
    for i in reversed(range(n)):
        qc.h(i)
        for j in reversed(range(i)):
            qc.cp(math.pi / 2 ** (i - j), j, i)
    for i in range(n // 2):
        qc.swap(i, n - i - 1)

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

    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.append(QFT(n),range(n))
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc = QuantumCircuit(n)
    for i in range(n):
        qc.h(i)
        for j in range(i+1, n):
            qc.cp(math.pi/(2**(j-i)), j, i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc = QuantumCircuit(n)
    for i in range(n):
        qc.h(i)
        for j in range(i+1, n):
            qc.cp(math.pi/(2**(j-i)), j, i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc = QuantumCircuit(n)
    for i in range(n):
        qc.h(i)
        for j in range(i+1, n):
            qc.cp(math.pi/(2**(j-i)), j, i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for j in reversed(range(n)):
        qc.h(j)
        for k in reversed(range(j)):
            qc.cp(np.pi/2**(j-k), k, j)
        qc.barrier()
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for j in reversed(range(n)):
        qc.h(j)
        for k in reversed(range(j)):
            qc.cp(np.pi/2**(j-k), k, j)
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


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

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

    return QFT(n)
'''


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

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

    for j in reversed(range(n)):
        qc.h(j)
        for k in range(j):
            qc.cp(np.pi/2**(j-k), k, j)
        qc.barrier()
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for j in reversed(range(n)):
        qc.h(j)
        for k in range(j):
            qc.cp(np.pi/2**(j-k), k, j)
        qc.barrier()
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for j in reversed(range(n)):
        qc.h(j)
        for k in range(j):
            qc.cp(np.pi/2**(j-k), k, j)
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for j in range(n):
        qc.h(j)
        for k in range(j):
            qc.cp(np.pi/2**(j-k), k, j)
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


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

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

    for j in range(n):
        qc.h(j)
        for k in range(j):
            qc.cp(pi/2**(j-k), k, j)
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


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

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

    for j in range(n):
        qc.h(j)
        for k in reversed(range(j)):
            qc.cp(pi/2**(j-k), k, j)
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


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

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

    for j in reversed(range(n)):
        qc.h(j)
        for k in range(j):
            qc.cp(pi/2**(j-k), k, j)
    #for i in range(n//2):
    #    qc.swap(i, n-i-1)

    return qc
'''


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

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

    for j in reversed(range(n)):
        qc.h(j)
        for k in range(j):
            qc.cp(pi/2**(j-k), k, j)
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


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

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

    for j in range(n):
        qc.h(j)
        for k in range(j):
            qc.cp(pi/2**(j-k), k, j)
    #for i in range(n//2):
    #    qc.swap(i, n-i-1)

    return qc
'''


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

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

    for j in reversed(range(n)):
        qc.h(j)
        for k in reversed(range(j)):
            qc.cp(pi/2**(j-k), k, j)

    return qc
'''


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

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

    for j in range(n):
        qc.h(j)
        for k in reversed(range(j)):
            qc.cp(pi/2**(j-k), k, j)

    return qc
'''


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

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

    for j in reversed(range(n)):
        qc.h(j)
        for k in range(j):
            qc.cp(pi/2**(j-k), k, j)

    return qc
'''


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

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

    for j in range(n):
        qc.h(j)
        for k in range(j + 1, n):
            qc.cp(pi/2**(k-j), j, k)

    return qc
'''


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

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

    for j in range(n):
        qc.h(j)
        for k in range(j + 1, n):
            qc.cp(pi/2**(k-j), j, k)
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


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

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

    for j in range(n):
        qc.h(j)
        for k in range(j + 1, n):
            qc.cp(pi/2**(k-j), j, k)
    #for i in range(n//2):
    #    qc.swap(i, n-i-1)

    return qc
'''


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

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

    for j in range(n):
        qc.h(j)
        for k in range(j + 1, n):
            qc.cp(2*pi*(k-j)/2**n, j, k)
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


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

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

    for j in range(n):
        qc.h(j)
        for k in range(j + 1, n):
            qc.cp(2*pi/2**(k-j+1), j, k)
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


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

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

    for j in range(n):
        qc.h(j)
        for k in range(j + 1, n):
            qc.cp(2*pi/(2**(k-j+1)), j, k)
    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(n-i-1)
        for j in range(i+1, n):
            qc.append(U1Gate(math.pi/2**j).control(1), [n-j-1,n-i-1])

    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(n-i-1)
        for j in range(i+1, n):
            qc.append(U1Gate(math.pi/2**j).control(1), [n-j-1,n-i-1])

    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(n-i-1)
        for j in range(1, n-i):
            qc.append(U1Gate(math.pi/2**j).control(1), [n-i-j-1,n-i-1])

    for i in range(n//2):
        qc.swap(i, n-i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

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

    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qft = QFT(n, inverse=False)  # Inverse=False for QFT, True for QFT†
    qc.append(qft, range(n))
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for j in range(n):
        qc.h(j)
        for k in range(j+1,n):
            qc.cu1(math.pi/float(2**(k-j)),k,j)
        qc.barrier()
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for j in range(n):
        qc.h(j)
        for k in range(j+1,n):
            qc.cu1(math.pi/float(2**(k-j)),k,j)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for j in range(n):
        qc.h(j)
        for k in range(j+1,n):
            qc.cu1(3.141592/float(2**(k-j)),k,j)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for j in range(n):
        qc.h(j)
        for k in range(j+1,n):
            qc.cu1(3.141592/2**(k-j),k,j)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for j in range(n):
        qc.h(j)
        for k in range(j+1,n):
            qc.cp(3.141592/2**(k-j),k,j)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for j in range(n):
        qc.h(j)
        for k in range(j+1,n):
            qc.cu(3.141592/2**(k-j),k,j)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for j in range(n):
        qc.h(j)
        for k in range(j+1,n):
            qc.cu(3.141592/2**(k-j),0,0,0,k,j)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for j in range(n):
        qc.h(j)
        for k in range(j+1,n):
            qc.cu(0,0,3.141592/2**(k-j),0,k,j)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for j in range(n):
        qc.h(j)
        for k in range(j+1,n):
            qc.cu(0,0,0,3.141592/2**(k-j),k,j)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n):
        qc.h(n-1-i)
        for j in range(i+1,n):
            qc.cp(2 * 3.141592 / 2**(j+1-i), n-1-j, n-1-i)
    return qc
'''


'''python
import math

from qiskit import QuantumCircuit

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

    for i in reversed(range(n)):
        qc.h(i)
        for q in reversed(range(i)):
            qc.cp(pi/2**(i-q),q,i)
    for i in range(math.floor(n/2)):
        qc.swap(i,n-(i+1))

    return qc
'''


'''python
import math
from numpy import pi

from qiskit import QuantumCircuit

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

    for i in reversed(range(n)):
        qc.h(i)
        for q in reversed(range(i)):
            qc.cp(pi/2**(i-q),q,i)
    for i in range(math.floor(n/2)):
        qc.swap(i,n-(i+1))

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    n -= 1
    qc.h(n)
    for qubit in range(n):
        qc.cp(math.pi / 2 ** (n - qubit), qubit, n)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    def qft_rotations(circuit, n):
        if n == 0:
            return circuit
        n -= 1
        circuit.h(n)
        for qubit in range(n):
            circuit.cp(math.pi / 2 ** (n - qubit), qubit, n)
        qft_rotations(circuit, n)

    qft_rotations(qc, n)

    for qubit in range(n // 2):
        qc.swap(qubit, n - qubit - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    def qft_rotations(circuit, n):
        circuit.h(n)
        for qubit in range(n + 1, circuit.num_qubits):
            circuit.cp(math.pi / 2 ** (qubit - n), qubit, n)

    for i in range(n):
        qft_rotations(qc, i)

    for qubit in range(n // 2):
        qc.swap(qubit, n - qubit - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    def qft_rotations(circuit, n):
        circuit.h(n)
        for qubit in range(n + 1, circuit.num_qubits):
            circuit.cp(math.pi / 2 ** (n - qubit), qubit, n)

    for i in range(n):
        qft_rotations(qc, i)

    for qubit in range(n // 2):
        qc.swap(qubit, n - qubit - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for i in range(n):
        qc.h(i)
        rotation = math.pi / 2
        for j in range(i + 1, n):
            qc.cp(rotation, j, i)
            rotation /= 2
    for i in range(n // 2):
        qc.swap(i, n - i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for i in range(n):
        qc.h(i)
        rotation = math.pi / 2
        for j in range(i + 1, n):
            qc.cp(rotation, j, i)
            rotation /= 2
    for i in range(n // 2):
        qc.swap(i, n - i - 1)

    qc = qc.reverse_bits()

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    n -= 1 # インデックスは0から始める
    qc.h(n) # Hゲートを最上位量子ビットに適用する
    for qubit in range(n):
        # 量子ビットごとに、Indexが小さい方が
        # 角度の小さい制御回転を実行
        qc.cp(pi/2**(n-qubit), qubit, n)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    n -= 1 # インデックスは0から始める
    qc.h(n) # Hゲートを最上位量子ビットに適用する
    for qubit in range(n):
        # 量子ビットごとに、Indexが小さい方が
        # 角度の小さい制御回転を実行
        qc.cp(np.pi/2**(n-qubit), qubit, n)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def qft_rotations(qc, n):
    if n == 0:
        return qc
    n -= 1
    qc.h(n)
    for qubit in range(n):
        qc.cp(np.pi/2**(n-qubit), qubit, n)
    # この関数の最後で、次の量子ビットで同じ関数を再度呼び出します
    # （関数の前の方ですでにnを1つ減らしています）。
    qft_rotations(qc, n)

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    qft_rotations(qc, n)
    return qc
'''


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

def qft_rotations(qc, n):
    if n == 0:
        return qc
    n -= 1
    qc.h(n)
    for qubit in range(n):
        qc.cp(np.pi/2**(n-qubit), qubit, n)
    # この関数の最後で、次の量子ビットで同じ関数を再度呼び出します
    # （関数の前の方ですでにnを1つ減らしています）。
    qft_rotations(qc, n)

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    qft_rotations(qc, n)
    return qc
'''


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

def qft_rotations(qc, n):
    if n == 0:
        return qc
    n -= 1
    qc.h(n)
    for qubit in range(n):
        qc.cp(np.pi/2**(n-qubit), qubit, n)
    # この関数の最後で、次の量子ビットで同じ関数を再度呼び出します
    # （関数の前の方ですでにnを1つ減らしています）。
    qft_rotations(qc, n)

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    qft_rotations(qc, n)
    swap_registers(qc, n)
    return qc
'''


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

def qft_rotations(qc, n):
    if n == 0:
        return qc
    n -= 1
    qc.h(n)
    for qubit in range(n):
        qc.cp(np.pi/2**(n-qubit), qubit, n)
    # この関数の最後で、次の量子ビットで同じ関数を再度呼び出します
    # （関数の前の方ですでにnを1つ減らしています）。
    qft_rotations(qc, n)

def swap_registers(circuit, n):
    for qubit in range(n//2):
        circuit.swap(qubit, n-qubit-1)
    return circuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    qft_rotations(qc, n)
    swap_registers(qc, n)
    return qc
'''


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

def qft_rotations(qc, n):
    if n == 0:
        return qc
    n -= 1
    qc.h(n)
    for qubit in range(n):
        qc.cp(np.pi/2**(n-qubit), qubit, n)
    # この関数の最後で、次の量子ビットで同じ関数を再度呼び出します
    # （関数の前の方ですでにnを1つ減らしています）。
    qft_rotations(qc, n)

def swap_registers(circuit, n):
    for qubit in range(n//2):
        circuit.swap(qubit, n-qubit-1)
    return circuit

def qft(circuit, n):
    """QFT on the first n qubits in circuit"""
    qft_rotations(circuit, n)
    swap_registers(circuit, n)
    return circuit

def inverse_qft(circuit, n):
    """Does the inverse QFT on the first n qubits in circuit"""
    # First we create a QFT circuit of the correct size:
    qft_circ = qft(QuantumCircuit(n), n)
    # Then we take the inverse of this circuit
    invqft_circ = qft_circ.inverse()
    # And add it to the first n qubits in our existing circuit
    circuit.append(invqft_circ, circuit.qubits[:n])
    return circuit.decompose() # .decompose() allows us to see the individual gates

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    qc_d = inverse_qft(qc, n)
    return qc_d
'''


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

def qft_rotations(qc, n):
    if n == 0:
        return qc
    n -= 1
    qc.h(n)
    for qubit in range(n):
        qc.cp(np.pi/2**(n-qubit), qubit, n)
    # この関数の最後で、次の量子ビットで同じ関数を再度呼び出します
    # （関数の前の方ですでにnを1つ減らしています）。
    qft_rotations(qc, n)

def swap_registers(circuit, n):
    for qubit in range(n//2):
        circuit.swap(qubit, n-qubit-1)
    return circuit

def qft(circuit, n):
    """QFT on the first n qubits in circuit"""
    qft_rotations(circuit, n)
    swap_registers(circuit, n)
    return circuit

def inverse_qft(circuit, n):
    """Does the inverse QFT on the first n qubits in circuit"""
    # First we create a QFT circuit of the correct size:
    qft_circ = qft(QuantumCircuit(n), n)
    # Then we take the inverse of this circuit
    invqft_circ = qft_circ.inverse()
    # And add it to the first n qubits in our existing circuit
    circuit.append(invqft_circ, circuit.qubits[:n])
    return circuit.decompose() # .decompose() allows us to see the individual gates

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    qc_d = inverse_qft(qc, n)
    return qc_d
'''


'''python
import math

import numpy as np
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(n)):
        qc.h(i)
        for qubit in reversed(range(0, i)):
            qc.cp(np.pi / 2 **(i - qubit), qubit, i)
    for i in range(math.floor(n / 2)):
        qc.swap(i, n - (i + 1))

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(i + 1, n):
            qc.cp(np.pi / 2**(j - i), j, i)

    for i in range(n//2):
        qc.swap(i, n - i -1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(i + 1, n):
            qc.cp(np.pi / 2**(j - i), j, i)

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


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(i + 1, n):
            qc.cp(np.pi / 2**(j - i), j, i)

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


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(i + 1, n):
            qc.cp(np.pi / 2**(j - i), i, j)

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


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(i + 1, n):
            qc.cp(np.pi / 2**(j - i), i, j)

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


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(i + 1, n):
            qc.cp(2 * np.pi / 2**n, i, j)

    for i in range(n//2):
        qc.swap(i, n - i - 1)
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in range(i + 1, n):
            qc.cp(np.pi / 2**(i - j), j, i)

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


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)
        for j in reversed(range(i)):
            qc.cp(np.pi / 2**(i - j), j, i)

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


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(n)):
        qc.h(i)
        for j in reversed(range(i)):
            qc.cp(np.pi / 2**(i - j), j, i)

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


'''python
import math
from qiskit import QuantumCircuit
from qiskit.circuit.library import ZGate, PhaseGate, QFT

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

# if __name__ == "__main__":
#     from qiskit.quantum_info import Statevector
#     import numpy as np
#     qc = solve(2)
#     # sv = Statevector(qc)
#     # print(sv)
#     print(qc)
#     print(f"{qc.depth() = }")
#     sv = Statevector.from_label('10')
#     print(sv.evolve(qc))
'''


'''python
import math
from qiskit import QuantumCircuit
from qiskit.circuit.library import ZGate, PhaseGate #, QFT

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # qc.append(QFT(n), range(n))
    return qc

# if __name__ == "__main__":
#     from qiskit.quantum_info import Statevector
#     import numpy as np
#     qc = solve(2)
#     # sv = Statevector(qc)
#     # print(sv)
#     print(qc)
#     print(f"{qc.depth() = }")
#     sv = Statevector.from_label('10')
#     print(sv.evolve(qc))
'''


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

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

    for i in reversed(range(n)):
        qc.h(i)
        for j in range(i):
            theta = math.pi / 2 ** (i - j)
            qc.crz(theta, j, i)
    return qc
'''


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

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

    for i in reversed(range(n)):
        qc.h(i)
        for j in range(i):
            theta = math.pi / 2 ** (i - j)
            qc.cp(theta, j, i)
    for i in range(n // 2):
        qc.swap(i, n - i - 1)
    return qc
'''


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

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

    for i in reversed(range(n)):
        qc.h(i)
        for j in reversed(range(i)):
            theta = math.pi / 2 ** (i - j)
            qc.cp(theta, j, i)
    for i in range(n // 2):
        qc.swap(i, n - i - 1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for j in range(n):
        # Apply the Hadamard gate to the jth qubit
        qc.h(j)
        # Apply the controlled phase rotations
        for k in range(j+1, n):
            # Apply the controlled R_k gate
            qc.cp(np.pi/2**(k-j), j, k)

    # Reverse the order of the qubits
    for j in range(n//2):
        qc.swap(j, n-j-1)
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for j in range(n):
        # Apply the Hadamard gate to the jth qubit
        qc.h(j)
        # Apply the controlled phase rotations
        for k in range(j+1, n):
            # Apply the controlled R_k gate
            qc.cp(np.pi/2**(k-j), j, k)

    # Reverse the order of the qubits
    for j in range(n//2):
        qc.swap(j, n-j-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np
from qiskit.circuit.library import QFT

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    # for j in range(n):
    #     # Apply the Hadamard gate to the jth qubit
    #     qc.h(j)
    #     # Apply the controlled phase rotations
    #     for k in range(j+1, n):
    #         # Apply the controlled R_k gate
    #         qc.cp(np.pi/2**(k-j), j, k)

    # # Reverse the order of the qubits
    # for j in range(n//2):
    #     qc.swap(j, n-j-1)
    for j in reversed(range(n)):
        qc.h(j)
        for k in range(j):
            lam = np.pi * (2.0 ** (k - j))
            qc.cp(lam, k, j)
    # qc.append(QFT(n))
    return qc
'''


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

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    # for j in range(n):
    #     # Apply the Hadamard gate to the jth qubit
    #     qc.h(j)
    #     # Apply the controlled phase rotations
    #     for k in range(j+1, n):
    #         # Apply the controlled R_k gate
    #         qc.cp(np.pi/2**(k-j), j, k)

    # # Reverse the order of the qubits
    # for j in range(n//2):
    #     qc.swap(j, n-j-1)
    for j in reversed(range(n)):
        qc.h(j)
        for k in range(j):
            lam = np.pi * (2.0 ** (k - j))
            qc.cp(lam, k, j)
    # qc.append(QFT(n))
    return qc
'''


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

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

    for k in range(n):
        j = n-k
        j2 = n-j
        qc.h(j2-1)

        for i in reversed(range(j-1)):
            j3 = n - (j-i)
            i2 = j-1 - i
            j4 = n-(j-1)
            qc.cu1(2*np.pi/2**(j3), i2, j4)

        for i in range(n//2):
            qc.swap(i, n-i-1)

    return qc
'''


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

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

    for k in range(n):
        j = n-k
        # j2 = n-j
        qc.h(j)

        for i in reversed(range(j-1)):
            # j3 = n - (j-i)
            # i2 = j-1 - i
            # j4 = n-(j-1)
            qc.cu1(2*np.pi/2**(j-i), i, j-1)

        for i in range(n//2):
            qc.swap(i, n-i-1)

    return qc
'''


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

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

    for k in range(n):
        j = n-1-k
        # j2 = n-j
        qc.h(j)

        for i in reversed(range(j-1)):
            # j3 = n - (j-i)
            # i2 = j-1 - i
            # j4 = n-(j-1)
            qc.cp(2*np.pi/2**(j-i), i, j-1)

        for i in range(n//2):
            qc.swap(i, n-i-1)

    return qc
'''