import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

public class selfdual_sm_large {

	void solve() throws IOException {
		int n = Integer.parseInt(br.readLine());
		if (n % 4 != 0 && n % 4 != 1) {
			out.println("NO");
			return;
		}
		out.println("YES");
		out.println(n * (n - 1) / 4);
		if (n % 4 == 0) {
			for (int i = 0; i < n / 2; i++) {
				for (int j = i + 1; j < n / 2; j++) {
					out.println((i + 1) + " " + (j + 1));
				}
			}
			out.println();
			for (int i = 0; i < n / 2; i++) {
				for (int j = 0; j < n / 4; j++) {
					// System.err.println(i + " " + j);
					out
							.println((i + 1) + " "
									+ (n / 2 + (i + j) % (n / 2) + 1));
				}
			}
			for (int i = 0; i < n / 2; i++) {
				out.print((n / 2 + i + 1) + " ");
			}
			int k = 1;
			for (int i = 0; i < n / 2; i++) {
				out.print(((i + k) % (n / 2) + 1) + " ");
			}
		} else if (n % 4 == 1) {
			int k = n / 4;
			outClique(k + 1, 2 * k);
			outClique(2 * k + 1, 3 * k);
			outBipart(1, k, k + 1, 2 * k);
			outBipart(k + 1, 2 * k, 2 * k + 1, 3 * k);
			outBipart(2 * k + 1, 3 * k, 3 * k + 1, 4 * k);
			outBipart(n, n, k + 1, 2 * k);
			outBipart(n, n, 2 * k + 1, 3 * k);
			for (int i = 0; i < k; i++) {
				out.print((2 * k + i + 1) + " ");
			}
			for (int i = 0; i < k; i++) {
				out.print((i + 1) + " ");
			}
			for (int i = 0; i < k; i++) {
				out.print((3 * k + i + 1) + " ");
			}
			for (int i = 0; i < k; i++) {
				out.print((k + i + 1) + " ");
			}
			out.println(n);
		}
	}

	void outClique(int first, int last) {
		for (int i = first; i <= last; i++) {
			for (int j = i + 1; j <= last; j++) {
				out.println(i + " " + j);
			}
		}
	}

	void outBipart(int Lfirst, int Llast, int Rfirst, int Rlast) {
		for (int i = Lfirst; i <= Llast; i++) {
			for (int j = Rfirst; j <= Rlast; j++) {
				out.println(i + " " + j);
			}
		}
	}

	BufferedReader br;
	PrintWriter out;

	public void run() {
		try {
			br = new BufferedReader(new FileReader("selfdual.in"));
			out = new PrintWriter(new FileWriter("selfdual.out"));
			solve();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public static void main(String[] args) {
		new selfdual_sm_large().run();
	}
}
