#include <fstream>
#include <cassert>

using namespace std;

const int maxN = 1000;

int main()
{
  ifstream in("selfdual.in");
  int n;
  assert(in >> n);
  assert(1 <= n && n <= maxN);
  in.close();

  ofstream out("selfdual.out");
  if (n % 4 > 1)
    out << "NO" << endl;
  else if (n == 1)
    out << "YES" << endl << "0" << endl << "1" << endl;
  else
  {
    out << "YES" << endl;
    out << (n * (n - 1) / 4) << endl;
    int k = n / 4;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < i; j++)
      {
        int ii = i / k, jj = j / k;
        if (ii == 0 && jj == 0 || ii == 1 && jj == 1 ||
            ii == 2 && jj == 0 || ii == 3 && jj == 1 ||
            ii == 3 && jj == 2 || ii == 4 && jj < 2)
          out << (i + 1) << " " << (j + 1) << endl;
      }
    for (int i = 0; i < n; i++)
    {
      int ii = i / k;
      if (ii == 0)      out << (i + 2 * k + 1);
      else if (ii == 1) out << (i + 2 * k + 1);
      else if (ii == 2) out << (i - 1 * k + 1);
      else if (ii == 3) out << (i - 3 * k + 1);
      else              out << (i + 1);
      if (i + 1 < n) out << " ";
    }
    out << endl;
  }
  out.close();
  return 0;
}
