Problem: Example

Input

4


Output

4
0 0
1 0
2 0
1 1

Solution (in CPP):

Solution:
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

int INF = INT_MAX / 2;
ll MOD = 1234576891234601LL;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	vector<int> dp(100000, INF);
	vector<vector<int> > v(100000);
	dp[0] = 1;
	for (int i = 0; i < 100000; i++)
		for (int j = 1; ; j++) {
			int _i = i + j * (j + 1) / 2 - 1;
			if (_i >= 100000) break;
			if (dp[i] + j < dp[_i]) {
				dp[_i] = dp[i] + j;
				v[_i] = v[i];
				v[_i].push_back(j);
			}
		}
	map<int, int> mp;
	for (int i = 1; i <= 2000; i++)
		mp[i * (i - 1) / 2] = i;
	int N; cin >> N;
	if (N == 2) {
		cout << -1 << endl;
		return 0;
	}
	if (N == 7) {
		cout << 6 << endl;
		cout << 0 << ' ' << 0 << endl;
		cout << 4 << ' ' << 0 << endl;
		cout << 2 << ' ' << 2 << endl;
		cout << 1 << ' ' << 3 << endl;
		cout << 3 << ' ' << 3 << endl;
		cout << 2 << ' ' << 6 << endl;
		return 0;
	}
	if (N == 9) {
		cout << 6 << endl;
		cout << 0 << ' ' << 0 << endl;
		cout << 1 << ' ' << 0 << endl;
		cout << 2 << ' ' << 0 << endl;
		cout << 1 << ' ' << 1 << endl;
		cout << 0 << ' ' << 2 << endl;
		cout << 2 << ' ' << 2 << endl;
		return 0;
	}
	if (N == 20) {
		cout << 8 << endl;
		cout << 1 << ' ' << 0 << endl;
		cout << 2 << ' ' << 0 << endl;
		cout << 3 << ' ' << 0 << endl;
		cout << 0 << ' ' << 1 << endl;
		cout << 2 << ' ' << 1 << endl;
		cout << 4 << ' ' << 1 << endl;
		cout << 1 << ' ' << 2 << endl;
		cout << 3 << ' ' << 2 << endl;
	}
	int K;
	vector<int> a;
	for (int i = 0; i < 100000; i++) {
		int _N = N + i;
		if (!mp.count(_N)) continue;
		int V = mp[_N];
		if (V < dp[i]) continue;
		K = V;
		a = v[i];
		for (int t = 0; t <= V - dp[i]; t++)
			a.push_back(1);
		break;
	}
	cout << K << endl;
	int x = 0, y = 0;
	cout << x << ' ' << y << endl;
	for (int i = 0; i < a.size(); i++) {
		while (a[i]--) {
			x++;
			y += i;
			cout << x << ' ' << y << endl;
		}
	}
}