malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     int arr[2000];     memset(arr, 0, sizeof(arr));     string s;     cin >> s;     for (int i = 0; i < n; i++) arr[s[i]]++;     int m = 10000000;     for (int i = 65; i < 65 + k; i++) m = min(arr[i], m);     cout << m * k;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2e1 + 5;   map<int, int> mp;   long long n, arr[MAXN], brr[MAXN], crr[MAXN];   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> arr[i];       brr[i] = arr[i];     }     sort(arr, arr + n);     for (int i = 0; i < n; i++) {       crr[i] = arr[(i + 1) % n];     }     for (int i = 0; i < n; i++) {       mp[arr[i]] = crr[i];     }     for (int i = 0; i < n; i++) {       cout << mp[brr[i]] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   const int N = 1e5 + 1, B = 128;   int i, j, n, m, r, a[N], f[N][B];   int main() {     for (scanf( %d , &n); ++i <= n; scanf( %d , a + i))       ;     for (j = 1; j < B; ++j)       for (i = n; i; --i) f[i][j] = i + j + a[i] > n ? 1 : f[i + j + a[i]][j] + 1;     for (scanf( %d , &m); m--;) {       scanf( %d%d , &i, &j);       if (j < B)         printf( %d n , f[i][j]);       else {         for (r = 0; i <= n; i += j + a[i]) ++r;         printf( %d n , r);       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> a(n);     for (auto &ai : a) cin >> ai;     vector<pair<int, int>> v;     vector<bool> b(n);     for (int i = 0; i < n; i++) {       if (a[i] == 0) {         sort(begin(v), end(v));         for (int k = 0; k < 3; k++)           if (!v.empty()) {             b[v.back().second] = true, v.pop_back();           }         v.clear();       } else {         v.emplace_back(a[i], i);       }     }     int cnt = 0;     for (int i = 0; i < n; i++) {       if (a[i] == 0) {         cout << cnt;         if (1 <= cnt) cout <<   popStack ;         if (2 <= cnt) cout <<   popQueue ;         if (3 <= cnt) cout <<   popFront ;         cout << endl;         cnt = 0;       } else {         if (b[i]) {           cnt++;           if (cnt == 1) cout <<  pushStack  << endl;           if (cnt == 2) cout <<  pushQueue  << endl;           if (cnt == 3) cout <<  pushFront  << endl;         } else {           cout <<  pushBack  << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, kezd[200002], veg[200002], pos[200002], inv[200002], x, csa, csb;   vector<pair<pair<int, int>, int> > sz;   vector<int> v;   priority_queue<pair<int, int> > q;   void p() {     for (int i = 1; i <= n; i++) inv[pos[i]] = i;     for (int i = 1; i <= n; i++) cout << inv[i] <<    ;     cout <<   n ;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) {       int a, b;       cin >> a >> b, kezd[i] = a, veg[i] = b;       sz.push_back({{a, b}, i});     }     sort(sz.begin(), sz.end());     for (int i = 1; i <= n; i++) {       while (x < n && sz[x].first.first == i)         q.push({-sz[x].first.second, sz[x].second}), x++;       pos[i] = q.top().second, q.pop();     }     for (int i = 1; i <= n; i++) {       while (v.size() > 0 && veg[pos[v.back()]] < i) {         v.pop_back();       }       int a = kezd[pos[i]], b = veg[pos[i]];       if (v.size() > 0 && a <= v.back()) {         csa = i, csb = v.back();       }       while (v.size() > 0 && b >= veg[pos[v.back()]]) v.pop_back();       v.push_back(i);     }     if (!csa) {       cout <<  YES             <<   n ;       p();     } else {       cout <<  NO             <<   n ;       p();       swap(pos[csa], pos[csb]);       p();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     bool ok = 0;     int res = 0;     char c;     while (((c = getchar()) <  0  || c >  9 ) && c !=  - )       ;     if (c ==  - )       ok = 1;     else       res = c - 48;     while ((c = getchar()) >=  0  && c <=  9 )       res = (res << 3) + (res << 1) + (c - 48);     return ok ? ~res + 1 : res;   }   const int N = 4e5, M = 4e5;   int h[N], net[M], go[M], val[M], dep[N], ecnt = 1, cap[M];   void add(int u, int v, int w) {     go[++ecnt] = v;     cap[ecnt] = w;     net[ecnt] = h[u];     h[u] = ecnt;     swap(u, v);     go[++ecnt] = v;     cap[ecnt] = 0;     net[ecnt] = h[u];     h[u] = ecnt;   }   int s, t, n, m;   int bfs() {     memset(dep, 0, sizeof(dep));     queue<int> q;     q.push(s);     dep[s] = 1;     while (!q.empty()) {       int u = q.front();       q.pop();       for (int e = h[u]; e; e = net[e]) {         int v = go[e];         if (!dep[v] && cap[e]) {           dep[v] = dep[u] + 1;           q.push(v);         }       }     }     return dep[t];   }   int dfs(int u, int flow) {     if (u == t) return flow;     int res = 0, tot = 0;     for (int e = h[u]; e; e = net[e]) {       int v = go[e];       if (dep[v] == dep[u] + 1 && cap[e]) {         res = dfs(v, min(flow, cap[e]));         tot += res;         cap[e] -= res;         cap[e ^ 1] += res;         flow -= res;       }     }     if (tot == 0) dep[u] = 0;     return tot;   }   int a[100000], v[100000];   int g;   int main() {     int cntg = 0;     int sum = 0;     int sum1 = 0;     s = N - 2;     t = N - 1;     n = read();     m = read();     g = read();     for (int i = 1; i <= n; i++) a[i] = read();     for (int i = 1; i <= n; i++) {       v[i] = read();       if (a[i] == 0)         sum -= v[i], add(s, i, v[i]), sum1 += v[i];       else         add(i, t, v[i]);     }     for (int i = 1, w, k, u, op; i <= m; i++) {       op = read();       w = read();       k = read();       while (k--) {         u = read();         if (op)           add(u, i + n, 1e9);         else           add(i + n, u, 1e9);       }       int newop = read();       if (op == 0 && newop == 1) sum -= g;       if (op == 0)         add(s, i + n, w + (newop ? g : 0)), sum1 += w + (newop ? g : 0);       else         add(i + n, t, w + (newop ? g : 0));       if (op == 1) sum += w;     }     int ans = 0;     int res = 0;     while (bfs()) {       ans += dfs(s, 1e9);     }     printf( %d n , sum + sum1 - ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   auto SEED = chrono::steady_clock::now().time_since_epoch().count();   mt19937 rng(SEED);   int main() {     int n, k;     cin >> n >> k;     int dist[n][n];     for (int i = (0); i < (n); i++) {       for (int j = (0); j < (n); j++) {         cin >> dist[i][j];       }     }     int t = 0;     int color[n];     long long int ans = 1ll << 60;     while (t < 5000) {       for (int i = (0); i < (n); i++) {         int tt = uniform_int_distribution<int>(1, n)(rng);         color[i] = tt & 1;       }       long long int dp[n][k];       for (int j = (0); j < (k + 1); j++) {         for (int i = (0); i < (n); i++) {           if (j) {             dp[i][j] = 1ll << 60;             for (int l = (0); l < (n); l++) {               if (color[i] + color[l] == 1) {                 dp[i][j] = min(dp[i][j], dp[l][j - 1] + dist[l][i]);               }             }           } else {             if (i)               dp[i][j] = 1ll << 60;             else               dp[i][j] = 0;           }         }       }       ans = min(ans, dp[0][k]);       t++;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> q1;   vector<long long> q2;   long long n, x, y, a, b, k;   long long l = 1, r = n;   long long ans = 0;   long long mid;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   bool cmp(long long a, long long b) { return a > b; }   int main() {     int T;     scanf( %d , &T);     while (T--) {       q1.clear();       scanf( %lld , &n);       for (int i = 1; i <= n; i++) {         long long t;         scanf( %lld , &t);         q1.push_back(t);       }       scanf( %lld %lld %lld %lld %lld , &x, &a, &y, &b, &k);       long long gc = gcd(a, b);       long long lcm = a * b / gc;       sort(q1.begin(), q1.end(), cmp);       l = 1, r = n;       ans = 0;       while (l <= r) {         q2.clear();         mid = (l + r) / 2;         for (int j = 1; j <= mid; j++) {           if (j % lcm == 0) {             q2.push_back(x + y);           } else if (j % a == 0) {             q2.push_back(x);           } else if (j % b == 0) {             q2.push_back(y);           }         }         long long res = 0;         sort(q2.begin(), q2.end(), cmp);         for (int i = 0; i < q2.size(); i++) {           res += q1[i] * q2[i];         }         if (res >= k * 100) {           r = mid - 1;           ans = mid;         } else {           l = mid + 1;         }       }       if (!ans)         printf( -1 n );       else         printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string tmp;     map<string, vector<vector<string> > > m;     for (int i = 0; i < n; i++) {       cin >> tmp;       getline(cin, tmp);       bool f = false;       string name;       vector<string> v;       for (int j = 0; j < tmp.length(); j++) {         string s;         while (j < tmp.length() &&                ((tmp[j] >=  a  && tmp[j] <=  z ) ||                 (tmp[j] >=  0  && tmp[j] <=  9 ) || tmp[j] ==  T ))           s += tmp[j++];         if (!s.empty()) {           if (f)             v.push_back(s);           else {             name = s;             f = true;           }         }       }       m[name].push_back(v);     }     int V;     cin >> V;     map<string, string> v;     for (int i = 0; i < V; i++) {       string type, name;       cin >> type >> name;       v[name] = type;     }     int k;     scanf( %i n , &k);     for (int i = 0; i < k; i++) {       getline(cin, tmp);       string name;       int j = 0;       while (tmp[j] !=  ( ) {         if (tmp[j] !=    ) name += tmp[j];         j++;       }       vector<string> a;       while (j < tmp.length()) {         string s;         while (j < tmp.length() &&                ((tmp[j] >=  a  && tmp[j] <=  z ) ||                 (tmp[j] >=  0  && tmp[j] <=  9 ) || tmp[j] ==  T ))           s += tmp[j++];         if (!s.empty()) {           a.push_back(v[s]);         }         j++;       }       int ans = 0;       for (int k = 0; k < m[name].size(); k++) {         bool eq = true;         if (a.size() != m[name][k].size()) continue;         for (int j = 0; j < a.size(); j++)           if (a[j] != m[name][k][j] && m[name][k][j] !=  T ) {             eq = false;             break;           }         if (eq) ans++;       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int x1, x2, y1, y2;       cin >> x1 >> y1 >> x2 >> y2;       if (x1 == x2 || y1 == y2)         cout << abs(x1 - x2) + abs(y1 - y2) << endl;       else         cout << abs(x1 - x2) + abs(y1 - y2) + 2 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline void read(int &x) {     char c = getchar();     x = 0;     while (!isdigit(c) && !isalpha(c)) c = getchar();     if (isalpha(c)) return void(x = c -  a );     while (isdigit(c)) x = x * 10 + c -  0 , c = getchar();   }   const int N = 5e5 + 5, SZ = 22;   int n, vv, ww;   int e, head[N], to[N << 1], val[N << 1], nxt[N << 1];   inline void add(int u, int v, int w) {     to[++e] = v;     val[e] = w;     nxt[e] = head[u];     head[u] = e;   }   inline void add_edge(int u, int v, int w) {     add(u, v, w);     add(v, u, w);   }   int sz[N], son[N], f[1 << 22 | 5], dep[N], Son, Max, ans[N], cur[N], s[N];   inline void dfs1(int u, int fa) {     sz[u] = 1;     for (int i = head[u]; i; i = nxt[i])       if (to[i] != fa) {         int v = to[i], w = val[i];         s[v] = s[u] ^ (1 << w);         dep[v] = dep[u] + 1;         dfs1(v, u);         sz[u] += sz[v];         if (sz[v] > sz[son[u]]) son[u] = v;       }   }   inline void calc(int u, int fa) {     if (f[s[u]]) Max = max(Max, f[s[u]] + dep[u]);     for (int i = 1; i <= (1 << 21); i <<= 1)       if (f[i ^ s[u]]) Max = max(Max, f[i ^ s[u]] + dep[u]);     for (int i = head[u]; i; i = nxt[i])       if (to[i] != fa) calc(to[i], u);   }   inline void update(int u, int fa) {     f[s[u]] = max(f[s[u]], dep[u]);     for (int i = head[u]; i; i = nxt[i])       if (to[i] != fa) update(to[i], u);   }   inline void get_Max(int u, int fa) {     for (int i = head[u]; i; i = nxt[i])       if (to[i] != fa && to[i] != Son) {         calc(to[i], u);         update(to[i], u);       }   }   inline void clear(int u, int fa) {     f[s[u]] = 0;     for (int i = head[u]; i; i = nxt[i])       if (to[i] != fa) clear(to[i], u);   }   inline void dfs2(int u, int fa, bool keep) {     for (int i = head[u]; i; i = nxt[i])       if (to[i] != fa && to[i] != son[u]) dfs2(to[i], u, false);     if (son[u]) dfs2(son[u], u, true);     Son = son[u];     f[s[u]] = max(f[s[u]], dep[u]);     get_Max(u, fa);     ans[u] = max(f[s[u]] - dep[u], Max - 2 * dep[u]);     for (int i = 1; i <= (1 << 21); i <<= 1)       ans[u] = max(ans[u], f[i ^ s[u]] - dep[u]);     for (int i = head[u]; i; i = nxt[i])       if (to[i] != fa) ans[u] = max(ans[u], ans[to[i]]);     Son = Max = 0;     if (!keep) clear(u, fa);   }   int main() {     read(n);     for (int uu = 2; uu <= n; uu++) {       read(vv);       read(ww);       add_edge(uu, vv, ww);     }     dfs1(1, 0);     dfs2(1, 0, 0);     for (int i = 1; i <= n; i++) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, t, i, j, ii, a;     while (scanf( %d%d%d , &n, &k, &t) != EOF) {       for (i = 1; i <= n; i++) {         if ((i * k + 1) * 100 > t * n * k) break;       }       for (j = 0; j <= k; j++) {         a = (i - 1) * k + j;         if (n * k * t >= 100 * a && (a + 1) * 100 > t * n * k) {           for (ii = 1; ii <= i - 1; ii++) printf( %d  , k);           printf( %d , j);           for (ii = i + 1; ii <= n; ii++) printf(  %d , 0);           printf(  n );           break;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long fat[200005];   void gerafat() {     fat[0] = 1;     for (long long i = 1; i < 200005; i++) {       fat[i] = (fat[i - 1] * i) % 1000000007;     }   }   long long modInv(long long a) {     long long v = 1;     long long e = 1000000007 - 2;     while (e) {       if (e % 2) {         v *= a;         v %= 1000000007;       }       e /= 2;       a *= a;       a %= 1000000007;     }     return v;   }   long long comb(int a, int b) {     if (a < b) return 0;     long long res =         ((fat[a] * modInv(fat[b])) % 1000000007 * modInv(fat[a - b])) %         1000000007;     return res;   }   int main() {     long long n, k;     cin >> n >> k;     gerafat();     vector<long long> num(0);     set<long long> sete;     vector<pair<long long, long long> > v(n, {0, 0});     for (long long i = 0; i < n; i++) {       long long a, b;       cin >> a >> b;       v[i] = {a, b};       if (!sete.count(a)) {         num.push_back(a);         sete.insert(a);       }       if (!sete.count(b)) {         num.push_back(b);         sete.insert(b);       }       if (!sete.count(b + 1)) {         num.push_back(b + 1);         sete.insert(b + 1);       }     }     sort(num.begin(), num.end());     long long tam = num.size();     map<long long, long long> mapa;     for (long long i = 0; i < tam; i++) mapa[num[i]] = i;     vector<long long> pref(tam, 0);     for (int i = 0; i < n; i++) {       pref[mapa[v[i].first]]++;       pref[mapa[v[i].second + 1]]--;     }     for (int i = 1; i < tam; i++) pref[i] += pref[i - 1];     long long res = comb(pref[0], k) % 1000000007;     for (long long i = 1; i < tam; i++) {       res = (res + comb(pref[i], k)) % 1000000007;       res = (res + ((long long)(num[i] - num[i - 1] - 1) *                     comb(min(pref[i], pref[i - 1]), k)) %                        1000000007) %             1000000007;     }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, r;     long long a;     map<int, long long> d;     int ans[300010];     int k = 0;     ans[0] = 1;     cin >> n;     for (int i = 1; i <= n; ++i) {       scanf( %I64d , &a);       if (d[a] > r) {         ans[++k] = i;         r = i;       } else         d[a] = i;     }     if (k) {       printf( %i n%i , k, ans[0]);       for (int i = 1; i < k; ++i) printf(  %i n%i , ans[i], ans[i] + 1);       printf(  %i , n);     } else       cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed long long n, m, answer;   signed long long calc(signed long long n, signed long long m) {     signed long long answer;     if (m - n >= 1) {       answer = n;     } else {       answer =           m + (signed long long)ceil((sqrt(1.0L + 8.0L * (n - m)) - 1.0L) / 2.0L);     }     return answer;   }   int main() {     cin >> n >> m;     cout << calc(n, m);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, vis[4001], children, ans[4001];   long long v[4001], abcdefghijklmnopqrstuvwxyz[4001], d[4001];   int main() {     while (~scanf( %d , &n)) {       memset(vis, 0, sizeof(vis));       children = 0;       for (register int i = 1; i <= n; i++) {         scanf( %lld%lld%lld , &v[i], &d[i], &abcdefghijklmnopqrstuvwxyz[i]);       }       for (register int i = 1; i <= n; i++) {         if (vis[i]) {           continue;         }         ans[children++] = i;         register long long temp1 = v[i], temp2 = 0;         for (register int j = i + 1; j <= n; j++)           if (!vis[j]) {             abcdefghijklmnopqrstuvwxyz[j] -= temp1;             temp1--;             if (temp1 < 0) {               break;             }           }         for (register int j = i + 1; j <= n; j++) {           if (!vis[j]) {             abcdefghijklmnopqrstuvwxyz[j] -= temp2;           }           if (abcdefghijklmnopqrstuvwxyz[j] < 0 && !vis[j]) {             temp2 += d[j];             vis[j] = 1;           }         }       }       printf( %d n , children);       for (register int i = 0; i < children; i++) {         printf( %d%c , ans[i], i == children - 1 ?   n  :    );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   using pii = pair<int, int>;   using pll = pair<ll, ll>;   using vi = vector<int>;   const ll INF = 100000000000ll;   const int N = 200005;   const int prime = 31;   const ll mod = 1000000007;   const ld eps = 1e-5;   mt19937_64 strong_random(       chrono::system_clock::now().time_since_epoch().count());   ll n;   void input() { scanf( %lld , &n); }   void solve() {     vector<ll> divisors;     ll nval = n;     ll dv = 2;     while (dv * dv <= n) {       if (n % dv == 0) {         int cc = 0;         divisors.push_back(1);         while (n % dv == 0) {           n /= dv;           divisors.back() *= dv;         }       } else {         dv++;       }     }     if (n != 1) {       divisors.push_back(n);     }     int bitcnt = (int)(divisors).size();     pll ans = {nval, 1};     for (int i = 0; i < (1 << bitcnt); i++) {       ll a = 1, b = 1;       for (int j = 0; j < bitcnt; j++) {         if ((1 << j) & i) {           a *= divisors[j];         } else {           b *= divisors[j];         }       }       if (a < b) swap(a, b);       ans = min(ans, {a, b});     }     cout << ans.second <<     << ans.first << endl;   }   void precalc() {}   int main() {     precalc();     int testcases = 1;     for (int testId = 1; testId <= testcases; testId++) {       input();       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename Arg1>   void __f(const char* name, Arg1&& arg1) {     cerr << name <<   :   << arg1 << std::endl;   }   template <typename Arg1, typename... Args>   void __f(const char* names, Arg1&& arg1, Args&&... args) {     const char* comma = strchr(names + 1,  , );     cerr.write(names, comma - names) <<   :   << arg1 <<   |  ;     __f(comma + 1, args...);   }   vector<int> f, g;   void fdo(int k) {     if (k == 0) return;     vector<int> temp = f;     f.clear();     f.push_back(0);     for (auto it : temp) f.push_back(it);     bool flag = true;     int ch = 0;     for (int i = 0; i < g.size(); i++) {       if (abs(f[i] + g[i]) > 1) flag = false;     }     for (int i = 0; i < g.size(); i++) {       if (flag) {         f[i] = f[i] + g[i];       } else {         f[i] = f[i] - g[i];       }     }     g = temp;     for (int i = 0; i < f.size(); i++) {       assert(abs(f[i]) < 2);     }     assert(f[f.size() - 1] == 1);     assert(g[g.size() - 1] == 1);     fdo(k - 1);   }   int main() {     int n;     scanf( %d , &n);     f.push_back(0);     f.push_back(1);     if (n != 1)       g.push_back(-1);     else       g.push_back(1);     fdo(n - 1);     cout << f.size() - 1 << endl;     for (auto it : f) cout << it <<    ;     cout << endl;     cout << g.size() - 1 << endl;     for (auto it : g) cout << it <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a, b;   int ans = 0;   bool ok = true;   int gcd(int a, int b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   void solve(int a) {     while (a % 2 == 0) {       a /= 2;       ans++;     }     while (a % 3 == 0) {       a /= 3;       ans++;     }     while (a % 5 == 0) {       a /= 5;       ans++;     }     if (a != 1) ok = false;   }   int main() {     scanf( %d%d , &a, &b);     int x = gcd(a, b);     a = a / x;     b = b / x;     solve(a);     solve(b);     if (ok)       printf( %d n , ans);     else       puts( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> g;   int n;   int a = 0;   int b = 0;   int ans = 0;   bool used[200][200];   void dfs(int a, int b) {     used[a][b] = 1;     for (int i = max(0, n - a); i <= min(n, b); i++) {       if (!used[a + i - (n - i)][b - i + (n - i)]) {         dfs(a + i - n + i, b - i - i + n);       }     }   }   int main() {     scanf( %d , &n);     for (int i = 0; i < 2 * n - 1; i++) {       int x;       scanf( %d , &x);       if (x <= 0)         b++;       else         a++;       g.push_back(abs(x));     }     sort(g.begin(), g.end());     for (int i = 0; i < 200; i++) {       for (int j = 0; j < 200; j++) {         used[i][j] = 0;       }     }     dfs(a, b);     for (int i = 0; i <= 2 * n - 1; i++) {       if (used[2 * n - 1 - i][i]) {         for (int j = 0; j < i; j++) {           ans -= g[j];         }         for (int j = i; j < g.size(); j++) {           ans += g[j];         }         printf( %d , ans);         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ull = unsigned long long;   using pii = pair<int, int>;   using pll = pair<ll, ll>;   template <class T>   inline bool Min(T &a, T b) {     return a > b ? (a = b, true) : false;   }   template <class T>   inline bool Max(T &a, T b) {     return a < b ? (a = b, true) : false;   }   inline int ni() {     int a;     scanf( %d , &a);     return a;   }   inline ll nl() {     ll a;     scanf( %lld , &a);     return a;   }   inline double nd() {     double a;     scanf( %lf , &a);     return a;   }   inline void pi(int a) { printf( %d  , a); }   inline void pl(ll a) { printf( %lld  , a); }   inline void pd(double a) { printf( %.12lf  , a); }   void solve() {     int n = ni();     vector<int> xs(n);     for (int i = 0; i < (int)(n); ++i) xs[i] = ni();     vector<int> cnt(n + 1);     vector<int> ans(n + 1);     for (int i = 0; i < n; i++) {       fill((cnt).begin(), (cnt).end(), 0);       int maxCnt = -1, maxNum = n;       for (int j = i; j < n; j++) {         cnt[xs[j]]++;         if (maxCnt <= cnt[xs[j]]) {           if (maxCnt < cnt[xs[j]] or (maxCnt == cnt[xs[j]] and xs[j] < maxNum))             maxNum = xs[j];           maxCnt = cnt[xs[j]];         }         ans[maxNum]++;       }     }     for (int i = 1; i <= n; i++) pi(ans[i]);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     srand((int)clock());     solve();     return 0;   }