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:
n = int(input())

if n % 4 == 3:
  print("Yes")
  for i in range(2*n-1):
    print(" ".join([str(i+1),str(i+2)]))
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())

def init3():
    for i  in range(1,3):
        print(i,i+1)
    print(3,4)
    for i  in range(1,3):
        print(3+i,3+i+1)

def bl_print(n):
    for i in range(0,3):
        print(n+i,n+i+1)
    print(n+3,n+4)
    for i in range(0,3):
        print(n+4+i,n+4+i+1)



def mod3(n):
    init3()
    #print("hoge")
    k = (n-3)//4
    for i in range(k):
        print((i+1)*4+2,(i+1)*4+3)
        bl_print((i+1)*4+3)


if (n%2 == 0 or n == 1):
    print("No")
else:
    print("Yes")
    if (n%4 == 3):
        mod3(n)
    if (n%4 == 1):
        mod3((n-2))
        print(n,n-1)
        print(n-1,1)
        print(1,2*n)
        print(2*n,2*n-1)

Submission status: Wrong Answer

Solution code:
n = int(input())

def init3():
    for i  in range(1,3):
        print(i,i+1)
    print(3,4)
    for i  in range(1,3):
        print(3+i,3+i+1)

def bl_print(n):
    for i in range(0,3):
        print(n+i,n+i+1)
    print(n+3,n+4)
    for i in range(0,3):
        print(n+4+i,n+4+i+1)



def mod3(n):
    init3()
    print("hoge")
    k = (n-3)//4
    for i in range(k):
        print((i+1)*4+2,(i+1)*4+3)
        bl_print((i+1)*4+3)


if (n%2 == 0 or n == 1):
    print("No")
else:
    print("Yes")
    if (n%4 == 3):
        mod3(n)
    if (n%4 == 1):
        mod3((n-2))
        print(n,n-1)
        print(n-1,1)
        print(1,2*n)
        print(2*n,2*n-1)

Submission status: Wrong Answer

Solution code:
N=int(input())
if N==1:
    print("No")
elif N%2==0:
    print("No") 
else:
    print("Yes")
    print("1 2")
    print("2 3")
    line = [3,1+N]
    print(" ".join(map(str,line)))
    line = [1+N,2+N] 
    print(" ".join(map(str,line)))
    line = [2+N,3+N]
    print(" ".join(map(str,line)))
    for i in range((N-3)//2):    
        line = [1,(i+2)*2]              
        print(" ".join(map(str,line)))
        line = [(i+2)*2,(i+2)*2+1]
        print(" ".join(map(str,line)))
        line = [1,(i+2)*2+1+N]  
        print(" ".join(map(str,line)))
        line = [(i+2)*2+N,(i+2)*2+1+N]     
        print(" ".join(map(str,line)))

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())
mod = n % 4

if mod in (0, 2) or n == 1:
    print('No')
    sys.exit()

print('Yes')
for i in range(1, 3):
    print(i, i + 1)
    print(i + n, i + n + 1)
print(3, n + 1)

loop_i = (n - 3) // 4
for i in range(loop_i):
    j_ = 4 + i * 4
    print(j_ - 1, j_)
    print(j_ + 3, j_ + n)
    for j in range(j_, j_ + 3):
        print(j, j + 1)
        print(j + n, j + n + 1)

if mod == 1:
    print(n - 1, n)
    print(n, 1)
    print(1, 2 * n - 1)
    print(2 * n - 1, 2 * n)

Submission status: Wrong Answer

Solution code:
N = int(input())
n = 1<<N.bit_length()-1
if N == n:
    print("No")
else:
    print("Yes")
    # print(n)
    ANS = []
    if N % 2:
        for i in range(1, n-1):
            ANS.append((i, i+1))
        ANS.append((n-1, N+1))
        for i in range(1, n-1):
            ANS.append((i+N, i+N+1))
        for i in range(0, N-n, 2):
            ANS.append((1+N, i+n))
            ANS.append((i+n, i+n+1))
            ANS.append((1+N, i+n+1+N))
            ANS.append((i+n+1+N, i+n+N))
    else:
        a, b, c = N-2, N-1, N
        X = [i for i in range(1, n) if i != a^c] + [c, a]
        # print("X =", X)
        for i in range(n-1):
            ANS.append((X[i], X[i+1]))
        ANS.append((X[n-1], X[0]+N))
        for i in range(n-1):
            ANS.append((X[i]+N, X[i+1]+N))
        for i in range(0, N-n-3, 2):
            ANS.append((1+N, i+n))
            ANS.append((i+n, i+n+1))
            ANS.append((1+N, i+n+1+N))
            ANS.append((i+n+1+N, i+n+N))
        ANS.append((a, a^c))
        ANS.append((c, a^c+N))
        ANS.append((1+N, b))
        ANS.append((a, b+N))
    # print(len(ANS))
    # print(ANS)
    if N == 3:
        ANS = [(1,2),(2,3),(3,4),(4,5),(5,6)]
    for ans in ANS:
        print(*ans)
    # print("len =", len(ANS))

Submission status: Wrong Answer

Solution code:
n=int(input())
if n<=2:
  print("No")
elif n==3:
  print("Yes")
  for i in range(5):
    print(i+1,i+2)
elif n%2==0:
  if 2^3^(n+1)==n:
    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):
      print(1,i)
      if i%2==0:
        print(i,i+n+1)
      else:
        print(i,i+n-1)
    print(2,n)
    print(n+1,2*n)
  elif 3^(n+1)==n:
    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):
      print(1,i)
      if i%2==0:
        print(i,i+n+1)
      else:
        print(i,i+n-1)
    print(3,n)
    print(n+1,2*n)
  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+1):
    print(1,i)
    if i%2==0:
      print(i,i+n+1)
    else:
      print(i,i+n-1)

Submission status: Wrong Answer

Solution code:
n= int(input())
if n%4 == 3:
  print("Yes")
  for i in range(1,2*n):
    print(i,i+1)
elif n%4 == 1 and n>1:
  print("Yes")
  print(n,n-1)
  print(1,n)
  print(2*n-1,1)
  print(n+1,n-1)
  print(2*n,n+1)
  for i in range(n-2,2,-2):
    print(i,i-1)
    print(i-1,n)
    print(n-1,i+n)
    print(i+n,i+n-1)
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())

# if n == 12:
#     print('Yes')
#     l = [12,1,2,3,5,6,7,9,10,11]
#     p = l[:]
#     for i in p:
#         l.append(i + n)
#     m = [4, 8, 12, 16, 20]
#     for i,j in zip(l, l[1:]):
#         print(i, j)
#     for i,j in zip(m, m[1:]):
#         print(i, j)
#     exit()

# if n == 24:
#     print('Yes')
#     l = [24,2,4,6,7,8,9,10,11,13,14,15,17,18,19,21,22]
#     p = l[:]
#     for i in p:
#         l.append(i + n)
#     m = [1,3,5,12,16,20,23]
#     p = m[:]
#     m.append(24)
#     for i in p:
#         m.append(i + n)
#     for i,j in zip(l, l[1:]):
#         print(i, j)
#     for i,j in zip(m, m[1:]):
#         print(i, j)
#     exit()

# if n == 1 or n % 2 == 0:
#     print('No')
#     exit()

l = [False] * (n + 1)
p = [n]
b = bin(n)[2:][::-1]
pw = 0
for i in b:
    if i == '1':
        p.append(2 ** int(pw))
        l[2 ** pw] = True
    pw += 1

q = []
xr = 0
for i in range(1, n):
    if not l[i]:
        xr ^= i
        q.append(i)
# print(xr)
# print(p)
# print(q)
res1 = []
for i in p:
    res1.append(i)
for i in p:
    res1.append(i + n)

res2 = []
if xr == 0:
    res2 = [n]
    for i in q:
        res2.append(i)
    for i in q:
        res2.append(i + n)
else:
    res2 = []
    for i in q:
        res2.append(i)
    res2.append(xr)
    for i in q:
        res2.append(i + n)

res = []
for i,j in zip(res1, res1[1:]):
    res.append([i, j])
    if i == j:
        print('No')
        exit()
    # print(i, j)
for i,j in zip(res2, res2[1:]):
    res.append([i, j])
    if i == j:
        print('No')
        exit()
    # print(i, j)

if len(res) != 2 * n - 1:
    print('No')
else:
    print('Yes')
    for i in res:
        print(*i)

Submission status: Wrong Answer

Solution code:
n = int(input())

k = 2

while pow(2,k)-1 <= n:
    if pow(2,k)-1 == n:
        print("Yes")
        for i in range(2*n-1):
            print(i+1, i+2)
        exit()
    k+=1

print("No")

Submission status: Wrong Answer

Solution code:
N=int(input())
if N==1:
    print("No")
elif N%2==0:
    print("No") 
else:
    print("Yes")
    print("1 2")
    print("2 3")
    print("3 4")
    print("4 5")
    print("5 6")
    for i in range((N-3)//2):    
        line = [1,(i+2)*2]              
        print(" ".join(map(str,line)))
        line = [(i+2)*2,(i+2)*2+1]
        print(" ".join(map(str,line)))
        line = [1,(i+2)*2+1+N]  
        print(" ".join(map(str,line)))
        line = [(i+2)*2+N,(i+2)*2+1+N]     
        print(" ".join(map(str,line)))

Submission status: Wrong Answer

Solution code:
n = int(input())
bl = True
if n <= 2:
    bl = False
elif (n - 3) % 4 == 0:
    x = (n - 3) // 4
    cnt = 2 + 4 * x
    a = list(range(2, 2 + cnt)) + [1] + list(range(2 + n, 2 + n + cnt)) + [1 + n]
    ans = []
    for a1, a2 in zip(a, a[1:]):
        ans.append((a1, a2))
else:
    bl = False

if bl:
    print('Yes')
    for aa in ans:
        print(*aa)
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())

if n == 12:
    print('Yes')
    l = [12,1,2,3,5,6,7,9,10,11]
    p = l[:]
    for i in p:
        l.append(i + n)
    m = [4, 8, 12, 16, 20]
    for i,j in zip(l, l[1:]):
        print(i, j)
    for i,j in zip(m, m[1:]):
        print(i, j)
    exit()

if n == 24:
    print('Yes')
    l = [24,2,4,6,7,8,9,10,11,13,14,15,17,18,19,21,22]
    p = l[:]
    for i in p:
        l.append(i + n)
    m = [1,3,5,12,16,20,23]
    p = m[:]
    m.append(24)
    for i in p:
        m.append(i + n)
    for i,j in zip(l, l[1:]):
        print(i, j)
    for i,j in zip(m, m[1:]):
        print(i, j)
    exit()

if n == 1 or n % 2 == 0:
    print('No')
    exit()

l = [False] * (n + 1)
p = [n]
b = bin(n)[2:][::-1]
pw = 0
for i in b:
    if i == '1':
        p.append(2 ** int(pw))
        l[2 ** pw] = True
    pw += 1

q = []
xr = 0
for i in range(1, n):
    if not l[i]:
        xr ^= i
        q.append(i)
# print(xr)
# print(p)
# print(q)
res1 = []
for i in p:
    res1.append(i)
for i in p:
    res1.append(i + n)

res2 = []
if xr == 0:
    res2 = [n]
    for i in q:
        res2.append(i)
    for i in q:
        res2.append(i + n)
else:
    res2 = []
    for i in q:
        res2.append(i)
    res2.append(xr)
    for i in q:
        res2.append(i + n)

print('Yes')
for i,j in zip(res1, res1[1:]):
    print(i, j)
for i,j in zip(res2, res2[1:]):
    print(i, j)

Submission status: Wrong Answer

Solution code:
n=int(input())
if n<3:
  print("No")
  exit()
if n%2==0:
  print("No")
  exit()
ans=["1 2","2 3","3 "+str(1+n),str(1+n)+" "+str(2+n),str(2+n)+" "+str(3+n)]
for i in range(4,n+1):
  if i%2==0:
    ans.append(str(i)+" "+str(i+1))
    ans.append(str(i+1)+" "+str(1))
    ans.append(str(1)+" "+str(i+n))
    ans.append(str(i+n)+" "+str(i+n+1))
print("Yes")
for i in range(len(ans)):
  print(ans[i])

Submission status: Wrong Answer

Solution code:
n = int(input())
power = [2**i-1 for i in range(2,14) ]
m = 0
for p in power:
  if n % p == 0:
    m = p
    d = n // p
    break
if m == 0:
  print("No")
elif d == 1:
  print("Yes")
  for i in range(2*n-1):
    print(" ".join([str(i+1),str(i+2)]))
else:
  print("Yes")
  for k in range(d): 
    for i in range(m-1):
      print(" ".join([str(k*m+i+1),str(k*m+i+2)]))
      print(" ".join([str(k*m+i+1+n),str(k*m+i+2+n)]))
    print(" ".join([str(k*m+m),str(k*m+n+1)]))
    if k != d-1:
      print(" ".join([str(k*m+1),str(k*m+m+1)]))

Submission status: Wrong Answer

Solution code:
N = input()

if N<=2 or N%2==0:
  print "No"
  exit(0)

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+1, 2):
  print i, i+1
  print i+1, 1
  print 1, N+i
  print N+i, N+i+1

Submission status: Wrong Answer

Solution code:
def is_2power(n: int)->bool:
    a = 1
    while a < n:
        a <<= 1
    return a == n


def skolem_xor_tree(N: int)->list:
    if not is_2power(N+1) or N == 1:
        return []

    return [(a, a+1) for a in range(1, 2*N)]


if __name__ == "__main__":
    N = int(input())

    ans = skolem_xor_tree(N)
    if ans:
        print('Yes')
        for a, b in ans:
            print(a, b)
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N=int(input())
if N==1:
    print("No")
elif N%2==0:
    print("No") 
else:
    print("Yes")
    print("1 2")
    print("2 3")
    print("3 4")
    print("4 5")
    print("5 6")
    for i in range((N-3)//2):    
        line = [1,(i+2)*2]              
        print(" ".join(map(str,line)))
        line = [(i+2)*2,(i+2)*2+1]
        print(" ".join(map(str,line)))
        line = [1,((i+2)*2+1)*2]
        print(" ".join(map(str,line)))
        line = [((i+2)*2)*2,((i+2)*2+1)*2]
        print(" ".join(map(str,line)))

Submission status: Wrong Answer

Solution code:

import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline
mii=lambda:map(int,input().split())

# n=4k+3 <=> the line graph works
# these fail: 1 2 4 8 16 32 ...

# 1 2 3 1 2 3
# 4 5 1 4 5
# 6 7 1 6 7

# so n=2k+1 (except n=1) works

def get(n):
    e=[]
    p=1
    while p*2<=n:
        p*=2
    if n!=p:
        # make line graph
        m=n
        while m%4!=3: m-=1
        for i in range(1,m):
            e.append([i,i+1])
            e.append([n+i,n+i+1])
        e.append([m,n+1])
        if n%4==1 or n%4==2:
            m=n
            if n%4==2: m-=1
            e.append([m-1,m])
            e.append([m,n+1])
            e.append([n+1,n+m-1])
            e.append([n+m-1,n+m])
        if n%4==0 or n%4==2:    # not a power of 2
            t=n-1
            e.append([n,t])
            for i in range(1,n+1):
                t^=i
                if t==n:
                    e.append([n+i,n+n])
                    break
    return e

n=int(input())
e=get(n)
for i,j in e:
    print("%d %d"%(i,j))

"""
def dfs(u):
    vis[u]=1
    root[u]^=(u-1)%n+1
    for v in g[u]:
        if vis[v]: continue
        root[v]=root[u]
        dfs(v)

for n in range(1,50):
    g=[[] for _ in range(2*n+1)]
    e=get(n)
    if not e: continue
    assert len(e)==n*2-1
    for i,j in e:
        g[i].append(j)
        g[j].append(i)
    for i in range(1,n+1):
        vis=[0]*(2*n+1)
        root=[0]*(2*n+1)
        dfs(i)
        assert root[n+i]==i
"""

Submission status: Wrong Answer

Solution code:
N = int(input())

if N % 4 != 3:
    print('No')
else:
    print("Yes")
    for i in range(1, 2 * N):
        print(str(i) + " " + str(i + 1))

Submission status: Wrong Answer

Solution code:
N=int(input())
if N==1:
    print("No")
elif N%2==0:
    print("No")
else:
    print("1 2")
    print("2 3")
    print("3 4")
    print("4 5")
    print("5 6")
    for i in range((N-3)//2):    
        line = [1,(i+2)*2]              
        print(" ".join(map(str,line)))
        line = [(i+2)*2,(i+2)*2+1]
        print(" ".join(map(str,line)))
        line = [1,((i+2)*2+1)*2]
        print(" ".join(map(str,line)))
        line = [((i+2)*2)*2,((i+2)*2+1)*2]
        print(" ".join(map(str,line)))

Submission status: Wrong Answer

Solution code:
n=int(input())
if n<=2:
  print("No")
elif n==3:
  print("Yes")
  for i in range(5):
    print(i+1,i+2)
elif n%2==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+1):
    print(1,i)
    if i%2==0:
      print(i,i+n+1)
    else:
      print(i,i+n-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
if n != 1 and n % 4 != 0:
    print('Yes')
    for i in range(1,2 * n):
        print(str(i) + ' ' + str(i + 1))
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
if n != 1 and n % 2 != 0:
    print('Yes')
    for i in range(1,2 * n):
        print(str(i) + ' ' + str(i + 1))
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from sys import stdout
def main():
    n = int(raw_input())
    if n == 1 or n % 2 == 0:
        print "No"
        return
    print "Yes"
    ans = [(1, 2), (2, 3), (3, n + 1), (n + 1, n + 2), (n + 2, n + 3)]
    for i in xrange(3, n, 2):
        ans.append((1, i + 1))
        ans.append((i + 1, i + 2))
        ans.append((2, i + n + 2))
        ans.append((i + n + 2, i + n + 1))
    stdout.write(''.join('%d %d\n' % (x, y) for x, y in ans))
main()

Submission status: Wrong Answer

Solution code:
N = int(input())
n = 1<<N.bit_length()-1
if N == n:
    print("No")
else:
    print("Yes")
    # print(n)
    ANS = []
    if N % 2:
        for i in range(1, n-1):
            ANS.append((i, i+1))
        ANS.append((n-1, N+1))
        for i in range(1, n-1):
            ANS.append((i+N, i+N+1))
        for i in range(0, N-n, 2):
            ANS.append((1+N, i+n))
            ANS.append((i+n, i+n+1))
            ANS.append((1+N, i+n+1+N))
            ANS.append((i+n+1+N, i+n+N))
    else:
        a, b, c = N-2, N-1, N
        X = [i for i in range(1, n) if i != a^c] + [c, a]
        # print("X =", X)
        for i in range(n-1):
            ANS.append((X[i], X[i+1]))
        ANS.append((X[n-1], X[0]+N))
        for i in range(n-1):
            ANS.append((X[i]+N, X[i+1]+N))
        for i in range(0, N-n-3, 2):
            ANS.append((1+N, i+n))
            ANS.append((i+n, i+n+1))
            ANS.append((1+N, i+n+1+N))
            ANS.append((i+n+1+N, i+n+N))
        ANS.append((a, a^c))
        ANS.append((c, a^c))
        ANS.append((1+N, b))
        ANS.append((a, b))
    # print(len(ANS))
    # print(ANS)
    if N == 3:
        ANS = [(1,2),(2,3),(3,4),(4,5),(5,6)]
    for ans in ANS:
        print(*ans)

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())
if n % 4 != 3:
    print('No')
    sys.exit()

print('Yes')
for i in range(1, 3):
    print(i, i + 1)
    print(i + n, i + n + 1)
print(3, n + 1)

for i in range(n // 4):
    j_ = 4 + i * 4
    print(j_ - 1, j_)
    print(j_ + 3, j_ + n)
    for j in range(j_, j_ + 3):
        print(j, j + 1)
        print(j + n, j + n + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
power = [2**i-1 for i in range(2,14) ]

if n in power:
  print("Yes")
  for i in range(2*n-1):
    print(" ".join([str(i+1),str(i+2)]))
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n= int(input())
if n != 2**(n.bit_length())-1 or n==1:
  print("No")
else:
  print("Yes")
  for i in range(1,2*n):
    print(i,i+1)

Submission status: Wrong Answer

Solution code:
n = int(input())

if bin(n).count('1') == 1:
    print('No')
else:
    print('1 2')
    print('2 3')
    print('3 {0}'.format(n + 1))
    print('{0} {1}'.format(n + 1, n + 2))
    print('{0} {1}'.format(n + 2, n + 3))

    if n >= 5:
        if n % 2 == 1:
            for i in range(4, n + 1):
                print('1 {0}'.format(i))
                if i % 2 == 0:
                    print('{0} {1}'.format(i, i + 1 + n))
                else:
                    print('{0} {1}'.format(i, i - 1 + n))
        else:
            for i in range(4, n):
                print('1 {0}'.format(i))
                if i % 2 == 0:
                    print('{0} {1}'.format(i, i + 1 + n))
                else:
                    print('{0} {1}'.format(i, i - 1 + n))
            print('{0} {1}'.format(n - 1, n))
            print('{0} {1}'.format((n - 1) ^ 1 ^ n, n * 2))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n = int(input())
#a = [int(i) for i in readline().split()]
m = n
while m%2 ==0:
    m//=2
if m == 1:
    print("No")
    exit()
elif n%2:
    print("Yes")
    for i in range(2,n):
        print(i, i+1)
    print(n,1)
    print(1,n+n-1)
    for i in range(2,n,2):
        print(i+n,i+n+1)
    for i in range(2,n-2,2):
        print(i+n,i+n+3)
    print(n+1,n-1)
else:
    m=n-1
    print("Yes")
    for i in range(2,m):
        print(i, i+1)
    print(m,1)
    print(1,m+n-1)
    for i in range(2,m,2):
        print(i+n,i+n+1)
    for i in range(2,m-2,2):
        print(i+n,i+n+3)
    print(n+1,m-1)
    
    c = n^(n-2)^1
    print(c,n)
    if ((n-2)-c-1)%2==1:
        print(n-2,n+n)    
    else:
        print(n+1,n+n)

Submission status: Wrong Answer

Solution code:
N=int(input())
if N%4==3:
    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())

sum = 0
for i in range(1,n+1):
    sum ^= i

if sum != 0:
    print('No')
else:
    print('Yes')
    for i in range(1,(2 * n)):
        print("{} {}".format(i, i+1))

Submission status: Wrong Answer

Solution code:
n = int(input())

if bin(n).count('1') == 1:
    print('No')
else:
    print('1 2')
    print('2 3')
    print('3 {0}'.format(n + 1))
    print('{0} {1}'.format(n + 1, n + 2))
    print('{0} {1}'.format(n + 2, n + 3))

    if n >= 5:
        if n % 2 == 1:
            for i in range(2, n + 1):
                print('1 {0}'.format(i))
                if i % 2 == 0:
                    print('{0} {1}'.format(i, i + 1 + n))
                else:
                    print('{0} {1}'.format(i, i - 1 + n))
        else:
            for i in range(2, n):
                print('1 {0}'.format(i))
                if i % 2 == 0:
                    print('{0} {1}'.format(i, i + 1 + n))
                else:
                    print('{0} {1}'.format(i, i - 1 + n))
            print('{0} {1}'.format(n - 1, n))
            print('{0} {1}'.format((n - 1) ^ 1 ^ n, n * 2))

Submission status: Wrong Answer

Solution code:
import math

N = int(input())

if math.floor(math.log(N, 2)) == math.log(N, 2):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N = int(input())

res = 'Yes'

k = 0

while 2 ** (k + 1) - 1 <= N:
    k += 1

K = 2 ** k - 1

if (N - K) % 2 == 1:
    res = 'No'
if N == 1:
    res = 'No'
# print(N, K)
print(res)

if res == 'Yes':
    for i in range(1, K):
        print(i, i + 1)
    print(K, N + 1)
    for i in range(1, K):
        print(N + i, N + i + 1)
    if N > K and (N - K) % 4 == 2:
        print(1, K + 1)
        for i in range(K + 1, N):
            print(i, i + 1)
        for i in range(K + 1, N):
            print(N + i, N + i + 1)
        print(2 * N, 1)
    elif N > K:
        print(1, K + 1)
        for i in range(K + 1, N - 2):
            print(i, i + 1)
        for i in range(K + 1, N - 2):
            print(N + i, N + i + 1)
        print(2 * N - 2, 1)
        print(N + 1, N - 1)
        print(N - 1, N)
        print(2 * N - 1, 2 * N)
        print(2 * N, N + 1)

Submission status: Wrong Answer

Solution code:
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict, Counter
from bisect import bisect

setrecursionlimit(10**6)

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N = read()

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

assert N >= 3
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(1, i)
  print(i, i+1)
  
  print(1, N + i+1)
  print(N + i+1, N + i)

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
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

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

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

    return

#C
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:
        if n%4:
            ans.append((n-1,n))
            ans.append((2,2*n))
            print("Yes")
            for i,j in ans:
                print(i,j)
        else:
            print("No")
    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    C()

Submission status: Wrong Answer

Solution code:
N = int(input())

res = 'Yes'

k = 0

while 2 ** (k + 1) - 1 <= N:
    k += 1

K = 2 ** k - 1

if (N - K) % 2 == 1:
    res = 'No'
if N == 1:
    res = 'No'
# print(N, K)
print(res)

if res == 'Yes':
    for i in range(1, K):
        print(i, i + 1)
    print(K, N + 1)
    for i in range(1, K):
        print(N + i, N + i + 1)
    if N > K and (N - K) % 4 == 2:
        print(1, K + 1)
        for i in range(K + 1, N):
            print(i, i + 1)
        for i in range(K + 1, N):
            print(N + i, N + i + 1)
        print(2 * N, 1)
    else:
        print(1, K + 1)
        for i in range(K + 1, N - 2):
            print(i, i + 1)
        for i in range(K + 1, N - 2):
            print(N + i, N + i + 1)
        print(2 * N - 2, 1)
        print(N + 1, N - 1)
        print(N - 1, N)
        print(2 * N - 1, 2 * N)
        print(2 * N, N + 1)

Submission status: Wrong Answer

Solution code:
N=int(input())
L=[str(bin(i))[2:] for i in range(1,N+1)]
dic=dict([(i,0) for i in range(30)])
for s in L:
    for i,c in enumerate(s[::-1]):
        if c=='1':
            dic[i]+=1
for i in dic.values():
    if i%2==1:
        print("No")
        exit(0)
else:
    print("Yes")
    for i in range(1,2*N):
        print(i,i+1)

Submission status: Wrong Answer

Solution code:
N=int(input())
L=[str(bin(i))[2:] for i in range(1,N+1)]
dic=dict([(i,0) for i in range(30)])
for s in L:
    for i,c in enumerate(s[::-1]):
        if c=='1':
            dic[i]+=1
for i in dic.values():
    if i%2==1:
        print("No")
        exit(0)
else:
    print("Yes")
    for i in range(1,N):
        print(i,i+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
if bin(n).count('1') == 1:
    print("No")
else:
    print("Yes")
    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:
        print(n, n + 2)
        print(n - 1, n * 2)

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
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

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

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

    return

#C
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:
        for i in range(n):
            if p[i]&n:
                break
        ans.append((n-1,n))
        ans.append((p[i],2*n))
        print("Yes")
        for i,j in ans:
            print(i,j)

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    C()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

sum = 0
for i in range(1,n+1):
    sum ^= i

if sum != 0:
    print('No')
else:
    for i in range(1,(2 * n)):
        print("{} {}".format(i, i+1))

Submission status: Wrong Answer

Solution code:
import sys, collections

def solve():
    input = sys.stdin.readline
    N = int(input())
    if N % 2 == 0 or N == 1: print("No")
    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 + 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)


    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
N = int(input())

res = 'Yes'

k = 0

while 2 ** (k + 1) - 1 <= N:
    k += 1

K = 2 ** k - 1

if (N - K) % 2 == 1:
    res = 'No'
if N == 1:
    res = 'No'
# print(N, K)
print(res)
if res == 'Yes':
    for i in range(1, K):
        print(i, i + 1)
    print(K, N + 1)
    for i in range(1, K):
        print(N + i, N + i + 1)
    if N > K:
        print(1, K + 1)
        for i in range(K + 1, N):
            print(i, i + 1)
        for i in range(K + 1, N):
            print(N + i, N + i + 1)
        print(2 * N, 1)

Submission status: Wrong Answer

Solution code:
n = int(input())

sum = 0
for i in range(1,n):
    sum ^= i

if sum != 0:
    print('No')
else:
    for i in range(1,(2 * n)):
        print("{} {}".format(i, i+1))