malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long k;     cin >> k;     map<char, long long> m;     for (long long g = 0; g < k; g++) {       long long n;       cin >> n;       string s, t;       cin >> s >> t;       m.clear();       for (long long i = 0; i < n; i++) {         m[s[i]]++;         m[t[i]]++;       }       bool found = 0;       for (map<char, long long>::iterator it = m.begin(); it != m.end(); it++)         if ((*it).second % 2 == 1) {           found = 1;           break;         }       if (found) {         cout <<  No n ;       } else {         cout <<  Yes n ;         vector<pair<long long, long long> > ans;         ans.clear();         for (long long i = 0; i < n; i++)           if (s[i] != t[i]) {             for (long long j = 0; j < n; j++)               if (i != j && t[j] != s[j]) {                 if (s[i] == s[j] || t[i] == t[j]) {                   swap(s[i], t[j]);                   ans.push_back({i, j});                   i = 0;                   break;                 }                 if (s[i] == t[j]) {                   swap(s[j], t[j]);                   swap(s[j], t[i]);                   ans.push_back({j, j});                   ans.push_back({j, i});                   i = 0;                   break;                 }                 if (t[i] == s[j]) {                   swap(s[j], t[j]);                   swap(s[i], t[j]);                   ans.push_back({j, j});                   ans.push_back({i, j});                   i = 0;                   break;                 }               }           }         cout << ans.size() << endl;         for (long long i = 0; i < ans.size(); i++)           cout << ans[i].first + 1 <<     << ans[i].second + 1 << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   const int N = 1e6 + 100;   const int inf = 1e9 + 100;   int n, w, m, a[N], seg[N << 2];   long long fen[N];   void change(int dex, int val, int v = 1, int s = 0, int e = N) {     if (dex < s || e <= dex) {       return;     }     if (e - s == 1) {       seg[v] = val;       return;     }     int mid = (s + e) >> 1, lc = v << 1, rc = lc | 1;     change(dex, val, lc, s, mid);     change(dex, val, rc, mid, e);     seg[v] = max(seg[lc], seg[rc]);   }   int get_max(int l, int r, int v = 1, int s = 0, int e = N) {     if (r <= s || e <= l) return -inf;     if (l <= s && e <= r) return seg[v];     int mid = (s + e) >> 1, lc = v << 1, rc = lc | 1;     return max(get_max(l, r, lc, s, mid), get_max(l, r, rc, mid, e));   }   void add(int dex, long long val) {     for (++dex; dex < N; dex += dex & -dex) fen[dex] += val;   }   long long get(int dex) {     long long res = 0;     for (; dex; dex ^= dex & -dex) res += fen[dex];     return res;   }   void ADD(int l, int r, long long x) {     add(l, x);     add(r, -x);   }   void act(int i) {     ADD(i, i + 1, max(i + m < w || i >= w ? 0 : -inf, get_max(i + m - w, i + 1)));   }   void get_line() {     int maxi = 0;     cin >> m;     for (int i = 0; i < m; i++) {       cin >> a[i];       change(i, a[i]);       maxi = max(maxi, a[i]);     }     for (int i = 0; i < m; i++) {       act(i);     }     for (int i = 0; i < m && w - i - 1 >= m; i++) {       act(w - i - 1);     }     if (2 * m < w) {       ADD(m, w - m, maxi);     }     for (int i = 0; i < m; i++) {       change(i, 0);     }   }   int main() {     cin >> n >> w;     for (int i = 0; i < n; i++) {       get_line();     }     for (int i = 0; i < w; i++) {       cout << get(i + 1) <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100000;   int n;   long long int d[MAXN], st[2 * MAXN];   long long int arr(int i) {     if (i == 0 || i == n - 1) return 0;     return max(0ll, -d[i - 1]) + max(0ll, d[i]);   }   void build() {     for (int i = 0; i < n; ++i) st[i + n] = arr(i);     for (int i = n - 1; i > 0; --i) st[i] = min(st[2 * i], st[2 * i + 1]);   }   long long int query(int l, int r) {     long long int res = LLONG_MAX;     for (l += n, r += n; l < r; l /= 2, r /= 2) {       if (l & 1) res = min(res, st[l++]);       if (r & 1) res = min(res, st[--r]);     }     return res;   }   void update(int idx) {     st[idx + n] = arr(idx);     for (int i = idx + n; i > 1; i /= 2) st[i / 2] = min(st[i], st[i ^ 1]);   }   int main() {     cin.sync_with_stdio(0);     cin.tie(0);     cin >> n;     long long int sum = 0;     int a1, a2;     cin >> a1;     for (int i = 0; i < n - 1; ++i)       cin >> a2, d[i] = a2 - a1, sum += abs(d[i]), a1 = a2;     int q;     cin >> q;     build();     while (q--) {       int t, l, r;       long long int x;       cin >> t >> l >> r >> x;       l--, r--;       if (t == 1) {         long long int res = sum + (l == r ? abs(d[l - 1] + x) - abs(d[l - 1]) +                                                 abs(d[l] - x) - abs(d[l])                                           : max(0ll, 2 * (x - query(l, r + 1))));         cout << res << endl;       } else {         for (int i : {l - 1, r})           sum -= abs(d[i]), d[i] += (i == l - 1 ? x : -x), sum += abs(d[i]);         for (int i : {l - 1, l, r, r + 1}) update(i);       }     }   }
#include <bits/stdc++.h>   #pragma GCC target( avx2 )   #pragma GCC optimization( O3 )   #pragma GCC optimization( unroll-loops )   using namespace std;   template <class T1, class T2>   ostream &operator<<(ostream &os, const pair<T1, T2> &p) {     os <<  {  << p.first <<  ,  << p.second <<  } ;     return os;   }   const int N = 3e5 + 5;   const int oo = 1e9 + 7;   double s, a, b, c;   double func(double x, double y, double z) {     return a * log(x) + b * log(y) + c * log(z);   }   double ans2(double x, double S, double &y) {     double l = 1e-9, r = S;     for (int i = 0; i < 500; i++) {       double l1 = (l * 2 + r) / 3;       double l2 = (l + 2 * r) / 3;       if (func(x, l1, S - l1) > func(x, l2, S - l2))         r = l2;       else         l = l1;     }     y = l;     return func(x, l, S - l);   }   pair<double, pair<double, double> > ans1(double S) {     double l = 1e-9, r = S;     double y;     for (int i = 0; i < 500; i++) {       double l1 = (l * 2 + r) / 3;       double l2 = (l + 2 * r) / 3;       if (ans2(l1, S - l1, y) > ans2(l2, S - l2, y))         r = l2;       else         l = l1;     }     ans2(l, S - l, y);     return {l, {y, S - l - y}};   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> s >> a >> b >> c;     auto x = ans1(s);     cout << fixed << setprecision(15) << x.first <<     << x.second.first <<              << x.second.second <<   n ;   }
#include <bits/stdc++.h>   int main() {     int a;     scanf( %d , &a);     int A[a];     for (int i = 0; i < a; ++i) {       scanf( %d , &A[i]);     }     for (int i = 0; i < a; ++i) {       int l, m;       int K = 0;       l = (int)(sqrtl(A[i]));       m = (int)(cbrtl(A[i]));       int z = 0;       z = (int)cbrtl(sqrtl(A[i]));       K = (l + m - z);       printf( %d n , K);     }     return 0;   }
#include <bits/stdc++.h>   int N;   int T[20000 + 10];   int Cnt[20000 + 10];   int Ans;   int main() {     scanf( %d , &N);     for (int i = 0; i < N; i++) scanf( %d , &T[i]);     Ans = -1000000000;     for (int i = 1; i <= N; i++)       if (N % i == 0 && N / i >= 3) {         for (int j = 0; j < i; j++) Cnt[j] = 0;         for (int j = 0; j < N; j++) Cnt[j % i] += T[j];         for (int j = 0; j < i; j++)           if (Cnt[j] > Ans) Ans = Cnt[j];       }     printf( %d n , Ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int i[105] = {0};   int j[105] = {0};   int f[100005] = {0};   int main() {     int n, m;     cin >> n;     for (int a = 1; a <= n; a++) cin >> i[a];     cin >> m;     for (int a = 1; a <= m; a++) cin >> j[a];     for (int a = 1; a <= m; a++) {       for (int b = 1; b <= n; b++) {         if (j[a] % i[b] == 0) {           f[j[a] / i[b]]++;         }       }     }     int Themax = 0;     for (int a = 10000; a >= 1; a--) {       if (f[a] != 0) {         cout << f[a] << endl;         break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 205;   char g[N];   map<char, int> h;   void work() {     int i, j;     int s1 = 0, s2 = 0;     h[ q ] = 9;     h[ r ] = 5;     h[ b ] = 3;     h[ n ] = 3;     h[ p ] = 1;     h[ k ] = 0;     for (i = 0; i < 8; ++i) {       scanf( %s , g);       for (j = 0; j < 8; ++j)         if (islower(g[j]))           s1 += h[g[j]];         else if (isupper(g[j]))           s2 += h[g[j] -  A  +  a ];     }     if (s1 > s2)       puts( Black );     else if (s1 == s2)       puts( Draw );     else       puts( White );   }   int main() {     work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct segment {     int pos;     int len;     int type;   };   struct lengthComparator {     bool operator()(const segment &a, const segment &b) const {       if (a.len != b.len)         return a.len > b.len;       else         return a.pos < b.pos;     }   };   struct positionComparator {     bool operator()(const segment &a, const segment &b) const {       return a.pos < b.pos;     }   };   set<segment, lengthComparator> lengthSet;   set<segment, positionComparator> positionSet;   void add_segment(segment s) {     lengthSet.insert({s});     positionSet.insert({s});   }   void remove_segment(segment s) {     lengthSet.erase({s});     positionSet.erase({s});   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; i++) {       cin >> a[i];     }     a.push_back(-1);     int start = 0;     for (int i = 0; i < a.size(); i++) {       if (i > 0 and a[i] != a[i - 1]) {         segment s = {start, (i - 1) - start + 1, a[i - 1]};         lengthSet.insert(s);         positionSet.insert(s);         start = i;       }     }     int sol = 0;     while (!lengthSet.empty()) {       segment s = *lengthSet.begin();       segment left, right;       bool leftExists = false, rightExists = false;       auto lbIterator = positionSet.find(s);       if (lbIterator != positionSet.begin()) {         left = *(--lbIterator);         leftExists = true;       }       auto ubIterator = positionSet.find(s);       if (++ubIterator != positionSet.end()) {         right = *ubIterator;         rightExists = true;       }       if (leftExists and rightExists and left.type == right.type) {         segment merged = {left.pos, left.len + right.len, left.type};         remove_segment(left);         remove_segment(right);         add_segment(merged);       }       remove_segment(s);       sol++;     }     cout << sol <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int dr[] = {-1, 0, 1, 0, -1, -1, 1, 1};   const int dc[] = {0, -1, 0, 1, -1, 1, -1, 1};   long long ax, ay, bx, by, cx, cy;   long long dist(long long x1, long long y1, long long x2, long long y2) {     return ((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2));   }   int main() {     cin >> ax >> ay >> bx >> by >> cx >> cy;     if (dist(ax, ay, bx, by) != dist(bx, by, cx, cy)) {       cout <<  No n ;       return 0;     }     if (ax - bx == bx - cx && ay - by == by - cy)       cout <<  No n ;     else if (ax - cx == cx - bx && ay - cy == cy - by)       cout <<  No n ;     else if (bx - ax == ax - cx && by - ay == ay - cy)       cout <<  No n ;     else if (bx - cx == cx - ax && by - cy == cy - ay)       cout <<  No n ;     else if (cx - ax == ax - cx && cy - ay == ay - cy)       cout <<  No n ;     else if (cx - bx == bx - cx && cy - by == by - cy)       cout <<  No n ;     else       cout <<  Yes n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5e2 + 7;   int c[N], n;   int f[N][N];   int main() {     memset(f, 0x7f7f, sizeof f);     scanf( %d , &n);     for (register int i = 1; i <= n; ++i) {       scanf( %d , &c[i]);       f[i][i] = 1;     }     for (register int i = 1; i < n; ++i) {       if (c[i] == c[i + 1])         f[i][i + 1] = 1;       else         f[i][i + 1] = 2;     }     for (register int le = 3; le <= n; ++le)       for (register int l = 1, r = l + le - 1; r <= n; l++, r++) {         if (c[l] == c[r]) f[l][r] = f[l + 1][r - 1];         for (register int k = l; k < r; ++k)           f[l][r] = min(f[l][r], f[l][k] + f[k + 1][r]);       }     cout << f[1][n];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s, ans;   int p;   int main() {     cin >> s;     while (p < s.length()) {       if (s[p] ==  . )         ans.push_back( 0 ), ++p;       else if (s[p + 1] ==  . )         ans.push_back( 1 ), p += 2;       else         ans.push_back( 2 ), p += 2;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   int a[N];   int main() {     int T;     scanf( %d , &T);     while (T--) {       int n;       scanf( %d , &n);       for (int i = 1; i <= n; ++i) {         scanf( %d , &a[i]);       }       sort(a + 1, a + n + 1);       int ans = a[1];       for (int i = 1; i < n; ++i) {         ans = max(a[i + 1] - a[i], ans);       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s[100];     int i, j, count = 0, num = 0;     cin >> s[0];     for (i = 0; i < s[0].length(); i++) {       s[i + 1] = s[i];       num = 0;       rotate(s[i + 1].rbegin(), s[i + 1].rbegin() + 1, s[i + 1].rend());     }     for (i = 0; i < s[0].length(); i++) {       num = 0;       for (j = i + 1; j < s[0].length(); j++) {         if (i != j && s[i].compare(s[j]) == 0) {           num = 1;           break;         }       }       if (num != 1) count++;     }     cout << count;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     scanf( %d%d , &n, &m);     queue<int> x, y;     for (int i = 0; i < n; ++i) {       int tmp;       scanf( %d , &tmp);       x.push(tmp);     }     for (int i = 0; i < m; ++i) {       int tmp;       scanf( %d , &tmp);       y.push(tmp);     }     int ans = 0, xSum = x.front(), ySum = y.front();     x.pop(), y.pop();     while (!x.empty() && !y.empty()) {       if (xSum == ySum) {         ++ans;         xSum = x.front();         x.pop();         ySum = y.front();         y.pop();       } else {         if (xSum < ySum) {           xSum += x.front();           x.pop();         } else {           ySum += y.front();           y.pop();         }       }     }     cout << ans + 1 << endl;     return 0;   }
#include <bits/stdc++.h>   void err() { std::cout << std::endl; }   template <typename T, typename... Args>   void err(T a, Args... args) {     std::cout << a <<    ;     err(args...);   }   using namespace std;   const int mod = 1e9 + 7;   const int maxn = 1e3 + 22;   int n, m, d[maxn], vis[maxn], root0, g[maxn];   int v[maxn][maxn], c, x, y;   int main() {     cin >> n;     for (int i = 1; i <= n - 1; i++) {       cin >> x >> y;       d[x]++;       d[y]++;       v[x][y] = 1;       v[y][x] = 1;     }     int k1, k2, cnt = 1;     while (cnt <= n / 2) {       int a, b;       for (int i = 1; i <= n; i++) {         if (d[i] == 1) {           a = i;           d[i]--;           break;         }       }       for (int i = 1; i <= n; i++) {         if (d[i] == 1) {           b = i;           d[i]--;           break;         }       }       for (int i = 1; i <= n; i++) {         if (v[a][i]) {           v[a][i] = 0;           v[i][a] = 0;           d[i]--;         }       }       for (int i = 1; i <= n; i++) {         if (v[b][i]) {           v[b][i] = 0;           v[i][b] = 0;           d[i]--;         }       }       g[a] = 1;       g[b] = 1;       cout <<  ?   << a <<     << b << endl;       cin >> c;       if (c == a || c == b) {         cout <<  !   << c << endl;         return 0;       }       cnt++;     }     for (int i = 1; i <= n; i++) {       if (!g[i]) {         cout <<  !   << i << endl;         break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 50;   char str[maxn];   int pre[30], now[30];   int l, r, len, cnt;   void sov() {     scanf( %s , str);     len = strlen(str);     cnt = 1;     l = 0, r = 0;     memset(now, 0, sizeof(now));     int i = 1;     while (i < len) {       if (str[i] == str[i - 1])         cnt++;       else         break;       i++;     }     if (cnt == len) return;     l = cnt;     cnt = 1;     int j = len - 2;     while (j >= 0) {       if (str[j] == str[j + 1])         cnt++;       else         break;       j--;     }     r = cnt;     if (cnt + l == len) return;     cnt = 1;     for (++i; i <= j + 1; i++) {       if (str[i] != str[i - 1]) {         now[str[i - 1] -  a ] = max(now[str[i - 1] -  a ], cnt);         cnt = 1;       } else if (str[i] == str[i - 1])         cnt++;     }   }   int main() {     int n;     scanf( %d , &n);     for (int j = 0; j < n; j++) {       if (j == 3) int ok = 1;       sov();       if (cnt == len) {         int t = str[0] -  a ;         pre[t] = pre[t] + (pre[t] + 1) * len;         for (int i = 0; i < 26; i++)           if (i != t) {             if (pre[i])               pre[i] = 1;             else               pre[i] = 0;           }       } else if (str[0] == str[len - 1]) {         int t = str[0] -  a ;         if (pre[t])           pre[t] = max(now[t], l + r + 1);         else           pre[t] = max(max(l, r), now[t]);         for (int i = 0; i < 26; i++)           if (i != t) {             if (pre[i])               pre[i] = max(1, now[i]);             else               pre[i] = now[i];           }       } else {         int t = str[0] -  a ;         if (pre[t])           pre[t] = max(1 + l, now[t]);         else           pre[t] = max(l, now[t]);         t = str[len - 1] -  a ;         if (pre[t])           pre[t] = max(1 + r, now[t]);         else           pre[t] = max(r, now[t]);         for (int i = 0; i < 26; i++)           if (i != str[0] -  a  && i != str[len - 1] -  a ) {             if (pre[i])               pre[i] = max(1, now[i]);             else               pre[i] = now[i];           }       }     }     int anss = -1;     for (int i = 0; i < 26; i++) anss = max(anss, pre[i]);     printf( %d n , anss);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, x, res = 0;     cin >> n;     int t[n + 1];     fill(t, t + (n + 1), 0);     for (int i = 1; i <= n; i++) {       cin >> x;       t[x] = t[x - 1] + 1;       res = max(res, t[x]);     }     cout << n - res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool debug = 0;   int n, m, k;   int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};   string direc =  RDLU ;   long long ln, lk, lm;   int r, c;   vector<int> v[3105];   multiset<int> ms;   int pos[30];   void fmain() {     scanf( %d%d%d%d , &r, &c, &n, &k);     for (int i = 0, x, y; i < n; i++) {       scanf( %d%d , &x, &y);       v[x].push_back(y);     }     long long ans = 0, cnt = 0;     for (int(i) = 1; (i) <= (int)(r); (i)++) {       ms.clear();       cnt = 0;       for (int(j) = 0; (j) < (int)(k + 1); (j)++) {         ms.insert(0);         ms.insert(c + 1);       }       for (int j = i; j <= r; j++) {         for (int x : v[j]) {           auto it = ms.insert(x), it1 = it;           for (int z = k; z >= 0; z--) {             pos[z] = *it;             it--;           }           it1++;           for (int z = k + 1; z <= k + k; z++) {             pos[z] = *it1;             it1++;           }           for (int z = k; z < k + k; z++) {             cnt += (long long)(pos[z + 1] - pos[z]) *                    (pos[z - (k - 1)] - pos[z - k]);           }         }         ans += cnt;       }     }     printf( %lld n , ans);   }   int main() {     fmain();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int T, a, b, c;     cin >> T;     for (int t = 0; t < T; t++) {       cin >> a >> b >> c;       cout << (min(c / 2, b) * 3) + min(a, (b - min(c / 2, b)) / 2) * 3 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c;     cin >> a >> b >> c;     while (a > 0) {       if (2 * a <= b && 4 * a <= c) {         cout << 7 * a;         return 0;       } else {         a--;       }     }     cout <<  0 ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   const int M = 505;   const int nmax = 1e3 + 5;   const long long inf = 1e9;   const int mod = 1e9 + 7;   const long long P = 31;   const int K = 20;   const long double eps = 1e-9;   const int dx[4] = {-1, 0, 1, 0};   const int dy[4] = {0, -1, 0, 1};   set<double> s;   long long a[N];   int main() {     ios_base::sync_with_stdio(false);     long long sum;     int n;     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> a[i];       s.insert(double(a[i]));       sum += a[i];     }     sort(a, a + n);     long long sm = a[(n >> 1) - 1], bg = a[n >> 1];     while ((int)s.size() > 2) {       double med = 1.0 * (sm + bg) / 2.0;       auto ib = s.begin();       auto ie = s.end();       ie--;       if ((med - *ib) < (*ie - med)) {         auto it = s.lower_bound(sm);         sm = *(--it);         it++;         sum -= *ie;         sum -= *it;         s.erase(ie);         s.erase(it);       } else {         auto it = s.lower_bound(bg);         bg = *(++it);         it--;         sum -= *ib;         sum -= *it;         s.erase(ib);         s.erase(it);       }     }     cout << bg - sm <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline bool CHMAX(T& a, T b) {     if (a < b) {       a = b;       return true;     }     return false;   }   template <class T>   inline bool CHMIN(T& a, T b) {     if (a > b) {       a = b;       return true;     }     return false;   }   constexpr long long INF = 1e18;   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long N;     cin >> N;     vector<long long> a(N);     for (long long i = 0; i < (long long)(N); i++) cin >> a[i];     map<long long, long long> mp;     for (long long i = 0; i < (long long)(N); i++) {       mp[a[i]]++;     }     vector<long long> cnt(N + 1);     long long now = 0;     for (auto e : mp) cnt[e.second]++;     for (long long i = (long long)cnt.size() - 1 - 1; i >= 0; i--) {       cnt[i] += cnt[i + 1];     }     long long ma = -INF;     long long h, w;     for (long long i = 1; i < (long long)cnt.size(); i++) {       now += cnt[i];       for (long long j = i; j * j <= now; j++) {         long long nj = now / j;         if (CHMAX(ma, j * nj)) {           h = j, w = nj;         }       }     }     vector<long long> c;     map<long long, long long> mpp;     for (long long i = 0; i < (long long)(N); i++)       if (++mpp[a[i]] <= h) {         c.push_back(a[i]);         if (c.size() == h * w) break;       }     sort(c.begin(), c.end());     vector<pair<long long, long long>> d;     long long ren = 1;     for (long long i = 0; i < (long long)(c.size()); i++) {       if (i + 1 == c.size() || c[i] != c[i + 1]) {         d.push_back({ren, c[i]});         ren = 1;       } else {         ren++;       }     }     sort(d.begin(), d.end());     reverse(d.begin(), d.end());     vector<long long> e;     for (long long i = 0; i < (long long)(d.size()); i++) {       for (long long j = 0; j < (long long)(d[i].first); j++) {         e.push_back(d[i].second);       }     }     vector<vector<long long>> ans(h, vector<long long>(w));     long long cntcnt = 0;     for (long long j = 0; j < (long long)(w); j++)       for (long long i = 0; i < (long long)(h); i++) ans[i][j] = e[cntcnt++];     cout << h * w <<   n ;     cout << h <<     << w <<   n ;     for (long long i = 0; i < (long long)(h); i++) {       for (long long j = 0; j < (long long)(w); j++) {         if (j) cout <<    ;         cout << ans[i][(j - i + w) % w];       }       cout <<   n ;     }   }