Problem:
Score : 700 points

Problem Statement

You are given an integer N.
Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions:

The graph is simple and connected.

There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S.

It can be proved that at least one such graph exists under the constraints of this problem.

Constraints

All values in input are integers.

3 \leq N \leq 100

Input

Input is given from Standard Input in the following format:

N

Output

In the first line, print the number of edges, M, in the graph you made. In the i-th of the following M lines, print two integers a_i and b_i, representing the endpoints of the i-th edge.

The output will be judged correct if the graph satisfies the conditions.

Sample Input 1

3

Sample Output 1

2
1 3
2 3

For every vertex, the sum of the indices of the vertices adjacent to that vertex is 3.

Solution in C# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using System.Collections.Generic;
using System.Linq;

class Program {
  public Program () { }

  Scanner cin;

  int N;

  static void Main (string[] agrs) {
    new Program ().Do ();
  }

  public void Do () {
    cin = new Scanner ();
    N = cin.nextInt ();

    int M;
    if (N % 2 == 0) {
      M = 2 * N;
      Console.WriteLine (M);
      for (int i = 0; i < N / 2; i++) {
        if (i + 1 < N / 2) {
          Console.WriteLine ("{0} {1}", i + 1, i + 2);
          Console.WriteLine ("{0} {1}", i + 1, N - 1 - i);
          Console.WriteLine ("{0} {1}", N - i, i + 2);
          Console.WriteLine ("{0} {1}", N - i, N - 1 - i);
        } else {
          Console.WriteLine ("{0} {1}", i + 1, 1);
          Console.WriteLine ("{0} {1}", i + 1, N);
          Console.WriteLine ("{0} {1}", N - i, 1);
          Console.WriteLine ("{0} {1}", N - i, N);
        }
      }
    } else {
      M = ((N - 1) / 4) * 8 + (N - 1);
      M = 2 * (N - 1) + 4;
      Console.WriteLine (M);
      for (int i = 0; i < (N - 1) / 2; i++) {
        if (N - 1 == 2) {
          break;
        }
        if (i + 1 < (N - 1) / 2) {
          Console.WriteLine ("{0} {1}", i + 1, i + 2);
          Console.WriteLine ("{0} {1}", i + 1, N - 2 - i);
          Console.WriteLine ("{0} {1}", N - 1 - i, i + 2);
          Console.WriteLine ("{0} {1}", N - 1 - i, N - 2 - i);
        } else {
          Console.WriteLine ("{0} {1}", i + 1, 1);
          Console.WriteLine ("{0} {1}", i + 1, N - 1);
          Console.WriteLine ("{0} {1}", N - 1 - i, 1);
          Console.WriteLine ("{0} {1}", N - 1 - i, N - 1);
        }
      }

      Console.WriteLine ("{0} {1}", N, 1);
      Console.WriteLine ("{0} {1}", N, N - 1);
      Console.WriteLine ("{0} {1}", N, N / 2);
      Console.WriteLine ("{0} {1}", N, N / 2 + 1);
    }
  }
}

class Scanner {
  string[] s;
  int i;
  int max_i;

  public Scanner () {
    s = new string[0];
    max_i = 0;
    i = 0;
  }

  public string nextString () {
    if (i >= s.Length) {
      s = Console.ReadLine ().Split (' ');
      max_i = s.Length;
      i = 0;
      if (max_i == 0) {
        return "";
      }
      return s[i++];
    } else {
      return s[i++];
    }
  }

  public int nextInt () {
    return int.Parse (nextString ());
  }

  public long nextLong () {
    return long.Parse (nextString ());
  }

  public double nextDouble () {
    return double.Parse (nextString ());
  }

  public string[] arrayString () {
    return Console.ReadLine ().Split (' ');
  }

  public int[] arrayInt () {
    string[] str = Console.ReadLine ().Split (' ');
    int[] array = new int[str.Length];
    for (int i = 0; i < str.Length; i++) {
      array[i] = int.Parse (str[i]);
    }
    return array;
  }

  public long[] arrayLong () {
    string[] str = Console.ReadLine ().Split (' ');
    long[] array = new long[str.Length];
    for (int i = 0; i < str.Length; i++) {
      array[i] = long.Parse (str[i]);
    }
    return array;
  }

  public double[] arrayDouble () {
    string[] str = Console.ReadLine ().Split (' ');
    double[] array = new double[str.Length];
    for (int i = 0; i < str.Length; i++) {
      array[i] = double.Parse (str[i]);
    }
    return array;
  }
}