Problem:
 Score : 700 points    Problem Statement You are given an integer N . Determine if there exists a tree with 2N vertices numbered 1 to 2N satisfying the following condition, and show one such tree if the answer is yes.   Assume that, for each integer i between 1 and N (inclusive), Vertex i and N+i have the weight i . Then, for each integer i between 1 and N , the bitwise XOR of the weights of the vertices on the path between Vertex i and N+i (including themselves) is i .       Constraints  N is an integer.  1 \leq N \leq 10^{5}         Input Input is given from Standard Input in the following format:  N       Output If there exists a tree satisfying the condition in the statement, print Yes ; otherwise, print No .
Then, if such a tree exists, print the 2N-1 edges of such a tree in the subsequent 2N-1 lines, in the following format:  a_{1}  b_{1}  \vdots  a_{2N-1}  b_{2N-1}   Here each pair ( a_i , b_i ) means that there is an edge connecting Vertex a_i and b_i . The edges may be printed in any order.        Sample Input 1 3      Sample Output 1 Yes
1 2
2 3
3 4
4 5
5 6   The sample output represents the following graph:          Sample Input 2 1      Sample Output 2 No   There is no tree satisfying the condition.

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    n = I()
    a = LI()
    ans = 0
    for i in a:
        ans ^= i
    if not ans:
        print("Yes")
    else:
        print("No")
    return


def B():
    n,m = LI()

    return


def C():
    n = I()
    p = [(1<<i) for i in range(100)]
    if n in p:
        print("No")
        quit()
    if n+1 in p:
        print("Yes")
        for i in range(1,2*n):
            print(i,i+1)
        quit()
    ans = []
    for i in range(1,3):
        ans.append((i,i+1))
    ans.append((3,n+1))
    for i in range(1,3):
        ans.append((i+n,i+n+1))
    u = 1
    d = 1
    for i in range(2,n//2+n%2):
        ans.append((u,2*i))
        ans.append((d,2*i+1))
        ans.append((2*i,2*i+n+1))
        ans.append((2*i+1,2*i+n))
        u = 2*i+n+1
        d = 2*i+n

    if n%2:
        print("Yes")
        for i,j in ans:
            print(i,j)
    else:
        ans.append((n-1,n))
        for i in range(n):
            if p[i]&n:
                break
        ans.append((p[i+1]-2,2*n))
        print("Yes")
        for i,j in ans:
            print(i,j)
    return


def D():
    n = I()

    return


def E():
    n = I()

    return


def F():
    n = I()

    return


if __name__ == "__main__":
    C()

Solution (Python):
n=int(input())
l=1
while n>l:
    l*=2
if n==l:
    print("No")
    quit()
print("Yes")
for i in range((n-1)//2):
    t=i*2
    print(1,2+t)
    print(2+t,3+t)
    print(1,3+n+t)
    print(3+n+t,2+n+t)
print(3,1+n)
if n%2==0:
    print(n,(n&-n)+1+n)
    print(2*n,n-(n&-n))

Solution (Python):
import sys
input = sys.stdin.readline

N = int(input())


n = N.bit_length()
if N == 1 << (n-1):
    print('No')
    exit()

def solve(N):
    graph = []
    for n in range(2,N,2):
        graph.append((n,n+1))
        graph.append((n+1,1))
        graph.append((1,N+n))
        graph.append((N+n,N+n+1))
    graph.append((N+1,2))
    if N&1:
        return graph
    L = N.bit_length()
    n = 1 << (L-1)
    m = N ^ n ^ 1
    
    graph.append((N,m))
    graph.append((n+N,N+N))
    return graph


graph = solve(N)

print('Yes')
for a,b in graph:
    print(a,b)

Solution (Python):
import sys, collections

def solve():
    input = sys.stdin.readline
    N = int(input())
    k = 1
    while k <= N:
        if k == N:
            print("No")
            break
        else: k *= 2
    else:
        if N % 2 == 1:
            print("Yes")
            ans = ""
            ans += "1 2\n"
            ans += "2 3\n"
            ans += "3 " + str(N + 1) + "\n"
            ans += str(N + 1) + " " + str(N + 2) + "\n"
            ans += str(N + 2) + " " + str(N + 3) + "\n"
            for i in range(2, N // 2 + 1):
                ans += str(2 * i) + " " + str(2 * i + 1) + "\n"
                ans += str(2*i+1) + " 1\n"
                ans += "1 " + str(N + 2*i) + "\n"
                ans += str(N+2*i) + " " + str(N+2*i+1) + "\n"
            print(ans)
        else:
            print("Yes")
            ans = ""
            ans += "1 2\n"
            ans += "2 3\n"
            ans += "3 " + str(N + 1) + "\n"
            ans += str(N + 1) + " " + str(N + 2) + "\n"
            ans += str(N + 2) + " " + str(N + 3) + "\n"
            for i in range(2, N // 2):
                ans += str(2 * i) + " " + str(2 * i + 1) + "\n"
                ans += str(2*i+1) + " 1\n"
                ans += "1 " + str(N + 2*i) + "\n"
                ans += str(N+2*i) + " " + str(N+2*i+1) + "\n"
            b = N ^ (N - 1)
            ans += str(N) + " " + str(N-1) + "\n"
            if b % 2 == 1:
                ans += str(N + b - 1) + " " + str(2 * N)
            else:
                ans += str(b + 1) + " " + str(2 * N)
            print(ans)

    return 0

if __name__ == "__main__":
    solve()