malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long pre[26][100005], suff[26][100005];   int main() {     string s;     cin >> s;     int n = s.length();     if (n == 1) {       cout << 1 << endl;       return 0;     }     if (n == 2) {       if (s[0] == s[1]) {         cout << 2 << endl;         return 0;       }       cout << 1 << endl;       return 0;     }     for (int i = 0; i < n; i++) {       if (i != 0) {         for (int j = 0; j < 26; j++) {           pre[j][i] = pre[j][i - 1];         }       }       int ind = s[i] -  a ;       pre[ind][i]++;     }     long long ans = 0;     map<string, long long> m;     for (int i = 1; i < n; i++) {       string temp =   ;       for (int j = 0; j < 26; j++) {         temp.push_back( a  + j);         temp.push_back(s[i]);         m[temp] += pre[j][i - 1];       }     }     for (auto it = m.begin(); it != m.end(); it++) {       ans = max(ans, it->second);     }     for (int i = 0; i < 26; i++) {       ans = max(ans, pre[i][n - 1]);     }     cout << ans << endl;   }
#include <iostream>      using namespace std;      int t;   int n, k;      int main() {    for (cin >> t; t--; ) {     cin >> n >> k;     for (n -= k - 3; k != 3; k--) {      cout << 1 <<    ;     }     if (n == 3)      cout << 1 <<     << 1 <<     << 1 << endl;     else if (n % 4 == 0)      cout << n / 2 <<     << n / 4 <<     << n / 4 << endl;     else if (n % 4 == 1)      cout << n / 2 <<     << n / 2 <<     << 1 << endl;     else if (n % 4 == 2)      cout << n / 2 - 1 <<     << n / 2 - 1 <<     << 2 << endl;     else       cout << n / 2 <<     << n / 2 <<     << 1 << endl;    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int64_t N = 5e6 + 10;   int64_t n, m;   int64_t it[N];   bool hamband[N];   int64_t adj[N];   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     if (m == (n - 1) * n >> 1) {       cout << 0;       return 0;     }     for (int64_t i = 0; i < m; i++) {       int64_t x, y;       cin >> x >> y;       x--, y--;       adj[x] += (1 << y);       adj[y] += (1 << x);     }     hamband[0] = true;     int64_t tow = 1;     for (int64_t mask = 1; mask < (1 << n); mask++) {       if (mask == tow) {         hamband[mask] = true;         tow <<= 1;         continue;       }       for (int64_t now = mask; now;) {         int64_t i = __builtin_ctz(now);         if (hamband[mask ^ (1 << i)] && (adj[i] & mask)) {           hamband[mask] = true;           break;         }         now ^= (1 << i);       }     }     int64_t ans = 0, Ans = 0;     for (int64_t mask = 1; mask < (1 << n); mask++) {       if (!hamband[mask]) {         continue;       }       int64_t all = 0;       for (int64_t now = mask; now; now ^= (1 << __builtin_ctz(now))) {         all |= adj[__builtin_ctz(now)];       }       if ((all & ((1 << n) - 1 - mask)) == ((1 << n) - 1 - mask)) {         if (ans < n - __builtin_popcount(mask)) {           ans = n - __builtin_popcount(mask);           Ans = mask;         }       }     }     cout << n - ans <<   n ;     for (int64_t i = 0; i < n; i++) {       if (Ans & (1 << i)) {         cout << i + 1 <<    ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int N = 1e5 + 5;   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int T;     cin >> T;     while (T--) {       string x, y;       cin >> x >> y;       int lx = x.size(), ly = y.size();       int py = 1;       while (y[ly - py] ==  0 ) ++py;       int px = py;       while (lx >= px && x[lx - px] ==  0 ) ++px;       cout << px - py << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   int main() {     int n;     long long k;     cin >> n >> k;     vector<long long> a(n + 1);     for (int i = 0; i <= n; ++i) cin >> a[i];     vector<long long> suff(n + 1);     suff[n] = a[n];     for (int i = n - 1; i >= 0; --i) {       suff[i] = suff[i + 1] * 2 + a[i];       if (abs(suff[i]) > k) {         for (int j = 0; j < i; ++j) suff[j] = INF;         break;       }     }     vector<long long> pref(n + 1);     pref[0] = 0;     for (int i = 1; i <= n; ++i) {       if ((pref[i - 1] + a[i - 1]) % 2 != 0) {         for (int j = i; j <= n; ++j) pref[j] = INF;         break;       }       pref[i] = (pref[i - 1] + a[i - 1]) / 2;     }     int ans = 0;     for (int i = 0; i <= n; ++i) {       if (pref[i] + suff[i] < INF) {         long long u = pref[i] + suff[i];         if (abs(a[i] - u) <= k && !(a[n] == u && i == n)) ++ans;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a, b, c, d, e, t1, t2, t3;   long long la, lb, lc;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, m, s;     cin >> n >> m >> s;     a = 0;     b = 0;     long long i = 0;     c = 1;     if (s <= n) {       while (i < n) {         if (i + s < n) {           i += s;           ++c;         } else {           a = n - (i + 1);           ++a;           break;         }       }     } else {       c = n;       a = 1;     }     i = 0;     d = 1;     if (s <= m) {       while (i < m) {         if (i + s < m) {           i += s;           ++d;         } else {           b = m - (i + 1);           ++b;           break;         }       }     } else {       d = m;       b = 1;     }     e = c * d;     t1 = a * b;     cout << t1 * e;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   long long n, k, m, t, x, b[N], a[N];   int i, j;   map<int, long long> C;   int main() {     cin >> n;     for (i = 2; i <= n; i++) {       cin >> a[i];       a[i] += a[i - 1];       m = min(m, a[i]);     }     x = 1 - m;     for (i = 1; i <= n; i++) {       a[i] += x;       if (a[i] < 1 || a[i] > n || b[a[i]] == 1) {         cout << -1;         return 0;       }       b[a[i]] = 1;     }     for (i = 1; i <= n; i++) cout << a[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   pair<T, vector<int>> hungarian(const vector<vector<T>>& A) {     int n = (int)A.size(), m = (int)A[0].size();     T inf = numeric_limits<T>::max() / 2;     vector<int> way(m + 1), p(m + 1), used(m + 1);     vector<T> u(n + 1), v(m + 1), minv(m + 1);     for (int i = 1; i <= n; i++) {       p[0] = i;       int j0 = 0;       minv.assign(m + 1, inf), used.assign(m + 1, 0);       do {         int i0 = p[j0], j1 = 0;         T delta = inf;         used[j0] = true;         for (int j = 1; j <= m; j++)           if (!used[j]) {             int cur = A[i0 - 1][j - 1] - u[i0] - v[j];             if (cur < minv[j]) {               minv[j] = cur;               way[j] = j0;             }             if (minv[j] < delta) {               delta = minv[j];               j1 = j;             }           }         for (int j = 0; j <= m; j++)           if (used[j]) {             u[p[j]] += delta;             v[j] -= delta;           } else             minv[j] -= delta;         j0 = j1;       } while (p[j0] != 0);       do {         int j1 = way[j0];         p[j0] = p[j1];         j0 = j1;       } while (j0 != 0);     }     vector<int> matching(n);     for (int i = 1; i <= m; i++) {       if (p[i] > 0) matching[p[i] - 1] = i - 1;     }     return {-v[0], matching};   }   char c(int k) {     if (k < 26)       return  a  + k;     else       return  A  + k - 26;   }   int idx(char a) {     if ( a  <= a && a <=  z )       return a -  a ;     else       return (a -  A ) + 26;   }   int main() {     int N, K;     string enc, ans;     cin >> N >> K >> enc >> ans;     vector<vector<int>> A(K, vector<int>(K, 0));     for (int i = 0; i < N; i++) {       A[idx(enc[i])][idx(ans[i])]--;     }     auto res = hungarian(A);     cout << -res.first << endl;     for (int k = 0; k < K; k++) {       cout << c(res.second[k]);     }     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   int cnt, n, vis[305], a[305], C[305][305], sum[305];   map<int, int> m;   vector<int> v[305];   int num[305], top;   long long jie[305], ans, f[305][305];   void pre() {     jie[0] = 1;     for (int i = 1; i <= 300; i++) jie[i] = jie[i - 1] * i % mod;     C[0][0] = 1;     for (int i = 1; i <= 300; i++) {       C[i][0] = C[i][i] = 1;       for (int j = 1; j < i; j++) {         C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;       }     }   }   bool check(long long a) {     long long temp = (long long)sqrt(a);     return temp * temp == a;   }   void dfs(int a) {     cnt++;     vis[a] = 1;     for (auto to : v[a]) {       if (vis[to] == 0) dfs(to);     }   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     pre();     for (int i = 1; i <= n; i++) {       for (int j = i + 1; j <= n; j++) {         if (check((long long)a[i] * a[j])) v[i].push_back(j);       }     }     for (int i = 1; i <= n; i++) {       cnt = 0;       if (vis[i] == 0) {         dfs(i);         num[++top] = cnt;       }     }     for (int i = 1; i <= top; i++) {       sum[i] = sum[i - 1] + num[i];     }     f[0][0] = 1;     for (int i = 1; i <= top; i++) {       for (int j = 0; j <= 1 + sum[i - 1]; j++) {         for (int k = 1; k <= num[i]; k++) {           for (int p = 0; p <= min(k, j); p++) {             f[i][j + num[i] - k - p] =                 (f[i][j + num[i] - k - p] +                  f[i - 1][j] * C[j][p] % mod * C[num[i] - 1][k - 1] % mod *                      C[1 + sum[i - 1] - j][k - p] % mod) %                 mod;           }         }       }     }     ans = f[top][0];     for (int i = 1; i <= top; i++) {       ans = ans * jie[num[i]] % mod;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, l, k, v1, v2;   bool chk(long double X) {     long double curr = 0;     long double nn = l;     long double f_time;     long double x = X;     for (long long i = 1; i < (n + k - 1) / k; i++) {       long double diss = nn - curr;       long double y = ((x * (long double)v1 * (long double)v2) -                        (l * (long double)v2) + (curr * (long double)v2)) /                       (long double)((long double)v1 - (long double)v2);       long double time = y / (long double)v2;       y += curr;       curr += (time * v1);       long double xx = ((y - curr) * (long double)v1) / (long double)(v1 + v2);       curr += xx;       f_time = (curr / (long double)v1);       x = X - f_time;     }     x -= ((l - curr) / (long double)v2);     return (x >= 0);   }   void query() {     cin >> n >> l >> v1 >> v2 >> k;     long double L = 0.0, R = l * (long double)v1, ans = R, diff = 1e-6;     while ((R - L) >= 1e-6) {       long double mid = (L + R) / 2.0;       if (chk(mid)) {         R = mid;         ans = min(ans, mid);       } else {         L = mid;       }     }     cout << setprecision(15) << ans <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long t = 1;     while (t--) {       query();     }   }
#include <bits/stdc++.h>   using namespace std;   int n;   int main() {     scanf( %d , &n);     for (int i = 0; i < 2 * n + 1; i++) {       for (int j = 0; j < 2 * n + 1; j++) {         if (i < n + 1) {           if (j < n - i) {             printf(    );           } else if (j < n + i) {             if (j <= n) {               printf( %d  , j - n + i);             } else {               printf( %d  , abs(j - n - i));             }           } else if (j == n + i) {             printf( 0 );           }         } else {           int temp = i;           i = 2 * n - i;           if (j < n - i) {             printf(    );           } else if (j < n + i) {             if (j <= n) {               printf( %d  , j - n + i);             } else {               printf( %d  , abs(j - n - i));             }           } else if (j == n + i) {             printf( 0 );           }           i = temp;         }       }       printf(  n );     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T, class U>   inline void chmin(T &t, U f) {     if (t > f) t = f;   }   template <class T, class U>   inline void chmax(T &t, U f) {     if (t < f) t = f;   }   long long N;   char S[11111];   long long ex[27 * 26 * 26];   long long dp[11111][2];   long long get(long long l, long long r) {     if (r > N) return -1;     long long x = 0;     for (long long i = l; i < r; i++) {       x = x * 26 + (S[i] -  a );     }     if (r - l == 2) x += 26 * 26 * 26;     return x;   }   signed main() {     scanf( %s , S);     N = strlen(S);     if (N <= 6) {       puts( 0 );       return 0;     }     if (N == 7) {       puts( 1 );       printf( %s , S + 5);       return 0;     }     ex[get(N - 2, N)] = true;     ex[get(N - 3, N)] = true;     dp[N - 2][0] = true;     dp[N - 3][1] = true;     for (long long i = N - 4; i >= 5; i--) {       long long t2 = get(i, i + 2);       long long t3 = get(i, i + 3);       if (t2 == get(i + 2, i + 4))         dp[i][0] = dp[i + 2][1];       else         dp[i][0] = dp[i + 2][0] | dp[i + 2][1];       if (t3 == get(i + 3, i + 6))         dp[i][1] = dp[i + 3][0];       else         dp[i][1] = dp[i + 3][0] | dp[i + 3][1];       if (dp[i][0]) ex[t2] = true;       if (dp[i][1]) ex[t3] = true;     }     vector<string> vec;     for (long long i = 0; i < (26); i++)       for (long long j = 0; j < (26); j++)         if (ex[26 * 26 * 26 + i * 26 + j])           vec.push_back(string(1,  a  + i) + string(1,  a  + j));     for (long long i = 0; i < (26); i++)       for (long long j = 0; j < (26); j++)         for (long long k = 0; k < (26); k++)           if (ex[i * 26 * 26 + j * 26 + k])             vec.push_back(string(1,  a  + i) + string(1,  a  + j) +                           string(1,  a  + k));     sort((vec).begin(), (vec).end());     printf( %lld n , (long long)vec.size());     for (long long i = 0; i < (vec.size()); i++) printf( %s n , vec[i].c_str());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<int, int> m;   int main() {     map<int, int>::iterator ptr;     int n, i, x, a[3];     cin >> n;     for (i = 0; i < n; i++) {       cin >> x;       m[x]++;     }     if (m.size() > 3) {       cout <<  NO ;       return 0;     }     if (m.size() <= 2) {       cout <<  YES ;       return 0;     }     i = 0;     for (ptr = m.begin(); ptr != m.end(); ptr++) a[i++] = ptr->first;     if ((a[0] + a[2]) == (2 * a[1]))       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   int n;   int mt[256][256];   int xy[256], yx[256];   int lx[256], ly[256], slk[256], slkx[256], prv[256];   char S[256], T[256];   void updtree(int x) {     for (int y = 0; y < (int)(n); y++)       if (lx[x] + ly[y] - mt[x][y] < slk[y]) {         slk[y] = lx[x] + ly[y] - mt[x][y];         slkx[y] = x;       }   }   int hungar() {     for (int i = 0; i < (int)(n); i++) {       ly[i] = 0;       lx[i] = *max_element(mt[i], mt[i] + n);     }     memset(xy, -1, sizeof(xy));     memset(yx, -1, sizeof(yx));     for (int m = 0; m < (int)(n); m++) {       memset(S, 0, sizeof(S));       memset(T, 0, sizeof(T));       memset(prv, -1, sizeof(prv));       memset(slk, 0x7f, sizeof(slk));       queue<int> q;       for (int i = 0; i < (int)(n); i++)         if (xy[i] == -1) {           {             q.push(i);             prv[i] = -2;             S[i] = 1;             updtree(i);           };           break;         }       int x = 0, y = -1;       while (y == -1) {         while (!q.empty() && y == -1) {           x = q.front();           q.pop();           for (int j = 0; j < (int)(n); j++)             if (mt[x][j] == lx[x] + ly[j] && !T[j]) {               if (yx[j] == -1) {                 y = j;                 break;               }               T[j] = 1;               {                 q.push(yx[j]);                 prv[yx[j]] = x;                 S[yx[j]] = 1;                 updtree(yx[j]);               };             }         }         if (y != -1) break;         int dlt = 0x7f7f7f7f;         for (int j = 0; j < (int)(n); j++)           if (!T[j]) dlt = min(dlt, slk[j]);         for (int k = 0; k < (int)(n); k++) {           if (S[k]) lx[k] -= dlt;           if (T[k]) ly[k] += dlt;           if (!T[k]) slk[k] -= dlt;         }         for (int j = 0; j < (int)(n); j++)           if (!T[j] && !slk[j]) {             if (yx[j] == -1) {               x = slkx[j];               y = j;               break;             } else {               T[j] = 1;               if (!S[yx[j]]) {                 q.push(yx[j]);                 prv[yx[j]] = slkx[j];                 S[yx[j]] = 1;                 updtree(yx[j]);               };             }           }       }       if (y != -1) {         for (int p = x; p != -2; p = prv[p]) {           yx[y] = p;           int ty = xy[p];           xy[p] = y;           y = ty;         }       } else         break;     }     int res = 0;     for (int i = 0; i < (int)(n); i++) res += mt[i][xy[i]];     return res;   }   string s, t;   int f(char c) {     if ( A  <= c && c <=  Z )       return (int)(c -  A  + 26);     else       return (int)(c -  a );   }   char invf(int i) {     if (i < 26)       return (char)(i +  a );     else       return (char)(i - 26 +  A );   }   int main() {     int N;     cin >> N >> n;     cin >> s >> t;     memset(mt, 0, sizeof(mt));     for (int i = 0; i < (int)(N); i++) {       mt[f(s[i])][f(t[i])]++;     }     cout << hungar() << endl;     for (int i = 0; i < (int)(n); i++) {       cout << invf(xy[i]);     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 300;   int n, m;   struct cell {     int mask = 0;     bool operator[](int i) { return mask & (1 << i); }   };   cell arr[MAX][MAX];   vector<pair<int, int> > adj[MAX][MAX];   int inDegree[MAX][MAX], _Time, visTime[MAX][MAX], lowTime[MAX][MAX],       compIdx[MAX][MAX];   bool inStack[MAX][MAX];   void SCC(int x, int y, stack<pair<int, int> >& s) {     visTime[x][y] = lowTime[x][y] = ++_Time;     s.push({x, y});     inStack[x][y] = 1;     for (auto v : adj[x][y])       if (!visTime[v.first][v.second]) {         SCC(v.first, v.second, s);         lowTime[x][y] = min(lowTime[x][y], lowTime[v.first][v.second]);       } else if (inStack[x][y])         lowTime[x][y] = min(lowTime[x][y], lowTime[v.first][v.second]);     if (visTime[x][y] == lowTime[x][y]) {       vector<pair<int, int> > temp;       int cnt = 0;       int v, u;       compIdx[x][y] = lowTime[x][y];       do {         cnt++;         v = s.top().first, u = s.top().second;         s.pop();         inStack[v][u] = 0;         compIdx[v][u] = compIdx[x][y];         arr[x][y].mask |= arr[v][u].mask;         vector<pair<int, int> >& to = adj[v][u];         for (int i = 0; i < int(to.size()); i++)           if (!inStack[to[i].first][to[i].second] &&               compIdx[to[i].first][to[i].second] != compIdx[x][y])             temp.push_back(to[i]);       } while (v != x || u != y);       if (cnt > 1) inDegree[x][y] = 0;       adj[x][y] = temp;     }   }   void getDAG() {     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++)         if (!visTime[i][j]) {           stack<pair<int, int> > s;           SCC(i, j, s);         }   }   bool getPath(int x, int y, int idx, string& str) {     if (idx + arr[x][y][str[idx] -  0 ] == int(str.size())) return 1;     vector<pair<int, int> >& to = adj[x][y];     for (int i = 0; i < int(to.size()); i++)       if (getPath(to[i].first, to[i].second, idx + arr[x][y][str[idx] -  0 ],                   str))         return 1;     return 0;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int q;     cin >> n >> m >> q;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         char ch;         cin >> ch;         arr[i][j].mask |= 1 << (ch -  0 );       }     for (int k = 0; k < 10; k++) {       int x, y;       cin >> x >> y;       for (int i = 0; i < n; i++)         for (int j = 0; j < m; j++)           if (arr[i][j][k] && i + x >= 0 && i + x < n && j + y >= 0 && j + y < m)             adj[i + x][j + y].push_back({i, j}), inDegree[i][j]++;     }     getDAG();     while (q--) {       string str;       cin >> str;       reverse(str.begin(), str.end());       for (int i = 0; i < n; i++)         for (int j = 0; j < m; j++)           if (!inDegree[i][j]) {             int idx = 0;             while (arr[i][j][str[idx] -  0 ]) idx++;             if (getPath(i, j, idx, str)) {               cout <<  YES n ;               goto ESHTA;             }           }       cout <<  NO n ;     ESHTA:;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   T abs(T a) {     return a < 0 ? -a : a;   }   template <typename T>   T sqr(T a) {     return a * a;   }   const int INF = (int)1e9;   const long double EPS = 1e-9;   const long double PI = 3.1415926535897932384626433832795;   const int N = 4;   struct pt {     int first, second;     pt() { first = second = 0; }     pt(int cX, int cY) : first(cX), second(cY) {}   };   int n, m;   int used[N * N];   pt a[N * N];   int s;   int sum[3 * N];   int szst[N][N];   int st[N][N][3 * N];   int szfn[N][N];   int fn[N][N][3 * N];   int mn[N][N];   inline void put(int i, int j, int v) {     mn[i][j] = v;     for (int k = 0; k < int(szst[i][j]); ++k) sum[st[i][j][k]] += v;   }   inline void take(int i, int j) {     for (int k = 0; k < int(szst[i][j]); ++k) sum[st[i][j][k]] -= mn[i][j];   }   void solve(int x, int y) {     if (y == n) {       x++;       y = 0;     }     if (x == n) {       printf( %d n , s);       for (int i = 0; i < int(n); ++i) {         for (int j = 0; j < int(n); ++j) {           printf( %d , mn[i][j]);           if (j + 1 != n) printf(   );         }         puts(  );       }       exit(0);     }     for (int i = 0; i < int(m); ++i) {       if (used[i] < a[i].second) {         put(x, y, a[i].first);         used[i]++;         bool good = true;         for (int j = 0; j < int(szfn[x][y]); ++j)           if (sum[fn[x][y][j]] != s) {             good = false;             break;           }         if (good) solve(x, y + 1);         used[i]--;         take(x, y);       }     }   }   void pickRow(int idx) {     if (idx == n) {       s = sum[0];       solve(1, 0);       s = INF;       return;     }     for (int i = 0; i < int(m); ++i)       if (used[i] < a[i].second) {         used[i]++;         put(0, idx, a[i].first);         pickRow(idx + 1);         used[i]--;         take(0, idx);       }   }   int main() {     cin >> n;     vector<int> c;     c.resize(n * n);     for (int i = 0; i < int(n * n); ++i) {       scanf( %d , &c[i]);     }     sort((c).begin(), (c).end());     m = 0;     int cnt = 1;     for (int i = 1; i < n * n; ++i) {       if (c[i] != c[i - 1]) {         a[m++] = pt(c[i - 1], cnt);         cnt = 1;       } else         cnt++;     }     a[m++] = pt(c[n * n - 1], cnt);     for (int i = 0; i < int(n); ++i)       for (int j = 0; j < int(n); ++j) {         st[i][j][szst[i][j]++] = i;         st[i][j][szst[i][j]++] = n + j;         if (i == j) st[i][j][szst[i][j]++] = 2 * n;         if (i == n - j - 1) st[i][j][szst[i][j]++] = 2 * n + 1;         if (j == n - 1) fn[i][j][szfn[i][j]++] = i;         if (i == n - 1) fn[i][j][szfn[i][j]++] = n + j;         if (i == n - 1 && j == n - 1) fn[i][j][szfn[i][j]++] = 2 * n;         if (i == n - 1 && j == 0) fn[i][j][szfn[i][j]++] = 2 * n + 1;       }     random_shuffle(a, a + m);     s = INF;     pickRow(0);     return 0;   }