#define _USE_MATH_DEFINES #pragma GCC target("avx2") #pragma GCC optimize("O3") #include #include #include #include #include #include using namespace std; #define LP(I,S,G) for (long long int I = (S); I < (G); ++I) #define IN(X) for (int in = 0; in < X.size(); in++)cin >> X[in] #define OUT(X) for (int in = 0; in < X.size(); in++)cout << X[in]<<" " #define SORT(X) sort((X).begin(), (X).end()) #define CSORT(X,Y) sort(X.begin(), X.end(),Y) #define COPY(X,Y) copy(X.begin(), X.end(), Y.begin()) #define ALL(X,Y) for (auto (X) :(Y)) #define FULL(a) (a).begin(),(a).end() #define BFS(Q,S) for(Q.push(S);Q.size()!=0;Q.pop()) typedef long long int ll; typedef unsigned long long int ull; long long int M = 998244353; chrono::system_clock::time_point starttime; using namespace std::chrono; #ifndef ONLINE_JUDGE #define DEBUG #endif inline float getTime() { #ifdef DEBUG return duration_cast(system_clock::now() - starttime).count() * 2.0; #else return duration_cast(system_clock::now() - starttime).count(); #endif } int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 }; ll MAX(ll A, ll B) { return ((A) > (B) ? (A) : (B)); } ll MIN(ll A, ll B) { return ((A) < (B) ? (A) : (B)); } inline long long int xor128() { static long long int x = 123456789, y = 362436069, z = 521288629, w = 88675123; long long int t = (x ^ (x << 11)); x = y; y = z; z = w; return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8))); } long long int pow_n(long long int x, long long int n) { if (n == 0) return 1; if (n % 2 == 0) return pow_n(x * x, n / 2); else return x * pow_n(x, n - 1); } int main(int argc, char* argv[]) { starttime = chrono::system_clock::now(); ios::sync_with_stdio(false); std::cin.tie(nullptr); ll n; ll border = 5 * pow_n(10, 17); cin >> n; vector a(n), b(n); LP(i, 0, n)cin >> a[i] >> b[i]; vector> ans; LP(t, 0, 50) { cerr << t<<":" << ll(2000000 - 100000 * log10(max(abs(border-a[0]), abs(border-b[0])) + 1)) << "\n"; ll now_score = abs(a[0] - border) + abs(b[0] - border); ll next_score = LLONG_MAX, select = -1; LP(i, 1, n) { ll avga = (a[0] + a[i]) / 2, avgb = (b[0] + b[i]) / 2; ll score = abs(avga - border) + abs(avgb - border); if (score < next_score)select = i, next_score = score; } if (now_score > next_score) { ll avga = (a[0] + a[select]) / 2, avgb = (b[0] + b[select]) / 2; a[0] = a[select] = avga; b[0] = b[select] = avgb; ans.push_back({ 1,select + 1 }); } else if (t != 49) { next_score = LLONG_MAX; ll si = -1, sk = -1; LP(i, 1, n) { LP(k, 1, i) { ll avgap = (a[i] + a[k]) / 2, avgbp = (b[i] + b[k]) / 2; ll avga = (a[0] + avgap) / 2, avgb = (b[0] + avgbp) / 2; ll score = abs(avga - border) + abs(avgb - border); if (score < next_score)si = i, sk = k, next_score = score; } } if (now_score < next_score)break; ll avgap = (a[si] + a[sk]) / 2, avgbp = (b[si] + b[sk]) / 2; ll avga = (a[0] + avgap) / 2, avgb = (b[0] + avgbp) / 2; a[si] = a[sk] = avgap; b[si] = b[sk] = avgbp; a[0] = a[si] = avga; b[0] = b[si] = avgb; ans.push_back({ si + 1,sk + 1 }); ans.push_back({ 1,si + 1 }); } } cerr << "score:" << ll(2000000 - 100000 * log10(max(abs(border - a[0]), abs(border - b[0])) + 1)) << "\n"; cerr << a[0] << " " << b[0] << "\n"; cout << ans.size() << "\n"; ALL(x, ans)cout << x.first << " " << x.second << "\n"; exit(0); }