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++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MAX = 500010;
const int MOD = (ll)1e9 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;

typedef pair<int, int>P;

int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };





vector<int>v[1010];
vector<int>ans[1010];
signed main() {
	int N; cin >> N;
	if (N % 2 == 0) {
		int k = N / 2;
		REP(i, k) {
			v[i].pb(i + 1); v[i].pb(k - i);
		}
		int cnt = 0;
		REP(i, k-1) {
			for (auto x : v[i]) {
				for (auto y : v[i + 1]) {
					cnt++;
				}
			}
		}
		if (k > 2) {
			for (auto x : v[k - 1]) {
				for (auto y : v[0]) {
					cnt++;
				}
			}
		}
		print(cnt);
		REP(i, k - 1) {
			for (auto x : v[i]) {
				for (auto y : v[i + 1]) {
					pe(x); print(y);
				}
			}
		}
		if (k > 2) {
			for (auto x : v[k - 1]) {
				for (auto y : v[0]) {
					pe(x); print(y);
				}
			}
		}
	}
	if (N % 2 == 1) {
		int k = N / 2 + 1;
		REP(i, k-1) {
			v[i].pb(i + 1); v[i].pb(N - i - 1);
		}
		v[k - 1].pb(N);
		int cnt = 0;
		REP(i, k - 1) {
			for (auto x : v[i]) {
				for (auto y : v[i + 1]) {
					cnt++;
				}
			}
		}
		if (k > 2) {
			for (auto x : v[k - 1]) {
				for (auto y : v[0]) {
					cnt++;
				}
			}
		}
		print(cnt);
		REP(i, k - 1) {
			for (auto x : v[i]) {
				for (auto y : v[i + 1]) {
					pe(x); print(y);
				}
			}
		}
		if (k > 2) {
			for (auto x : v[k - 1]) {
				for (auto y : v[0]) {
					pe(x); print(y);
				}
			}
		}
	}
}