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.



Sample input:
3


Sample output:
Yes
1 2
2 3
3 4
4 5
5 6

Submission status: Wrong Answer

Solution code:

"""

https://atcoder.jp/contests/agc035/tasks/agc035_c

全ての対の頂点に関して、パス上の重みのxorが自分に等しい
1から順に求めていくことを考える

A,Bの関係を考える
木なので、片方のパス上にあればいい→片方にのみ含ませることも、両方に含ませることも可能

1をいい感じに使って構築できないか？

101-100-1-101-100
みたいに、1の位だけ違う数字をまとめて処理すればいい感じになる
もう一つの1は、どっかの葉につけておけばおk
これで、Nが奇数かつ1でない場合は全て構築可能！！

偶数の時は？ 2,4みたいな場合は自明にダメ
6は？
001 010 011 100 101 110
xorで110になるのは010と100

101-100-1-010-011
    |     |
    110   100

→分からんけどとりあえず提出

偶数でも可能な場合がある…
(N+i)-(N+i+1)- -(i)-(i+1)
とする

"""
import sys
N = int(input())

if N == 1:
    print ("No")

elif N % 2 == 1:
    print ("Yes")

    for i in range(2,N+1,2):
        print (1,i)
        print (i,i+1)
        print (1,i+1+N)
        print (i+1+N,i+N)

    print (N+1,3)

else:

    a = None
    b = None

    for i in range(1,N):
        if N ^ i < N:
            a = i
            b = N ^ i

    if a == None:
        print ("No")
        sys.exit()
    
    print ("Yes")
    for i in range(3,N,2):
        print (i,i+1)
        print (N+i,N+i+1)

        #1につけていく
        if i not in (a,b) and i+1 not in (a,b):
            print (1,i)
            print (1,N+i+1)

    pa = a^1
    pb = b^1

    print (N+1,a)
    print (a,b)
    print (N,a)
    print (b,2*N)
    print (1,pa)

    print (1,a+N)
    print (pa+N,pb+N)

Submission status: Wrong Answer

Solution code:

"""

https://atcoder.jp/contests/agc035/tasks/agc035_c

全ての対の頂点に関して、パス上の重みのxorが自分に等しい
1から順に求めていくことを考える

A,Bの関係を考える
木なので、片方のパス上にあればいい→片方にのみ含ませることも、両方に含ませることも可能

1をいい感じに使って構築できないか？

101-100-1-101-100
みたいに、1の位だけ違う数字をまとめて処理すればいい感じになる
もう一つの1は、どっかの葉につけておけばおk
これで、Nが奇数かつ1でない場合は全て構築可能！！

偶数の時は？ 2,4みたいな場合は自明にダメ
6は？
001 010 011 100 101 110
xorで110になるのは010と100

101-100-1-010-011
    |     |
    110   100

→分からんけどとりあえず提出

"""

N = int(input())

if N == 1 or N % 2 == 0:
    print ("No")
else:

    print ("Yes")

    for i in range(2,N+1,2):
        print (1,i)
        print (i,i+1)
        print (1,i+1+N)
        print (i+1+N,i+N)

    print (N+1,3)

Submission status: Wrong Answer

Solution code:
n,k,i=int(input()),1,2
v=n+1
p=print
if-n&k:p("No");exit()
p("Yes",v,3)
while i<n:p(1,i,i,i+1,1,v+i,v+i,n+i);i+=2;k*=1+(k*2<v)
if~n&1:p(n,v+k,n+n,n^k)

Submission status: Wrong Answer

Solution code:
n,k=int(input()),1
while k*2<n:k*=2
p=print
if n==k:p("No");exit()
p("Yes",v:=n+1,3)
for i in range(2,n,2):p(1,i,i,i+1,1,v+i,v+i,n+i)
if~n&1:p(n,n+k+1,n+n,n^k)

Submission status: Wrong Answer

Solution code:
n,k=int(input()),1
while k*2<n:k*=2
p=print
if n==k:p("No");exit()
p("Yes",v:=n+1,3)
for i in range(2,n,2):p(1,i,i,i+1,1,v+i,v+i,n+i)
if~n&1:p(n,k,n+n,n+n^k^1)

Submission status: Wrong Answer

Solution code:
n,k=int(input()),1
while k*2<n:k*=2
p=print
if n==k:p("No");exit()
p("Yes",v:=n+1,3)
for i in range(2,n,2):p(1,i,i,i+1,1,v+i,v+i,n+i)
if~n&1:p(n,n+k,n+n,n^k^1)

Submission status: Wrong Answer

Solution code:
n,k=int(input()),1
while k*2<n:k*=2
p=print
if n==k:p("No");exit()
p("Yes",v:=n+1,3)
for i in range(2,n,2):p(1,i,i,i+1,1,v+i,v+i,n+i)
if~n&1:p(n,k+1,n+n,n^k+n)

Submission status: Wrong Answer

Solution code:
n,k=int(input()),4
while k*2<n:k*=2
p=print
if n==k:p("No");exit()
p("Yes",n+1,3)
for i in range(2,n,2):p(1,i,i,i+1,1,n+i+1,n+i+1,n+i)
if~n&1:p(n,1,n+n,n^1)

Submission status: Wrong Answer

Solution code:
n=int(input())
p,r=print,range
if n&-n==n:p("No");exit(0)
p("Yes")
if n==3:p(1,2);p(2,3);p(3,4);p(4,5);p(5,6);exit(0)
k=1
while k*2<n:k*=2
for i in r(k+2):p(i+1,i+2)
p(k-1,n+1)
for i in r(k+2):p(n+i+1,n+i+2)
p(n+k,n+1);p(n+k+1,k)
for i in r(n-k):p(n+i+1,n+k+i+1);p(n+k+i,k+i+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
nn = n
f = lambda x, y: x + y * nn
g = lambda x: x if x % 2 == 1 else x + nn

# 2の累乗はむり
b = bin(n)
if b.count('0') == len(b) - 2:
    print('No')
    exit(0)

ret = [
    [f(1, 0), f(2, 0)],
    [f(2, 0), f(3, 0)],
    [f(3, 0), f(1, 1)],
    [f(1, 1), f(2, 1)],
    [f(2, 1), f(3, 1)],
]

if n % 2 == 0:
    p = 2 ** (len(b) - 3)
    q = n ^ 1 ^ p
    ret.append([g(p), f(n, 0)])
    ret.append([g(q), f(n, 1)])
    n -= 1

# nは奇数
while n > 3:
    ret.append([f(n - 1, 0), f(n, 0)])
    ret.append([f(n, 0), f(1, 0)])
    ret.append([f(1, 0), f(n - 1, 1)])
    ret.append([f(n - 1, 1), f(n, 1)])
    n -= 2

print('Yes')
for x, y in ret:
    # x = x if x <= nn else x - nn
    # y = y if y <= nn else y - nn
    print(x, y)

Submission status: Wrong Answer

Solution code:
n = int(input())
nn = n
f = lambda x, y: x + y * nn

# 2の累乗はむり
b = bin(n)
if b.count('0') == len(b) - 2:
    print('No')
    exit(0)

ret = [
    [f(1, 0), f(2, 0)],
    [f(2, 0), f(3, 0)],
    [f(3, 0), f(1, 1)],
    [f(1, 1), f(2, 1)],
    [f(2, 1), f(3, 1)],
]

if n % 2 == 0:
    m = n ^ 1
    if m % 2 == 0:
        m += n
    ret.append([f(n, 0), f(1, 1)])
    ret.append([f(n, 1), m])
    n -= 1

# nは奇数
while n > 3:
    ret.append([f(n - 1, 0), f(n, 0)])
    ret.append([f(n, 0), f(1, 0)])
    ret.append([f(1, 0), f(n - 1, 1)])
    ret.append([f(n - 1, 1), f(n, 1)])
    n -= 2

print('Yes')
for x, y in ret:
    # x = x if x <= nn else x - nn
    # y = y if y <= nn else y - nn
    print(x, y)

Submission status: Wrong Answer

Solution code:
n = int(input())
nn = n
f = lambda x, y: x + y * nn

# 2の累乗はむり
b = bin(n)
if b.count('0') == len(b) - 2:
    print(-1)
    exit(0)

ret = [
    [f(1, 0), f(2, 0)],
    [f(2, 0), f(3, 0)],
    [f(3, 0), f(1, 1)],
    [f(1, 1), f(2, 1)],
    [f(2, 1), f(3, 1)],
]

if n % 2 == 0:
    m = n ^ 1
    if m % 2 == 0:
        m += n
    ret.append([f(n, 0), f(1, 1)])
    ret.append([f(n, 1), m])
    n -= 1

# nは奇数
while n > 3:
    ret.append([f(n - 1, 0), f(n, 0)])
    ret.append([f(n, 0), f(1, 0)])
    ret.append([f(1, 0), f(n - 1, 1)])
    ret.append([f(n - 1, 1), f(n, 1)])
    n -= 2

print('Yes')
for x, y in ret:
    # x = x if x <= nn else x - nn
    # y = y if y <= nn else y - nn
    print(x, y)

Submission status: Wrong Answer

Solution code:
N=int(input())
if (N&-N)==N:
  print('No')
  exit()
print('Yes')
M=str(bin(N))[2:]
M=1<<(len(M)-1)
P=[]
B=False
if set(str(bin(N))[2:])==set('1'):
  N+=2
  M=str(bin(N))[2:]
  M=1<<(len(M)-1)
  B=True
  N-=2
for i in range(M-2):
  P.append([i+1,i+2])
P.append([M-1,N+1])
for i in range(M-2):
  P.append([N+1+i,N+2+i])
if B:
  for i in range(len(P)):
    print(*P[i])
  exit()
for i in range(1,((N-M+3)>>1)):
  P.append([1,M+(i<<1)-2])
  P.append([M+(i<<1)-2,M+(i<<1)-1])
  P.append([1,N+M+(i<<1)-1])
  P.append([N+M+(i<<1)-1,N+M+(i<<1)-2])
if len(P)!=(N<<1)-1:
  X=(N-M)^(N-M-1)
  P.append([N,N-M])
  for i in range(len(P)):
    if P[i][0]==N-M-1:
      if X^(P[i][1]%N)==N:
        P.append([N<<1,P[i][1]])
        break
    if P[i][1]==N-M-1:
      if X^(P[i][0]%N)==N:
        P.append([N<<1,P[i][0]])
        break
for i in range(len(P)):
  print(*P[i])

Submission status: Wrong Answer

Solution code:
N=int(input())
if (N&-N)==N:
  print('No')
  exit()
print('Yes')
M=str(bin(N))[2:]
M=1<<(len(M)-1)
P=[]
B=False
if set(str(bin(N))[2:])==set('1'):
  N+=2
  M=str(bin(N))[2:]
  M=1<<(len(M)-1)
  B=True
  N-=2
for i in range(M-2):
  P.append([i+1,i+2])
P.append([M-1,N+1])
for i in range(M-2):
  P.append([N+1+i,N+2+i])
if B:
  for i in range(len(P)):
    print(*P[i])
  exit()
for i in range(1,((N-M+3)>>1)):
  P.append([(i<<1)-1,M+(i<<1)-2])
  P.append([M+(i<<1)-2,M+(i<<1)-1])
  P.append([(i<<1)-1,N+M+(i<<1)-1])
  P.append([N+M+(i<<1)-1,N+M+(i<<1)-2])
if len(P)!=(N<<1)-1:
  X=(N-M)^(N-M-1)
  P.append([N,N-M])
  for i in range(len(P)):
    if P[i][0]==N-M-1:
      if X^(P[i][1]%N)==N:
        P.append([N<<1,P[i][1]])
        break
    if P[i][1]==N-M-1:
      if X^(P[i][0]%N)==N:
        P.append([N<<1,P[i][0]])
        break
for i in range(len(P)):
  print(*P[i])

Submission status: Wrong Answer

Solution code:
N=int(input())
if (N&-N)==N:
  print('No')
  exit()
print('Yes')
M=str(bin(N))[2:]
M=1<<(len(M)-1)
P=[]
for i in range(M-2):
  P.append([i+1,i+2])
P.append([M-1,N+1])
for i in range(M-2):
  P.append([N+1+i,N+2+i])
for i in range(1,((N-M+2)>>1)):
  P.append([(i<<1)-1,M+(i<<1)-2])
  P.append([M+(i<<1)-2,M+(i<<1)-1])
  P.append([(i<<1)-1,N+M+(i<<1)-1])
  P.append([N+M+(i<<1)-1,N+M+(i<<1)-2])
if len(P)!=(N<<1)-1:
  X=(N-M)^(N-M-1)
  P.append([N,N-M])
  for i in range(len(P)):
    if P[i][0]==N-M-1:
      if X^(P[i][1]%N)==N:
        P.append([N<<1,P[i][1]])
        break
    if P[i][1]==N-M-1:
      if X^(P[i][0]%N)==N:
        P.append([N<<1,P[i][0]])
        break
for i in range(len(P)):
  print(*P[i])

Submission status: Wrong Answer

Solution code:
N=int(input())
if (N&-N)==N:
  print('No')
  exit()
M=str(bin(N))[2:]
M=1<<(len(M)-1)
P=[]
for i in range(M-2):
  P.append([i+1,i+2])
P.append([M-1,N+1])
for i in range(M-2):
  P.append([N+1+i,N+2+i])
for i in range(1,((N-M+2)>>1)):
  P.append([(i<<1)-1,M+(i<<1)-2])
  P.append([M+(i<<1)-2,M+(i<<1)-1])
  P.append([(i<<1)-1,N+M+(i<<1)-1])
  P.append([N+M+(i<<1)-1,N+M+(i<<1)-2])
if len(P)!=(N<<1)-1:
  X=(N-M)^(N-M-1)
  P.append([N,N-M])
  for i in range(len(P)):
    if P[i][0]==N-M-1:
      if X^(P[i][1]%N)==N:
        P.append([N<<1,P[i][1]])
        break
    if P[i][1]==N-M-1:
      if X^(P[i][0]%N)==N:
        P.append([N<<1,P[i][0]])
        break
for i in range(len(P)):
  print(*P[i])

Submission status: Wrong Answer

Solution code:
N=int(input())
if N%2==0:
    print("No")
elif N==1:
    print("No")
else:
    print("Yes")
    k=N//2
    for i in range(1,k+1):
        print(2*k,2*k+1)
        print(2*k+1,1)
        print(1,2*k+N)
        print(2*k+N,2*k+1+N)
    print(1+N,2)

Submission status: Wrong Answer

Solution code:
n=int(input())
if n==2 or n==1:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
n=int(input());p=print;b=1<<(n.bit_length()-1)
if n==b:p("No");exit()
p("Yes");p(n+1,n+2)
for i in range(3,n+1,2):p(1,i);p(1,i-1);p(i,n+i-1);p(i-1,n+i)
if~n&1:p(n,b+n);p(n+n,n^b^1)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=0
for i in range(1,n+1):
  a=a^i
if a==0:
  print("Yes")
  for i in range(2*n-1):
    print(i+1,i+2)
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
if n in [3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32787,65535,131071,262143,524287]:
  print("Yes")
  for i in range(2*n-1):
    print(i+1,i+2)
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
for k in range(2,30):
    p = (1 << k) - 1
    if p == N:
        print("Yes")
        for i in range(2*N-1):
            print(i+1, i+2)
        exit(0)
print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())
for k in range(2,30):
    p = (1 << k) - 1
    if p == N:
        print("Yes")
        for i in range(N-1):
            print(i+1, i+2)
        exit(0)
print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
if "0"in bin(n)[2:] or n==1:print("No");exit()
print("Yes")
for i in range(1,2*n):print(i,i+1)

Submission status: Wrong Answer

Solution code:
import sys

N=int(input())
n=N
while n%2==0:
    n//=2
if n==1:
    print("No")
    sys.exit()

m=0
while True:
    m+=1
    if 2**m>N:
        m-=1
        break

ans=[]
if N%2==0:
    ans.append([N,2**m])
    ans.append([2*N,((N^(2**m))+1+N)])

ans.append([N+1,3])
for i in range(1,(N-1)//2+1):
    num=2*i
    ans.append([1,num])
    ans.append([num,num+1])
    ans.append([1,N+num+1])
    ans.append([N+num+1,N+num])

for u in ans:
    print(*u)

Submission status: Wrong Answer

Solution code:
import sys

N=int(input())
n=N
while n%2==0:
    n//=2
if n==1:
    print("No")
    sys.exit()

m=0
while True:
    m+=1
    if 2**m>N:
        m-=1
        break
        
if N%2==0:
    print(N,2**m)
    print(2*N,(N-2**m+1+N))
print(N+1,N+2)
for i in range(1,(N-1)//2+1):
    num=2*i
    print(1,num)
    print(num,num+1)
    print(1,N+num+1)
    print(N+num,N+num+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
b = 1 << (n.bit_length()-1)
if n - b == 0:
  print("No")
else:
  print("Yes")
  print(1, 2)
  print(2, 3)
  print(3, n+1)
  print(n+1, n+2)
  print(n+2, n+3)
  for i in range(4, n, 2):
    print(i, i+1)
    print(i+n, i+n+1)
    print(1+n, i+n)
    print(1+n, i+1)
  if (~n)&1:
    print(n, b)
    a = n ^ b ^ 1
    print(n+n, a)

Submission status: Wrong Answer

Solution code:
n = int(input())
b = 1 << (n.bit_length()-1)
if n - b == 0:
  print("No")
else:
  print("Yes")
  print(1, 2)
  print(2, 3)
  print(3, n+1)
  print(n+1, n+2)
  print(n+2, n+3)
  for i in range(4, n, 2):
    print(i, i+1)
    print(i+n, i+n+1)
    print(1, i)
    print(1, i+n+1)
  if n%2 == 0:
    print(n, b)
    a = n ^ b ^ 1
    print(n+n, n+a)

Submission status: Wrong Answer

Solution code:
n = int(input())
b = 1 << (n.bit_length()-1)
if n - b == 0:
  print("No")
else:
  print("Yes")
  print(1, 2)
  print(2, 3)
  print(3, n+1)
  print(n+1, n+2)
  print(n+2, n+3)
  for i in range(4, n, 2):
    print(i, i+1)
    print(i+n, i+n+1)
    print(1, i)
    print(1, i+n+1)
  if (~n)&1:
    print(n, b)
    a = n - b - 1
    print(n+n, n+a)

Submission status: Wrong Answer

Solution code:
n = int(input())
b = 1 << (n.bit_length()-1)
if n - b == 0:
  print("No")
else:
  print("Yes")
  print(1, 2)
  print(2, 3)
  print(3, n+1)
  print(n+1, n+2)
  print(n+2, n+3)
  for i in range(4, n, 2):
    print(i, i+1)
    print(i+n, i+n+1)
    print(1, i)
    print(1, i+n+1)
  if (~n)&1:
    print(n, b)
    a = n - b
    if a&1:
      print(n+n, a+n)
    else:
      print(n+n, a)

Submission status: Wrong Answer

Solution code:
n = int(input())
b = 1 << (n.bit_length()-1)
if n - b == 0:
  print("No")
else:
  print("Yes")
  for i in range(1, 4):
    print(i, i+1)
    print(i+n, i+n+1)
  for i in range(4, n, 2):
    print(i, i+1)
    print(i+n, i+n+1)
    print(1, i)
    print(1, i+n+1)
  if (~n)&1:
    print(n, b)
    a = n - b
    if a&1:
      print(n+n, a+n)
    else:
      print(n+n, a)

Submission status: Wrong Answer

Solution code:
n = int(input())
for i in range(100):
  if n == 1<<i:
    print(-1)
    exit()
l = (n+1).bit_length()-1
ans = []
for i in range(2,2**l):
  ans.append((i-1,i))
  ans.append((n+i-1,n+i))
ans.append((2**l-1,n+1))
m = n-1+(n%2)
for i in range(2**l+1,m+1):
  ans.append((i-1,i))
  ans.append((n+i-1,n+i))
if n != 2**l-1:
  if (m+1)%4 == 0:
    ans.append((1,2**l))
    ans.append((m,n+2**l))
  else:
    ans.append((m+n,1))
    ans.append((1,2**l))
if n>m and (m+1)%4 == 0:
  ans.append((n-2**l,n))
  ans.append((2**l,2*n))
elif n>m:
  ans.append((2,n))
  ans.append((2*n,2*n-1))
for edge in ans:
  print(*edge)

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    k = N.bit_length()

    if 1<<(k-1) == N:
        print('No')
        exit()
    print('Yes')
    if N == 3:
        for i in range(1, 6):
            print(i, i+1)
        exit()

    N0 = 1<<(k-1)
    e = [(N0-1, N+1)]
    for i in range(1, N0-1):
        e.append((i, i+1))
        e.append((i+N, i+1+N))

    for i in range(N0, N+1):
        if i%2 == 0:
            e.append((i, 2))
            e.append((i+N, i+1+N))
        else:
            e.append((i, i-1))
            e.append((i+N, 3+N))
    if N % 2 == 0:
        e.pop()
        e.pop()
        e.append((N, N-2))
        e.append((N+N, 2+N))
    for edge in e:
        print(*edge)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    k = N.bit_length()

    if 1<<(k-1) == N:
        print('No')
        exit()
    print('Yes')
    if N == 3:
        for i in range(1, 6):
            print(i, i+1)
        exit()

    N0 = 1<<(k-1)
    e = [(N0-1, N+1)]
    for i in range(1, N0-1):
        e.append((i, i+1))
        e.append((i+N, i+1+N))

    for i in range(N0, N+1):
        if i%2 == 0:
            e.append((i, 2))
            e.append((i+N, i+1+N))
        else:
            e.append((i, i-1))
            e.append((i+N, 3+N))
    if N % 2 == 0:
        e.pop()
        e.append((N+N, 2+N))
    for edge in e:
        print(*edge)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

if (N & -N) == N:
    print('No')
    sys.exit()

N2 = N if N%2 else N-1
anss = []
for i in range(2, N2+1):
    anss.append((1, i))
for i in range(2, N2+1):
    anss.append((i, (i^1)+N))
anss.append((2+N, 1+N))

if N%2 == 0:
    N2 = N+1
    k = 1<<(N2.bit_length()-1)
    anss.append((N, k))
    anss.append((N, N2^k))

print('Yes')
print('\n'.join(map(lambda x: str(x[0])+' '+str(x[1]), anss)))

Submission status: Wrong Answer

Solution code:
N = int(input())
b = N.bit_length()
if 2 ** (b - 1) == N:
    print('No')
    exit()

ans = [(N + 2, N + 1)]
for i in range(2, N, 2):
    ans.append((1, i))
    ans.append((1, i + 1))
    ans.append((i, N + i + 1))
    ans.append((i + 1, N + i))

if N % 2 == 0:
    ans.append((N, 5))
    ans.append((2 * N, 4))

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

Submission status: Wrong Answer

Solution code:
N = int(input())
b = N.bit_length()
if 2 ** (b - 1) == N:
    print('No')
    exit()

ans = [(2, N + 1)]
for i in range(2, N, 2):
    ans.append((i + 1, i))
    ans.append((1, i + 1))
    ans.append((1, N + i + 1))
    ans.append((N + 1, N + i))

if N % 2 == 0:
    k = 0
    ans.append((N, 5))
    ans.append((2 * N, N + 4))

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

Submission status: Wrong Answer

Solution code:
N = int(input())
b = N.bit_length()
if 2 ** (b - 1) == N:
    print('No')
    exit()

ans = [(N + 2, N + 1)]
for i in range(2, N, 2):
    ans.append((1, i))
    ans.append((1, i + 1))
    ans.append((i, N + i + 1))
    ans.append((i + 1, N + i))

if N % 2 == 0:
    k = 0
    ans.append((N, 5))
    ans.append((2 * N, N + 4))

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=len(bin(n))-2
if 2**(s-1)==n:
  print("No")
elif n==3:
  print("Yes")
  for i in range(1,6):
    print(i,i+1)
else:
  print("Yes")
  print(2**(s-1)-1,1+n)
  for i in range(1,2**(s-1)-1):
    print(i,i+1)
    print(i+n,i+n+1)
  print(2**(s-1),2**(s-1)+1)
  print(2**(s-1)+1,1)
  print(2**(s-1)+n,1)
  print(2**(s-1)+n,2**(s-1)+1+n)
  for i in range(2**(s-1)+2,n+1):
    print(i,i-1+n)
    print(i+n,i-2**(s-1))

Submission status: Wrong Answer

Solution code:
n=int(input())
s=len(bin(n))-2
if 2**(s-1)==n:
  print("No")
else:
  print("Yes")
  print(2**(s-1)-1,1+n)
  for i in range(1,2**(s-1)-2):
    print(i,i+1)
    print(i+n,i+n+1)
  print(2**(s-1),2**(s-1)+1)
  print(2**(s-1)+1,1)
  print(2**(s-1)+n,1)
  print(2**(s-1)+n,2**(s-1)+1+n)
  for i in range(2**(s-1)+2,n+1):
    print(i,i-1+n)
    print(i+n,i-2**(s-1))

Submission status: Wrong Answer

Solution code:
N = int(input())
d = len(bin(N))-2
if N+1 == 2**d:
    print('Yes')
    for i in range(1,2*N):
        print(i,i+1)
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n=int(input())
s=len(bin(n))-2
if n+1==2**s:
  print('Yes')
  for i in range(1,2*n+1):
    print(i,i+1)
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
if n < 3 or n%2 == 0:
	print("No")
else:
	print("Yes")
	for i in range(2, n, 2):
		print(1, i)
		print(i, i+1)
		print(1, n+i+1)
		print(n+i+1, n+i)
	print(3, n+1)

Submission status: Wrong Answer

Solution code:
N = int(input())

if N & (N-1) == 0:
  print("No")
  exit()

print("Yes")
print(1, 2)
print(2, 3)
print(3, N+1)
print(N+1, N+2)
print(N+2, N+3)

for i in range(4, N, 2):
  print(i, i+1)
  print(i+1, N+1)
  print(N+1, N+i)
  print(N+i, N+i+1)

if N % 2 == 0:
  print(N, N-1)
  print(N+N^(N-1)^1, 2*N)

Submission status: Wrong Answer

Solution code:
N = int(input())

if N & (N-1) == 0:
  print("No")
  exit()

print("Yes")
print(1, 2)
print(2, 3)
print(3, N+1)
print(N+1, N+2)
print(N+2, N+3)

for i in range(4, N, 2):
  print(i, i+1)
  print(i+1, N+1)
  print(N+1, N+i)
  print(N+i, N+i+1)

if N % 2 == 0:
  print(N, N-1)
  print(N^(N-1)^1, 2*N)

Submission status: Wrong Answer

Solution code:
N = int(input())

if N & (N-1) == 0:
  print("No")
  exit()

print("Yes")
print(1, 2)
print(2, 3)
print(3, N+1)
print(N+1, N+2)
print(N+2, N+3)

for i in range(4, N, 2):
  print(i, i+1)
  print(i+1, N+1)
  print(N+1, N+i)
  print(N+i, N+i+1)

if N % 2 == 0:
  print(N, N-1)
  print(N+2, 2*N)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n = int(input())
t = n
while t > 0 and t % 2 == 0:
    t //= 2
ans = (t != 1)
print(['No', 'Yes'][ans])
if not ans:
    exit()
print(1, 2)
for i in range(2, n, 2):
    print(i, i + 1)
    print(i + 1, n + 1)
    print(n + 1, n + i)
    print(n + i, n + i + 1)
if n % 2 == 0:
    nob = len(bin(n)[2:])
    a = 1 << (nob - 1)
    b = (n + 1) ^ a
    a = n + a if a % 2 == 0 else a
    b = n + b if b % 2 == 0 else b
    print(n, a)
    print(a, n + 1)
    print(n + 1, b)
    print(b, 2 * n)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n = int(input())
t = n
while t > 0 and t % 2 == 0:
    t //= 2
ans = (t != 1)
print(['No', 'Yes'][ans])
if not ans:
    exit()
print(1, 2)
for i in range(2, n, 2):
    print(i, i + 1)
    print(i + 1, n + 1)
    print(n + 1, n + i)
    print(n + i, n + i + 1)
if n % 2 == 0:
    nob = len(bin(n)[2:])
    a = (1 << nob) - 1
    b = (n + 1) ^ a
    a = n + a if a % 2 == 0 else a
    b = n + b if b % 2 == 0 else b
    print(n, a)
    print(a, n + 1)
    print(n + 1, b)
    print(b, 2 * n)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n = int(input())
t = n
while t > 0 and t % 2 == 0:
    t //= 2
ans = (t != 1)
print(['No', 'Yes'][ans])
if not ans:
    exit()
print(1, 2)
for i in range(2, n, 2):
    print(i, i + 1)
    print(i + 1, n + 1)
    print(n + 1, n + i)
    print(n + i, n + i + 1)
if n % 2 == 0:
    nob = len(bin(n)[2:])
    a = 1 << nob - 1
    b = (n + 1) ^ a
    a = n + a if a % 2 == 0 else a
    b = n + b if b % 2 == 0 else b
    print(n, a)
    print(a, n + 1)
    print(n + 1, b)
    print(b, 2 * n)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n = int(input())
t = n
while t > 0 and t % 2 == 0:
    t //= 2
ans = (t != 1)
print(['No', 'Yes'][ans])
if not ans:
    exit()
print(1, 2)
for i in range(2, n, 2):
    print(i, i + 1)
    print(i + 1, n + 1)
    print(n + 1, n + i)
    print(n + i, n + i + 1)
if n % 2 == 0:
    nob = len(bin(n)[2:])
    a = 1 << nob - 1
    b = (n + 1) ^ a
    print(n, a)
    print(a, n + 1)
    print(n + 1, b)
    print(b, 2 * n)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n = int(input())
t = n
while t > 0 and t % 2 == 0:
    t //= 2
ans = (t != 1)
print(['No', 'Yes'][ans])
if not ans:
    exit()
print(1, 2)
for i in range(2, n, 2):
    print(i, i + 1)
    print(i + 1, n + 1)
    print(n + 1, n + i)
    print(n + i, n + i + 1)
if n % 2 == 0:
    nob = len(bin(n)[2:])
    a = 1 << nob - 1
    b = n ^ a
    print(n, a)
    print(a, n + 1)
    print(n + 1, b)
    print(b, 2 * n)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n = int(input())
t = n
while t > 0 and t % 2 == 0:
    t //= 2
ans = (t != 1)
print(['No', 'Yes'][ans])
if not ans:
    exit()
print(1, 2)
for i in range(2, n, 2):
    print(i, i + 1)
    print(i + 1, n + 1)
    print(n + 1, n + i)
    print(n + i, n + i + 1)
if n % 2 == 0:
    nob = len(bin(n)[2:])
    a = 1 << nob - 1
    b = n ^ a
    print(n, a)
    print(a, 1)
    print(1, b)
    print(b, 2 * n)

Submission status: Wrong Answer

Solution code:
import sys
import math

input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())

def getlist():
    return list(map(int, input().split()))

n = getN() #22

dig_num = math.floor(math.log2(n + 1))  # 5
# print(dig_num)
sen_end = 2 ** (dig_num) - 1  # 15

if 2 ** (dig_num) == n or n == 1:
    print("No")
    sys.exit(0)
else:
    print("Yes")

for i in range(sen_end - 1):
    print(i+1, i+2)  # 1-2, 2-3, ..., 14-15
    print(i+1+n, i+2+n)  # 23-24, 24-25, ..., 36-37

print(n + 1, sen_end)

uni_end = n
if n % 2 == 0:
    uni_end -= 1  # 21

for i in range((uni_end - sen_end) // 2):  # 3 times
    print(1, sen_end + i * 2 + 1)  # 1-16
    print(1, sen_end + i * 2 + 2 + n)  # 1-39
    print(sen_end + i * 2 + 1 + n, sen_end + i * 2 + 2 + n)  # 38-39
    print(sen_end + i * 2 + 1, sen_end + i * 2 + 2)  # 16-17

if n % 2 == 0:
    one_count = 0
    for idx, digit in enumerate(bin(n)[2:]):
        # print(digit, one_count)
        if one_count == 0:
            # print(digit)
            if digit == "1":
                one_count += 1
        else:
            if digit == "1":
                one_goal = dig_num - idx  # second "1" from upper digit
                break

    print(n, 2**one_goal)
    print(2*n, n - 2**one_goal)

Submission status: Wrong Answer

Solution code:
N = int(input())

M = N
while M % 2 == 0 :
    M //= 2
    
if M == 1 or N < 3 :
    print('No')
else :
    print('Yes')
    print(1, 2)
    print(2, 3)
    print(3, 1 + N)
    print(1 + N, 2 + N)
    print(2 + N, 3 + N)
        
    for i in range(4, N, 2) :
        print(1, i)
        print(i, i + 1)
        print(1, N + i + 1)
        print(N + i + 1, N + i)
        
    if N % 2 == 0 :
        print(2, N)
        print(N + (N ^ 1 ^ 2), N * 2)

Submission status: Wrong Answer

Solution code:
N = int(input())

M = N
while M % 2 == 0 :
    M //= 2
    
if M == 1 or N < 3 :
    print('No')
else :
    print('Yes')
    print(1, 2)
    print(2, 3)
    print(3, 1 + N)
    print(1 + N, 2 + N)
    print(2 + N, 3 + N)
        
    for i in range(4, N, 2) :
        print(1, i)
        print(i, i + 1)
        print(1, N + i + 1)
        print(N + i + 1, N + i)
        
    if N % 2 == 0 :
        print(2 * N - 1, N)
        print(2, N)

Submission status: Wrong Answer

Solution code:
N = int(input())

M = N
while M % 2 == 0 :
    M //= 2
    
if M == 1 or N < 3 :
    print('No')
else :
    print('Yes')
    for i in range(1, 4) :
        print(i, i + 1)
        print(N + i, N + i + 1)
        
    for i in range(4, N, 2) :
        print(1, i)
        print(i, i + 1)
        print(1, N + i + 1)
        print(N + i + 1, N + i)
        
    if N % 2 == 0 :
        print(2 * N - 1, N)
        print(2, N)

Submission status: Wrong Answer

Solution code:
N = int(input())

M = N
while M % 2 == 0 :
    M //= 2
    
if M == 1 or N < 3 :
    print(-1)
else :
    for i in range(1, 4) :
        print(i, i + 1)
        print(N + i, N + i + 1)
        
    for i in range(4, N, 2) :
        print(1, i)
        print(i, i + 1)
        print(1, N + i + 1)
        print(N + i + 1, N + i)
        
    if N % 2 == 0 :
        print(2 * N - 1, N)
        print(2, N)

Submission status: Wrong Answer

Solution code:
import sys

def main():
    input = sys.stdin.readline
    N = int(input())

    is_ok = False
    k = 2
    while 2**k - 1 <= N:
        if 2**k - 1 == N:
            is_ok = True
            break
        k += 1

    if is_ok:
        print('Yes')
        for i in range(1, 2*N):
            print('{} {}'.format(i, i+1))
        exit()

    print('No')
    exit()


if __name__ == '__main__':
    print(main())

Submission status: Wrong Answer

Solution code:
n = int(input())
if n < 3 or format(n - 1, "b").count("0") == 0:
    print("No")
    exit()
else:
    print("Yes")
for i in range(1, 3):
    print(i, i + 1)
    print(i + n, i + 1 + n)
print(1, 3 + n)

for i in range(5, n + 1, 2):
    print(1, i - 1)
    print(i - 1, i)
    print(1, i + n)
    print(i + n, i - 1 + n)

if not n % 2:
    a = 1 << (len(format(n + 1, "b")) - 1)
    b = (n + 1) ^ a
    a = a if a % 2 else a + n
    b = b if b % 2 else b + n
    print(a, n)
    print(b, 2 * n)

Submission status: Wrong Answer

Solution code:
n = int(input())
if n < 3 or format(n - 1, "b").count("0") == 0:
    print("No")
    exit()
else:
    print("Yes")
for i in range(1, 3):
    print(i, i + 1)
    print(i + n, i + 1 + n)
print(1, 3 + n)

for i in range(5, n + 1, 2):
    print(1, i - 1)
    print(i - 1, i)
    print(1, i + n)
    print(i + n, i - 1 + n)

if not n % 2:
    a = 1 << (len(format(n + 1, "b")) - 1)
    b = (n + 1) ^ a
    print(a, b)
    a = a if a % 2 else a + n
    b = b if b % 2 else b + n
    print(a, n)
    print(b, 2 * n)

Submission status: Wrong Answer

Solution code:
n = int(input())
if n < 3 or format(n - 1, "b").count("0") == 0:
    print("No")
else:
    print("Yes")
for i in range(1, 3):
    print(i, i + 1)
    print(i + n, i + 1 + n)
print(1, 3 + n)

for i in range(5, n + 1, 2):
    print(1, i - 1)
    print(i - 1, i)
    print(1, i + n)
    print(i + n, i - 1 + n)

if not n % 2:
    a = 1 << (len(format(n + 1, "b")) - 1)
    b = (n + 1) ^ a
    print(a, b)
    a = a if a % 2 else a + n
    b = b if b % 2 else b + n
    print(a, n)
    print(b, 2 * n)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=N
k=0
while(a%2==0):
    a=a//2
    k+=1
#N=a*2**k
if a==1:
    print("No")
else:
    M=2**k
    print("Yes")
    edges=[]
    for i in range(M):
        edges.append((0*M+i,1*M+i))
        edges.append((1*M+i,2*M+i))
        edges.append((2*M+i,0*M+i+N))
        edges.append((0*M+i+N,1*M+i+N))
        edges.append((1*M+i+N,2*M+i+N))
        for j in range(3,a,2):
            edges.append((j*M+i,0*M+i+N))
            edges.append(((j+1)*M+i+N,0*M+i+N))
            edges.append((j*M+i,(j+1)*M+i))
            edges.append(((j+1)*M+i+N,j*M+i+N))
    for i in range(M-1):
        edges.append((i,i+1))
    for ans in edges:
        print(ans[0]+1,ans[1]+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
pow2s = [2**item for item in range(32)]
if n in pow2s:
    print("No")
    exit()
print("Yes")
print(1, n+2)
for i in range(3, n+1, 2):
    print(1, i)
    print(1, i - 1)
    print(i, n + i - 1)
    print(i - 1, n + i)
if n % 2 == 0:
    upper = 1 << (n.bit_length() - 1)
    lower = n ^ 1 ^ upper
    print(upper, n)
    print(lower, n + n)

Submission status: Wrong Answer

Solution code:
from math import log2
N = int(input())

if log2(N) == int(log2(N)):
    print('No')
    exit()