#include "testlib.h"
#include <bits/stdc++.h>

using namespace std;

const int MIN_N = 1;
const int MAX_N = 1e5;
const int MIN_COORD = -1e9;
const int MAX_COORD = 1e9;

const int rnd_test_n = 30;

template <typename T> void append(vector<T> &dest, const vector<T> &orig) {
	dest.insert(dest.end(), orig.begin(), orig.end());
}

string output_tc(const vector<pair<int, int>> &coords) {
	ostringstream oss;
    oss << coords.size() << endl;
    for (const auto [x, y] : coords) {
        oss << x << " " << y << endl;
    }
	return oss.str();
}

vector<string> generate_sample_tests() {
	vector<string> tests;
    tests.push_back(output_tc({{1, 1}, {2, 2}, {3, 3}}));
	return tests;
}

vector<string> generate_manual_tests() {
    vector<string> tests;
	tests.push_back(output_tc({{-1, 3}, {1, 1}, {2, 4}, {3, 2}, {4, 5}})); // expected answer is 7
    tests.push_back(output_tc({{3, -6}, {4, 9}, {9, -9}, {1, -7}, {-3, 2}})); // expected answer is 4
	tests.push_back(output_tc({{-1, -3}, {-2, -2}, {-3, -1}, {1, 3}, {2, 2}, {3, 1}})); // expected answer is 9
    tests.push_back(output_tc({{1, 1}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}}));
    tests.push_back(output_tc({{1, 1}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {6, 1}}));
	return tests;
}

vector<pair<int, int>> generate_random_points_array(int size) {
    vector<pair<int, int>> coords(size);
    for (int i = 0; i < size; i++) {
        int x = rnd.next(MIN_COORD, MAX_COORD);
        int y = rnd.next(MIN_COORD, MAX_COORD);
        coords[i] = {x, y};
    }
    return coords;
}

string rnd_test(int i){
    int min_n = MIN_N;
    int max_n = MAX_N;
    
    if(i<rnd_test_n / 3){
        max_n = 50;
    }
    else if(i<rnd_test_n / 2){
        max_n = 500;
    }

    int n = rnd.next(min_n, max_n);
    return(output_tc(generate_random_points_array(n)));
}

vector<string> generate_random_tests() { 
    vector<string> tests;
    for (int i = 0; i < rnd_test_n; i++){
        tests.push_back(rnd_test(i));
    } 
    return tests;
}

string extreme_test_1(){
    return(output_tc(generate_random_points_array(MAX_N)));
}

string extreme_test_2(){
    vector<pair<int, int>> coords(MAX_N);
    for (int i = 0; i < MAX_N; i++) {
        coords[i] = {i, i};
    }
    return(output_tc(coords));
}

string extreme_test_3(){
    vector<pair<int, int>> coords(MAX_N);
    for (int i = 0; i < MAX_N; i++) {
        coords[i] = {i, 0};
    }
    return(output_tc(coords));
}

string extreme_test_4(){
    vector<pair<int, int>> coords(MAX_N);
    for (int i = 0; i < MAX_N; i++) {
        coords[i] = {0, i};
    }
    return(output_tc(coords));
}

vector<string> generate_extreme_tests(){
    vector<string> tests;
    tests.push_back(extreme_test_1());
    tests.push_back(extreme_test_2());
    tests.push_back(extreme_test_3());
    tests.push_back(extreme_test_4());
    return tests;
}

int main(int argc, char *argv[]) {
	registerGen(argc, argv, 1);
	vector<string> tests;
	size_t test = 0;
	append(tests, generate_sample_tests());
	append(tests, generate_manual_tests());
	append(tests, generate_random_tests());
	append(tests, generate_extreme_tests());
	for (const auto &t : tests) {
		startTest(++test);
		cout << t;
	}
	return 0;
}