malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma comment(linker,  /stack:200000000 )   #pragma GCC optimize( Ofast )   #pragma GCC optimize( unroll-loops )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   const long long inf = numeric_limits<long long>::max() / 2;   const long double eps = 1e-9;   const long double pi = acos(-1);   template <typename T>   inline bool mineq(T& a, T b) {     return (a > b) ? (a = b, 1) : 0;   }   template <typename T>   inline bool maxeq(T& a, T b) {     return (a < b) ? (a = b, 1) : 0;   }   inline void solve(), read();   const string file =   ;   int main() {     if (file !=   ) {       freopen((file +  .in ).c_str(),  r , stdin);       freopen((file +  .out ).c_str(),  w , stdout);     }     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     ;     read();     solve();     return 0;   }   long long n;   vector<long long> a;   vector<pair<long long, long long> > b;   inline void solve() {     for (long long i = 0; i < n; i++) {       if (i && a[i] == a[i - 1]) {         ++b.back().second;       } else if (i == 0 || a[i] == a[i - 1] + 1) {         b.push_back({a[i], 1});       } else {         cout <<  NO               <<   n ;         return;       }     }     for (long long i = 0; i < (long long)((b).size()) - 2; i++) {       b[i + 1].second -= b[i].second;       if (b[i + 1].second <= 0) {         cout <<  NO               <<   n ;         return;       }     }     if (b[(long long)((b).size()) - 1].second !=         b[(long long)((b).size()) - 2].second) {       cout <<  NO             <<   n ;       return;     }     cout <<  YES           <<   n ;   }   inline void read() {     cin >> n;     a.resize(n);     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     sort((a).begin(), (a).end());   }
#include <bits/stdc++.h>   using namespace std;   long long base = 31, M = 1000000007, base1 = 29, M1 = 1000000009;   long long fpow(long long x, long long y) {     if (y == 0) return 1;     if (y == 1) return x;     long long p = fpow(x, y / 2) % M;     p *= p;     p %= M;     if (y & 1) p *= x;     return p % M;   }   long long po1[5005], pr[5005], po[5005], pr1[5005], suf[5005], suf1[5005];   int ans[5005][5005], dp[5005][5005];   pair<long long, long long> gethash(int i, int j) {     long long has = pr[j];     if (i != 0) has -= (pr[i - 1] * po[j - i + 1]) % M;     has += M;     has %= M;     long long has1 = pr1[j];     if (i != 0) has1 -= (pr1[i - 1] * po1[j - i + 1]) % M1;     has1 += M1;     has1 %= M1;     return {has, has1};   }   pair<long long, long long> gethash1(int i, int j) {     long long has = suf[j];     if (i != 0) has -= (suf[i - 1] * po[j - i + 1]) % M;     has += M;     has %= M;     long long has1 = suf1[j];     if (i != 0) has1 -= (suf1[i - 1] * po1[j - i + 1]) % M1;     has1 += M1;     has1 %= M1;     return {has, has1};   }   int main() {     po[0] = 1;     po1[0] = 1;     for (int i = 1; i <= 5001; i++) {       po[i] = po[i - 1] * base;       po1[i] = po1[i - 1] * base1;       po[i] %= M;       po1[i] %= M1;     }     string s, t;     char c[100005];     scanf( %s , &c);     s = c;     int n = s.size();     t = s;     reverse(t.begin(), t.end());     int q;     scanf( %d , &q);     pr[0] = s[0] -  a  + 1;     pr1[0] = s[0] -  a  + 1;     suf[0] = t[0] -  a  + 1;     suf1[0] = t[0] -  a  + 1;     for (int i = 1; i < s.size(); i++) {       long long x = s[i] -  a  + 1;       long long y = t[i] -  a  + 1;       pr[i] = (pr[i - 1] * base + x) % M;       pr1[i] = (pr1[i - 1] * base1 + x) % M1;       suf[i] = (suf[i - 1] * base + y) % M;       suf1[i] = (suf1[i - 1] * base1 + y) % M1;     }     for (int i = 0; i < n; i++) {       for (int j = i; j < n; j++) {         pair<long long, long long> o = gethash(i, j);         pair<long long, long long> os = gethash1(n - 1 - j, n - 1 - i);         if (o.first == os.first && o.second == os.second) ans[i][j]++;         if (j != i) ans[i][j] += ans[i][j - 1];       }     }     for (int i = n - 1; i >= 0; i--) {       for (int j = i; j >= 0; j--) {         dp[j][i] = dp[j + 1][i] + ans[j][i];       }     }     int l, r;     while (q--) {       scanf( %d%d , &l, &r);       l--;       r--;       printf( %d n , dp[l][r]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)3e5 + 50;   struct node {     int sum, suf;     void add(int val) {       sum += val;       suf = max(sum, 0);     }   };   node merge(node L, node R) {     return {L.sum + R.sum, max(R.sum + L.suf, R.suf)};   }   struct Tree {     node dat[4 * N];     void init(int n) { fill(dat, dat + 4 * n, node{0, 0}); }     void update(int pos, int x, int l, int r, int val) {       if (l == r) {         dat[x].add(val);         return;       }       int mid = (l + r) / 2;       if (pos <= mid)         update(pos, 2 * x + 1, l, mid, val);       else         update(pos, 2 * x + 2, mid + 1, r, val);       dat[x] = merge(dat[2 * x + 1], dat[2 * x + 2]);     }   } tree;   int n;   int loc[N];   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     tree.init(n);     for (int i = 0; i < n; i++) {       int x;       cin >> x;       x--;       loc[x] = i;     }     int cur = n - 1;     for (int i = 0; i < n; i++) {       while (cur >= 0 && tree.dat[0].suf == 0) {         tree.update(loc[cur--], 0, 0, n - 1, 1);       }       cout << cur + 2 <<    ;       int q;       cin >> q;       q--;       tree.update(q, 0, 0, n - 1, -1);     }   }
#include <bits/stdc++.h>   using namespace std;   long long max(long long a, long long b) {     if (a > b)       return a;     else       return b;   }   long long min(long long a, long long b) {     if (a < b)       return a;     else       return b;   }   int32_t main() {     ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     long long n;     cin >> n;     string s =   ;     long long i = 0;     while (i < n) {       if (i < n) {         s +=  a ;         i++;       }       if (i < n) {         s +=  a ;         i++;       }       if (i < n) {         s +=  b ;         i++;       }       if (i < n) {         s +=  b ;         i++;       }     }     cout << s <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 105;   int n, m, a[maxn][maxn];   int sumr[maxn], sumc[maxn];   bool ar[maxn], ac[maxn];   int main() {     ios_base::sync_with_stdio(0);     cin >> n >> m;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) cin >> a[i][j];     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) sumr[i] += a[i][j];     }     for (int j = 0; j < m; j++) {       for (int i = 0; i < n; i++) sumc[j] += a[i][j];     }     while (1) {       bool b = 0;       for (int i = 0; i < n; i++)         if (sumr[i] < 0) {           b = 1;           ar[i] ^= 1;           for (int j = 0; j < m; j++) sumc[j] -= 2 * a[i][j], a[i][j] = -a[i][j];           sumr[i] *= -1;         }       for (int j = 0; j < m; j++)         if (sumc[j] < 0) {           b = 1;           ac[j] ^= 1;           for (int i = 0; i < n; i++) sumr[i] -= 2 * a[i][j], a[i][j] = -a[i][j];           sumc[j] *= -1;         }       if (!b) break;     }     vector<int> vr, vc;     for (int i = 0; i < n; i++)       if (ar[i]) vr.push_back(i);     for (int i = 0; i < m; i++)       if (ac[i]) vc.push_back(i);     cout << vr.size() <<    ;     for (int i : vr) cout << i + 1 <<    ;     cout <<   n ;     cout << vc.size() <<    ;     for (int i : vc) cout << i + 1 <<    ;     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int x1, y1;     cin >> x1 >> y1;     int x2, y2;     cin >> x2 >> y2;     int ans = 0x3f3f3f3f;     for (int i = -1; i <= 1; i++) {       for (int j = -1; j <= 1; j++) {         if (i == 0 && j == 0) {           continue;         }         ans = min(ans, abs(x1 - (x2 + i)) + abs(y1 - (y2 + j)));       }     }     cout << 2 * ans + 8;   }
#include <bits/stdc++.h>   int main() {     int n, m, a, b, t;     while (scanf( %d%d%d%d , &n, &m, &a, &b) != EOF) {       if (b == n) b = (n - 1) / m * m + m;       a--;       b--;       if (a > b)         while (1)           ;       if (a / m == b / m || m == 1)         t = 1;       else if (a % m == 0) {         if (b % m == m - 1)           t = 1;         else           t = 2;       } else {         if (b / m - a / m == 1)           t = 2;         else if (b % m == m - 1)           t = 2;         else if ((b - a + 1) % m == 0)           t = 2;         else           t = 3;       }       printf( %d n , t);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int a[1000][7], i, j, m = 0, n;     string ar;     cin >> n;     for (i = 0; i < n; i++) {       cin >> ar;       for (j = 0; j < 7; j++) {         a[i][j] = ar[j] - 48;       }     }     for (j = 0; j < 7; j++) {       long long int l = 0;       for (i = 0; i < n; i++) {         if (a[i][j] == 1) {           l++;         }       }       if (l > m) {         m = l;       }     }     cout << m << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int Set(int N, int pos) { return N |= (1LL << pos); }   int Reset(int N, int pos) { return N &= ~(1LL << pos); }   bool Check(int N, int pos) { return N & (1LL << pos); }   int dx[] = {0, 0, 1, -1, 1, -1, 1, -1}, dy[] = {1, -1, 0, 0, 1, -1, -1, 1};   template <class T>   void cmin(T &a, T b) {     if (b < a) a = b;   }   template <class T>   void cmax(T &a, T b) {     if (b > a) a = b;   }   template <class T>   int len(const T &c) {     return (int)c.size();   }   template <class T>   int len(char c[]) {     return (int)strlen(c);   }   string itos(long n) {     string s;     while (n) {       s += (n % 10 + 48);       n /= 10;     }     reverse(s.begin(), s.end());     return s;   }   long stoi(string s) {     long n = 0;     for (int i(0), _n(len(s)); i < _n; ++i) n = n * 10 + (s[i] - 48);     return n;   }   long long n, ar[200005], arr[200005], m, a, p, b, aa, bb, mx = 0;   pair<int, int> fun(long d) {     p = upper_bound(ar, ar + n, d) - ar;     a = (p * 2 + (n - p) * 3);     p = upper_bound(arr, arr + m, d) - arr;     b = (p * 2 + (m - p) * 3);     return make_pair(a, b);   }   int main() {     mx = -100000000000000000LL;     cin >> n;     for (int i(0), _n(n); i < _n; ++i) cin >> ar[i];     cin >> m;     for (int i(0), _n(m); i < _n; ++i) cin >> arr[i];     sort(ar, ar + n);     sort(arr, arr + m);     aa = n * 3;     bb = m * 3;     mx = aa - bb;     pair<int, int> pr;     pr = fun(ar[0] - 1);     a = pr.first;     b = pr.second;     if (a - b > mx) {       mx = a - b;       aa = a;       bb = b;     } else if (a - b == mx && a > aa) {       aa = a;       bb = b;     }     for (int i(0), _n(n); i < _n; ++i) {       pr = fun(ar[i]);       a = pr.first;       b = pr.second;       if (a - b > mx) {         mx = a - b;         aa = a;         bb = b;       } else if (a - b == mx && a > aa) {         aa = a;         bb = b;       }     }     for (int i(0), _n(m); i < _n; ++i) {       pr = fun(arr[i]);       a = pr.first;       b = pr.second;       if (a - b > mx) {         mx = a - b;         aa = a;         bb = b;       } else if (a - b == mx && a > aa) {         aa = a;         bb = b;       }     }     pr = fun(ar[n - 1] + 1);     a = pr.first;     b = pr.second;     if (a - b > mx) {       mx = a - b;       aa = a;       bb = b;     } else if (a - b == mx && a > aa) {       aa = a;       bb = b;     }     cout << aa <<  :  << bb;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int getResult(long long y) {     printf( %lld n , y);     fflush(stdout);     int vd;     scanf( %d , &vd);     if (vd <= 0) exit(0);     vd--;     return vd;   }   bool solve(vector<long long> a) {     int maxIndex = 0;     for (int i = 1; i < 3; i++)       if (a[i] > a[maxIndex]) maxIndex = i;     int minIndex = 0;     for (int i = 1; i < 3; i++)       if (a[i] < a[minIndex]) minIndex = i;     int middle = 3 - maxIndex - minIndex;     long long w = 2 * a[maxIndex] - a[minIndex] - a[middle];     int r = getResult(w);     if (r == maxIndex) {       a[maxIndex] += w;       return solve(a);     } else {       int otherone = 3 - maxIndex - r;       long long w2 = a[maxIndex] - a[otherone];       int r2 = getResult(w2);       return r2 == 0;     }   }   int main() {     vector<long long> a(3);     for (int i = 0; i < 3; i++) scanf( %lld , &a[i]);     printf( First n );     fflush(stdout);     solve(a);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-8;   const int INFI = 1000 * 1000 * 1000;   const long long INFL = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;   const int MX_N = 1000;   int N;   string s, t;   string strs[] = { abc ,  acb ,  bac ,  bca ,  cab ,  cba };   int nstrs = 6;   int main() {     cin >> N;     cin >> s >> t;     int dobc = 0;     cout <<  YES  << endl;     if (s[0] == s[1]) ++dobc;     if (t[0] == t[1]) ++dobc;     if (N == 1 || !dobc) {       for (int i = 0; i < nstrs; ++i) {         string s1 = strs[i].substr(0, 2);         string s2 = strs[i].substr(1, 2);         if (s == s1 || s == s2 || t == s1 || t == s2) continue;         for (int j = 0; j < 3; ++j)           for (int k = 0; k < N; ++k) cout << strs[i][j];         putchar(  n );         return 0;       }     } else {       for (int i = 0; i < nstrs; ++i) {         bool pass = true;         string ap = strs[i] + strs[i];         for (int j = 0; j < ap.size() - 1 && pass; ++j) {           string sb = ap.substr(j, 2);           if (s == sb || t == sb) pass = false;         }         if (!pass) continue;         for (int j = 0; j < N; ++j) cout << strs[i];         cout << endl;         break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[200000];   long long INF = 1e12;   inline bool comp_bit(int x, int y) { return !!(x & y); }   inline int binsearch(int l, int r, int depth) {     return (upper_bound(a + l, a + r, 1 << depth, comp_bit) - a);   }   long long connect(int depth, int l1, int r1, int l2, int r2) {     if (l1 == r1 || l2 == r2) return INF;     if (a[l1] == a[r1 - 1] && a[l2] == a[r2 - 1]) return a[l1] ^ a[l2];     int mid1 = binsearch(l1, r1, depth), mid2 = binsearch(l2, r2, depth);     if (mid1 == l1 && mid2 == r2 || mid1 == r1 && mid2 == l2)       return connect(depth - 1, l1, r1, l2, r2);     else       return min(connect(depth - 1, l1, mid1, l2, mid2),                  connect(depth - 1, mid1, r1, mid2, r2));   }   long long solve(int depth, int l, int r) {     if (!depth) return (a[l] ^ a[r - 1]) & 1;     int mid = binsearch(l, r, depth);     if (mid == l || mid == r)       return solve(depth - 1, l, r);     else       return connect(depth - 1, l, mid, mid, r) + solve(depth - 1, l, mid) +              solve(depth - 1, mid, r);   }   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < n; ++i) scanf( %d , &a[i]);     sort(a, a + n);     printf( %lld , solve(29, 0, n));   }
#include <bits/stdc++.h>   using namespace std;   struct tim {     int begin, end;   } t[200005];   int cmp(tim a, tim b) {     if (a.begin != b.begin) return a.begin < b.begin;     return a.end < b.end;   }   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) cin >> t[i].begin >> t[i].end;     sort(t + 1, t + n + 1, cmp);     t[0].end = -1;     int p[3] = {0};     int i;     for (i = 1; i <= n; i++) {       if (t[p[1]].end < t[i].begin) {         p[1] = i;         continue;       }       if (t[p[2]].end < t[i].begin) {         p[2] = i;         continue;       }       break;     }     if (i > n)       cout <<  YES ;     else       cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   int c[210];   int pre[210][210];   int precnt[210];   int cnt[210] = {0};   int main() {     int n;     scanf( %d , &n);     for (int i = 0; i < (n); i++) {       scanf( %d , c + i);       c[i] %= 3;     }     for (int i = 0; i < (n); i++)       for (int j = 0; j < (n); j++) pre[i][j] = 0;     for (int i = 0; i < (n); i++) {       scanf( %d , precnt + i);       int t;       for (int j = 0; j < (precnt[i]); j++) {         scanf( %d , &t);         pre[i][t - 1] = 1;       }     }     int mintime = 1000100;     for (int p = 0; p < (3); p++) {       int pos = p, time = 0, done = 0;       for (int i = 0; i < (n); i++) cnt[i] = 0;       while (done < n) {         queue<int> Q;         for (int i = 0; i < (n); i++)           if (precnt[i] == cnt[i] && c[i] == pos) Q.push(i);         while (!Q.empty()) {           int part = Q.front();           Q.pop();           done++;           time++;           cnt[part]++;           for (int i = 0; i < (n); i++)             if (pre[i][part] == 1) {               cnt[i]++;               if (cnt[i] == precnt[i] && c[i] == pos) Q.push(i);             }         }         pos = (pos + 1) % 3;         time++;       }       time--;       if (time < mintime) mintime = time;     }     printf( %d n , mintime);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   bool isPrime(long long n) {     long long c;     if (n <= 1) return false;     c = sqrt(n);     for (int i = 2; i <= c; i++)       if (n % i == 0) return false;     return true;   }   int D(long long n) {     int count = 0;     while (n != 0) {       n = n / 10;       ++count;     }     return count;   }   const long long N = 2e5 + 7;   long long l, k, d, tr, n, m, sum, mini, maxi, a, b, c, x, y;   long long t[5007];   set<int> vis;   vector<int> v;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     for (cin >> tr; tr--;) {       cin >> n;       mini = 0;       cin >> t[0];       for (int i = 1; i < n; i++) {         cin >> t[i];         if (t[i] != t[i - 1]) {           a = i;           c = t[i];           b = i - 1;           mini++;         }       }       if (mini) {         cout <<  YES  << endl;         for (int i = 0; i < n; i++) {           if (i != a) {             if (t[i] != c) {               cout << i + 1 <<     << a + 1 << endl;             } else {               cout << i + 1 <<     << b + 1 << endl;             }           }         }       } else {         cout <<  NO  << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 3e5 + 5, LOG = 19, off = 1 << 19;   pair<int, int> t[LOG][2 * off];   void upd(int x, pair<int, int> p, int lg) {     for (x += off; x; x /= 2) {       t[lg][x].first = min(t[lg][x].first, p.first);       t[lg][x].second = max(t[lg][x].second, p.second);     }   }   pair<int, int> get(int x, int lo, int hi, int a, int b, int lg) {     if (lo >= a && hi <= b) {       return t[lg][x];     }     if (lo >= b || hi <= a) {       return {off, 0};     }     int mid = (lo + hi) >> 1;     pair<int, int> lson = get(x * 2, lo, mid, a, b, lg);     pair<int, int> rson = get(x * 2 + 1, mid, hi, a, b, lg);     return pair<int, int>(min(lson.first, rson.first),                           max(lson.second, rson.second));   }   int r[MAXN];   pair<int, int> par[MAXN][LOG];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> r[i];     }     if (n == 1) {       cout << 0;       return 0;     }     for (int i = 0; i < 2 * off; ++i)       for (int lg = 0; lg < LOG; ++lg) {         t[lg][i].first = off;       }     for (int i = 0; i < n; ++i)       for (int j = 0; j < 3; ++j) {         par[i + j * n][0].first = max(0, i + j * n - r[i]);         par[i + j * n][0].second = min(3 * n - 1, i + j * n + r[i]);         upd(i + j * n, par[i + j * n][0], 0);       }     for (int lg = 1; lg < LOG; ++lg) {       for (int i = n; i < 2 * n; ++i) {         par[i][lg] = get(1, 0, off, par[i][lg - 1].first,                          par[i][lg - 1].second + 1, lg - 1);       }       for (int i = 0; i < n; ++i) {         par[i][lg].first = max(0, par[i + n][lg].first - n);         par[i][lg].second = min(3 * n - 1, par[i + n][lg].second - n);       }       for (int i = 2 * n; i < 3 * n; ++i) {         par[i][lg].first = max(0, par[i - n][lg].first + n);         par[i][lg].second = min(3 * n - 1, par[i - n][lg].second + n);       }       for (int i = 0; i < 3 * n; ++i) {         upd(i, par[i][lg], lg);       }     }     for (int j = 0; j < n; ++j) {       int i = n + j;       int lo = i, hi = i, sol = 0;       for (int lg = LOG - 1; lg >= 0; --lg) {         pair<int, int> res = get(1, 0, off, lo, hi + 1, lg);         if (res.second - res.first + 1 < n) {           lo = res.first;           hi = res.second;           sol += (1 << lg);         }       }       cout << sol + 1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /STACK:255000000 )   bool firstout = 1;   template <class T>   T &minn(T &a, T b) {     if (b < a) a = b;     return a;   }   template <class T>   T &maxx(T &a, T b) {     if (a < b) a = b;     return a;   }   int &madd(int &a, int b) {     a += b;     if (a >= 1000000009) a -= 1000000009;     return a;   }   int &msub(int &a, int b) {     a -= b;     if (a < 0) a += 1000000009;     return a;   }   int &mmult(int &a, int b) { return a = (long long)a * b % 1000000009; }   int mdiv(long long a, long long b, long long m) {     a = (a % m + m) % m;     b = (b % m + m) % m;     if (a % b == 0) return a / b;     return (a + m * mdiv(-a, m, b)) / b;   }   int n, m;   int A[201234];   int B[201234];   int R[201234];   int RR[201234];   int P[201234];   vector<int> O[201234];   vector<int> OO[201234];   void fnd(int *R) {     int i, j, k;     for (i = (0); i < (n); ++i) P[B[i]] = i;     for (i = (0); i < (2 * n); ++i) OO[i].clear(), O[i].clear();     for (i = (0); i < (n); ++i) {       j = P[A[i]];       j = (i - j + n) % n;       O[j].push_back(-j);       OO[j + n - i].push_back(-j);     }     for (i = (0); i < (n); ++i) R[i] = 1012345678;     multiset<int> s;     s.clear();     for (i = (0); i < (2 * n); ++i) {       for (k = (0); k < (O[i].size()); ++k) s.insert(O[i][k]);       for (k = (0); k < (OO[i].size()); ++k) s.erase(s.find(OO[i][k]));       if (s.size()) minn(R[i % n], *s.begin() + i);     }   }   int main() {     int i, j, k;     char c;     int a, d;     int ts;     for (ts = 1; scanf( %                          d ,                        &(n)) > 0;          ++ts) {       for (i = (0); i < (n); ++i)         scanf(              %               d ,             &(A[i])),             --A[i];       for (i = (0); i < (n); ++i)         scanf(              %               d ,             &(B[i])),             --B[i];       fnd(R);       reverse(A, A + n);       reverse(B, B + n);       fnd(RR);       int res = 0;       for (i = (0); i < (n); ++i)         printf(              %               d ,             (min(RR[i], R[(n - i) % n]))),             printf(  n ), firstout = 1;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<double, int> a;   double b[200007];   inline long long int read() {     long long int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return x * f;   }   inline void writ(int x) {     if (x < 0) putchar( - ), x = -x;     if (x > 9) writ(x / 10);     putchar(x % 10 +  0 );   }   inline void write(int x) {     writ(x);     putchar(   );   }   int main() {     a.clear();     int n = read(), x, y, z;     for (int i = 1; i <= n; ++i)       x = read(), y = read(), z = read(), b[i] = (double)(x + y) / z, ++a[b[i]];     for (int i = 1; i <= n; ++i) write(a[b[i]]);     return 0;   }