malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename U>   inline void smin(T &a, U b) {     if (a > b) a = b;   }   template <typename T, typename U>   inline void smax(T &a, U b) {     if (a < b) a = b;   }   int power(int a, int b, int m, int ans = 1) {     for (; b; b >>= 1, a = 1LL * a * a % m)       if (b & 1) ans = 1LL * ans * a % m;     return ans;   }   struct point {     int first, second;     point(int first = 0, int second = 0) : first(first), second(second) {}     point operator-(point a) { return point(first - a.first, second - a.second); }     long long operator^(point a) {       return (long long)first * a.second - (long long)second * a.first;     }     long long operator*(point a) {       return (long long)first * a.first + (long long)second * a.second;     }     void input() { scanf( %d%d , &first, &second); }   };   int sgn(long long a) { return (a > 0) - (a < 0); }   int is_on(point a, point b, point c) {     if (sgn((a - b) ^ (a - c))) return 0;     return sgn((a - c) * (c - b)) > 0;   }   point ston[10], mons[1111];   int flag[1111], id[10], n, k, runs, used;   vector<int> adj[10][1111];   bool judge(int u) {     if (used >= k) return false;     flag[u] = runs;     int shoot = id[used++];     for (int i = 0; i < adj[shoot][u].size(); i++) {       int v = adj[shoot][u][i];       if (flag[v] != runs) {         if (!judge(v)) return false;       }     }     return true;   }   int main() {     scanf( %d%d , &k, &n);     for (int i = 0; i < k; i++) ston[i].input();     for (int i = 0; i < n; i++) mons[i].input();     for (int i = 0; i < k; i++) {       for (int j = 0; j < n; j++) {         for (int p = 0; p < n; p++)           if (p != j) {             if (is_on(ston[i], mons[j], mons[p])) adj[i][j].push_back(p);             if (adj[i][j].size() >= k) break;           }       }     }     int ans = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < k; j++) id[j] = j;       do {         ++runs;         used = 0;         if (judge(i)) {           ans++;           break;         }       } while (next_permutation(id, id + k));     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1000005, mod = 1000000007;   int ar[N];   inline int lowbit(int x) { return x & (-x); }   void add(int i, int v) {     for (; i < N; i += lowbit(i)) {       ar[i] += v;       if (ar[i] >= mod) {         ar[i] %= mod;       }     }   }   int sum(int i) {     int res = 0;     for (; i > 0; i -= lowbit(i)) {       res += ar[i];       if (res >= mod) res %= mod;     }     return res;   }   int main() {     int n;     scanf( %d , &n);     memset(ar, 0, sizeof(ar));     for (int tp, i = 1; i <= n; i++) {       scanf( %d , &tp);       int s = sum(tp), v = ((long long)s * tp + tp) % mod, t = sum(tp - 1);       t = v - s + t;       if (t < 0) t += mod;       if (t >= mod) t %= mod;       add(tp, t);     }     printf( %d n , sum(N - 1));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[1000010];   int main() {     int n;     scanf( %d , &n);     long long sum = 0;     for (int i = 1; i <= n; ++i) {       scanf( %lld , &a[i]);       sum += a[i];     }     if (sum <= 1) {       printf( -1 n );       return 0;     }     long long ans = 9999999999999999;     for (int i = 2; i * i <= sum; ++i) {       if (sum % i) continue;       long long cnt = 0, pre = 0;       while (sum % i == 0) sum /= i;       for (int j = 1; j <= n; ++j) {         pre = (pre + a[j]) % i;         cnt += min(pre, i - pre);       }       ans = min(ans, cnt);     }     if (sum > 1) {       long long pre = 0, cnt = 0;       for (int j = 1; j <= n; ++j) {         pre = (pre + a[j]) % sum;         cnt += min(pre, sum - pre);       }       ans = min(ans, cnt);     }     printf( %lld , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 1000009;   map<string, int> mapa;   int n, m, k, a, parent[maxN], used[maxN], rozmiar[maxN], centr[maxN], q;   vector<int> graf[maxN];   string s, s1;   void DFS(int start) {     used[start] = 1;     for (int i = 0; i < graf[start].size(); i++) {       if (!used[graf[start][i]]) {         DFS(graf[start][i]);         rozmiar[start] += rozmiar[graf[start][i]];       }     }     rozmiar[start]++;     for (int i = 0; i < graf[start].size(); i++) {       if (graf[start][i] != parent[start]) {         if (rozmiar[graf[start][i]] > rozmiar[start] / 2) {           if (rozmiar[start] - rozmiar[centr[graf[start][i]]] <=               rozmiar[start] / 2)             centr[start] = centr[graf[start][i]];           else {             int x = parent[centr[graf[start][i]]];             while (1) {               if (rozmiar[start] - rozmiar[x] <= rozmiar[start] / 2) {                 centr[start] = x;                 break;               }               x = parent[x];             }           }         }       }     }     if (centr[start] == 0) centr[start] = start;   }   int main() {     scanf( %d%d , &n, &q);     for (int i = 2; i <= n; i++) {       scanf( %d , &a);       parent[i] = a;       graf[i].push_back(a);       graf[a].push_back(i);     }     DFS(1);     for (int i = 0; i < q; i++) {       scanf( %d , &a);       printf( %d n , centr[a]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int a;     cin >> a;     string s;     cin >> s;     map<long long, long long> mp;     long long ans = 0;     for (int i = 0; i < s.size(); i++) {       long long c = 0;       for (int j = i; j < s.size(); j++) {         c += (s[j] -  0 );         mp[c]++;       }     }     for (auto i : mp) {       if (!i.first) {         if (!a) ans += (i.second * i.second);       } else if (a % i.first == 0) {         if (a == 0)           ans += (mp[0] * i.second * 2);         else           ans += (mp[a / i.first] * i.second);       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void fastio() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);   }   int main() {     fastio();     long long int T = 1;     cin >> T;     for (long long int test = 1; test <= T; test++) {       long long int n, m, k, ans, cnt, sum;       ans = 0;       cnt = 100;       sum = 0;       cin >> n >> k;       if (k < n)         ans = k;       else {         while (k && cnt--) {           if (k < n) {             ans += k;             break;           }           long long int z = k / n;           long long int a = z * n;           z *= (n - 1);           long long int q = k - z;           ans += a;           k = q;         }       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, a, b, c, d;     cin >> n >> k >> a >> b >> c >> d;     if (n == 4 || k < n + 1)       cout << -1 << endl;     else {       int cur = 1;       vector<int> ret;       ret.push_back(a);       ret.push_back(c);       while (cur == a || cur == b || cur == c || cur == d) cur++;       ret.push_back(cur);       cur++;       ret.push_back(d);       for (int x = 4; x < n - 1; x++) {         while (cur == a || cur == b || cur == c || cur == d) cur++;         ret.push_back(cur);         cur++;       }       ret.push_back(b);       for (int i = 0; i < n; i++) cout << ret[i] <<    ;       cout << endl;       cout << ret[1] <<     << ret[0] <<     << ret[2] <<     << ret[n - 1]            <<    ;       for (int i = n - 2; i > 2; i--) cout << ret[i] <<    ;       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int k;     cin >> k;     int sz = s.size();     string land;     bool equal;     int begin, lenth, idx, res = 0, end;     for (int i = 0; i < sz; i++) {       begin = i;       land =   ;       for (int j = i; j < sz; j++) {         land += s[j];         end = min(j + 1 + j - begin + 1 - 1, sz - 1);         idx = 0;         equal = 1;         for (int l = j + 1; l <= end; l++, idx++) {           if (land[idx] != s[l]) {             equal = 0;             break;           }         }         lenth = end - (j + 1) + 1;         if (equal && lenth != j - begin + 1 && (j - begin + 1) - lenth <= k) {           if (j == sz - 1)             res = max(res, (((j - begin + 1) + lenth + k) / 2) * 2);           else             res = max(res, 2 * (j - begin + 1));         }         if (equal && lenth == j - begin + 1) res = max(res, 2 * (j - begin + 1));       }     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n];     int cnt = 0;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 1; i < n - 1; i++) {       if (a[i] == 0) {         if (a[i + 1] == 1 && a[i - 1] == 1) {           if (i + 2 < n) {             if (a[i + 2] == 0) {               cnt++;               a[i + 1] = 0;             } else               cnt++;           } else             cnt++;         }       }     }     cout << cnt;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, k;     cin >> n >> m >> k;     int a[m];     for (int i = 0; i < m; ++i) a[i] = 1e7;     for (int i = 0; i < n; ++i) {       int r, c;       cin >> r >> c;       a[r - 1] = min(a[r - 1], c);     }     int ans = 0;     for (int i = 0; i < m; ++i) ans += a[i];     cout << min(ans, k) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 1e5 + 5;   char C[MAXN][20][20];   long long aans[MAXN];   struct node {     long long u, v, val, way;     node() {}     node(long long a, long long b, long long c) {       u = a;       v = b;       val = c;     }   };   vector<node> v;   vector<int> vv[MAXN];   long long fa[MAXN * 10];   bool cmp(node a, node b) { return a.val < b.val; }   long long getf(long long x) {     if (x == fa[x])       return x;     else       return fa[x] = getf(fa[x]);   }   void add(long long a, long long b) { fa[getf(a)] = getf(fa[b]); }   void dfs(long long x, long long fa) {     long long len = vv[x].size();     for (long long i = 0; i < len; i++) {       long long to = vv[x][i];       if (to != fa) {         cout << to <<     << x << endl;         dfs(to, x);       }     }   }   int main() {     long long n, m, k, w;     cin >> n >> m >> k >> w;     for (long long k1 = 1; k1 <= k; k1++) {       for (long long i = 1; i <= n; i++) {         cin >> C[k1][i] + 1;       }     }     for (long long k1 = 1; k1 <= k; k1++) {       for (long long k2 = k1 + 1; k2 <= k; k2++) {         long long num = 0;         for (long long i = 1; i <= n; i++) {           for (long long j = 1; j <= m; j++) {             if (C[k1][i][j] != C[k2][i][j]) num++;           }         }         v.push_back(node(k1, k2, num * w));       }     }     for (long long i = 1; i <= k; i++) {       v.push_back(node(0, i, n * m));     }     long long ans = 0;     for (long long i = 1; i <= k; i++) {       fa[i] = i;     }     sort(v.begin(), v.end(), cmp);     for (long long i = 0; i < v.size(); i++) {       long long aa = v[i].u, cc = v[i].val;       long long bb = v[i].v;       if (getf(aa) != getf(bb)) {         add(aa, bb);         ans += cc;         vv[aa].push_back(bb);         vv[bb].push_back(aa);       }     }     cout << ans << endl;     dfs(0, 0);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     double a1, b1, c1, a2, b2, c2;     cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2;     if (b1 || b2) {       if ((!a1 && !b1 && !c1) || (!a2 && !b2 && !c2)) {         cout << -1;         return 0;         ;       }       if ((!a1 && !b1) || (!a2 && !b2)) {         cout << 0;         return 0;         ;       }       if (!b1 || !b2) {         cout << 1;         return 0;         ;       }     } else {       if ((!a1 && c1) || (!a2 && c2)) {         cout << 0;         return 0;         ;       }       if (!(c2 || c1) || !(a2 || a1) || a1 / c1 == a2 / c2) {         cout << -1;         return 0;         ;       }       {         cout << 0;         return 0;         ;       }     }     if (a1 / b1 == a2 / b2) {       if (c1 / b1 == c2 / b2) {         cout << -1;         return 0;         ;       }       {         cout << 0;         return 0;         ;       }     }     cout << 1;     return 0;     ;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f;   int h[5005];   int dp[5005][2505][2];   void test_case() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d , &h[i]);     memset(dp, INF, sizeof(dp));     dp[0][0][0] = 0;     dp[1][0][0] = 0;     dp[1][1][1] = 0;     for (int i = 2; i <= n; ++i) {       for (int j = 0, c = (i + 1) / 2; j <= c; ++j)         dp[i][j][0] =             min(dp[i - 1][j][0], dp[i - 1][j][1] + max(0, h[i] - (h[i - 1] - 1)));       for (int j = 1, c = (i + 1) / 2; j <= c; ++j)         dp[i][j][1] = min(             dp[i - 2][j - 1][0] + max(0, h[i - 1] - (h[i] - 1)),             dp[i - 2][j - 1][1] +                 max(0, max(h[i - 1] - (h[i] - 1), h[i - 1] - (h[i - 2] - 1))));     }     for (int k = 1, c = (n + 1) / 2; k <= c; ++k)       printf( %d%c , min(dp[n][k][0], dp[n][k][1]),    n [k == c]);   }   int main() {     int t = 1;     for (int ti = 1; ti <= t; ++ti) {       test_case();     }   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:1024000000 )   using namespace std;   struct N {     int x, y;   };   queue<N> q;   char Map[2010][2010];   int jx[] = {-1, 0, 1, 0};   int jy[] = {0, 1, 0, -1};   char CalChar(int dir) {     if (dir == 0) return  v ;     if (dir == 1) return  < ;     if (dir == 2) return  ^ ;     return  > ;   }   int Check(int x, int y, int n, int m) {     bool hav = false;     int dir;     for (int i = 0; i < 4; ++i) {       if (1 <= x + jx[i] && x + jx[i] <= n && 1 <= y + jy[i] && y + jy[i] <= m &&           Map[x + jx[i]][y + jy[i]] ==  . ) {         if (hav) return -1;         hav = true;         dir = i;       }     }     if (hav == false) return -2;     return dir;   }   void Output(int n, int m) {     for (int i = 1; i <= n; ++i) puts(Map[i] + 1);     puts(  );   }   int main() {     int n, m, i, j, tmp;     scanf( %d %d , &n, &m);     for (i = 1; i <= n; ++i) scanf( %s , Map[i] + 1);     for (i = 1; i <= n; ++i) {       for (j = 1; j <= m; ++j) {         if (Map[i][j] ==  . ) {           tmp = Check(i, j, n, m);           if (0 <= tmp) {             q.push((N){i + jx[tmp], j + jy[tmp]});             Map[i][j] = CalChar(tmp);             Map[i + jx[tmp]][j + jy[tmp]] = CalChar((tmp + 2) % 4);           }         }       }     }     N f, t;     while (q.empty() == false) {       f = q.front();       q.pop();       for (i = 0; i < 4; ++i) {         t.x = f.x + jx[i];         t.y = f.y + jy[i];         if (1 <= t.x && t.x <= n && 1 <= t.y && t.y <= m &&             Map[t.x][t.y] ==  . ) {           tmp = Check(t.x, t.y, n, m);           if (tmp == -2) return puts( Not unique ), 0;           if (0 <= tmp) {             Map[t.x][t.y] = CalChar(tmp);             Map[t.x + jx[tmp]][t.y + jy[tmp]] = CalChar((tmp + 2) % 4);             q.push((N){t.x + jx[tmp], t.y + jy[tmp]});           }         }       }     }     for (i = 1; i <= n; ++i) {       for (j = 1; j <= m; ++j)         if (Map[i][j] ==  . ) return puts( Not unique ), 0;     }     for (i = 1; i <= n; ++i) puts(Map[i] + 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       string s;       cin >> s;       int n = s.length();       if (n <= 10) {         cout << s << endl;       } else {         cout << s.at(0);         cout << n - 2;         cout << s.at(n - 1) << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long a[1007];   long long cnt[1007];   long long ncr[1007][1007];   long long MOD = 998244353;   int main() {     long long n, res = 0, x;     scanf( %I64d , &n);     ;     for (long long i = 1; i <= n; ++i) scanf( %I64d , &a[i]);     ;     for (int i = 0; i < 1000; ++i) {       for (int j = 0; j <= i; ++j) {         if (i == 0 || j == 0)           ncr[i][j] = 1;         else           ncr[i][j] = (ncr[i - 1][j] + ncr[i - 1][j - 1]) % MOD;       }     }     for (long long i = n; i > 0; --i) {       if ((a[i] > 0) && ((i + a[i]) <= n)) {         x = ncr[n - i][a[i]];         cnt[i] = x;         for (long long j = i + a[i] + 1; j < n; ++j) {           x = ncr[j - i - 1][a[i]];           x = (x * cnt[j]) % MOD;           cnt[i] = (cnt[i] + x) % MOD;         }       }       res = (res + cnt[i]) % MOD;     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     while (cin >> n) {       if (n == 1) {         printf( a na nb nb n );         continue;       }       if (n % 2 == 0) {         for (int i = 0; i < 4; i++) {           for (int j = 0; j < n; j++) {             if (i % 4 < 2) {               printf( %c ,  a  + (i % 2 + (j % 4) / 2) % 2);             } else {               if (j == 0) {                 printf( %c ,  c );               } else if (j == n - 1) {                 printf( %c ,  f );               } else {                 printf( %c ,  d  + (i % 2 + (j - 1) % 4 / 2) % 2);               }             }           }           printf(  n );         }       } else {         for (int i = 0; i < 4; i++) {           for (int j = 0; j < n; j++) {             if (i < 2) {               if (j == n - 1) {                 printf( %c ,  c );               } else {                 printf( %c ,  a  + (i % 2 + (j % 4) / 2) % 2);               }             } else {               if (j < 1) {                 printf( %c ,  d );               } else {                 printf( %c ,  f  + (i % 2 + (j - 1) % 4 / 2) % 2);               }             }           }           printf(  n );         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = (int)1e9 + 7;   const int N = (int)3e5 + 4;   const int M = 1001;   int n, k;   int a[6];   double ans;   void f(int s) {     if (s == k) {       for (int i = 0; i < n; ++i) {         for (int j = i + 1; j < n; ++j) {           if (a[i] > a[j]) {             ++ans;           }         }       }       return;     }     for (int i = 0; i < n; ++i) {       for (int j = i; j < n; ++j) {         reverse(a + i, a + j + 1);         f(s + 1);         reverse(a + i, a + j + 1);       }     }   }   int main() {     cin >> n >> k;     for (int i = 0; i < n; ++i) {       cin >> a[i];     }     f(0);     for (int i = 0; i < k; ++i) {       ans /= n;       ans /= (n + 1);       ans *= 2.0;     }     printf( %.10lf , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long test, i, j, xy, flag = 0, n, u, count, d, o1 = 0, o2 = 0, s, e, l,                               r, x, y, m, z, max1, x1, y1, k, x2, y2, z1, sum, f,                               min1;     cin >> test;     while (test--) {       x1 = y1 = 0;       string a;       cin >> n >> x >> y >> z >> a;       for (i = 0; i < n; i++) {         if (a[i] ==  0 ) {           x1++;         } else {           y1++;         }       }       x2 = (x1 * z) + (x1 * y) + (y1 * y);       y2 = (y1 * z) + (y1 * x) + (x1 * x);       z1 = x1 * x + y1 * y;       cout << min(min(x2, y2), z1) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long s, x;     cin >> s >> x;     s -= x;     if (s % 2 || s < 0) {       cout << 0 <<   n ;       return 0;     }     s >>= 1;     bool ok = true;     for (int i = 50; i >= 0; --i)       if (s & (1LL << i)) ok &= (~x & (1LL << i)) != 0;     if (!ok) {       cout << 0 <<   n ;       return 0;     }     long long ans = 1LL << __builtin_popcountll(x);     cout << (s == 0 ? ans - 2 : ans) <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, a[105], b[105], i, q, j, f, x, c = 0;     double s = 0, s1 = 0, min = -1, max = -1;     cin >> n >> k;     for (i = 1; i <= n; i++) cin >> a[i];     cin >> q;     for (i = 1; i <= q; i++) {       f = 0;       s = 0;       for (j = 1; j <= n / k; j++) {         cin >> x;         if (a[x] == -1) {           f = 1;         }         s = s + a[x];         a[x] = -1;       }       if (f == 0) {         c++;         s = s / (n / k);         if (i == 1) {           min = s;           max = s;         } else {           if (s < min)             min = s;           else if (s > max)             max = s;         }       }     }     j = 0;     for (i = 1; i <= n; i++) {       if (a[i] != -1) b[j++] = a[i];     }     sort(b, b + j);     if (j >= (n / k) && k - c >= 1) {       s = 0;       s1 = 0;       for (i = 0; i < (n / k); i++) {         s = s + b[i];         s1 = s1 + b[j - 1 - i];       }       s = s / (n / k);       s1 = s1 / (n / k);       if (min == -1 && max == -1) {         min = s;         max = s1;       } else {         if (s < min) min = s;         if (s1 > max) max = s1;       }     }     printf( %0.10lf %0.10lf , min, max);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   using u64 = uint64_t;   using u32 = uint32_t;   using pi = pair<int, int>;   using pl = pair<ll, ll>;   using vi = vector<int>;   using vl = vector<ll>;   using vvi = vector<vi>;   using vpi = vector<pi>;   static constexpr int INF = (int)1e9;   static constexpr ll INFL = (ll)1e18;   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int n, m;     cin >> n >> m;     vector<string> s(n), t(m);     for (auto& si : s) cin >> si;     for (auto& ti : t) cin >> ti;     int q, y;     cin >> q;     while (q--) cin >> y, --y, cout << s[y % n] << t[y % m] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long int n;     cin >> n;     if (n > 2) {       for (long long int i = 0; i < n - 1; i++) cout << 2 <<    ;       cout << 1 << endl;     } else       cout << -1 << endl;   }   void testcase() {     int t;     cin >> t;     while (t--) {       solve();     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     solve();   }
#include <bits/stdc++.h>   using namespace std;   const int MOD(1000000007);   const int INF((1 << 30) - 1);   const int MAXN();   int main() {     long long k, b, t;     int n;     cin >> k >> b >> n >> t;     long long z = 1;     int num = 0;     while (z <= t) {       z = z * k + b;       num++;     }     printf( %d , max(0, n - num + 1));   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ull = unsigned long long;   using uint = unsigned int;   const int NMax = 1e2 + 5;   const ll inf_ll = 1e18 + 5;   const int inf_int = 1e9 + 5;   const int mod = 100003;   using zint = int;   void getABC(char* sir, int& a, int& b, int& c) {     ++sir;     a = 0;     while (isdigit(*sir)) {       a = a * 10 + *sir -  0 ;       ++sir;     }     ++sir;     b = 0;     while (isdigit(*sir)) {       b = b * 10 + *sir -  0 ;       ++sir;     }     ++sir;     ++sir;     c = 0;     while (*sir != 0 && isdigit(*sir)) {       c = c * 10 + *sir -  0 ;       ++sir;     }   }   int euclid(int a, int b) { return b ? euclid(b, a % b) : a; }   int main() {     cin.sync_with_stdio(false);     cin.tie(0);     int N;     cin >> N;     char sir[100];     map<pair<int, int>, int> make_pair;     vector<pair<int, int>> v(N + 1);     for (int i = 1; i <= N; ++i) {       cin >> sir;       int a, b, c;       getABC(sir, a, b, c);       int top = a + b;       int gcd = euclid(top, c);       top /= gcd;       c /= gcd;       make_pair[{top, c}]++;       v[i] = {top, c};     }     for (int i = 1; i <= N; ++i) {       cout << make_pair[v[i]] <<    ;     }     return 0;   }