malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<int> graf[1000001];   vector<int> chains[1000001];   vector<int> chainsbit[1000001];   int chainwhere[1000001], chainposition[1000001];   void update(int chainidx, int x, int val) {     while (x <= chainsbit[chainidx].size() - 1) {       chainsbit[chainidx][x] += val;       x += (x & -x);     }   }   int read(int chainidx, int x) {     if (chainsbit[chainidx].size() < x)       x = min(x, (int)(chainsbit[chainidx].size()) - 1);     int ret = 0;     while (x > 0) {       ret += chainsbit[chainidx][x];       x -= (x & -x);     }     return ret;   }   void DFS(int u, int chainidx, int prev) {     chains[chainidx].push_back(u);     chainsbit[u].push_back(0);     chainwhere[u] = chainidx;     chainposition[u] = chains[chainidx].size() - 1;     for (int i = 0; i < graf[u].size(); i++)       if (graf[u][i] != prev) DFS(graf[u][i], chainidx, u);   }   int rootvalue = 0;   int main() {     int n, q;     scanf( %d%d , &n, &q);     for (int i = 0; i < n - 1; i++) {       int u, v;       scanf( %d%d , &u, &v);       graf[u].push_back(v);       graf[v].push_back(u);     }     int chainnum = graf[1].size();     for (int i = 0; i < n + 15; i++) chainsbit[0].push_back(0);     for (int i = 0; i < graf[1].size(); i++) {       chains[i + 1].push_back(0);       chainsbit[i + 1].push_back(0);       DFS(graf[1][i], i + 1, 1);       int ln = chains[i + 1].size() * 100;       for (int j = 0; j < ln; j++) {         chains[i + 1].push_back(0);         chainsbit[i + 1].push_back(0);       }     }     while (q--) {       int t;       scanf( %d , &t);       if (t == 0) {         int v, x, d;         scanf( %d%d%d , &v, &x, &d);         if (v == 1) {           rootvalue += x;           update(0, 1, +x);           update(0, d + 1, -x);         } else {           int ch = chainwhere[v];           int depth = chainposition[v];           if (depth - d >= 1) {             update(ch, depth - d, +x);             update(ch, depth + d + 1, -x);           } else {             update(ch, 1, +x);             update(ch, depth + d + 1, -x);             int rest = d - depth;             rootvalue += x;             if (rest > 0) {               update(0, 1, +x);               update(0, rest + 1, -x);               update(ch, 1, -x);               update(ch, rest + 1, +x);             }           }         }       } else {         int v;         scanf( %d , &v);         if (v == 1)           printf( %d n , rootvalue);         else {           int ret =               read(0, chainposition[v]) + read(chainwhere[v], chainposition[v]);           printf( %d n , ret);         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, k;       cin >> n >> k;       vector<int> v(n);       for (int i = 0; i < n; i++) cin >> v[i];       vector<int> f(n, 0);       unordered_map<int, vector<int>> mp;       for (int i = 0; i < n; i++) mp[v[i]].push_back(i);       auto it = mp.begin();       int fg = 0;       bool flg = 0;       int ts = 0;       for (it; it != mp.end(); it++) {         auto vv = it->second;         if (vv.size() < k) continue;         ts += vv.size();         if (vv.size() >= k) {           int tt = 0;           while (tt < k) {             f[vv[tt]] = tt + 1;             tt++;           }         }       }       it = mp.begin();       for (it; it != mp.end(); it++) {         auto vv = it->second;         if (vv.size() >= k)           continue;         else {           int ii = 0;           while (ii < vv.size()) {             if (fg == 0 && (n - ts < k)) {               flg = 1;               break;             }             ts++;             f[vv[ii]] = fg + 1;             fg = (fg + 1) % k;             ii++;           }           if (flg) break;         }       }       for (int i = 0; i < n; i++) cout << f[i] <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char str[405][405];   int pre[405][405], now[405];   int main() {     int t, n, m, i, j, k, p, ans, mn;     scanf( %d , &t);     while (t--) {       scanf( %d%d , &n, &m);       ans = n * m;       for (i = 1; i <= (n); i++) {         scanf( %s , str[i] + 1);         for (j = 1; j <= (m); j++) pre[i][j] = pre[i][j - 1] + (str[i][j] ==  1 );       }       for (i = 1; i <= (m - 3); i++)         for (j = i + 3; j <= (m); j++) {           for (k = 1; k <= (4); k++)             now[k] = now[k - 1] + (str[k][i] ==  0 ) + (str[k][j] ==  0 ) +                      pre[k][j - 1] - pre[k][i];           mn = now[4] - now[1] + (j - 1 - i) - (pre[1][j - 1] - pre[1][i]);           for (k = 5; k <= (n); k++) {             ans = ((ans) < (mn + (j - 1 - i) - (pre[k][j - 1] - pre[k][i]))                        ? ans                        : mn + (j - 1 - i) - (pre[k][j - 1] - pre[k][i]));             p = (str[k][i] ==  0 ) + (str[k][j] ==  0 ) + pre[k][j - 1] -                 pre[k][i];             now[k] = now[k - 1] + p;             mn = ((mn + p) < (now[k] - now[k - 3] + (j - 1 - i) -                               (pre[k - 3][j - 1] - pre[k - 3][i]))                       ? mn + p                       : now[k] - now[k - 3] + (j - 1 - i) -                             (pre[k - 3][j - 1] - pre[k - 3][i]));           }         }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   const int N = 1e2 + 5, M = 1e5 + 5;   int lim = (1 << 10) - 1;   bool vis[M];   vector<int> primes;   int idx[M];   void pre() {     for (int i = 2; primes.size() < 110; ++i) {       if (vis[i]) continue;       primes.emplace_back(i);       for (int j = i; j < M; j += i) vis[j] = true;     }     for (int i = 0; i < 110; ++i) idx[primes[i]] = i;   }   vector<int> tmp;   void fac(int x) {     tmp.clear();     for (int i = 2; i * i <= x; ++i) {       if (x % i) continue;       tmp.emplace_back(idx[i]);       while (x % i == 0) x /= i;     }     if (x > 1) tmp.emplace_back(idx[x]);   }   int n, a[N];   int dp[N][1 << 10][N + 10];   int solve(int i, int msk, int j) {     if (i == n) return 0;     if (msk == lim && j == 110) return (int)1e7;     int &ret = dp[i][msk][j];     if (~ret) return ret;     ret = (int)1e7;     if (j < 110 && a[i] > primes[j])       cout <<  yala n2fl ya 3mna kda mb2tsh nf3a  << endl;     if (j < 110) ret = min(ret, solve(i + 1, msk, j + 1) - a[i] + primes[j]);     for (int f = 0; f < 10; ++f) {       if ((msk & (1 << f))) continue;       int nw = primes[f];       for (int k = 0; k <= 15 && (int)1e7 / nw >= primes[f]; ++k, nw *= primes[f])         ret = min(ret, solve(i + 1, (msk | (1 << f)), j) + abs(a[i] - nw));     }     for (int hna = 1; hna <= 30; ++hna) {       bool baz = false;       int nmsk = msk;       fac(hna);       for (auto f : tmp) {         nmsk |= (1 << f);         baz |= ((msk & (1 << f)) > 0);       }       if (baz) continue;       ret = min(ret, solve(i + 1, nmsk, j) + abs(a[i] - hna));     }     return ret;   }   vector<int> out;   void build(int i, int msk, int j) {     if (i == n) {       for (auto x : out) printf( %d%c , x,    n [&x == &out.back()]);       exit(0);     }     if (msk == lim && j == 110) return;     int m3lsh = solve(i, msk, j);     if (j < 110 && m3lsh == solve(i + 1, msk, j + 1) - a[i] + primes[j]) {       out.emplace_back(primes[j]);       build(i + 1, msk, j + 1);       return;     }     for (int f = 0; f < 10; ++f) {       if ((msk & (1 << f))) continue;       int nw = primes[f];       for (int k = 0; k <= 15 && (int)1e7 / nw >= primes[f];            ++k, nw *= primes[f]) {         if (m3lsh == solve(i + 1, (msk | (1 << f)), j) + abs(a[i] - nw)) {           out.emplace_back(nw);           build(i + 1, (msk | (1 << f)), j);           return;         }       }     }     for (int hna = 1; hna <= 30; ++hna) {       bool baz = false;       int nmsk = msk;       fac(hna);       for (auto f : tmp) {         nmsk |= (1 << f);         baz |= (msk & (1 << f));       }       if (baz) continue;       if (m3lsh == solve(i + 1, nmsk, j) + abs(a[i] - hna)) {         out.emplace_back(hna);         build(i + 1, nmsk, j);         return;       }     }   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     ;     pre();     scanf( %d , &n);     for (int i = 0; i < n; ++i) scanf( %d , a + i);     memset(dp, -1, sizeof dp);     solve(0, 0, 10);     build(0, 0, 10);   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long a, b;     cin >> a >> b;     if (a == 0 || b == 0) {       cout << 0 << endl;       return;     }     cout << min((a + b) / 3, min(a, b)) << endl;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int tc = 1;     cin >> tc;     while (tc--) solve();   }
#include <bits/stdc++.h>   using namespace std;   bool isvowel(char c) {     c = tolower(c);     return (c ==  a  || c ==  e  || c ==  i  || c ==  o  || c ==  u );   }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }   long long fastpow(long long base, long long p) {     if (p == 0) return 1;     long long num = fastpow(base, p / 2);     num *= num;     if (p % 2) num *= base;     return num;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     int n, m, x, q, ans = 0;     cin >> n >> m >> x;     string KeyBoard[n + 5], t;     map<char, bool> check;     vector<pair<int, int>> S;     for (int i = 1; i <= n; i++) {       cin >> KeyBoard[i];       for (int j = 0; j < m; j++) {         if (KeyBoard[i][j] ==  S ) S.push_back(make_pair(i, j + 1));       }     }     for (int i = 1; i <= n; i++) {       for (int j = 0; j < m; j++) {         if (KeyBoard[i][j] ==  S ) continue;         check[KeyBoard[i][j]] = true;         for (int k = 0; k < (int)S.size(); k++) {           if (sqrt(pow(i - S[k].first, 2) + pow(j - S[k].second + 1, 2)) <= x) {             check[toupper(KeyBoard[i][j])] = true;             break;           }         }       }     }     cin >> q >> t;     for (int i = 0; i < (int)t.size(); i++) {       if (!check[t[i]]) {         if (islower(t[i]) || !check[tolower(t[i])] || !S.size()) {           cout << -1;           return 0;         }         ans++;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, a, b;     while (cin >> n >> m >> a >> b) {       a--;       b--;       int oa, pa, ob, pb;       oa = a / m;       pa = a % m;       ob = b / m;       pb = b % m;       if (b == n - 1) {         pb = m - 1;       }       if (oa == ob) {         cout <<  1 ;         continue;       }       if (pa == 0 && pb == m - 1) {         cout <<  1 ;         continue;       }       if (pa - pb == 1) {         cout <<  2 ;         continue;       }       int hang = ob - oa;       if (pa > 0 && pb < m - 1) {         if (hang == 1) {           cout <<  2 ;           continue;         } else {           cout <<  3 ;           continue;         }       }       cout <<  2 ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, m, k;     cin >> n >> m >> k;     int arr[n][m];     int row[n];     int col[m];     for (int i = 0; i < n; i++) {       row[i] = i;       for (int j = 0; j < m; j++) {         col[j] = j;         cin >> arr[i][j];       }     }     while (k--) {       char c;       int x, y;       cin >> c >> x >> y;       if (c ==  c ) {         x -= 1;         y -= 1;         swap(col[x], col[y]);       } else if (c ==  r ) {         x -= 1;         y -= 1;         swap(row[x], row[y]);       } else {         x = row[x - 1];         y = col[y - 1];         cout << arr[x][y] <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000000007;   const long long SIZE = 100000;   const int INF = 0x3f3f3f3f;   const long long LL_INF = 0x3f3f3f3f3f3f3f3f;   const long double PI = acos(-1);   const long long MAXN = numeric_limits<long long>::max();   template <class T>   T maxT(T a, T b) {     return (a > b ? a : b);   }   template <class T>   T minT(T a, T b) {     return (a < b ? a : b);   }   template <class T>   void setmin(T &a, T b) {     a = (a > b ? a : b);   }   template <class T>   void setmax(T &a, T b) {     a = (a < b ? a : b);   }   void fileio() {     freopen( input.txt ,  r , stdin);     freopen( output.txt ,  w , stdout);     freopen( debug.txt ,  w , stderr);   }   void ofileio() {     freopen( input.txt ,  r , stdin);     freopen( output.txt ,  w , stdout);   }   void clock_out() {     cerr <<   nTime Elapsed :   << 1.0 * clock() / CLOCKS_PER_SEC <<   s n ;   }   void debug_out() { cerr << endl; }   template <typename Head, typename... Tail>   void debug_out(Head H, Tail... T) {     cerr <<     << H;     debug_out(T...);   }   void solve() {     string s;     cin >> s;     string temp =   ;     vector<int> cnt;     int c = 1;     temp += s[0];     for (int i = 1; i < s.size(); i++) {       if (s[i] == s[i - 1]) {         c++;       } else {         temp += s[i];         cnt.push_back(c);         c = 1;       }     }     cnt.push_back(c);     string w = temp;     reverse((w).begin(), (w).end());     if (w != temp) {       cout << 0;       return;     } else {       int pos = (cnt.size()) / 2;       for (long long i = 0; i < pos; i++) {         if ((cnt[i] + cnt[cnt.size() - i - 1]) < 3) {           cout << 0;           return;         }       }       if (cnt[pos] >= 2)         cout << cnt[pos] + 1;       else         cout << 0;       return;     }   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     srand(time(NULL));     1;     long long t = 1;     while (t--) {       solve();     }     1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     char c[2] = { w ,  b };     cin >> n;     if (n % 2 == 1)       cout <<  -1 ;     else {       for (int i = 1; i <= n; i++) {         for (int j = 0; j < n; j++) {           for (int k = 0; k < n; k++) {             if ((j / 2) % 2 == 0)               if ((k / 2) % 2 == 0)                 cout << c[i % 2];               else                 cout << c[!(i % 2)];             if ((j / 2) % 2 == 1)               if ((k / 2) % 2 == 0)                 cout << c[!(i % 2)];               else                 cout << c[i % 2];           }           cout << endl;         }         cout << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   ostream& operator<<(ostream& os, const vector<T>& v) {     for (auto i : v) os << i <<    ;     return os;   }   template <typename T>   ostream& operator<<(ostream& os, const set<T>& v) {     for (auto i : v) os << i <<    ;     return os;   }   template <typename T>   T read() {     char c = getchar();     T sgn = 1;     T t = 0;     while (!isdigit(c)) {       if (c ==  - ) sgn = -sgn;       c = getchar();     }     while (isdigit(c)) {       t *= 10;       t += c -  0 ;       c = getchar();     }     return t * sgn;   }   const int N = 1e5;   vector<int> atk, def, had;   bool used[N];   int main() {     int n = read<int>();     int m = read<int>();     for (int i = 0; i < n; ++i) {       char s[10];       int val;       scanf( %s %d , s, &val);       getchar();       if (s[0] ==  A ) atk.push_back(val);       if (s[0] ==  D ) def.push_back(val);     }     for (int i = 0; i < m; ++i) had.push_back(read<int>());     sort(atk.begin(), atk.end());     sort(def.begin(), def.end());     sort(had.begin(), had.end());     int ans = 0;     for (int i = m - 1; i >= 0; --i) {       int cur = 0;       for (int j = 0, t = atk.size(); j < m - i && j < t; ++j)         if (had[i + j] >= atk[j]) cur += had[i + j] - atk[j];       ans = max(ans, cur);     }     int p = 0;     for (auto i : def) {       while (p < m && had[p] <= i) p++;       if (p == m) {         printf( %d n , ans);         exit(0);       }       used[p] = true;       p++;     }     p = m - 1;     int ans2 = 0;     for (int i = atk.size() - 1; i >= 0; --i) {       int j = atk[i];       while (p >= 0 && used[p]) p--;       if (p == -1 || had[p] < j) {         printf( %d n , ans);         exit(0);       }       ans2 += had[p] - j;       used[p] = true;       p--;     }     for (int i = 0; i < m; ++i)       if (!used[i]) ans2 += had[i];     printf( %d n , max(ans, ans2));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int lazy[600005];   bool haslazy[600005];   int tree[600005];   int arr[200005];   int lft(int x) { return 2 * x + 1; }   int ryt(int x) { return 2 * x + 2; }   struct lol {     int x;     int y;     int z;   };   void updt(int x, int l, int r, int value) {     tree[x] = (value | tree[x]);     if (haslazy[x])       lazy[x] = (lazy[x] | value);     else       lazy[x] = value;     haslazy[x] = true;   }   void laze(int x, int l, int r) {     if (!haslazy[x]) return;     int mid = (l + r) / 2;     updt(ryt(x), mid + 1, r, lazy[x]);     updt(lft(x), l, mid, lazy[x]);     lazy[x] = 0;     haslazy[x] = false;   }   void prop(int x, int l, int r, int a, int b, int value) {     if (r < a || l > b) return;     if (l >= a && r <= b) {       updt(x, l, r, value);       return;     }     laze(x, l, r);     int mid = (l + r) / 2;     prop(lft(x), l, mid, a, b, value);     prop(ryt(x), mid + 1, r, a, b, value);     int ta = tree[lft(x)];     int tb = tree[ryt(x)];     tree[x] = (ta & tb);   }   int query(int x, int l, int r, int a, int b) {     if (l > b || r < a) return ((long long)1 << (long long)31) - 1;     if (l >= a && r <= b) {       return tree[x];     }     laze(x, l, r);     int mid = (l + r) / 2;     int ta = query(lft(x), l, mid, a, b);     int tb = query(ryt(x), mid + 1, r, a, b);     return (ta & tb);   }   void build(int x, int a, int b) {     if (a == b) {       tree[x] = 0;       return;     }     int mid = (a + b) / 2;     build(lft(x), a, mid);     build(ryt(x), mid + 1, b);     tree[x] = 0;   }   int main() {     cin >> n;     build(0, 0, n - 1);     int m;     cin >> m;     vector<lol> q;     for (int i = 0; i < m; i++) {       lol temp;       cin >> temp.x >> temp.y >> temp.z;       prop(0, 0, n - 1, temp.x - 1, temp.y - 1, temp.z);       q.push_back(temp);     }     bool flag = false;     for (int i = 0; i < m; i++) {       if (query(0, 0, n - 1, q[i].x - 1, q[i].y - 1) != q[i].z) {         flag = true;         break;       }     }     if (flag) {       cout <<  NO ;     } else {       cout <<  YES  << endl;       for (int i = 0; i < n; i++) {         int temp = query(0, 0, n - 1, i, i);         cout << temp <<    ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int i;   double a, b, c, d, base, top, mid, x11, x22, y11, y22, minim1, minim2, maxim1,       maxim2;   int main() {     scanf( %lf%lf%lf%lf , &a, &b, &c, &d);     base = 0.0;     top = 1000000000.0;     for (i = 1; i <= 100; i++) {       mid = (base + top) / 2.0;       x11 = a - mid;       x22 = a + mid;       y11 = d - mid;       y22 = d + mid;       minim1 = min(min(x11 * y11, x11 * y22), min(x22 * y11, x22 * y22));       maxim1 = max(max(x11 * y11, x11 * y22), max(x22 * y11, x22 * y22));       x11 = b - mid;       x22 = b + mid;       y11 = c - mid;       y22 = c + mid;       minim2 = min(min(x11 * y11, x11 * y22), min(x22 * y11, x22 * y22));       maxim2 = max(max(x11 * y11, x11 * y22), max(x22 * y11, x22 * y22));       if (maxim1 < minim2 || maxim2 < minim1)         base = mid;       else         top = mid;     }     printf( %.9lf n , top);   }
#include <bits/stdc++.h>   using namespace std;   int n;   pair<int, int> point[int(2e5 + 10)];   map<int, int> mark_x, mark_y;   long long res;   void sol() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> point[i].first >> point[i].second;       mark_x[point[i].first]++;       mark_y[point[i].second]++;     }     sort(point, point + n);     for (int i = 0; i < n; i++) {       if (i == 0 || point[i].first != point[i - 1].first) {         for (int j = i; point[j].first == point[i].first && j < n; j++) {           mark_y[point[j].second]--;         }       }       mark_x[point[i].first]--;       res += mark_x[point[i].first];       res += mark_y[point[i].second];     }     cout << res;   }   int main() {     std::ios::sync_with_stdio(false);     cin.tie(NULL);     sol();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   bool isPrime(T x) {     if (x <= 1) return false;     T i;     for (i = 2; i * i <= x; i++)       if (x % i == 0) return false;     return true;   }   template <class T>   class Prime {    public:     vector<T> z;     Prime() {       z.resize(1e5 + 7);       for (int i = (0); i < (((int)z.size())); i++) z[i] = 1;       z[0] = 0;       z[1] = 0;       T j;       for (int i = (2); i < (((int)z.size())); i++) {         if (z[i]) {           j = i + i;           while (j < ((int)z.size())) {             z[j] = 0;             j += i;           }         }       }     }   };   template <class T>   double dist(T x1, T y1, T x2, T y2) {     return sqrt(1. * (x2 - x1) * (x2 - x1) + 1. * (y2 - y1) * (y2 - y1));   }   template <class T>   class Point {    public:     T x, y;     Point() {}     Point(T a, T b) : x(a), y(b) {}     bool operator==(const Point& tmp) const { return (x == tmp.x && y == tmp.y); }     Point operator-(const Point& tmp) const {       return Point<T>(x - tmp.x, y - tmp.y);     }   };   char toLowerCase(char x) { return (x + 32); }   char toUpperCase(char x) { return (x - 32); }   bool isUpperCase(char x) { return (65 <= x && x <= 90) ? 1 : 0; }   bool isLowerCase(char x) { return (97 <= x && x <= 122) ? 1 : 0; }   bool isAlpha(char x) { return (isUpperCase(x) || isLowerCase(x)) ? 1 : 0; }   bool isDigit(char x) { return ( 0  <= x && x <=  9 ) ? 1 : 0; }   template <class T>   T toDec(string s) {     stringstream is(s);     T res;     is >> res;     return res;   }   template <class T>   string toStr(T n) {     string s;     stringstream is;     is << n;     is >> s;     return s;   }   template <class T>   void checkmin(T& a, T b) {     if (a > b) a = b;   }   template <class T>   void checkmax(T& a, T b) {     if (a < b) a = b;   }   vector<int> res;   string s;   void parse(int ind) {     string tmp = s.substr(ind + 7);     int p = tmp.find( <table> );     if (p != -1) {       parse(ind + 7 + p);       tmp = s.substr(ind + 7);     }     p = tmp.find( </table> ) + ind + 14;     int i, tot;     i = ind;     tot = 0;     while (i <= p) {       if (i + 3 <= p && s.substr(i, 4) ==  <td> ) tot++;       s[i] =  1 ;       i++;     }     res.push_back(tot);   }   int main() {     int c;     while ((c = getchar()) != EOF) {       if (c !=   n ) s += c;     }     parse(0);     sort(res.begin(), res.end());     for (int i = (0); i < (((int)res.size())); i++) cout << res[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool ispalindrom(string s) {     string rs;     reverse(s.begin(), s.end());     rs = s;     reverse(s.begin(), s.end());     if (rs == s)       return true;     else       return false;   }   int main() {     string s;     int k;     cin >> s >> k;     int n = s.length();     if (n % k != 0) {       cout <<  NO ;       return 0;     }     int i = n / k, count = 0;     for (int j = 0; j + i <= n; j += i) {       string temp = s.substr(j, i);       if (!ispalindrom(temp)) {         cout <<  NO ;         return 0;       }     }     cout <<  YES ;   }