Problem:
Score : 700 points

Problem Statement

You are given an integer N. Determine if there exists a tree with 2N vertices numbered 1 to 2N satisfying the following condition, and show one such tree if the answer is yes.

Assume that, for each integer i between 1 and N (inclusive), Vertex i and N+i have the weight i. Then, for each integer i between 1 and N, the bitwise XOR of the weights of the vertices on the path between Vertex i and N+i (including themselves) is i.

Constraints

N is an integer.

1 \leq N \leq 10^{5}

Input

Input is given from Standard Input in the following format:

N

Output

If there exists a tree satisfying the condition in the statement, print Yes; otherwise, print No.
Then, if such a tree exists, print the 2N-1 edges of such a tree in the subsequent 2N-1 lines, in the following format:

a_{1} b_{1}
\vdots
a_{2N-1} b_{2N-1}

Here each pair (a_i, b_i) means that there is an edge connecting Vertex a_i and b_i. The edges may be printed in any order.

Sample Input 1

3

Sample Output 1

Yes
1 2
2 3
3 4
4 5
5 6

The sample output represents the following graph:

Sample Input 2

1

Sample Output 2

No

There is no tree satisfying the condition.

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
vector<int>G[200001];
void make(int x,int a,int b){
	if(a==1&&b==0){
		REP(i,x-1){
			G[i].push_back(i+1);
		}
		G[x-1].push_back(N+0);
		REP(i,x-1){
			G[N+i].push_back(N+i+1);
		}
	}else{
		REP(i,x-1){
			G[i+b].push_back(i+b+1);
		}
		G[b+x-1].push_back(N+b+0);
		REP(i,x-1){
			G[N+i+b].push_back(N+i+b+1);
		}
		G[b].push_back(a);
		G[N+x-1].push_back(b-1);
	}
}

LL get(int x){
	LL now=1;
	while(1){
		if(x<now-1){
			break;;
		}
		now*=2;
	}
	now/=2;
	return now;
}

int main(){
	cin>>N;
	LL T=2*N;
	if(N%4==2||N%4==1){
		cout<<-1<<endl;
	}else{
		int a=1;
		int b=0;
		int X;
		while(N!=0){
			//Nの最上位ビットを取り出す
			LL M=get(N);
			//cout<<M<<endl;
			make(M-1,a,b);
			N-=M-1;
			b+=M;
		}
		//cout<<"aa"<<endl;
		//出力
		REP(i,T){
			REP(j,G[i].size()){
				cout<<i+1<<" "<<G[i][j]+1<<endl;
			}
		}
		
	}
	return 0;
}