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:
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op


# globals
inf = float('inf')
input = stdin.readline


def main():
    n = get_int()
    m = n.bit_length()
    if 2 ** (m - 1) == n:
        print('No')
        return
    print('Yes')
    if m == 2:
        # no node between 1 and N + 1
        for i in range(1, 6):
            print(i, i + 1)
        return
    for i in range(1, 2 ** (m - 1) - 1):
        print(i, i + 1)
        print(n + i, n + i + 1)
    print(2 ** (m - 1) - 1, n + 1)
    x = 1
    if n % 2 == 0:
        x = 2
    for i in range(2 ** (m - 1), n, 2):
        print(x, i)
        print(i, i + 1)
        print(x, n + i + 1)
        print(n + i + 1, n + i)
    if n % 2 == 0:
        print(x, n)
        print(2 ** (m - 1), n)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def gets(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
if n<3:
  print("No")
  exit()
if n%2!=0:
  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+n))
      ans.append(str(1+n)+" "+str(i+n))
      ans.append(str(i+n)+" "+str(i+n+1))
  print("Yes")
  for i in range(len(ans)):
    print(ans[i])
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
if n<3:
  print("No")
  exit()
if n%2==0:
  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+n))
      ans.append(str(1+n)+" "+str(i+n))
      ans.append(str(i+n)+" "+str(i+n+1))
  print("Yes")
  for i in range(len(ans)):
    print(ans[i])
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n=int(input())
if n<3:
  print("No")
  exit()
if n%2==0:
  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])
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((1, 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())
if n<3:
  print("No")
  exit()
if n-3%2==0:
  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+n))
      ans.append(str(1+n)+" "+str(i+n))
      ans.append(str(i+n)+" "+str(i+n+1))
  print("Yes")
  for i in range(len(ans)):
    print(ans[i])
else:
  print("No")

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)]))
if n % 4 == 2 and n > 3:
  print("Yes")
  print(" ".join([str(2),str(1)]))
  print(" ".join([str(n+2),str(n+1)]))
  print(" ".join([str(1),str(3)]))
  print(" ".join([str(n+1),str(n+3)]))
  for i in range(2,n-4):
    print(" ".join([str(i+1),str(i+2)]))
    print(" ".join([str(n+i+1),str(n+i+2)]))
  print(" ".join([str(n-3),str(n+1)]))
  print(" ".join([str(1),str(n-2)]))
  print(" ".join([str(n-2),str(n-1)]))
  print(" ".join([str(2),str(n)]))
  print(" ".join([str(1),str(2*n-1)]))
  print(" ".join([str(2*n-1),str(2*n-2)]))
  print(" ".join([str(n-2),str(2*n)]))
else:
  print("No")

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op


# globals
inf = float('inf')
input = stdin.readline


def main():
    n = get_int()
    m = n.bit_length()
    if 2 ** (m - 1) == n:
        print('No')
        return
    print('Yes')
    for i in range(1, 2 ** (m - 1) - 1):
        print(i, i + 1)
        print(n + i, n + i + 1)
    print(2 ** (m - 1) - 1, n + 1)
    x = 1
    if n % 2 == 0:
        x = 2
    for i in range(2 ** (m - 1), n, 2):
        print(x, i)
        print(i, i + 1)
        print(x, i + 1)
        print(i + 1, i)
    if n % 2 == 0:
        print(x, n)
        print(2 ** (m - 1), n)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def gets(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())

for i in range(n):
    pot = i
    lst = []
    for j in range(i-1,n+i):
        pot = pot^j
        lst.append(pot)
    if pot == i:
        print('Yes')
        if i%3 == 1:
            lst_all=[lst[0],lst[1],lst[2]]*n
            for k in range(2*n):
                print(k,lst_all[k])
        elif i%3 == 2:
            lst_all=[lst[2],lst[0],lst[1]]*n
            for k in range(2*n):
                print(k,lst_all[k])
        else:
            lst_all=[lst[1],lst[2],lst[0]]*n
            for k in range(2*n):
                print(k,lst_all[k])

Submission status: Wrong Answer

Solution code:
n=int(input())
if n<=2 or n==4:
  print("No")
elif n==3:
  print("Yes")
  for i in range(5):
    print(i+1,i+2)
elif n%2==0:
  if 4<=n^1<=n-1:
    m=n^1
    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(1,n)
    print(m,2*n)
  
  elif 4<=n^3<=n-1:
    m=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):
      print(1,i)
      if i%2==0:
        print(i,i+n+1)
      else:
        print(i,i+n-1)
    print(2,n)
    print(m,2*n)
  
  elif 4<=n^2<=n-1:
    m=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):
      print(1,i)
      if i%2==0:
        print(i,i+n+1)
      else:
        print(i,i+n-1)
    print(2,n)
    print(n+2,2*n)
  
  else:   
    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<3:
  print("No")
  exit()
if n-3%2==0:
  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])
elif n<n^3:
  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==n+1:
      ans.append(str(i^3)+" "+str(i))
      ans.append(str(2)+" "+str(i+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])
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):
        if (i + 1) & 3 == 0:
            ans.append((2, i + 1))
            ans.append((i + 1, i + 2))
            ans.append((3, i + n + 2))
            ans.append((i + n + 2, i + n + 1))
        else:
            ans.append((1, i + 1))
            ans.append((i + 1, i + 2))
            ans.append((n + 1, 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())
if n<3:
  print("No")
  exit()
if n-3%2==0:
  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])
elif n<n^3:
  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==n+1:
      ans.append(str(i^3)+" "+str(i))
      ans.append(str(2)+" "+str(i+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())

if N < 3:
  print('No')
  exit()

arr = {}
for i in range(1, 2*N+1):
  arr[i] = (i%N if i%N != 0 else N)

ans = []
for i in range(1, 2*N+1):
  if i not in arr: continue
  ans.append(i)
  tmp = []
  a = 0
  flg = False
  for j in range(i+1, 2*N+1):
    if a == arr[i] and (a^arr[j]) == 0:
      flg = True
      tmp.append(j)
      for t in tmp:
        key= [k for k, v in arr.items() if v == t]
        if len(key) > 0:tmp.append(key[1])
      ans.extend(tmp)
      break
    tmp.append(j)
    a = a^arr[j]
  if flg == False:
    ans = []
    break
  for a in ans:
    if a in arr: del arr[a]

if len(ans) == 0:
  print('No')
else:
  print('Yes')
  for i in range(len(ans)-1):
    print('{} {}'.format(ans[i], ans[i+1]))

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):
        if (i + 1) & 3 == 0:
            ans.append((2, i + 1))
            ans.append((i + 1, i + 2))
            ans.append((3, i + n + 2))
            ans.append((i + n + 2, i + n + 1))
        else:
            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())

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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 = []
res2 = []
if xr == 0:
    for i in p:
        res1.append(i)
    for i in p:
        res1.append(i + n)
    res2 = [n]
    for i in q:
        res2.append(i)
    for i in q:
        res2.append(i + n)
else:
    if xr in p:
        for i in p:
            res1.append(i)
        for i in p:
            res1.append(i + n)
        res2 = []
        for i in q:
            res2.append(i)
        res2.append(xr)
        for i in q:
            res2.append(i + n)
    else:
        if xr > n:
            print('No')
            exit()
        b = bin(xr)[2:][::-1]
        res2 = []
        for i in q:
            res2.append(i)
        qq = []
        pw = 0
        for i in b:
            if i == '1':
                qq.append(2 ** int(pw))
                # l[2 ** pw] = True
            pw += 1
        for i in qq:
            res2.append(i)
        for i in q:
            res2.append(i + n)
        qq.append(n)
        res1_tmp = [n]
        for i in qq:
            res1_tmp.append(i)
        for i in p:
            if i in res1_tmp:
                continue
            res1_tmp.append(i)
        for i in res1_tmp:
            res1.append(i)
        for i in res1_tmp:
            res1.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 = input()

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

for i in range(100):
  if 2**i==N:
    print "No"
    exit(0)

print "Yes"

print 1, 3
print 3, 2
print 2, N+1
print N+1, N+3
print N+3, N+2

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

if N%2==0:
  print N, N-2
  print 3, N+N

Submission status: Wrong Answer

Solution code:
N = int(input())
def judge(N):
  if N <= 2:
    print('No')
    return
  if N % 2 == 0:
    print('No')
    return
  print('Yes')
  for k in range(2, 18):
    if 2 ** k > N + 1:
       break
  K = 2 ** (k - 1) - 1
  for i in range(1, K):
    print('{} {}'.format(i, i + 1))
    print('{} {}'.format(i + N, i + 1 + N))
  print('{} {}'.format(K, N + 1))
  if K < N:
    for i in range(K + 1, N + 1):
      print('{} {}'.format(i, 1 if i % 2 else i + 1))
      print('{} {}'.format(i + N, 1 if i % 2 == 0 else i - 1 + N))
judge(N)

Submission status: Wrong Answer

Solution code:
n = int(input())

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 = []
res2 = []
if xr == 0:
    for i in p:
        res1.append(i)
    for i in p:
        res1.append(i + n)
    res2 = [n]
    for i in q:
        res2.append(i)
    for i in q:
        res2.append(i + n)
else:
    if xr in p:
        for i in p:
            res1.append(i)
        for i in p:
            res1.append(i + n)
        res2 = []
        for i in q:
            res2.append(i)
        res2.append(xr)
        for i in q:
            res2.append(i + n)
    else:
        if xr > n:
            print('No')
            exit()
        b = bin(xr)[2:][::-1]
        res2 = []
        for i in q:
            res2.append(i)
        qq = []
        pw = 0
        for i in b:
            if i == '1':
                qq.append(2 ** int(pw))
                # l[2 ** pw] = True
            pw += 1
        for i in qq:
            res2.append(i)
        for i in q:
            res2.append(i + n)
        qq.append(n)
        res1_tmp = [n]
        for i in qq:
            res1_tmp.append(i)
        for i in p:
            if i in res1_tmp:
                continue
            res1_tmp.append(i)
        for i in res1_tmp:
            res1.append(i)
        for i in res1_tmp:
            res1.append(i + n)
exit()

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

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

print "Yes"

print 1, 3
print 3, 2
print 2, N+1
print N+1, N+3
print N+3, N+2

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

if N%2==0:
  print N, N-2
  print 3, N+N

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((2, i + 1))
        ans.append((i + 1, i + 2))
        ans.append((3, 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())

def init3 (n):
    print(1,2)
    print(2,3)
    print(3,n+1)
    print(n+1,n+2)
    print(n+2,n+3)

def prop(k,n):
    print(k+n-1,k)
    for i in range(3):
        print(k+i,k+i+1)
    print(k+3,k+n)
    for i in range(3):
        print(k+n+i,k+n+i+1)

def mod3(n):
    init3(n)
    k = (n-3)//4
    for i in range(k):
        prop((i+1)*4,n)

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

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

print "Yes"

print 1, 3
print 3, 2
print 2, N+1
print N+1, N+3
print N+3, N+2

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

if N%2==0:
  print N, N-2
  print 3, N+N

Submission status: Wrong Answer

Solution code:
n = int(input())

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 = []
res2 = []
if xr == 0:
    for i in p:
        res1.append(i)
    for i in p:
        res1.append(i + n)
    res2 = [n]
    for i in q:
        res2.append(i)
    for i in q:
        res2.append(i + n)
else:
    if xr in p:
        for i in p:
            res1.append(i)
        for i in p:
            res1.append(i + n)
        res2 = []
        for i in q:
            res2.append(i)
        res2.append(xr)
        for i in q:
            res2.append(i + n)
    else:
        b = bin(xr)[2:][::-1]
        res2 = []
        for i in q:
            res2.append(i)
        qq = []
        pw = 0
        for i in b:
            if i == '1':
                qq.append(2 ** int(pw))
                # l[2 ** pw] = True
            pw += 1
        for i in qq:
            res2.append(i)
        for i in q:
            res2.append(i + n)
        qq.append(n)
        res1_tmp = [n]
        for i in qq:
            res1_tmp.append(i)
        for i in p:
            if i in res1_tmp:
                continue
            res1_tmp.append(i)
        for i in res1_tmp:
            res1.append(i)
        for i in res1_tmp:
            res1.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:
import sys

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

if n == 1 or n == 2 or mod == 0:
    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)
elif mod == 2:
    print(n - 2, n)
    print(n, 2)
    print(2, 2 * n - 2)
    print(2 * n - 2, 2 * n)
    print(3, n - 1)
    print(2 * n - 2, 2 * n - 1)

Submission status: Wrong Answer

Solution code:
pow2 = [2**i - 1 for i in range(20)]
N = int(input())
rest = 0
base = 0
if N == 1 or N == 2:
	print("No")
	exit()
for i in range(1,20):
	if pow2[i] + 1 == N:
		print("No")
		exit()
	if pow2[i] < N:
		continue
	if pow2[i] == N:
		base = pow2[i]
		print("Yes")
		break
	base = pow2[i-1]
	rest = N - (pow2[i-1] + 1)
	if rest in pow2:
		print("Yes")
		break
	print("No")
	exit()
base_list = [x+1 if x < base else N+(x%base)+1 for x in range(2*base)]
for i in range(len(base_list)-1):
	print(base_list[i], base_list[i+1])
if rest > 0:
	start = base + 1
	end = N
	for i in range(start, end+1):
		if i < end:
			print(i, i+1)
		else:
			print(i, rest)
	for i in range(start, end+1):
		if i > start:
			print(N+i, N+i+1)
		else:
			print(rest, N+i)

Submission status: Wrong Answer

Solution code:

n = int(input())

if n % 3 == 0:
    for i in range(2*n-1):
        print(i+1,i+2)
else:
    print(-1)

Submission status: Wrong Answer

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

def init3 (n):
    print(1,2)
    print(2,3)
    print(3,n+1)
    print(n+1,n+2)
    print(n+2,n+3)

def prop(k,n):
    print(k+n-1,k)
    for i in range(3):
        print(k+i,k+i+1)
    print(k+3,k+n)
    for i in range(3):
        print(k+n+i,k+n+i+1)

def mod3(n):
    init3(n)
    k = (n-3)//4
    for i in range(k):
        prop((i+1)*4,n)

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:
pow2 = [2**i - 1 for i in range(20)]
N = int(input())
rest = 0
if N == 1 or N == 2:
	print("No")
	exit()
for i in range(1,20):
	if pow2[i] + 1 == N:
		print("No")
		exit()
	if pow2[i] < N:
		continue
	if pow2[i] == N:
		print("Yes")
		break
	rest = N - (pow2[i-1] + 1)
	if rest in pow2:
		print("Yes")
		break
	print("No")
	exit()
base = N - rest - 1
base_list = [x+1 if x < base else N+(x%base)+1 for x in range(2*base)]
for i in range(len(base_list)-1):
	print(base_list[i], base_list[i+1])
if rest > 0:
	start = base + 1
	end = N
	for i in range(start, end+1):
		if i < end:
			print(i, i+1)
		else:
			print(i, rest)
	for i in range(start, end+1):
		if i > start:
			print(N+i, N+i+1)
		else:
			print(rest, N+i)

Submission status: Wrong Answer

Solution code:
import sys

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

if n == 1 or n == 2 or mod == 0:
    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)
elif mod == 2:
    print(n - 2, n)
    print(n, 2)
    print(2, 2 * n - 2)
    print(2 * n - 2, 2 * n)
    print(1, n - 1)
    print(2 * n - 2, 2 * n - 1)

Submission status: Wrong Answer

Solution code:
a = int(input())
def ch(n):
    return (n >2 and (n-3)%4==0)

if not ch(a):
    print("No")
else:
    print("Yes")
    for i in range(a*2-1):
        print(i+1,i+2)

Submission status: Wrong Answer

Solution code:
n = int(input())

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)
    if xr not in p:
        print('No')
        exit()
    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())
if n%4==3:
    print("Yes")
    for i in range(n*2-1):
        print(str(i+1)+" "+str(i+2))
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = input()

if bin(n).count('1') == 1:
    print "No"
    exit(0)

print "Yes"

for i in xrange(1, 3):
    print i, i + 1
    print i+n, i+n+1

print 3, 3 + n

for i in xrange(4, n, 2):
    print i, i + 1
    print i + 1, 1
    print 1, i + n
    print i + n, i + 1 + n

if n % 2 == 0:
    print n, n - 1
    print (n ^ (n - 1) ^ 1) + n, 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:
pow2 = [2**i - 1 for i in range(20)]
N = int(input())
rest = 0
if N == 1:
	print("No")
	exit()
for i in range(1,20):
	if pow2[i] < N:
		continue
	if pow2[i] == N:
		print("Yes")
		break
	rest = N - (pow2[i-1] + 1)
	if rest in pow2:
		print("Yes")
		break
	print("No")
	exit()
base = N - rest - 1
base_list = [x+1 if x < base else N+(x%base)+1 for x in range(2*base)]
for i in range(len(base_list)-1):
	print(base_list[i], base_list[i+1])
if rest > 0:
	start = base + 1
	end = N
	for i in range(start, end+1):
		if i < end:
			print(i, i+1)
		else:
			print(i, rest)
	for i in range(start, end+1):
		if i > start:
			print(N+i, N+i+1)
		else:
			print(rest, N+i)

Submission status: Wrong Answer

Solution code:
n= int(input())
if n%2 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:
import sys
# input = sys.stdin.readline
# inf = 10 ** 18
# P = 10 ** 9 + 7

N = int(input())

cnt = [0] * 32
for i in range(1, N + 1):
    for i_bit in range(32):
        cnt[i_bit] += (i >> i_bit) & 1

for cnti in cnt:
    if cnti % 2:
        print('No')
        break
else:
    print('Yes')
    for i in range(1, 2 * N):
        print(i, i + 1)