malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   const int N = 110;   using namespace std;   inline int read() {     int x = 0, f = 1;     int ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) {         f = -1;       }       ch = getchar();     }     while (ch <=  9  && ch >=  0 ) {       x = (x << 1) + (x << 3) + ch -  0 ;       ch = getchar();     }     return x * f;   }   int n, a[N];   int main() {     int q = read();     while (q--) {       bool flg = 0;       n = read();       for (int i = 1; i <= n; i++) {         a[i] = read();       }       sort(a + 1, a + 1 + n);       for (int i = 2; i <= n; i++) {         if (a[i] == a[i - 1] + 1) {           cout << 2 << endl;           flg = 1;           break;         }       }       if (!flg) cout << 1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n = 0;     int answer = 0;     cin >> n;     int last = -1;     int xs = 0, ys = 0, x = 0, y = 0;     for (int i = 0; i < n; i++) {       int px = x, py = y;       char c;       cin >> c;       if (c ==  L )         x--;       else if (c ==  R )         x++;       else if (c ==  U )         y++;       else         y--;       if (abs(x - xs) + abs(y - ys) != i - last)         answer++, last = i - 1, xs = px, ys = py;     }     answer++;     cout << answer;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = (long long)1000 * 1000 * 1000 * 1000 * 1000 * 100;   const int MOD = 1000 * 1000 * 1000 + 9;   const int SIZE = 5000;   int main() {     std::ios_base::sync_with_stdio(false);     int n;     cin >> n;     vector<int> a(n);     vector<vector<int> > p(100500);     for (int i = 0; i < n; ++i) {       cin >> a[i];       a[i] = abs(a[i]);       p[a[i]].push_back(i);     }     int cur = 0;     for (int i = 0; i < n; ++i) {       for (int j = i + 1; j < n; ++j)         if (a[j] < a[i]) ++cur;     }     for (int k = 1; k < 100500; ++k) {       if (p[k].size() == 0) continue;       int best = 0;       int before = 0;       int after = 0;       int tmp = 0;       for (int c = 0; c < n; ++c) {         if (a[c] > -k && a[c] < k) ++after;       }       int i = 0;       for (int cnt = 0; cnt < p[k].size(); ++cnt) {         for (; i != p[k][cnt]; ++i) {           if (a[i] > -k && a[i] < k) ++before, --after;         }         tmp += before - after;         if (tmp < best) best = tmp;       }       cur += best;     }     cout << cur << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100010;   const int inf = 1e9;   int n, l[maxn], c[maxn], ans, cnt, pri[maxn], lst, cur, p[maxn], st[maxn],       f[maxn];   bool tf[maxn];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , l + i);     for (int i = 1; i <= n; i++) scanf( %d , c + i);     for (int i = 2; i <= 100000; i++) {       if (!tf[i]) pri[++cnt] = i;       for (int j = 1; j <= cnt && i * pri[j] <= 100000; j++) {         tf[i * pri[j]] = true;         if (i % pri[j] == 0) break;       }     }     ans = inf;     for (int i = 1; i <= n; i++) {       lst = l[i];       cur = 0;       for (int j = 1; j <= cnt && pri[j] * pri[j] <= lst; j++)         if (lst % pri[j] == 0) {           p[++cur] = pri[j];           while (lst % pri[j] == 0) lst /= pri[j];         }       if (lst != 1) p[++cur] = lst;       for (int j = 1; j <= n; j++) {         st[j] = 0;         for (int k = 1; k <= cur; k++)           if (l[j] % p[k] == 0) st[j] |= (1 << (k - 1));       }       for (int i = 0; i < (1 << 10); i++) f[i] = inf;       f[(1 << cur) - 1] = c[i];       for (int i = 1; i <= n; i++)         for (int j = 0; j < (1 << cur); j++)           f[st[i] & j] = min(f[st[i] & j], f[j] + c[i]);       ans = min(ans, f[0]);     }     if (ans >= inf)       printf( -1 n );     else       printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   char st[55][25];   int f[1100005], dx[1100005];   long long ms[1100005];   double dp[1100005], cf[1100005];   int main() {     int i, j, k, sum, s;     double ans = 0, t;     cin >> n;     for (i = 1; i <= n; i++) scanf( %s , st[i]);     m = strlen(st[1]);     for (i = 1; i <= n; i++)       for (j = i + 1; j <= n; j++) {         sum = 0;         for (k = 0; k < m; k++)           if (st[i][k] == st[j][k]) sum |= (1 << k);         ms[sum] |= (1ll << i - 1) | (1ll << j - 1);       }     for (s = (1 << m) - 1; s >= 0; s--) {       f[s] = n;       for (k = 0; k < m; k++)         if (s & (1 << k)) dx[s]++;       for (i = 1; i <= n; i++)         if (ms[s] & (1ll << i - 1)) f[s]--;       for (k = 0; k < m; k++)         if (s & (1 << k)) ms[s ^ (1 << k)] |= ms[s];     }     dp[0] = 1;     for (s = 0; s < (1 << m); s++) {       ans += cf[s] * dx[s];       if (f[s] == n) continue;       t = dp[s] / (m - dx[s]) / (n - f[s]);       for (k = 0; k < m; k++)         if (!(s & (1 << k))) {           dp[s | (1 << k)] += t * (n - f[s | (1 << k)]);           cf[s | (1 << k)] += t * (f[s | (1 << k)] - f[s]);         }     }     printf( %.12f n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long num[200000];   pair<long long, long long> p[200000];   int main() {     long long n, m, k, sum = 0, cnt = 1;     cin >> n >> m >> k;     for (int i = 1; i <= n; i++) {       cin >> p[i].first;       p[i].second = i;     }     sort(p + 1, p + n + 1);     for (int i = n; i > n - m * k; i--) {       sum += p[i].first;       num[cnt++] = p[i].second;     }     cout << sum <<   n ;     sort(num + 1, num + m * k + 1);     for (int i = m; i < m * k; i += m) cout << num[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using ll = long long;   using ld = long double;   using ull = unsigned long long;   using namespace std;   const int N = 1e5 + 2, SQ = 400;   int n, q, a[N], jump[N], cost[N];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cin >> n >> q;     for (int i = (0); i <= (n - 1); ++i) cin >> a[i];     for (int i = (n - 1); i >= (0); --i) {       int nxt = min(n, i + a[i]);       if (nxt == n) {         jump[i] = i;         continue;       }       if (nxt / SQ > i / SQ)         jump[i] = nxt, cost[i] = 1;       else         jump[i] = jump[nxt], cost[i] = cost[nxt] + 1;     }     while (q--) {       int t;       cin >> t;       if (t == 0) {         int x, y;         cin >> x >> y;         x--;         a[x] = y;         for (int i = (x); i >= (x / SQ * SQ); --i) {           int nxt = min(n, i + a[i]);           if (nxt == n) {             jump[i] = i;             cost[i] = 0;             continue;           }           if (nxt / SQ > i / SQ)             jump[i] = nxt, cost[i] = 1;           else             jump[i] = jump[nxt], cost[i] = cost[nxt] + 1;         }       } else {         int x, res = 1;         cin >> x;         x--;         while (cost[x]) res += cost[x], x = jump[x];         cout << x + 1 <<     << res <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:102400000,102400000 )   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   const int maxn = 2e5 + 5;   map<int, int> dp, pos;   int pre[maxn];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int i, j, k, m, n;     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> k;       if (!dp.count(k - 1)) {         dp[k] = 1;         pre[i] = -1;         pos[k] = i;       } else if (dp[k - 1] + 1 > dp[k]) {         dp[k] = dp[k - 1] + 1;         pos[k] = i;         pre[i] = pos[k - 1];       }     }     pair<int, int> mst = {0, 0};     for (auto it : dp) {       if (it.second > mst.second) {         mst.first = it.first;         mst.second = it.second;       }     }     int npos = pos[mst.first];     vector<int> ans;     while (npos != -1) {       ans.push_back(npos);       npos = pre[npos];     }     reverse(ans.begin(), ans.end());     cout << ans.size() << endl;     for (auto it : ans) cout << it <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<vector<char> > v(4);     for (int i = 0; i < 4; i++) v[i].resize(4);     for (int i = 0; i < 4; i++) {       for (int j = 0; j < 4; j++) {         cin >> v[i][j];       }     }     for (int i = 0; i < 3; i++) {       for (int j = 0; j < 3; j++) {         int cntd = 0, cnth = 0;         if (v[i][j] ==  # )           cnth++;         else           cntd++;         if (v[i][j + 1] ==  # )           cnth++;         else           cntd++;         if (v[i + 1][j] ==  # )           cnth++;         else           cntd++;         if (v[i + 1][j + 1] ==  # )           cnth++;         else           cntd++;         if (cntd >= 3 || cnth >= 3) {           cout <<  YES n ;           return 0;         }       }     }     cout <<  NO n ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a[100], b[100], i, n, m, r;     cin >> n >> m >> r;     long long ans = r;     for (i = 0; i < n; ++i) {       cin >> a[i];     }     for (i = 0; i < m; ++i) {       cin >> b[i];     }     long long minn = *min_element(a, a + n);     long long akcia = r / minn;     r %= minn;     r += akcia * (*max_element(b, b + m));     cout << max(ans, r) << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(2)   #pragma GCC optimize(3,  Ofast ,  inline )   using namespace std;   void err(istream_iterator<string> it) { cerr << endl; }   template <typename T, typename... Args>   void err(istream_iterator<string> it, T a, Args... args) {}   namespace fastIO {   bool IOerror = 0;   inline char nc() {     static char buf[100000], *p1 = buf + 100000, *pend = buf + 100000;     if (p1 == pend) {       p1 = buf;       pend = buf + fread(buf, 1, 100000, stdin);       if (pend == p1) {         IOerror = 1;         return -1;       }     }     return *p1++;   }   inline bool blank(char ch) {     return ch ==     || ch ==   n  || ch ==   r  || ch ==   t ;   }   inline void read(int &x) {     char ch;     while (blank(ch = nc()))       ;     if (IOerror) return;     for (x = ch -  0 ; (ch = nc()) >=  0  && ch <=  9 ; x = x * 10 + ch -  0 )       ;   }   }  // namespace fastIO   using namespace fastIO;   const double PI = acos(-1.0);   const double eps = 1e-8;   const int maxn = 3e5 + 5;   int cnt[maxn];   int main() {     int t;     scanf( %d , &t);     while (t--) {       string s;       int n, k;       cin >> n >> k >> s;       int ans = 1;       for (int i = 0; i < k; ++i) cnt[i] = 0;       for (int i = 0; i < s.size(); ++i) {         if (s[i] ==  ? ) continue;         if ((s[i] ==  0  && cnt[i % k] == 1) ||             (s[i] ==  1  && cnt[i % k] == -1)) {           ans = 0;           break;         }         cnt[i % k] = s[i] ==  0  ? -1 : 1;       }       int cnt1 = 0, cnt0 = 0;       for (int i = 0; i < n; ++i)         if (cnt[i % k]) s[i] = cnt[i % k] == -1 ?  0  :  1 ;       for (int i = 0; i < k; ++i) {         if (s[i] ==  1 )           cnt1++;         else if (s[i] ==  0 )           cnt0++;       }       if (2 * cnt1 > k || 2 * cnt0 > k) ans = 0;       puts(ans ?  YES  :  NO );     }   }
#include <bits/stdc++.h>   using namespace std;   struct mat {     int num[4][4];   };   mat m1 = {{{1, 1, 1, 0}, {1, 0, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}}},       m2 = {{{1, 1, 0, 1}, {1, 0, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}}};   mat mult(mat &a, mat &b) {     mat ret;     for (int i = 0; i < 4; i++)       for (int j = 0; j < 4; j++) {         long long t = 0;         for (int k = 0; k < 4; k++) t += 1ll * a.num[i][k] * b.num[k][j];         ret.num[i][j] = t % 1000000007;       }     return ret;   }   int cal(string &s, string &q) {     int ret = 0;     for (int i = 0; i + q.size() <= s.size(); i++)       if (s.substr(i, q.size()) == q) ret++;     return ret;   }   int query(long long n, string &q) {     if (n == 1) {       return q ==  a  ? 1 : 0;     }     if (n == 2) {       return q ==  b  ? 1 : 0;     }     string s1 =  a , s2 =  b , s =  b ;     for (n -= 2; n && s1.size() < q.size(); n--, s1 = s2, s2 = s) s = s2 + s1;     int f1 = cal(s1, q), f2 = cal(s, q);     if (!n) return f2;     s = s2.substr(s2.size() - q.size() + 1, q.size() - 1) +         s2.substr(0, q.size() - 1);     int t1 = cal(s, q);     s = s1.substr(s1.size() - q.size() + 1, q.size() - 1) +         s1.substr(0, q.size() - 1);     int t2 = cal(s, q);     mat res, t = mult(m2, m1);     bool flag = 0;     if (n % 2) res = m1, flag = 1;     for (n /= 2; n; n >>= 1, t = mult(t, t))       if (n & 1) {         if (!flag)           res = t, flag = 1;         else           res = mult(res, t);       }     return (1ll * res.num[0][0] * f2 + 1ll * res.num[0][1] * f1 +             1ll * res.num[0][2] * t1 + 1ll * res.num[0][3] * t2) %            1000000007;   }   int main() {     long long n, m;     cin >> n >> m;     string s;     while (m--) cin >> s, cout << query(n, s) << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   string a, b;   map<pair<string, string>, int> m;   int f(string aa, string bb) {     if (aa == bb) return 2;     if (aa.size() % 2) return 1;     if (m[{aa, bb}] != 0) return m[{aa, bb}];     string a1, b1, a2, b2;     for (int i = 0; i < aa.size(); i++) {       if (i < aa.size() / 2) {         a1.push_back(aa[i]);         b1.push_back(bb[i]);       } else {         a2.push_back(aa[i]);         b2.push_back(bb[i]);       }     }     if (f(a1, b1) == 2 && f(a2, b2) == 2) return m[{aa, bb}] = 2;     if (f(a1, b2) == 2 && f(a2, b1) == 2) return m[{aa, bb}] = 2;     return m[{aa, bb}] = 1;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> a >> b;     if (f(a, b) == 2)       cout <<  YES ;     else       cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 102, M = 102 * 102;   int n, m;   vector<pair<int, int> > g[N];   char ans[N][N];   char dp[N][N][28] = {0};   void input() {     cin >> n >> m;     for (int i = (0); i < (m); ++i) {       int u, v;       char ch;       cin >> u >> v >> ch;       u--, v--;       g[u].push_back(make_pair(v, ch -  a ));     }   }   int dfs(int u, int v, char c) {     if (dp[u][v][c] != 0) return dp[u][v][c];     for (auto x : g[u]) {       int h = x.first;       char k = x.second;       int win = 0;       if (k >= c) {         win = dfs(v, h, k);         if (win == 2) {           dp[u][v][c] = 1;           return 1;         }       }     }     dp[u][v][c] = 2;     return 2;   }   void solve() {     for (int i = (0); i < (n); ++i) {       for (int j = (0); j < (n); ++j) {         ans[i][j] = ((dfs(i, j, 0) == 1) ?  A  :  B );       }     }   }   void output() {     for (int i = (0); i < (n); ++i) {       for (int j = (0); j < (n); ++j) {         cout << ans[i][j];       }       cout <<   n ;     }   }   int main() {     input();     solve();     output();   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e3 + 7;   const int inf = 1e9 + 7;   int T, n, dp[N][N], cnt[N], qzs[N][26], qzt[N][26];   char s[N], t[N];   void Min(int &x, int y) {     if (x > y) x = y;   }   void Main() {     fill(cnt, cnt + 26, 0);     scanf( %d , &n);     for (int i = 0, iE = n; i <= iE; i++)       for (int j = 0, jE = n; j <= jE; j++) dp[i][j] = inf;     scanf( %s%s , s + 1, t + 1);     for (int i = 1, iE = n; i <= iE; i++) cnt[s[i] -  a ]++, cnt[t[i] -  a ]--;     for (int i = 0, iE = 25; i <= iE; i++)       if (cnt[i]) return puts( -1 ), void();     for (int i = 1, iE = n; i <= iE; i++)       for (int j = 0, jE = 25; j <= jE; j++)         qzs[i][j] = qzs[i - 1][j] + (s[i] ==  a  + j),         qzt[i][j] = qzt[i - 1][j] + (t[i] ==  a  + j);     for (int i = 0, iE = n; i <= iE; i++) dp[0][i] = 0;     for (int i = 1, iE = n; i <= iE; i++)       for (int j = i, jE = n; j <= jE; j++) {         Min(dp[i][j], dp[i - 1][j] + 1);         if (s[i] == t[j]) Min(dp[i][j], dp[i - 1][j - 1]);         if (qzs[i][t[j] -  a ] < qzt[j][t[j] -  a ]) Min(dp[i][j], dp[i][j - 1]);       }     printf( %d n , dp[n][n]);   }   int main() {     scanf( %d , &T);     while (T--) Main();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, s[1000006], top, a[1000006];   int solve(int n, int mul) {     if (n == 1) return s[++top] = mul;     if (n == 2) return s[++top] = mul, s[++top] = mul * 2;     if (n == 3) return s[++top] = mul, s[++top] = mul, s[++top] = mul * 3;     for (int i = 1; i <= (n - n / 2); i++) s[++top] = mul;     for (int i = 1; i <= n / 2; i++) a[i] = a[i * 2] / 2;     solve(n / 2, mul << 1);   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) a[i] = i;     solve(n, 1);     for (int i = 1; i <= n; i++) printf( %d  , s[i]);   }
#include <bits/stdc++.h>   using namespace std;   const int SCALE = 101;   int g[SCALE * 2][SCALE * 2];   int tx, ty;   int stepr[4] = {0, -1, 0, 1};   int stepc[4] = {-1, 0, 1, 0};   string s;   bool BuildMap(const string& s) {     int x = 0;     int y = 0;     memset(g, 0, sizeof(g));     g[(x + SCALE)][(y + SCALE)] = 1;     for (int i = 0; i < s.size(); ++i) {       int d = 0;       switch (s[i]) {         case  L :           d = 0;           break;         case  U :           d = 1;           break;         case  R :           d = 2;           break;         case  D :           d = 3;           break;       }       x += stepr[d];       y += stepc[d];       if (g[(x + SCALE)][(y + SCALE)] == 1) {         return false;       } else {         g[(x + SCALE)][(y + SCALE)] = 1;       }     }     tx = x;     ty = y;     return true;   }   int Dfs(int x, int y, int cost) {     if (x == tx && y == ty) return cost;     int v = 10000;     for (int i = 0; i < 4; ++i) {       int tmpx = x + stepr[i];       int tmpy = y + stepc[i];       int& tmpg = g[(tmpx + SCALE)][(tmpy + SCALE)];       if (tmpg == 1) {         tmpg = -1;         int tv = Dfs(tmpx, tmpy, cost + 1);         v = min(tv, v);         tmpg = 1;       }     }     return v;   }   bool CheckShort() {     g[(0 + SCALE)][(0 + SCALE)] = -1;     int cost = Dfs(0, 0, 0);     if (cost < s.size() - 1) {       return false;     }     return true;   }   int main() {     while (cin >> s) {       bool b = BuildMap(s);       if (b == false) {         cout <<  BUG  << endl;         continue;       }       b = CheckShort();       if (b == false) {         cout <<  BUG  << endl;         continue;       }       cout <<  OK  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   istream& operator>>(istream& is, vector<T>& a) {     for (T& ai : a) is >> ai;     return is;   }   template <typename T>   ostream& operator<<(ostream& os, vector<T> const& a) {     os <<  [  ;     for (const T& ai : a) os << ai <<    ;     return os <<  ] ;   }   template <typename T1, typename T2>   istream& operator>>(istream& is, pair<T1, T2>& a) {     return is >> a.first >> a.second;   }   template <typename T1, typename T2>   ostream& operator<<(ostream& os, pair<T1, T2> const& a) {     return os <<  (  << a.first <<  ,   << a.second <<  ) ;   }   int f() {     int n, h, l, r;     cin >> n >> h >> l >> r;     vector<int> a(n), b(h, -1);     cin >> a;     b[0] = 0;     for (int ai : a) {       vector<int> c(h, -1);       for (int i = 0; i < h; ++i) {         if (b[i] < 0) continue;         int j = i + ai - 1;         if (j >= h) j -= h;         c[j] = max(c[j], b[i] + (l <= j && j <= r));         if (++j >= h) j -= h;         c[j] = max(c[j], b[i] + (l <= j && j <= r));       }       b.swap(c);     }     return *max_element((b).begin(), (b).end());   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout << f() <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   int n, m;   vector<long long> b(N, 0);   void add(int x, int k) {     while (x < N) {       b[x] += k;       x += x & -x;     }   }   long long sum(int x) {     long long ret = 0;     while (x) {       ret += b[x];       x -= x & -x;     }     return ret;   }   void add(int l, int r, int k) {     if (l > r) return;     add(l, k);     add(r + 1, -k);   }   int main() {     scanf( %d%d , &n, &m);     vector<int> x(m + 1, 0);     for (int i = 0, y; i < m; i++) {       scanf( %d , &x[i]);     }     for (int i = 1; i < m; i++) {       long long sum = 0;       int u = x[i - 1];       int v = x[i];       if (u == v) continue;       if (u < v) swap(u, v);       add(1, v - 1, u - v);       add(u + 1, n, u - v);       add(v + 1, u - 1, u - v - 1);       add(v, v, u - 1);       add(u, u, v);     }     for (int i = 1; i <= n; i++) {       printf( %lld%c , sum(i),    n [i == n]);     }     return 0;   }
#include <bits/stdc++.h>   const double PI =       3.141592653589793238462643383279502884197169399375105820974944;   using namespace std;   long long arr[] = {0,     9,      90,      900,      9000,                      90000, 900000, 9000000, 90000000, 900000000};   long long arr1[] = {0,     9,      99,      999,      9999,                       99999, 999999, 9999999, 99999999, 999999999};   void solve() {     long long n;     cin >> n;     int digits = 0;     long long temp = n;     while (temp != 0) {       ++digits;       temp = temp / 10;     }     long long ans = 0;     for (long long i = 0; i < digits; ++i) {       ans += arr[i] * (i);     }     ans += (n - arr1[digits - 1]) * (digits);     cout << ans <<   n ;   }   int main() {     bool testing = false;     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     if (testing) {       freopen( test.txt ,  rt , stdin);       int start = clock();       solve();       int end = clock();       cout <<  time:   << (end - start) / (double)(CLOCKS_PER_SEC)*1000            <<   milliseconds n ;     } else {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   int A[500][500];   int B[500][500];   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     int n, m;     cin >> n >> m;     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j) cin >> A[i][j];     int mx = -1e9;     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j)         B[i][j] = A[i][j] - (i && j ? B[i - 1][j - 1] : 0) +                   (i ? B[i - 1][j] : 0) + (j ? B[i][j - 1] : 0);     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j) {         int rx = A[i][j];         for (int k = 1; i + k < n && i - k > -1 && j + k < m && j - k > -1; ++k) {           rx += A[i - k + 1][j - k];           rx = B[i + k][j + k] + (i - k && j - k ? B[i - k - 1][j - k - 1] : 0) -                (i - k ? B[i - k - 1][j + k] : 0) -                (j - k ? B[i + k][j - k - 1] : 0) - rx;           mx = max(mx, rx);         }       }     cout << mx;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   #pragma comment(linker,  /stack:200000000 )   #pragma GCC optimize( unroll-loops )   using namespace std;   template <typename A>   ostream &operator<<(ostream &cout, vector<A> const &v);   template <typename A, typename B>   ostream &operator<<(ostream &cout, pair<A, B> const &p) {     return cout <<  (  << p.first <<  ,   << p.second <<  ) ;   }   template <typename A>   ostream &operator<<(ostream &cout, vector<A> const &v) {     cout <<  [ ;     for (int i = 0; i < v.size(); i++) {       if (i) cout <<  ,  ;       cout << v[i];     }     return cout <<  ] ;   }   template <typename A, typename B>   istream &operator>>(istream &cin, pair<A, B> &p) {     cin >> p.first;     return cin >> p.second;   }   const long long MAXN = 1e5 + 7;   void check() {     long long a[1000] = {0}, b[1000] = {0}, ans = 0;     string s1, s2;     cin >> s1 >> s2;     for (long long i = 0; i < s1.size(); i++) a[s1[i]]++, b[s2[i]]++;     for (long long i = 0; i < s1.size(); i++) {       if (s2[i] != s1[i]) {         if (a[s2[i]] < b[s2[i]]) {           ans++;           a[s2[i]]++;           a[s1[i]]--;           s1[i] = s2[i];         }       }     }     long long cnt = 0;     for (long long i = 0; i < s1.size(); i++) cnt += (s1[i] != s2[i]);     cnt /= 2;     cout << ans + cnt;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int t = 1;     for (int i = 1; i <= t; i++) {       check();     }     return 0;   }