malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 55;   int res[N][N][N][N];   int tmp[N][N], dat[N][N];   string s[N];   int n, m, q, a, b, c, d;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m >> q;     for (int i = 1; i <= n; i++) {       cin >> s[i];       for (int j = 1; j <= m; j++) dat[i][j] = (s[i][j - 1] ==  1 );     }     for (int i = 0; i <= n; i++) {       for (int j = 0; j <= m; j++) {         if (i == 0 || j == 0) continue;         tmp[i][j] = tmp[i - 1][j] + tmp[i][j - 1] - tmp[i - 1][j - 1] + dat[i][j];       }     }     for (int xa = 1; xa <= n; xa++)       for (int ya = 1; ya <= m; ya++)         for (int xb = 1; xb <= n; xb++)           for (int yb = 1; yb <= m; yb++) {             int sum = tmp[xb][yb] - tmp[xa - 1][yb] - tmp[xb][ya - 1] +                       tmp[xa - 1][ya - 1];             res[xa][ya][xb][yb] = (sum == 0);           }     for (int xa = n; xa >= 2; xa--)       for (int ya = 1; ya <= m; ya++)         for (int xb = xa; xb <= n; xb++)           for (int yb = ya; yb <= m; yb++)             res[xa - 1][ya][xb][yb] += res[xa][ya][xb][yb];     for (int xa = 1; xa <= n; xa++)       for (int ya = m; ya >= 2; ya--)         for (int xb = xa; xb <= n; xb++)           for (int yb = ya; yb <= m; yb++)             res[xa][ya - 1][xb][yb] += res[xa][ya][xb][yb];     for (int xa = 1; xa <= n; xa++)       for (int ya = 1; ya <= m; ya++)         for (int xb = xa; xb <= n; xb++)           for (int yb = ya; yb <= m; yb++)             res[xa][ya][xb + 1][yb] += res[xa][ya][xb][yb];     for (int xa = 1; xa <= n; xa++)       for (int ya = 1; ya <= m; ya++)         for (int xb = xa; xb <= n; xb++)           for (int yb = ya; yb <= m; yb++)             res[xa][ya][xb][yb + 1] += res[xa][ya][xb][yb];     while (q--) {       cin >> a >> b >> c >> d;       cout << res[a][b][c][d] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long t, n, k, a[200005];   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> t;     while (t--) {       cin >> n >> k;       for (long long i = 0; i < n; i++) cin >> a[i];       long long Min = k;       for (long long i = k; i < n; i++)         if (a[i] - a[i - k] < a[Min] - a[Min - k]) Min = i;       cout << (a[Min] + a[Min - k]) / 2 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   long long ax, ay, bx, by, cx, cy;   void check(long long xx, long long yy) {     if (cx == 0 && cy == 0) {       if (xx == 0 && yy == 0) {         cout <<  YES ;         exit(0);       } else         return;     }     if ((cx * (yy)-cy * (xx)) % (cx * cx + cy * cy) != 0 ||         (cx * (xx) + cy * (yy)) % (cx * cx + cy * cy) != 0)       return;     cout <<  YES ;     exit(0);   }   int main() {     cin >> ax >> ay >> bx >> by >> cx >> cy;     check(bx - ax, by - ay);     check(bx - ay, by + ax);     check(bx + ax, by + ay);     check(bx + ay, by - ax);     cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 356438;   int from[N], to[N], limL, nextp[N], headp[N], p[N], Lcnt[N], chcnt[N], num,       a[N], b[N], sz, c[N];   bool taboo[N], boo[N];   long long limW, W[N], Wcnt[N], ans;   inline int lowbit(int x) { return x & (-x); }   inline int ask(int x) {     int ans = 0;     while (x) {       ans += c[x];       x -= lowbit(x);     }     return ans;   }   inline void add(int x, int y) {     while (x < N) {       c[x] += y;       x += lowbit(x);     }   }   inline void addedge(int x, int y, long long z, int &tot) {     from[tot] = x;     to[tot] = y;     W[tot] = z;     nextp[tot] = headp[x];     headp[x] = tot;     ++tot;   }   void dfs(int x) {     a[sz] = x;     ++sz;     chcnt[x] = 1;     for (int i = headp[x]; i != -1; i = nextp[i]) {       if (taboo[i]) continue;       int y = to[i];       if (p[x] != -1 && from[p[x]] == y) continue;       p[y] = i;       dfs(y);       chcnt[x] += chcnt[y];     }   }   void dfs2(int x, bool b) {     boo[x] = b;     for (int i = headp[x]; i != -1; i = nextp[i]) {       if (taboo[i]) continue;       int y = to[i];       if (p[x] != -1 && from[p[x]] == y) continue;       p[y] = i;       Lcnt[y] = Lcnt[x] + 1;       Wcnt[y] = Wcnt[x] + W[i];       dfs2(y, b);     }   }   inline bool cmpb(int x, int y) {     if (Wcnt[x] != Wcnt[y]) return Wcnt[x] < Wcnt[y];     if (Lcnt[x] != Lcnt[y]) return Lcnt[x] < Lcnt[y];     return boo[x] < boo[y];   }   void work(int root) {     p[root] = -1;     Lcnt[root] = 0;     Wcnt[root] = 0;     sz = 0;     dfs(root);     if (sz == 1) return;     int tempsz = 0, tempedge = -1;     for (int i = 1; i < sz; ++i) {       int x = a[i];       if (min(chcnt[x], sz - chcnt[x]) > tempsz) {         tempsz = min(chcnt[x], sz - chcnt[x]);         tempedge = p[x];       }     }     taboo[tempedge] = taboo[tempedge ^ 1] = true;     Lcnt[from[tempedge]] = 0;     Wcnt[from[tempedge]] = 0;     p[from[tempedge]] = -1;     dfs2(from[tempedge], true);     Lcnt[to[tempedge]] = 0;     Wcnt[to[tempedge]] = 0;     p[to[tempedge]] = -1;     dfs2(to[tempedge], false);     for (int i = 0; i < sz; ++i) {       int x = a[i];       if (boo[x]) {         Lcnt[x] = limL - Lcnt[x] - 1;         Wcnt[x] = limW - Wcnt[x] - W[tempedge];       }       b[i] = x;     }     sort(b, b + sz, cmpb);     for (int i = 0; i < sz; ++i) {       int x = b[i];       if (boo[x]) {         if (Lcnt[x] < 0) continue;         ans += ask(Lcnt[x] + 1);       } else {         add(Lcnt[x] + 1, 1);       }     }     for (int i = 0; i < sz; ++i) {       int x = b[i];       if (boo[x]) {       } else {         add(Lcnt[x] + 1, -1);       }     }     work(to[tempedge]);     work(from[tempedge]);   }   int main() {     int n;     scanf( %d%d%I64d , &n, &limL, &limW);     int tot = 0;     memset(headp, -1, sizeof(headp));     for (int i = 2; i <= n; ++i) {       int j;       long long temp;       scanf( %d %I64d , &j, &temp);       addedge(i, j, temp, tot);       addedge(j, i, temp, tot);     }     work(1);     printf( %I64d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int K = 7;   const int N = 2005;   int a[K][N];   vector<int> s[N];   int d[N], n, k, p;   void read() {     cin >> n >> k;     for (int i = 0; i < int(k); ++i) {       for (int j = 0; j < int(n); ++j) {         cin >> p;         --p;         if (i == 0)           a[i][j] = p;         else           a[i][p] = j;       }     }   }   inline bool can_be_next(const vector<int>& a, const vector<int>& b) {     assert(a.size() == b.size());     for (int i = 0; i < int(a.size()); ++i) {       if (b[i] <= a[i]) return false;     }     return true;   }   void solve() {     for (int i = 0; i < int(n); ++i) {       s[i] = vector<int>(k - 1);       for (int j = 1; j < k; ++j) s[i][j - 1] = a[j][a[0][i]];     }     int res = 0;     for (int i = 0; i < int(n); ++i) {       d[i] = 1;       for (int j = 0; j < int(i); ++j)         if (can_be_next(s[j], s[i])) d[i] = max(d[j] + 1, d[i]);       res = max(res, d[i]);     }     cout << res << endl;   }   int main() {     read();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1000000007;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     ;     int n;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     long long ans = 0;     for (int i = 1; i <= n; i++) ans += abs(a[i - 1] - i);     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using point = pair<int, int>;   int D(point a, point b, point c) {     return a.first * (b.second - c.second) - a.second * (b.first - c.first) +            (b.first * c.second - b.second * c.first);   }   int main() {     int n, d;     cin >> n >> d;     vector<point> poligon;     poligon.push_back(make_pair(0, d));     poligon.push_back(make_pair(d, 0));     poligon.push_back(make_pair(n, n - d));     poligon.push_back(make_pair(n - d, n));     poligon.push_back(poligon[0]);     int k;     cin >> k;     vector<point> points(k);     for (auto &[x, y] : points) cin >> x >> y;     for (auto each : points) {       int s1 = 0, s2 = 0;       for (int i = 0; i < poligon.size() - 1; ++i) {         int test = D(each, poligon[i], poligon[i + 1]);         if (test > 0)           s1++;         else if (test < 0)           s2++;       }       if (s2 == 0 or s1 == 0)         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> prevSmall(vector<long long> &a, long long n) {     vector<long long> res(n, -1);     for (long long i = 1; i < n; ++i) {       long long j = i - 1;       while (j >= 0 && a[j] >= a[i]) j = res[j];       res[i] = j;     }     return res;   }   vector<long long> nextSmall(vector<long long> &a, long long n) {     vector<long long> res(n, n);     for (long long i = n - 2; i >= 0; --i) {       long long j = i + 1;       while (j < n && a[j] > a[i]) j = res[j];       res[i] = j;     }     return res;   }   vector<long long> prevLarge(vector<long long> &a, long long n) {     vector<long long> res(n, -1);     for (long long i = 1; i < n; ++i) {       long long j = i - 1;       while (j >= 0 && a[j] <= a[i]) j = res[j];       res[i] = j;     }     return res;   }   vector<long long> nextLarge(vector<long long> &a, long long n) {     vector<long long> res(n, n);     for (long long i = n - 2; i >= 0; --i) {       long long j = i + 1;       while (j < n && a[j] < a[i]) j = res[j];       res[i] = j;     }     return res;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     {       long long n;       cin >> n;       vector<long long> a(n);       for (long long i = 0; i < (n); ++i) cin >> a[i];       long long ans = 0;       auto pl = prevLarge(a, n), ps = prevSmall(a, n);       auto nl = nextLarge(a, n), ns = nextSmall(a, n);       for (long long i = 0; i < (n); ++i) {         long long lc = i - pl[i], rc = nl[i] - i;         ;         ans += lc * rc * a[i];         lc = i - ps[i], rc = ns[i] - i;         ;         ans -= lc * rc * a[i];       }       cout << ans;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int arr[int(1e7 + 100)];   void aum(int i) {     if (i % 2) {       arr[i / 2 + 1] += arr[i];       arr[i / 2] += arr[i];     } else       arr[i / 2] += 2 * arr[i];   }   int main() {     ios_base::sync_with_stdio(0);     set<int> conj;     memset(arr, 0, sizeof arr);     int n, m, l, ans = int(2 * 1e9 + 100), ptr = 0;     cin >> n >> m;     long long cnt = n, carry = 0, slices = m;     for (int i = 0; i < n; ++i) {       cin >> l;       carry += l;       ++arr[l];     }     if (carry < m) {       cout <<  -1 n ;       return 0;     }     for (int i = int(1e7 + 100); cnt < m; --i) {       if (arr[i]) {         aum(i);         cnt += arr[i];         arr[i] = 0;       }     }     long long aux = 0;     for (int i = int(1e7 + 100); i >= 1; --i) {       if (arr[i]) {         conj.insert(i);         aux += arr[i];         if (aux >= m) {           ans = i;           break;         }       }     }     for (int i = int(1e7 + 100); i >= 1; --i) {       if (arr[i]) {         int go = (i % 2 == 1 ? 1 : 0);         if (i / 2 + go <= *(conj.begin())) {           break;         } else {           aum(i);           if (i % 2) conj.insert(i / 2 + 1);           conj.insert(i / 2);           conj.erase(i);           aux += arr[i];           while (1) {             int val = (*conj.begin());             if (aux - arr[val] < m) break;             aux -= arr[val];             conj.erase(conj.begin());           }         }       }     }     cout << max(1, *(conj.begin())) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   int value, ans;   int bads[200010], maxDelay[200010], extraDelay[200010], a[200010], v[200010];   vector<int> T[200010], val[200010], pre[200010], post[200010];   void dfs(int x, int f) {     bads[x] = 0;     maxDelay[x] = 0;     extraDelay[x] = 0;     for (int i = 0; i < T[x].size(); ++i) {       int y = T[x][i];       if (y != f) {         dfs(y, x);         bads[x] += bads[y];         if (bads[y] == 0) {           maxDelay[x] += maxDelay[y];         } else {           extraDelay[x] = max(extraDelay[x], maxDelay[y]);         }       }     }     if (a[x] < value) {       bads[x]++;       maxDelay[x] = 0;     } else {       maxDelay[x] += extraDelay[x] + 1;     }   }   void dfs(int x, int f, int fBads, int fMaxDelay) {     if (a[x] >= value) {       int finalVal = maxDelay[x] - extraDelay[x];       finalVal += (fBads == 0 ? fMaxDelay + extraDelay[x]                               : max(fMaxDelay, extraDelay[x]));       ans = max(ans, finalVal);     }     for (int i = 0; i < T[x].size(); ++i) {       int y = T[x][i];       if (y == f) {         val[x][i] = (fBads > 0 ? fMaxDelay : 0);       } else {         val[x][i] = (bads[y] > 0 ? maxDelay[y] : 0);       }     }     int sz = T[x].size();     pre[x][0] = val[x][0];     post[x][sz - 1] = val[x][sz - 1];     for (int i = 1; i < sz; ++i) pre[x][i] = max(val[x][i], pre[x][i - 1]);     for (int i = sz - 2; i >= 0; --i) post[x][i] = max(val[x][i], post[x][i + 1]);     for (int i = 0; i < T[x].size(); ++i) {       int y = T[x][i];       if (y == f) continue;       if (a[x] < value) {         dfs(y, x, bads[x] - bads[y] + fBads, 0);       } else {         int newBads = bads[x] - bads[y] + fBads;         int newMaxDelay =             maxDelay[x] - extraDelay[x] - (bads[y] == 0 ? maxDelay[y] : 0) +             (fBads == 0 ? fMaxDelay : 0) +             max((i == 0 ? 0 : pre[x][i - 1]), (i == sz - 1 ? 0 : post[x][i + 1]));         dfs(y, x, newBads, newMaxDelay);       }     }   }   void reset() {}   int check(int tval) {     reset();     value = tval;     ans = 0;     dfs(1, 0);     dfs(1, 0, 0, 0);     return (ans >= k);   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> k;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       v[i] = a[i];     }     sort(v + 1, v + n + 1);     for (int i = 1; i < n; ++i) {       int a, b;       cin >> a >> b;       T[a].push_back(b);       T[b].push_back(a);     }     for (int i = 1; i <= n; ++i) {       val[i].resize(T[i].size(), 0);       pre[i].resize(T[i].size(), 0);       post[i].resize(T[i].size(), 0);     }     int lo = 0, hi = n + 1;     while (hi - lo > 1) {       int mid = (lo + hi) / 2;       if (check(v[mid]))         lo = mid;       else         hi = mid;     }     cout << v[lo];   }
#include <bits/stdc++.h>   using namespace std;   const double _PI = 3.141592653589793;   double n, m, k, ans = 0;   signed main() {     scanf( %lf %lf %lf , &n, &m, &k);     ans += ((n * n * sqrt(3)) / 4) * (sqrt(n * n * 2 / 3)) / 3;     ans += (m * m) / 3 * (sqrt(m * m / 2));     double S = (k * k * 5) / (4 * tan(_PI / 5)), r = S / (2.5 * k);     ans += S * sqrt(3 * k * k / 4 - r * r) / 3;     printf( %0.12lf , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long b, d, s, mx, sm = 0;     cin >> b >> d >> s;     mx = max(b, max(s, d));     if (mx != b) b++;     if (mx != d) d++;     if (mx != s) s++;     sm += mx - b;     sm += mx - d;     sm += mx - s;     cout << sm << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, h, x[2010], fall[2][2010];   double p, dp[2010][2010][2][2];   double solve(int l, int r, int fl, int fr) {     if (l > r) return 0;     if (dp[l][r][fl][fr] != -1) return dp[l][r][fl][fr];     dp[l][r][fl][fr] = 0;     double res = 0;     int nl = min(r, l + fall[0][l] - 1);     if (nl == r) {       if (!fr)         res += (1 - p) * (x[r] - x[l] + min(h, x[r + 1] - x[r] - h));       else         res += (1 - p) * (x[r] - x[l] + min(h, x[r + 1] - x[r]));     } else {       res += (1 - p) * solve(nl + 1, r, 1, fr);       res += (1 - p) * (x[nl] - x[l] + h);     }     if (fl)       res += p * min(h, x[l] - x[l - 1] - h);     else       res += p * min(h, x[l] - x[l - 1]);     res += p * solve(l + 1, r, 0, fr);     int nr = max(l, r - fall[1][r] + 1);     if (nr == l) {       if (fl)         res += p * (x[r] - x[l] + min(h, x[l] - x[l - 1] - h));       else         res += p * (x[r] - x[l] + min(h, x[l] - x[l - 1]));     } else {       res += p * solve(l, nr - 1, fl, 0);       res += p * (x[r] - x[nr] + h);     }     if (!fr)       res += (1 - p) * min(h, x[r + 1] - x[r] - h);     else       res += (1 - p) * min(h, x[r + 1] - x[r]);     res += (1 - p) * solve(l, r - 1, fl, 1);     res /= 2;     return dp[l][r][fl][fr] = res;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(NULL);     cin >> n >> h >> p;     for (int i = (1); i <= (n); i++) cin >> x[i];     x[++n] = 1000000000;     x[++n] = -1000000000;     sort(x + 1, x + n + 1);     fall[1][1] = 1;     for (int i = (2); i <= (n); i++) {       if (x[i] - x[i - 1] < h)         fall[1][i] = fall[1][i - 1] + 1;       else         fall[1][i] = 1;     }     fall[0][n] = 1;     for (int i = (n - 1); i >= (1); i--) {       if (x[i + 1] - x[i] < h)         fall[0][i] = fall[0][i + 1] + 1;       else         fall[0][i] = 1;     }     for (int i = (1); i <= (n); i++)       for (int j = (1); j <= (n); j++)         for (int k = (0); k <= (1); k++)           for (int l = (0); l <= (1); l++) dp[i][j][k][l] = -1;     cout << fixed << setprecision(9) << solve(2, n - 1, 0, 1);     return 0;   }
#include <bits/stdc++.h>   const int MAX_N = 300000;   const int MAX_M = 300000;   std::vector<int> types[1 + MAX_N];   std::vector<int> neighbours[1 + MAX_N];   int c;   int colours[1 + MAX_M];   bool used[1 + MAX_M];   void dfs(int u = 1, int father = 0) {     for (int type : types[u])       if (colours[type] != 0) used[colours[type]] = true;     int i = 0, j = 1;     while (i < (int)types[u].size()) {       if (used[j]) {         j++;       } else {         if (colours[types[u][i]] == 0) {           colours[types[u][i]] = j;           j++;         }         i++;       }     }     for (int type : types[u]) used[colours[type]] = false;     for (int v : neighbours[u])       if (v != father) {         dfs(v, u);       }   }   int main(void) {     int n, m;     scanf( %d%d , &n, &m);     int c = 1;     for (int i = 1; i <= n; i++) {       int s;       scanf( %d , &s);       c = std::max(c, s);       for (int j = 0; j < s; j++) {         int type;         scanf( %d , &type);         types[i].push_back(type);       }     }     for (int i = 0; i < n - 1; i++) {       int u, v;       scanf( %d%d , &u, &v);       neighbours[u].push_back(v);       neighbours[v].push_back(u);     }     dfs();     for (int i = 1; i <= m; i++)       if (colours[i] == 0) colours[i] = 1;     printf( %d n , c);     for (int i = 1; i <= m; i++) printf( %d  , colours[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = (long int)3e5 + 5;   long long power(long long x, long long y) {     long long res = 1;     while (y > 0) {       if (y & 1) res = (res * x) % 1000000007;       y = y >> 1;       x = (x * x) % 1000000007;     }     return res;   }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long a, b, prev;     cin >> a >> b;     long long n = (sqrt(1 + 8 * (a + b)) - 1) / 2;     std::vector<long long> d1, d2;     for (long long i = n; i > 0; i--) {       if (a - i >= 0) {         d1.push_back(i);         a -= i;       } else if (b - i >= 0) {         d2.push_back(i);         b -= i;       }     }     cout << d1.size() << endl;     for (auto i : d1) cout << i <<    ;     cout << endl;     cout << d2.size() << endl;     for (auto i : d2) cout << i <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int n = 10, dir[4][2] = {{1, 0}, {0, 1}, {1, -1}, {1, 1}};   int main() {     char b[n][n];     for (int i = 0; i < 10; i++)       for (int j = 0; j < n; j++) scanf(  %c , &b[i][j]);     bool found = false;     for (int i = 0; !found && i < n; i++)       for (int j = 0; !found && j < n; j++)         for (int k = 0; k < 4; k++) {           int p = 0, q = 0;           for (int l = 0; l < 5; l++) {             int x = i + dir[k][0] * l, y = j + dir[k][1] * l;             if (x < 0 || x >= n || y < 0 || y >= n) break;             ;             char c = b[x][y];             p += (c ==  X ), q += (c ==  . );           }           if (p == 4 && q == 1) found = true;         }     if (found)       printf( YES n );     else       printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_ROW = 2000 + 7;   const int MAX_COLUMN = 200 + 7;   const int BASE = 2807;   const int MOD = 1e7 + 7;   int n, m;   char TableA[MAX_ROW][MAX_COLUMN], TableB[MAX_COLUMN][MAX_ROW];   int HashA[MAX_ROW][MAX_COLUMN], HashB[MAX_COLUMN][MAX_ROW], Pow2807[MAX_ROW],       HashFinding[MOD];   int GetHash(const int& L, const int& R, const int H[]) {     return (1LL * H[R] - 1LL * H[L - 1] * Pow2807[R - L + 1] + 1LL * MOD * MOD) %            MOD;   }   int main() {     ios::sync_with_stdio(false);     cout.tie(0), cin.tie(0);     Pow2807[0] = 1;     for (int i = 1; i < MAX_ROW; ++i)       Pow2807[i] = 1LL * Pow2807[i - 1] * BASE % MOD;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) scanf( %s , TableA[i] + 1);     for (int j = 1; j <= m; ++j) scanf( %s , TableB[j] + 1);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j)         HashA[i][j] = (1LL * HashA[i][j - 1] * BASE + TableA[i][j]) % MOD;     for (int i = 1; i <= m; ++i)       for (int j = 1; j <= n; ++j)         HashB[i][j] = (1LL * HashB[i][j - 1] * BASE + TableB[i][j]) % MOD;     for (int j = 1; j <= (n - m + 1); ++j) {       int HashBase = 0;       for (int k = j; k <= (j + m - 1); ++k)         HashBase = (1LL * HashBase * Pow2807[m] + GetHash(1, m, HashA[k])) % MOD;       HashFinding[HashBase] = j;     }     for (int j = 1; j <= (n - m + 1); ++j) {       int HashTest = 0;       for (int i = 1; i <= m; ++i)         HashTest =             (1LL * HashTest * Pow2807[m] + GetHash(j, j + m - 1, HashB[i])) % MOD;       if (HashFinding[HashTest]) {         cout << HashFinding[HashTest] <<     << j <<   n ;         return 0;       }     }     cout <<  Error 404! n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long aa[15];     long long bb[15];     for (int i = 0; i < 14; i++) {       scanf( %lld , &aa[i]);       bb[i] = aa[i];     }     long long maxx = 0;     for (int i = 0; i < 14; i++) {       if (!aa[i]) continue;       long long sum = 0;       int c = aa[i] % 14;       for (int k = 1; k <= c; k++) {         if (i + k < 14)           bb[k + i]++;         else {           bb[(i + k) % 14]++;         }       }       for (int j = 0; j < 14; j++) {         if (j != i)           bb[j] += aa[i] / 14;         else           bb[j] = aa[i] / 14;         if (bb[j] % 2 == 0) sum += bb[j];       }       if (sum > maxx) maxx = sum;       for (int j = 0; j < 14; j++) bb[j] = aa[j];     }     cout << maxx << endl;     return 0;   }