malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long n, a[100001], b[100001];   vector<long long> v[100001];   signed main() {     cin >> n;     long long i;     for (i = 1; i < n + 1; i++) {       cin >> a[i];       v[a[i]].push_back(i);     }     bool ok = 1;     long long clr = 1;     for (i = 0; i < 100001; i++) {       if (!v[i].empty()) {         long long k = v[i].size();         long long j;         if (k % (n - i) != 0) {           ok = 0;           break;         }         long long t = k / (n - i);         long long temp = 1;         j = 0;         while (temp <= t) {           while (j < temp * (n - i)) {             b[v[i][j]] = clr;             j++;           }           clr++;           temp++;         }       }     }     if (ok) {       cout <<  Possible n ;       for (i = 1; i < n + 1; i++) cout << b[i] <<    ;     } else       cout <<  Impossible ;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   bool uin(T &a, T b) {     return a > b ? (a = b, true) : false;   }   template <class T>   bool uax(T &a, T b) {     return a < b ? (a = b, true) : false;   }   const long long maxn = 1000001, mod = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     int ar[n];     map<int, int> mapp;     for (long long i = 0; i < (long long)(n); ++i) {       cin >> ar[i];       mapp[ar[i]] = i;     }     set<int> s;     s.insert(-1);     s.insert(n);     int ans = 0;     for (int i = n; i >= 1; i--) {       int idx = mapp[i];       auto it = s.lower_bound(idx);       auto iit = s.upper_bound(idx);       if (it != s.begin()) it--;       int a = *it + 1;       int b = *iit - 1;       if (idx - a < b - idx) {         for (long long j = (long long)(a); j <= (long long)(idx - 1); ++j) {           int acha = mapp[i - ar[j]];           if (acha > idx && acha <= b) {             ans++;           }         }       } else {         for (long long j = (long long)(idx + 1); j <= (long long)(b); ++j) {           int acha = mapp[i - ar[j]];           if (acha < idx && acha >= a) {             ans++;           }         }       }       s.insert(mapp[i]);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Trie {     Trie *nx[2];     int cnt;     Trie() {       nx[0] = nx[1] = nullptr;       cnt = 0;     }   };   Trie *root;   void ins(long long x) {     Trie *now = root;     for (int bit = 45; bit >= 0; --bit) {       int p = (x >> bit) & 1LL;       if (now->nx[p] == nullptr) now->nx[p] = new Trie();       now = now->nx[p];       now->cnt++;     }   }   long long query(long long x) {     Trie *now = root;     long long ret = 0LL;     for (int bit = 45; bit >= 0; --bit) {       int p = (x >> bit) & 1LL;       p ^= 1;       if (now->nx[p] != nullptr && now->nx[p]->cnt > 0) {         ret += 1LL << bit;         now = now->nx[p];       } else {         now = now->nx[p ^ 1];       }       if (now == nullptr || now->cnt == 0) break;     }     return ret;   }   const int MXSZ = 1e5;   int n;   long long a[MXSZ + 5];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     root = new Trie();     cin >> n;     long long curr = 0LL;     for (int i = 1; i <= n; i++) {       cin >> a[i];       curr ^= a[i];       ins(curr);     }     long long mx = 0LL;     mx = max(mx, query(0));     curr = 0LL;     for (int i = n; i >= 1; --i) {       curr ^= a[i];       mx = max(mx, query(curr));     }     cout << mx <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int b[5000];   int f[5000];   int main() {     scanf(  %d , &n);     for (int i = 0; i < (int)(n); i++) scanf(  %d , b + i);     for (int i = 0; i < (int)(n); i++) b[i]--;     for (int i = 0; i < n; i++) {       int c[5000] = {};       pair<int, int> best = make_pair(0, 0);       for (int j = i; j < n; j++) {         c[b[j]]++;         best = max(best, make_pair(c[b[j]], -b[j]));         f[-best.second]++;       }     }     for (int i = 0; i < (int)(n); i++) printf( %d  , f[i]);     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int t;   int main() {     cin >> t;     while (t--) {       int n, m;       bool nope = false;       cin >> n >> m;       for (int i = 0; i != n; i++) {         for (int j = 0; j != m; j++) {           ll a;           cin >> a;           if ((a > 4 && 0 < j < m - 1 && 0 < i < n - 1) || (a > 3 && j == 0) ||               (a > 3 && j == m - 1) || (a > 3 && i == 0) ||               (a > 3 && i == n - 1) || (a > 2 && j == 0 && i == 0) ||               (a > 2 && j == 0 && i == n - 1) ||               (a > 2 && j == m - 1 && i == n - 1) ||               (a > 2 && j == m - 1 && i == 0)) {             nope = true;           }         }       }       if (nope) cout <<  NO  << endl;       if (!nope) {         cout <<  YES n ;         for (int i = 0; i != n; i++) {           for (int j = 0; j != m; j++) {             if ((i == 0 && j == 0) || (i == 0 && j == m - 1) ||                 (i == n - 1 && j == 0) || (i == n - 1 && j == m - 1)) {               cout << 2 <<    ;             } else if ((0 < i < n - 1 && j == 0) ||                        (0 < i < n - 1 && j == m - 1) ||                        (i == 0 && 0 < j < m - 1) ||                        (i == n - 1 && 0 < j < m - 1)) {               cout << 3 <<    ;             } else {               cout << 4 <<    ;             }           }           cout <<   n ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using LL = long long;   const int maxn = 3000010;   int n, b;   int pre[maxn], vis[maxn];   vector<int> prime;   struct init {     init() {       memset(pre, 0, sizeof pre);       prime.clear();       for (int i = 2; i < maxn; i++) {         if (pre[i] == 0) {           pre[i] = i;           prime.emplace_back(i);         }         for (int j = 0; j < prime.size() && i * prime[j] < maxn; j++) {           if (prime[j] > pre[i]) break;           pre[i * prime[j]] = prime[j];         }       }     }   } init_;   bool ok(int x) {     if (x == 1) return 0;     return pre[x] == 0;   }   signed main() {     while (cin >> n) {       memset(vis, 0, sizeof vis);       for (int i = 1; i <= 2 * n; i++) {         scanf( %d , &b);         vis[b]++;       }       for (int i = maxn - 1; i > 1; i--) {         if (pre[i] == i) continue;         while (vis[i] > 0) {           printf( %d  , i);           vis[i]--;           vis[i / pre[i]]--;         }       }       for (int i = 2; i < maxn; i++) {         while (vis[i] > 0) {           printf( %d  , i);           vis[i]--;           vis[prime[i - 1]]--;         }       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0), cin.tie(0);     string s;     cin >> s;     sort(s.begin(), s.end());     reverse(s.begin(), s.end());     cout << s[0];     for (long long int(i) = (1); (i) < (s.length()); (i)++) {       if (s[i] == s[i - 1])         cout << s[i];       else         break;     }     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       if ((i * (i + 1)) / 2 == n) {         cout <<  YES  << endl;         return 0;       }       if ((i * (i + 1)) / 2 > n) {         cout <<  NO  << endl;         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool KT(long long k, long long n) {     long long take = 0, cur = n;     while (cur > 0) {       long long temp = min(k, cur);       take += temp;       cur -= temp;       cur -= cur / 10;     }     if (take * 2 >= n) return true;     return false;   }   int main() {     long long n;     cin >> n;     long long left = 1, right = n, res = 0;     while (left <= right) {       long long mid = (left + right) / 2;       if (KT(mid, n)) {         res = mid;         right = mid - 1;       } else {         left = mid + 1;       }     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct in {     int x, y;   } a[300000];   int get(int prex, int prey, int x, int y, int k) {     int num, ans = 100000000;     if (prex <= k) {       num = (prex + x + k - 1) / k - 1;       if (y == num)         ans = prex + x - num * k;       else if (y > num && y <= (long long)x * k)         ans = 1;     }     if (prey <= k) {       num = (x + k - 1) / k - 1;       if (y == num)         ans = min(ans, x - num * k);       else if (y > num && y - k + prey <= (long long)(x - 1) * k)         ans = 1;     }     return ans;   }   int main() {     int N, K, pre0 = 0, pre1 = 0, next0, next1;     scanf( %d%d , &N, &K);     for (int i = 1; i <= N; i++) scanf( %d , &a[i].x);     for (int i = 1; i <= N; i++) scanf( %d , &a[i].y);     for (int i = 1; i <= N; i++) {       next0 = get(pre0, pre1, a[i].x, a[i].y, K);       next1 = get(pre1, pre0, a[i].y, a[i].x, K);       pre0 = next0;       pre1 = next1;     }     if (pre0 <= K || pre1 <= K)       puts( YES );     else       puts( NO );     return 0;   }
#include <bits/stdc++.h>   float a1(float x, float y, float z) {     if (x >= 1.0)       return z * log(y) + log(log(x));     else if (x < 1.0 && y < 1.0 && z < 1.0)       return z * log(y) + log(log(1 / x));     else       return 0.0 / 0.0;   }   float a2(float x, float y, float z) {     if (x >= 1.0)       return log(z) + log(y) + log(log(x));     else if (x < 1.0 && y < 1.0 && z < 1.0)       return log(z) + log(y) + log(log(1 / x));     else       return 0.0 / 0.0;   }   int main() {     float x, y, z;     scanf( %f %f %f , &x, &y, &z);     float a[12];     char pat[12][10] = { x^y^z 0 ,  x^z^y 0 ,  (x^y)^z 0 ,  (x^z)^y 0 ,                          y^x^z 0 ,  y^z^x 0 ,  (y^x)^z 0 ,  (y^z)^x 0 ,                          z^x^y 0 ,  z^y^x 0 ,  (z^x)^y 0 ,  (z^y)^x 0 };     a[0] = a1(x, y, z);     a[1] = a1(x, z, y);     a[2] = a2(x, y, z);     a[3] = a2(x, z, y);     a[4] = a1(y, x, z);     a[5] = a1(y, z, x);     a[6] = a2(y, x, z);     a[7] = a2(y, z, x);     a[8] = a1(z, x, y);     a[9] = a1(z, y, x);     a[10] = a2(z, x, y);     a[11] = a2(z, y, x);     float ans;     int pos, i;     if (x >= 1.0) {       ans = a[0];       pos = 0;     } else if (y >= 1.0) {       ans = a[4];       pos = 4;     } else {       ans = a[8];       pos = 8;     }     if (x < 1 && y < 1 && z < 1) {       for (i = 11; i >= 0; --i) {         if (a[i] <= ans) {           ans = a[i];           pos = i;         }       }     } else {       for (i = 11; i >= 0; --i) {         if (a[i] >= ans) {           ans = a[i];           pos = i;         }       }     }     printf( %s , pat[pos]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> vi;   void primefact(int n) {     while (n % 2 == 0) {       vi.push_back(2);       n /= 2;     }     int i = 3;     while (i <= n) {       while (n % i == 0) {         vi.push_back(i);         n /= i;       }       i += 2;     }     if (n > 2) vi.push_back(n);   }   int main() {     int n, k, last = 1, i;     cin >> n >> k;     primefact(n);     if (k > vi.size())       cout <<  -1  << endl;     else {       for (i = 0; i < k - 1; i++) cout << vi[i] <<    ;       for (i = k - 1; i < vi.size(); i++) last *= vi[i];       cout << last;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200005;   const long long INF = 1e9;   const long long MOD = 1000000007;   int prevs[20];   int main() {     ios ::sync_with_stdio(0);     cin.tie(0);     int n, q;     cin >> n >> q;     int arr[n];     for (int i = 0; i < n; i++) cin >> arr[i];     int ar[n][20];     for (int i = 0; i < n; i++)       for (int j = 0; j < 20; j++) ar[i][j] = n + 3;     for (int i = n - 1; i >= 0; i--) {       int x = 1;       for (int j = 0; j < 20; j++) {         if ((x << j) & arr[i]) {           ar[i][j] = i;           if (prevs[j] != 0)             for (int k = 0; k < 20; k++)               ar[i][k] = min(ar[i][k], ar[prevs[j]][k]);           prevs[j] = i;         }       }     }     while (q--) {       int x, y;       cin >> x >> y;       x--, y--;       if (!arr[x] || !arr[y]) {         cout <<  Fou  << endl;         continue;       }       int p = 1;       int l = 0;       for (int j = 0; j < 20; j++)         if (p << j & arr[y])           if (ar[x][j] <= y) {             l = 1;             continue;           }       if (l == 1)         cout <<  Shi  << endl;       else         cout <<  Fou  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int n;   char s[1000005];   int main() {     int i, j, l, r, p = 0;     scanf( %s , s);     n = strlen(s);     for (j = 0; j < n && s[j] !=  . ; j++)       ;     if (j == n) {       s[n] =  . ;       n++;     }     for (i = 0; i < n && s[i] ==  0 ; i++)       ;     if (i == j) {       for (; i < n - 1 && s[i + 1] ==  0 ; i++) swap(s[i], s[i + 1]), p--;       if (i == n - 1) {         printf( 0 n );         return 0;       }       swap(s[i], s[i + 1]), p--;       for (r = n - 1; s[r] ==  0 ; r--)         ;       if (s[r] ==  . ) r--;       for (; i <= r; i++) printf( %c , s[i]);       if (p != 0) printf( E%d n , p);     } else {       for (; j > i + 1; j--) swap(s[j], s[j - 1]), p++;       for (r = n - 1; s[r] ==  0 ; r--)         ;       if (s[r] ==  . ) r--;       for (; i <= r; i++) printf( %c , s[i]);       if (p != 0) printf( E%d n , p);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 1000 + 10;   const int INF = 0x7f7f7f7f;   const double eps = 1e-10;   const double pi = acos(-1.0);   inline int realcmp(double a, double b) {     return (a > b + eps) ? 1 : ((a + eps < b) ? -1 : 0);   }   int main() {     double hh, mm;     ios::sync_with_stdio(0);     scanf( %lf:%lf , &hh, &mm);     hh += mm / 60;     while (realcmp(hh, 12) >= 0) hh -= 12;     printf( %.9lf  , 30.0 * hh);     printf( %.9lf n , 6.0 * mm);     return 0;   }
#include <bits/stdc++.h>   struct point {     long x;     long y;     long z;   };   const long maxn = 5001;   const double inf = 2000000000;   const double eps = 1.0e-8;   point a[maxn];   double nnew, min;   long n, q, choice1, choice2;   double d[maxn];   double sqr(double x) { return (x * x); }   double dist(point a, point b) {     return (pow(sqr(a.x - b.x) + sqr(a.y - b.y) + sqr(a.z - b.z), 0.5));   }   int main() {     scanf( %ld , &n);     for (q = 1; q <= n; q++) scanf( %ld%ld%ld , &a[q].x, &a[q].y, &a[q].z);     min = inf;     for (long h = 2; h <= n; h++) d[h] = dist(a[1], a[h]);     for (choice1 = 2; choice1 <= n; choice1++)       for (choice2 = choice1 + 1; choice2 <= n; choice2++) {         nnew = (d[choice1] + d[choice2] + dist(a[choice1], a[choice2])) / 2;         if (min - nnew > eps) min = nnew;       }     printf( %0.8lf , min);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x, i, y, ans = 0, q;     scanf( %d%d , &n, &x);     y = int(sqrt(x));     if (n < y) y = n;     for (i = 1; i <= y; i++) {       if (x % i == 0) {         q = x / i;         if (q <= n) {           if (i == q)             ans++;           else             ans += 2;         }       }     }     if (x == 1)       printf( %d n , 1);     else       printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mx = 1e9;   struct Data {     int p1, p2, p3, p4;     Data(int a = mx, int b = mx, int c = mx, int d = mx) {       p1 = a, p2 = b, p3 = c, p4 = d;     }   };   inline Data UN(Data a, Data b) {     Data c;     c.p1 = min(a.p1 + b.p1, a.p2 + b.p3), c.p2 = min(a.p1 + b.p2, a.p2 + b.p4);     c.p3 = min(a.p3 + b.p1, a.p4 + b.p3), c.p4 = min(a.p3 + b.p2, a.p4 + b.p4);     c.p1 = min(c.p1, mx), c.p2 = min(c.p2, mx), c.p3 = min(c.p3, mx),     c.p4 = min(c.p4, mx);     return c;   }   struct node {     int l, r;     Data s;   } T[200010 << 2];   char G[3][200010];   void build(int rt, int l, int r) {     T[rt].l = l, T[rt].r = r;     int mid = (l + r) >> 1;     if (l == r) {       if (G[1][l] ==  . ) T[rt].s.p1 = 1;       if (G[2][l] ==  . ) T[rt].s.p4 = 1;       if (G[1][l] ==  .  && G[2][l] ==  . ) T[rt].s.p2 = T[rt].s.p3 = 2;       return;     }     build(rt << 1, l, mid), build(rt << 1 | 1, mid + 1, r);     T[rt].s = UN(T[rt << 1].s, T[rt << 1 | 1].s);   }   Data query(int rt, int start, int end) {     int l = T[rt].l, r = T[rt].r, mid = (l + r) >> 1;     if (start <= l && r <= end) return T[rt].s;     if (end <= mid) return query(rt << 1, start, end);     if (start > mid) return query(rt << 1 | 1, start, end);     return UN(query(rt << 1, start, end), query(rt << 1 | 1, start, end));   }   int main() {     int n, q;     scanf( %d%d , &n, &q);     scanf( %s%s , G[1] + 1, G[2] + 1);     build(1, 1, n);     while (q--) {       int a, b;       scanf( %d%d , &a, &b);       int l = a > n ? a - n : a, r = b > n ? b - n : b, res;       if (l > r) swap(l, r), swap(a, b);       Data tmp = query(1, l, r);       if (a <= n && b <= n) res = tmp.p1;       if (a <= n && b > n) res = tmp.p2;       if (a > n && b <= n) res = tmp.p3;       if (a > n && b > n) res = tmp.p4;       if (res < 1e8)         printf( %d n , res - 1);       else         printf( -1 n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t, x, y, a, b;     scanf( %lld , &t);     while (t--) {       scanf( %lld %lld %lld %lld , &x, &y, &a, &b);       bool yes = false;       int i = 0;       int tens = 1000000;       while (x <= y) {         if (x == y) {           yes = true;           break;         }         while (x + a * tens > y - b * tens && tens > 1) tens /= 10;         x += tens * a;         y -= tens * b;         i += tens;       }       printf( %d n , yes ? i : -1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rnd(228);   const int N = 404;   int mod;   int fact[N], d0[N], d[N], d2[N][N];   int main() {     int qq;     cin >> qq >> mod;     fact[0] = 1;     for (int i = 1; i < N; ++i) fact[i] = (1LL * fact[i - 1] * i) % mod;     d[1] = 1;     d0[1] = 1;     for (int n = 2; n < N; ++n) {       d0[n] = fact[n];       for (int k = 1; k < n; ++k)         d0[n] = (d0[n] - 1LL * d0[k] * fact[n - k]) % mod;       if (d0[n] < 0) d0[n] += mod;     }     d2[0][0] = 1;     for (int n = 1; n < N; ++n) {       d2[n][1] = fact[n];       for (int k = 2; k <= n; ++k)         for (int x = 1; x < n; ++x)           d2[n][k] = (d2[n][k] + 1LL * fact[x] * d2[n - x][k - 1]) % mod;     }     for (int n = 2; n < N; ++n) {       int dz = 0;       for (int x = 1; x < n - 1; ++x)         for (int y = x; y < n - 1; ++y) {           int c = fact[y - x + 1];           c = (1LL * c * d0[x]) % mod;           c = (1LL * c * d0[n - y - 1]) % mod;           dz += c;           if (dz >= mod) dz -= mod;         }       dz = (dz * 2) % mod;       int cd = fact[n];       cd = (cd - dz + mod) % mod;       for (int k = 3; k < n; ++k) {         cd = (cd - 1LL * d2[n][k] * d[k]) % mod;       }       if (n != 2) {         for (int x = 1; x < n; ++x) cd = (cd - 1LL * d0[x] * d0[n - x]) % mod;         for (int x = 1; x < n; ++x) cd = (cd - 1LL * d0[x] * d0[n - x]) % mod;       }       cd = (cd + mod) % mod;       d[n] = cd;     }     while (qq--) {       int x;       cin >> x;       cout << d[x] <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   vector<pair<int, int> > adj[N];   int ans[N];   int off[N];   int lvl[N], anc[N][25];   int n, a, b, k;   void dfs(int u = 0, int par = 0, int l = 0) {     lvl[u] = l;     anc[u][0] = par;     for (auto nxt : adj[u])       if (nxt.first != par) dfs(nxt.first, u, l + 1);   }   void buildLCA() {     int lg = ceil(log2(n));     for (int j = 1; j < lg; j++)       for (int i = 0; i < n; i++) anc[i][j] = anc[anc[i][j - 1]][j - 1];   }   int LCA(int i, int j) {     int lg = ceil(log2(n));     int st = lg;     if (lvl[i] > lvl[j]) swap(i, j);     int cur = lvl[j];     for (; st >= 0; st--)       if (cur - (1 << st) >= lvl[i]) cur -= (1 << st), j = anc[j][st];     if (i == j) return 2 * i - j;     cur = lvl[i];     for (st = lg; st >= 0; st--)       if (anc[i][st] != anc[j][st])         cur -= (1 << st), i = anc[i][st], j = anc[j][st];     return anc[i][0];   }   int solve(int u = 0, int par = 0) {     int cnt = off[u];     for (auto nxt : adj[u]) {       if (par == nxt.first) continue;       int x = solve(nxt.first, u);       ans[nxt.second] = x;       cnt += x;     }     return cnt;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n - 1; i++) {       scanf( %d%d , &a, &b);       a--, b--;       adj[a].push_back({b, i});       adj[b].push_back({a, i});     }     dfs();     buildLCA();     scanf( %d , &k);     for (int i = 0; i < k; i++) {       scanf( %d%d , &a, &b);       a--, b--;       off[a]++, off[b]++;       off[LCA(a, b)] -= 2;     }     solve();     for (int i = 0; i < n - 1; i++) printf( %d%c , ans[i],    n [i == n - 2]);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   using namespace std;   struct Point {     int x, y, type, index;   } num[20005];   int ans[10005];   Point c;   bool cmp(Point a, Point b) {     return (a.x - c.x) * (b.y - c.y) - (a.y - c.y) * (b.x - c.x) > 0;   }   bool cmp2(Point a, Point b) { return (a.x < b.x) || (a.x == b.x && a.y < b.y); }   void f(int l, int r) {     if (l >= r) return;     int i;     swap(num[l], num[min_element(num + l, num + r + 1, cmp2) - num]);     for (i = l + 1; i <= r; i++) {       num[i].x -= num[l].x;       num[i].y -= num[l].y;     }     num[l].x = num[l].y = 0;     c = num[l];     sort(num + l + 1, num + r + 1, cmp);     int pre = num[l].type, minv = 1000000000, id = -1;     for (i = l + 1; i <= r; i++) {       pre += num[i].type;       if (!pre && num[i].type != num[l].type && max(i - l - 1, r - i) < minv) {         minv = max(i - l - 1, r - i);         id = i;       }     }     if (num[l].type == 1)       ans[num[id].index] = num[l].index;     else       ans[num[l].index] = num[id].index;     f(l + 1, id - 1);     f(id + 1, r);   }   int main() {     int i, n;     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %d%d , &num[i].x, &num[i].y);       num[i].type = -1;       num[i].index = i + 1;     }     for (i = 0; i < n; i++) {       scanf( %d%d , &num[n + i].x, &num[n + i].y);       num[n + i].type = 1;       num[n + i].index = i + 1;     }     f(0, 2 * n - 1);     for (i = 1; i <= n; i++) printf( %d n , ans[i]);   }