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: Accepted)

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;

int main(){
    cin >> n;
    // vector<P> vp;
    // rep(i,n)FOR(j,i+1,n)vp.push_back(P(i,j));
    // cout << vp.size() << endl;
    // rep(i,(1LL << (n*(n-1) / 2))){
    //     vector<ll> cnt(n,0);
    //     rep(j,n*(n-1)/2){
    //         if(i & (1LL << j)){
    //             ll a = vp[j].first;
    //             ll b = vp[j].second;
    //             cnt[a] += (b+1);
    //             cnt[b] += (a+1);
    //         }
    //     }
    //     bool f = true;
    //     // cout << i << ":";
    //     // rep(i,n)cout << cnt[i] << " ";
    //     // cout << endl;
    //     rep(i,n-1)if(cnt[i+1] != cnt[i])f = false;
    //     if(f){
    //         rep(j,n*(n-1)/2){
    //             if(i & (1LL << j)){
    //                 ll a = vp[j].first;
    //                 ll b = vp[j].second;
    //                 cout << a+1 << " " << b+1 << endl;
    //             }
    //         }
    //     }
    // }
    vector<P> ans;
    FOR(i,1,n - n % 2 + 1){
        FOR(j,i+1,n - n % 2 + 1){
            if(j != n - n % 2-i+1)ans.push_back(P(i,j));
        }
    }
    if(n%2){
        FOR(i,1,n - n % 2 + 1){
            ans.push_back(P(i,n));
        }
    }
    cout << ans.size() << endl;
    rep(i,ans.size()){
        cout << ans[i].first << " " << ans[i].second << endl;
    }
}