malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   const int N = 1e3 + 10, O = 27;   int cnt, n, m;   bool v[O], ok[O], cur[O];   std::vector<int> empty, full;   std::string s, temp;   int main() {     scanf( %d , &n);     std::cin >> s;     for (int i = 0; i < n; i++) {       if (s[i] !=  * ) {         v[s[i] -  a ] = true;         full.push_back(i);       } else {         empty.push_back(i);       }     }     for (int i = 0; i < 26; i++) ok[i] = !v[i];     scanf( %d , &m);     for (int i = 0; i < m; i++) {       static bool acc;       acc = true;       std::cin >> temp;       for (int j : full)         if (s[j] != temp[j]) {           acc = false;           break;         }       if (!acc) continue;       for (int j : empty)         if (v[temp[j] -  a ]) {           acc = false;           break;         }       if (!acc) continue;       memset(cur, 0, sizeof cur);       for (int j : empty) cur[temp[j] -  a ] = true;       for (int j = 0; j < 26; j++)         if (!cur[j]) ok[j] = false;     }     for (int i = 0; i < 26; i++)       if (ok[i]) cnt++;     printf( %d n , cnt);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-9;   const double pi = acos(-1.0);   int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};   int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};   struct point_i {     int x, y;     point_i() { x = y = 0; };     point_i(int x_, int y_) : x(x_), y(y_) {}   };   struct line {     double a, b, c;   };   struct point {     double x, y;     point() { x = y = 0.0; };     point(double x_, double y_) : x(x_), y(y_) {}     bool operator<(point other) const {       if (fabs(x - other.x) < EPS) return y < other.y;       return x < other.x;     }     bool operator==(point other) const {       return fabs(x - other.x) < EPS && fabs(y - other.y) < EPS;     }   };   double dist(point p1, point p2) { return hypot(p1.x - p2.x, p1.y - p2.y); }   void pointsToLine(point p1, point p2, line &l) {     if (fabs(p1.x - p2.x) < EPS) {       l.a = 1.0, l.b = 0.0, l.c = -p1.x;     } else {       l.a = -(double)(p1.y - p2.y) / (p1.x - p2.x);       l.b = 1.0;       l.c = -(double)(l.a * p1.x) - p1.y;     }   }   bool areParallel(line l1, line l2) {     return (fabs(l1.a - l2.a) < EPS && fabs(l1.b - l2.b) < EPS);   }   bool areIntersect(line l1, line l2, point &p) {     if (areParallel(l1, l2)) return false;     p.x = (l2.b * l1.c - l1.b * l2.c) / (l2.a * l1.b - l1.a * l2.b);     if (fabs(l1.b) > EPS)       p.y = -(l1.a * p.x + l1.c);     else       p.y = -(l2.a * p.x + l2.c);     return true;   }   bool between(point p1, point p2, point p) {     return (p.x + EPS >= min(p1.x, p2.x) && p.x <= max(p1.x, p2.x) + EPS &&             p.y + EPS >= min(p1.y, p2.y) && p.y <= max(p1.y, p2.y) + EPS);   }   int main() {     point p1, p2;     cin >> p1.x >> p1.y >> p2.x >> p2.y;     line l1;     pointsToLine(p1, p2, l1);     int n;     cin >> n;     line a[n];     for (int i = 0; i < n; ++i) {       cin >> a[i].a >> a[i].b >> a[i].c;       point f, s;       if (!a[i].a) {         f.y = (-a[i].a * 1 - a[i].c) / a[i].b;         f.x = 1;         s.y = (-a[i].a * 2 - a[i].c) / a[i].b;         s.x = 2;       } else {         f.x = (-a[i].b * 1 - a[i].c) / a[i].a;         f.y = 1;         s.x = (-a[i].b * 2 - a[i].c) / a[i].a;         s.y = 2;       }       pointsToLine(f, s, a[i]);     }     int ans = 0;     point p;     for (int i = 0; i < n; ++i) {       if (areIntersect(l1, a[i], p) && between(p1, p2, p)) {         ++ans;       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::system_clock::now().time_since_epoch().count());   mt19937_64 rngll(rng());   const int mn = 1e6 + 10;   const long long mod = 1e9 + 7;   long long fact[mn];   long long po(long long a, long long b = mod - 2) {     if (b < 0) b += mod - 1;     long long ans = 1;     for (; b; b >>= 1, a *= a, a %= mod)       if (b & 1) ans *= a, ans %= mod;     return ans;   }   long long ch(long long n, long long k) {     if (k < 0 || k > n) return 0;     return fact[n] * po(fact[k] * fact[n - k] % mod) % mod;   }   int main() {     int n, m, a, b;     scanf( %d%d%d%d , &n, &m, &a, &b);     fact[0] = 1;     for (int i = 1; i < mn; i++) fact[i] = fact[i - 1] * i % mod;     long long ans = 0;     for (int i = 1; i <= n - 1; i++) {       long long num = ch(m - 1, i - 1);       num *= ch(n - 2, i - 1) * fact[i - 1] % mod, num %= mod;       num *= po(m, n - i - 1), num %= mod;       num *= (i + 1) * po(n, n - 1 - i - 1) % mod, num %= mod;       ans += num, ans %= mod;     }     printf( %lld , ans);   }
#include <bits/stdc++.h>   using namespace std;   struct P {     long long x;     long long y;     bool operator<(const P &a) const { return y > a.y; }   };   vector<long long> v[3];   int a, c, i, b, n, m, k, d;   long long o[1333331];   int l[1111111];   int j[1111115];   int e[1111111];   int dx[10] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[10] = {1, 0, -1, 0, 1, -1, 1, -1},       dz[10] = {0, 0, 0, 0, 1, -1};   long long x, y, mod = 1000000007, mod2 = 1000000009, mod3 = 2017;   long long z;   double pi = 3.14159265;   P u[1];   queue<int> q;   bool as(P a, P b) {     if (a.x != b.x) return a.x < b.x;     return a.y < b.y;   }   long long f(long long a, long long b) {     for (; b;) {       long long h = a;       a = b;       b = h % b;     }     return a;   }   int main() {     scanf( %d , &a);     for (int t = 1; t <= a; t++) scanf( %lld , &o[t]);     for (int t = 2; t <= a; t++) scanf( %d , &l[t]);     for (int t = a; t > 0; t--) o[l[t]] += o[t];     for (int t = a; t > 0; t--)       if (o[1] / f(o[1], o[t]) <= a) {         j[o[1] / f(o[1], o[t])]++;       }     for (int t = a; t > 0; t--) {       for (int h = t * 2; h <= a; h += t) j[h] += j[t];     }     for (int t = 1; t <= a; t++)       if (j[t] >= t) e[t] = 1;     for (int t = a; t > 0; t--)       if (e[t]) {         for (int h = t * 2; h <= a; e[t] %= mod, h += t) e[t] += e[h];       }     printf( %d  , e[1]);   }
#include <bits/stdc++.h>   using namespace std;   char moves[4] = { L ,  U ,  R ,  D };   long long dx[4] = {-1, 0, 1, 0};   long long dy[4] = {0, -1, 0, 1};   const long long N = 1e3 + 1;   bool visited[N];   vector<long long> adj[N];   long long n, k;   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> k;     for (long long i = 1; i < k + 1; i++) {       cout << 2 * i <<     << 2 * i - 1 <<    ;     }     for (long long i = 2 * k + 1; i < 2 * n + 1; i++) cout << i <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     string s;     cin >> s;     int l = s.length();     int f[l + 2];     int a[26] = {0};     int l1[1000005], l2[1000005];     for (int i = 0; i <= l; i++) {       f[i] = 0, l1[i] = 0, l2[i] = 0;     }     for (int i = 0; i < 26; i++) a[i] = 0;     int flag = 0;     for (int i = 0; i < l; i++) {       if (a[s[i] -  A ] == 0) {         a[s[i] -  A ] = 1;         l1[i] = 1;       }     }     for (int i = 0; i < 26; i++) a[i] = 0;     for (int i = l - 1; i >= 0; i--) {       if (a[s[i] -  A ] == 0) {         a[s[i] -  A ] = 1;         l2[i + 1] = -1;       }     }     f[0] = l1[0];     for (int i = 1; i <= l; i++) {       f[i] = f[i - 1] + l1[i] + l2[i];     }     for (int i = 0; i <= l; i++) {       if (f[i] > k) {         flag = 1;         break;       }     }     if (flag == 1)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long int i, k, j, l, a, b, len;     scanf( %ld%ld , &len, &k);     if (k > len) {       printf( -1 n );       return 0;     }     if ((len > 1) && (k == 1)) {       printf( -1 n );       return 0;     }     if ((len == 1) && (k == 1)) {       printf( a n );       return 0;     }     if ((len == 2) && (k == 2)) {       printf( ab n );       return 0;     } else if (k == 2) {       for (i = 1; i <= len; i++) {         if (i % 2 == 1)           printf( a );         else if (i % 2 == 0)           printf( b );       }       printf(  n );     } else {       for (i = 1; i <= (len + 2 - k); i++) {         if (i % 2 == 1)           printf( a );         else if (i % 2 == 0)           printf( b );       }       b = k - 1;       for (i = 1; i <= (k - 2); i++) {         a = i % b;         printf( %c , (98 + a));       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     ;     int precision = numeric_limits<double>::digits10;     ;     int n;     cin >> n;     int j = sqrt(n), k = sqrt(n);     for (int i = j; i > 0; i--) {       for (int p = k; p < n + 1; p++) {         if (i * p == n) {           cout << i <<     << p << endl;           return 0;         }       }     }   }
#include <bits/stdc++.h>   const long long MOD = 1e9 + 7;   using pii = std::pair<long long, long long>;   using namespace std;   long long n;   string s;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n >> s;     long long good = 1;     for (long long i = 0; i < n; i++)       for (long long j = 0; j < i; j++)         for (long long k = 0; k < j; k++)           if (s[k] > s[j] && s[j] > s[i]) {             good = 0;             break;           }     long long ans[205] = {0};     for (long long i = 0; i < n; i++)       for (long long j = i + 1; j < n; j++)         if (s[j] < s[i]) ans[j] = !ans[i];     if (!good)       cout <<  NO n ;     else {       cout <<  YES n ;       for (long long i = 0; i < n; i++) cout << ans[i];       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 50005;   int n;   int id[N];   vector<pair<int, int> > val;   vector<int> sol;   int main() {     ios ::sync_with_stdio(false);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> id[i];     }     id[n] = id[0];     for (int i = 0; i < n; i++) {       val.push_back(make_pair((n - id[i]) - id[i + 1], i));     }     sort(val.begin(), val.end());     sol.resize(n);     for (int i = 0; i < n; i++) {       sol[val[i].second] = n - i - 1;     }     for (int i = 0; i < n; i++) {       cout << sol[i] <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int ch[3000005][2];   int v[3000005];   map<int, int> mp;   int sz;   void inser(int x) {     int u = 0;     for (int i = 20; i >= 0; i--) {       int c = x >> i & 1;       if (!ch[u][c]) {         memset(ch[sz], 0, sizeof(ch[sz]));         v[sz] = 0;         ch[u][c] = sz++;       }       u = ch[u][c];     }     v[u] = x;   }   int query(int y) {     int u = 0;     for (int i = 20; i >= 0; i--) {       int c = y >> i & 1;       if (ch[u][c])         u = ch[u][c];       else         u = ch[u][c ^ 1];     }     return v[u] ^ y;   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     sz = 1;     for (int i = 1; i <= n; i++) {       int x;       scanf( %d , &x);       mp[x] = 1;     }     for (int i = 0; i <= 600005; i++) {       if (mp[i] == 0) inser(i);     }     int yi = 0;     for (int i = 1; i <= m; i++) {       int y;       scanf( %d , &y);       yi ^= y;       printf( %d n , query(yi));     }     return 0;   }
#include <bits/stdc++.h>   const int N = 205;   int n, m, A[N][N], a[N][N], h[N], l[N];   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) scanf( %d , &A[i][j]);     for (int i = 0; i <= m; i++) {       int f = 1;       memcpy(a, A, sizeof(A));       memset(h, 0, sizeof(h));       memset(l, 0, sizeof(l));       for (int j = 1; j <= m; j++)         if ((j <= i && a[1][j]) || (j > i && a[1][j] == 0)) {           for (int k = 1; k <= n; k++) a[k][j] ^= 1;           l[j] ^= 1;         }       for (int j = 2; j <= n; j++) {         int f0 = 1, f1 = 1;         for (int k = 1; k <= m; k++)           if (a[j][k])             f0 = 0;           else             f1 = 0;         if (f0)           h[j] ^= 1;         else if (!f1) {           f = 0;           break;         }       }       if (f) {         puts( YES );         for (int j = 1; j <= n; j++) printf( %d , h[j]);         puts(  );         for (int j = 1; j <= m; j++) printf( %d , l[j]);         puts(  );         return 0;       }     }     memcpy(a, A, sizeof(A));     memset(h, 0, sizeof(h));     memset(l, 0, sizeof(l));     for (int i = 1; i <= m; i++)       if (a[1][i]) {         for (int k = 1; k <= n; k++) a[k][i] ^= 1;         l[i] ^= 1;       }     int f = 2;     for (int j = 2; j <= n; j++) {       int cnt = 0, c = a[j][1];       for (int k = 2; k <= m; k++)         if (a[j][k] != a[j][k - 1]) cnt++;       if (cnt > 1) {         puts( NO );         return 0;       }       if (cnt == 0 && f == 2) {         if (c == 1) h[j] ^= 1;         continue;       }       if (cnt == 0 && f == 1) {         if (c == 0) h[j] ^= 1;         continue;       }       if (cnt == 1 && f == 2) {         f--;         if (c) h[j] ^= 1;         continue;       }       puts( NO );     }     puts( YES );     for (int j = 1; j <= n; j++) printf( %d , h[j]);     puts(  );     for (int j = 1; j <= m; j++) printf( %d , l[j]);     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long maxn = 60;   const char spec1[5] = { T ,  J ,  Q ,  K ,  A };   const char spec2[4] = { S ,  D ,  H ,  C };   long start[maxn];   bool pos[maxn][maxn][maxn][maxn];   long n;   bool ispair[maxn][maxn];   int main() {     scanf( %ld , &n);     long q;     long maxx = -1;     for (q = 1; q <= n; q++) {       long tmp1 = -1;       long tmp2 = -1;       string s;       cin >> s;       if ((s[0] >=  2 ) && (s[0] <=  9 ))         tmp1 = s[0] -  2 ;       else {         for (long j = 0; j <= 4; j++)           if (spec1[j] == s[0]) {             tmp1 = j + 8;             break;           }       }       for (long j = 0; j <= 3; j++)         if (spec2[j] == s[1]) {           tmp2 = j;           break;         }       assert(tmp1 != -1);       assert(tmp2 != -1);       start[q] = tmp2 * 13 + tmp1 + 1;       maxx = max(maxx, start[q]);     }     for (long first = 1; first <= 52; first++)       for (long second = 1; second <= 52; second++) {         long t1 = (first - 1) % 13;         long t2 = (first - 1) / 13;         long t3 = (second - 1) % 13;         long t4 = (second - 1) / 13;         ispair[first][second] = ((t1 == t3) || (t2 == t4));       }     long t1, t2, t3;     if (n >= 3)       t1 = start[n - 2];     else       t1 = 0;     if (n >= 2)       t2 = start[n - 1];     else       t2 = 0;     t3 = start[n];     pos[n][t1][t2][t3] = true;     for (long it = n; it > 1; it--)       for (long first = 0; first <= maxx; first++)         for (long second = 0; second <= maxx; second++)           for (long third = 0; third <= maxx; third++)             if (pos[it][first][second][third]) {               if (ispair[second][third]) {                 long tmp;                 if (it - 3 > 0)                   tmp = start[it - 3];                 else                   tmp = 0;                 pos[it - 1][tmp][first][third] = true;               }               if ((it - 3 > 0) && (ispair[start[it - 3]][third]))                 pos[it - 1][third][first][second] = true;             }     for (long j = 0; j <= maxx; j++)       if (pos[1][0][0][j]) {         printf( YES n );         exit(0);       }     printf( NO n );   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5005;   template <class I>   inline void ckMax(I& p, I q) {     p = (p > q ? p : q);   }   template <class I>   inline void ckMin(I& p, I q) {     p = (p < q ? p : q);   }   template <class I>   inline I Max(I& p, I q) {     return p > q ? p : q;   }   template <class I>   inline I Min(I& p, I q) {     return p < q ? p : q;   }   template <class I>   inline void sp(I& p, I& q) {     I x = p;     p = q, q = x;   }   int n, m, k, a[N];   long long f[N][N], ans;   deque<int> q[N];   int main() {     scanf( %d%d%d , &n, &k, &m);     register int i, j;     for (i = 1; i <= n; ++i) scanf( %d , &a[i]);     q[0].push_back(0);     for (i = 1; i <= n; ++i)       for (j = m; j; --j) {         while ((!q[j - 1].empty()) && q[j - 1].front() < i - k)           q[j - 1].pop_front();         if (q[j - 1].empty()) continue;         f[i][j] = f[q[j - 1].front()][j - 1] + a[i];         while ((!q[j].empty()) && f[q[j].back()][j] <= f[i][j]) q[j].pop_back();         q[j].push_back(i);       }     for (i = n - k + 1; i <= n; ++i) ckMax(ans, f[i][m]);     printf( %lld , ans > 0 ? ans : -1ll);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int matrix[505][505];   int m, n;   int col[505];   int row[505];   int prime[110000];   int pc;   bool visit[110000];   void init() {     for (int i = 2; i < 110000; i++) {       if (visit[i]) continue;       for (int j = i * 2; j < 110000; j += i) visit[j] = true;     }     for (int i = 2; i < 110000; i++)       if (!visit[i]) prime[pc++] = i;   }   int next(int num) {     int l, r, mid;     l = 0;     r = pc - 1;     while (l < r) {       mid = (l + r) / 2;       if (prime[mid] < num)         l = mid + 1;       else         r = mid;     }     return prime[r] - num;   }   int main() {     int i, j, v, tmp, min;     cin >> n >> m;     init();     for (i = 0; i < n; i++)       for (j = 0; j < m; j++) cin >> matrix[i][j];     for (i = 0; i < n; i++) {       v = 0;       for (j = 0; j < m; j++) {         tmp = next(matrix[i][j]);         col[j] += tmp;         v += tmp;       }       row[i] = v;     }     min = INT_MAX;     for (i = 0; i < n; i++)       if (min > row[i]) min = row[i];     for (j = 0; j < m; j++)       if (min > col[j]) min = col[j];     cout << min << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1010;   const double eps = 1e-9;   const double pi = acos(-1.0);   int Sng(double x) {     if (x < -eps) return -1;     if (x > eps) return 1;     return 0;   }   class Point {    public:     double x, y;     Point(double x = 0, double y = 0) : x(x), y(y) {}     void Read() { scanf( %lf%lf , &x, &y); }     double Angle() { return atan2(y, x); }     friend double Dis(const Point &A, const Point &B);   };   Point operator-(const Point &A, const Point &B) {     return Point(A.x - B.x, A.y - B.y);   }   double Dis(const Point &A, const Point &B) {     return sqrt(((A.x - B.x) * (A.x - B.x)) + ((A.y - B.y) * (A.y - B.y)));   }   struct Data {     double x;     int io;     Data(double x = 0, int io = 0) : x(x), io(io) {}     bool operator<(const Data &O) const {       if (Sng(x - O.x)) return x < O.x;       return io > O.io;     }   };   void Good(double &x) {     while (x < -pi) x += 2.0 * pi;     while (x > pi) x -= 2.0 * pi;   }   Point p[N];   Data sk[N * 20];   double ang[N][N], dis[N][N];   int w, h, n, top;   int Add(double l, double r) {     Good(l);     Good(r);     sk[top++] = (Data(l, 1));     sk[top++] = (Data(r, -1));     return l > r;   }   bool Check(int id, double m) {     if (Sng(m) == 0) return true;     int cnt = 0;     top = 0;     if (p[id].x < m) {       double agl = acos(p[id].x / m);       cnt += Add(pi - agl, pi + agl);       cnt += Add(pi - agl, pi + agl);     }     if (p[id].x + m > w) {       double agl = acos((w - p[id].x) / m);       cnt += Add(-agl, agl);       cnt += Add(-agl, agl);     }     if (p[id].y < m) {       double agl = acos(p[id].y / m);       cnt += Add(1.5 * pi - agl, 1.5 * pi + agl);       cnt += Add(1.5 * pi - agl, 1.5 * pi + agl);     }     if (p[id].y + m > h) {       double agl = acos((h - p[id].y) / m);       cnt += Add(0.5 * pi - agl, 0.5 * pi + agl);       cnt += Add(0.5 * pi - agl, 0.5 * pi + agl);     }     for (int i = 0; i < n; i++) {       if (i == id || Sng(dis[id][i]) == 0 || dis[id][i] >= 2 * m) continue;       double agl = acos((dis[id][i] / 2 / m));       cnt += Add(ang[i][id] - agl, ang[i][id] + agl);     }     if (cnt <= 1) return true;     sort(sk, sk + top);     for (int i = 0; i < top; i++) {       cnt += sk[i].io;       if (cnt <= 1) return true;     }     return false;   }   int main() {     scanf( %d%d%d , &w, &h, &n);     for (int i = 0; i < n; i++) {       p[i].Read();     }     random_shuffle(p, p + n);     for (int i = 0; i < n; i++)       for (int j = i + 1; j < n; j++) {         ang[i][j] = (p[i] - p[j]).Angle();         ang[j][i] = (p[j] - p[i]).Angle();         dis[j][i] = dis[i][j] = Dis(p[i], p[j]);       }     double ans = 0.0;     for (int i = 0; i < n; i++) {       if (Check(i, ans + eps) == false) continue;       double l = ans, r = sqrt(1.0 * w * w + 1.0 * h * h);       for (int t = 0; r - l > 1e-10; t++) {         double mid = (l + r) / 2.0;         if (Check(i, mid))           l = mid + eps, ans = mid;         else           r = mid - eps;       }     }     printf( %.15lf n , ans);     return 0;   }
#include <bits/stdc++.h>   struct el {     int x, y, z;   };   using namespace std;   int cmp(el a, el b) { return a.x < b.x; }   int cmp1(el a, el b) { return a.y < b.y; }   int main(int argc, const char* argv[]) {     int n, w;     cin >> n >> w;     vector<el> a;     el b;     int ans = 0;     for (int i = 0; i < n; i++) {       cin >> b.x;       ans += b.x / 2 + b.x % 2;       b.z = b.x / 2 + b.x % 2;       b.y = i;       a.push_back(b);     }     if (ans > w) {       cout << -1;       return 0;     }     int diff = w - ans;     sort(a.begin(), a.end(), cmp);     for (int i = (int)a.size() - 1; (i > -1) && (diff > 0); i--) {       int tmp = min(diff, a[i].x - (a[i].x / 2 + a[i].x % 2));       a[i].z += tmp;       diff -= tmp;     }     sort(a.begin(), a.end(), cmp1);     for (auto i = a.begin(); i != a.end(); i++) {       cout << (*i).z <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie();     int n;     cin >> n;     vector<pair<int, int> > arr[1001];     for (int i = 1; i <= n; i++) {       int x, y;       cin >> x >> y;       arr[x / 1000].push_back(make_pair(y, i));     }     for (int i = 0; i < 1001; i++)       if (arr[i].size() > 1) sort(arr[i].begin(), arr[i].end());     bool flag = 0;     for (int i = 0; i < 1001; i++) {       if (arr[i].size()) {         flag = (!flag);         if (flag)           for (int j = 0; j < arr[i].size(); j++) cout << arr[i][j].second <<    ;         else           for (int j = arr[i].size() - 1; j >= 0; j--)             cout << arr[i][j].second <<    ;       }     }   }