malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     std::ios_base::sync_with_stdio(false);     std::cin.tie(nullptr);     map<char, char> mp = {{ A ,  A }, { T ,  T }, { b ,  d }, { d ,  b },                           { H ,  H }, { I ,  I }, { M ,  M }, { O ,  O },                           { o ,  o }, { p ,  q }, { q ,  p }, { V ,  V },                           { v ,  v }, { W ,  W }, { w ,  w }, { X ,  X },                           { x ,  x }, { Y ,  Y }, { U ,  U }};     string s;     cin >> s;     int n = s.size();     for (int i = 0; i <= n / 2 - (n % 2 == 0); ++i) {       if (!mp.count(s[i]) or mp[s[i]] != s[n - i - 1]) {         cout <<  NIE  <<   n ;         return 0;       }     }     cout <<  TAK  <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int dx[] = {0, 0, 1, -1, -1, 1, -1, 1};   int dy[] = {-1, 1, 0, 0, 1, 1, -1, -1};   int dz[] = {0, 0, 1, -1, -1, 1, -1, 1};   int kx[] = {2, 2, -2, -2, 1, -1, 1, -1};   int ky[] = {1, -1, 1, -1, 2, 2, -2, -2};   double _distance(double x1, double y1, double x2, double y2) {     double x1x2 = x1 - x2;     double y1y2 = y1 - y2;     return sqrt((x1x2 * x1x2) + (y1y2 * y1y2));   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n;     cin >> n;     long long c[n];     long long sum = 0;     for (int i = 0; i < n; i++) cin >> c[i];     sum += c[n - 1];     for (int i = n - 2; i >= 0; i--) {       if (c[i] < c[i + 1])         sum += c[i];       else {         c[i] = max(0LL, c[i + 1] - 1);         sum += c[i];       }     }     cout << sum << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     int q;     cin >> q;     while (q--) {       int n;       cin >> n;       int a = 100000, b = 100000, c = -100000, d = -100000;       vector<bool> ok(4, false);       for (int i = 0; i < n; i++) {         int x, y;         cin >> x >> y;         int f[4];         for (int j = 0; j < 4; j++) cin >> f[j];         if (f[0] == 0) d = max(d, x), ok[0] = true;         if (f[1] == 0) a = min(a, y), ok[1] = true;         if (f[2] == 0) b = min(b, x), ok[2] = true;         if (f[3] == 0) c = max(c, y), ok[3] = true;       }       if (a < c || d > b)         cout << 0;       else         cout << 1 <<     << (d + b) / 2 <<     << (a + c) / 2;       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, r, R, k, l, A[100005];   string cad, aux;   char x, y;   map<int, int> M;   struct Res {     int X, Y, Z;     Res() {}     Res(int a, int b, int c) {       int F[5];       F[0] = a;       F[1] = b;       F[2] = c;       sort(F, F + 3);       X = F[2];       Y = F[1];       Z = F[0];     }   };   vector<Res> Sol;   struct node {     int elem, prio;     node() {}     node(int e, int p) {       elem = e;       prio = p;     }     bool operator<(const node &b) const {       if (prio != b.prio) return prio < b.prio;       return elem < b.elem;     }   };   priority_queue<node> q;   void calc() {     node n1, n2, n3;     int r;     Sol.clear();     while (1) {       if (q.empty()) return;       n1 = q.top();       q.pop();       if (q.empty()) return;       n2 = q.top();       q.pop();       if (q.empty()) return;       n3 = q.top();       q.pop();       r = 1;       for (int i = 0; i < r; i++) {         Sol.push_back(Res(n1.elem, n2.elem, n3.elem));       }       if (r != n1.prio) q.push(node(n1.elem, n1.prio - r));       if (r != n2.prio) q.push(node(n2.elem, n2.prio - r));       if (r != n3.prio) q.push(node(n3.elem, n3.prio - r));     }   }   int main() {     scanf( %d , &n);     M.clear();     for (int i = 0; i < n; i++) {       scanf( %d , &A[i]);     }     sort(A, A + n);     int c = 1;     for (int i = 1; i < n; i++)       if (A[i] != A[i - 1]) {         q.push(node(A[i - 1], c));         c = 1;       } else         c++;     q.push(node(A[n - 1], c));     calc();     cout << Sol.size() << endl;     for (int i = 0; i < Sol.size(); i++)       cout << Sol[i].X <<     << Sol[i].Y <<     << Sol[i].Z << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = int(2e6) + 12, mod = int(1e9) + 7;   int n, z[N];   char second[N];   int Z(string x) {     int m = int(x.size());     string t = x;     reverse((t).begin(), (t).end());     string second = x +  #  + t;     int res = 0;     for (int i = 1, l = 0, r = 0; i < second.size(); i++) {       z[i] = 0;       if (i <= r) z[i] = min(r - i + 1, z[i - l]);       while (i + z[i] < second.size() && second[z[i]] == second[i + z[i]]) z[i]++;       if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;       if (i > m && i + z[i] == int(second.size())) {         res = max(res, z[i]);       }     }     return res;   }   void solve() {     scanf(  n%s , second + 1);     n = strlen(second + 1);     int l = 1, r = n;     while (l <= r) {       if (second[l] == second[r]) {         l++;         r--;       } else         break;     }     string a =   ;     for (int i = l; i <= r; i++) {       a += second[i];     }     string b = a;     string ans =   ;     reverse((b).begin(), (b).end());     int z1 = Z(a);     int z2 = Z(b);     for (int i = 1; i < l; i++) ans += second[i];     if (z1 > z2) {       for (int i = 0; i < z1; i++) ans += a[i];     } else {       for (int i = 0; i < z2; i++) ans += b[i];     }     for (int i = max(r + 1, l); i <= n; i++) ans += second[i];     for (int i = 0; i < ans.size(); i++) {       putchar(ans[i]);     }     puts(  );   }   int main() {     int T = 1;     scanf( %d , &T);     while (T--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   constexpr int N = 5e5 + 5;   vector<int> elm[N];   struct SegTree {     struct Dat {       int l, r;       Dat *lc, *rc;       long long lmx, rmx, mx, sum;       int len() { return r - l + 1; }       void fset(long long kval) { lmx = rmx = mx = sum = kval; }       void pushup() {         lmx = max(lc->lmx, lc->sum + rc->lmx);         rmx = max(rc->rmx, rc->sum + lc->rmx);         mx = max({lc->mx, rc->mx, lc->rmx + rc->lmx});         sum = lc->sum + rc->sum;       }       void pushdown() {}     } dat[N << 2];     int siz = 0;     void init(int n) {       function<Dat *(int, int)> build = [&](int l, int r) {         Dat &nw = dat[siz++];         nw = {l, r};         if (l == r) {         } else {           int mid = (l + r) >> 1;           nw.lc = build(l, mid), nw.rc = build(mid + 1, r);           nw.pushup();         }         return &nw;       };       build(1, n);     }     template <typename Fn>     void travsal(int l, int r, Fn f) {       function<void(Dat &)> trav = [&](Dat &p) {         if (r < p.l || l > p.r) return;         if (p.l >= l && p.r <= r) {           return f(p);         } else {           p.pushdown();           int mid = (l + r) >> 1;           trav(*p.lc);           trav(*p.rc);           p.pushup();         }       };       trav(dat[0]);     }     void update(int x, long long val) {       travsal(x, x, [&](Dat &e) { e.fset(val); });     }     int query() { return dat[0].mx; }   } seg;   int a[N];   int main() {     ios::sync_with_stdio(false);     int n, c;     cin >> n >> c;     seg.init(n);     int base = 0;     for (int i = 1; i < n + 1; i++) {       cin >> a[i];       if (a[i] == c)         seg.update(i, -1), base++;       else         elm[a[i]].push_back(i);     }     int ans = base;     for (int i = 1; i < N; i++) {       if (elm[i].empty()) continue;       for (int pos : elm[i]) seg.update(pos, 1);       ans = max(ans, base + seg.query());       for (int pos : elm[i]) seg.update(pos, 0);     }     cout << ans << endl;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   using namespace std;   long long n, m;   long long a[((long long)(2e6 + 600))];   int main() {     cin >> n >> m;     long long l = 0;     long long pas = 0;     for (int i = 0; i < n; i++) {       cin >> a[i];       if (i && a[i] == a[i - 1]) l = i;       pas = max(pas, i - l + 1);     }     cout << pas;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   inline int read() {     int x = 0;     char ch = getchar();     while (ch <  0  || ch >  9 ) ch = getchar();     while (ch <=  9  && ch >=  0 ) x = x * 10 + ch -  0 , ch = getchar();     return x;   }   int A[maxn], B[maxn], N, MOD, fir, d, len;   int ksm(int x, int y) {     int res = 1;     for (; y; y >>= 1, x = (long long)x * x % MOD)       if (y & 1) res = (long long)res * x % MOD;     return res;   }   void Solve(int *P, int Len) {     int kd = P[1] - P[0], cnt = 0;     map<int, bool> vis;     for (int i = 0; i < N; ++i) vis[P[i]] = true;     for (int i = 0; i < N; ++i)       if (!vis.count((P[i] + kd) % MOD)) ++cnt;     d = (long long)kd * ksm(cnt, MOD - 2) % MOD;     fir = -1;     len = (MOD - d) % MOD;     for (int i = 0; i < N; ++i)       if (!vis.count((P[i] + d) % MOD))         if (~fir) {           fir = -1;           break;         } else           fir = P[i];   }   int main() {     MOD = read();     N = read();     for (int i = 0; i < N; ++i) A[i] = read();     if (N == 1 || N == MOD)       printf( %d 1 n , A[0]);     else {       sort(A, A + N);       if (2 * N < MOD)         Solve(A, N);       else {         map<int, bool> vis;         for (int i = 0; i < N; ++i) vis[A[i]] = true;         N = 0;         for (int i = 0; i < MOD; ++i)           if (!vis.count(i)) B[N++] = i;         Solve(B, N);         if (~fir) (fir += (long long)len * N % MOD) %= MOD;       }       if (~fir)         printf( %d %d n , fir, len);       else         puts( -1 );     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     int t, k;     long long int ans;     cin >> t;     while (t--) {       cin >> k;       ans = (k / 18) * 30;       k = k % 18;       if (k == 0) {         ans--;       }       while (k) {         ans++;         if (ans % 3 != 0 && ans % 10 != 3) {           k--;         }       }       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int64_t binexp(int64_t base, int64_t exponent) {     int64_t res = 1;     base = (base + 1000000007) % 1000000007;     while (exponent) {       if (exponent & 1) {         res = (res * base) % 1000000007;       }       exponent = exponent >> 1;       base = (base * base) % 1000000007;     }     return res;   }   void solve() {     double n;     cin >> n;     n = 2.0 * n;     double param, result;     param = (3.14159265 / n);     result = sin(param);     double ans1 = (1.0 / (result));     double res = cos(param / 2.0);     double ans2 = (1.0 * res);     double ans = (ans1 * ans2);     printf( %.10f n , ans);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int T = 1;     cin >> T;     while (T--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:102400000,102400000 )   using namespace std;   const int N = 200100;   int a[N], t[N];   multiset<int> st1, st2;   multiset<int>::iterator it;   int sum = 0, nowt = 0, res = 0;   int n, m, k;   void ins(int x) {     sum += a[x];     if (st1.size() < m) {       st1.insert(t[x]);       nowt += (t[x] + 1) / 2;     } else {       it = st1.begin();       if ((*it) < t[x]) {         nowt += (t[x] + 1) / 2;         nowt -= ((*it) + 1) / 2;         nowt += (*it);         st1.insert(t[x]);         st2.insert((*it));         st1.erase(it);       } else {         nowt += t[x];         st2.insert(t[x]);       }     }   }   void del(int x) {     sum -= a[x];     if (st2.size() && st2.find(t[x]) != st2.end()) {       nowt -= t[x];       st2.erase(st2.find(t[x]));     } else {       nowt -= (t[x] + 1) / 2;       assert(st1.find(t[x]) != st1.end());       st1.erase(st1.find(t[x]));       if (st2.size()) {         it = st2.end();         it--;         nowt -= (*it);         nowt += ((*it) + 1) / 2;         st1.insert((*it));         st2.erase(it);       }     }   }   int main() {     cin >> n >> m >> k;     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     for (int i = 1; i <= n; i++) {       scanf( %d , &t[i]);     }     for (int i = 1, j = 1; i <= n; i++) {       while (j <= n) {         ins(j);         if (nowt > k) {           del(j);           break;         }         j++;       }       if (nowt <= k) res = max(res, sum);       if (i != j)         del(i);       else         j++;     }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int q, n, x;     char a, b;     vector<char> v;     cin >> q;     for (int i = 0; i < q; i++) {       x = 0;       cin >> n;       for (int j = 0; j < n; j++) {         cin >> a;         v.push_back(a);       }       if (v[0] < v[n - 1]) {         cout <<  YES  << endl;         cout <<  2  << endl;         for (int j = 0; j < n; j++) {           if (j == 0)             cout << v[j] <<    ;           else             cout << v[j];         }         cout << endl;       } else {         for (int j = 1; j < n - 1; j++) {           if (v[j] !=  0 ) {             x = 1;             break;           }         }         if (x == 0)           cout <<  NO  << endl;         else {           cout <<  YES  << endl;           cout <<  2  << endl;           for (int j = 0; j < n; j++) {             if (j == 0)               cout << v[j] <<    ;             else               cout << v[j];           }           cout << endl;         }       }       v.clear();     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = (int)1e5 + 100;   const int mod = (int)1e9 + 7;   const int maxlog = (int)20;   const int P = mod;   int n, m, q, id[maxn], sq, res, cnt[maxn][500];   long long toadd[505], a[maxn];   long long ans[505];   vector<int> g[maxn];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cin >> n >> m >> q;     sq = 320;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= m; i++) {       int k;       cin >> k;       if (k >= sq) {         id[i] = ++res;       }       for (; k--;) {         int x;         cin >> x;         g[i].push_back(x);       }     }     for (int i = 1; i <= m; i++) {       if (id[i]) {         static bool used[maxn + 5];         memset(used, 0, sizeof used);         for (int x : g[i]) ans[id[i]] += a[x], used[x]++;         for (int j = 1; j <= m; j++) {           for (int x : g[j]) {             cnt[j][id[i]] += used[x];           }         }       }     }     for (; q--;) {       char s;       cin >> s;       if (s ==  ? ) {         int k;         cin >> k;         if (id[k]) {           cout << ans[id[k]] << endl;         } else {           long long Res = 0;           for (int x : g[k]) Res += a[x];           for (int i = 1; i <= res; i++) Res += toadd[i] * cnt[k][i];           cout << Res << endl;         }       } else {         int k, val;         cin >> k >> val;         if (!id[k])           for (int x : g[k]) a[x] += val;         else           toadd[id[k]] += val;         for (int i = 1; i <= res; i++) {           ans[i] += val * 1ll * cnt[k][i];         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int rlen = 1 << 18 | 1;   inline char gc() {     static char buf[rlen], *ib, *ob;     (ib == ob) && (ob = (ib = buf) + fread(buf, 1, rlen, stdin));     return ib == ob ? -1 : *ib++;   }   inline int read() {     int ans = 0;     char ch = gc();     while (!isdigit(ch)) ch = gc();     while (isdigit(ch)) ans = ((ans << 2) + ans << 1) + (ch ^ 48), ch = gc();     return ans;   }   const int N = 1e5 + 5;   vector<pair<int, int> > e[N];   int n, m, dis[N];   bool vis[N];   namespace xxj {   int a[31];   inline void insert(int x) {     if (!x) return;     for (register int i = 30; ~i; --i)       if ((x >> i) & 1)         if (!a[i]) {           a[i] = x;           break;         } else           x ^= a[i];   }   inline int query(int x) {     for (register int i = 30; ~i; --i) x = min(x, x ^ a[i]);     return x;   }   }  // namespace xxj   void dfs(int p, int fa) {     vis[p] = 1;     for (register int i = 0, v; i < e[p].size(); ++i) {       if ((v = e[p][i].first) == fa) continue;       if (!vis[v])         dis[v] = dis[p] ^ e[p][i].second, dfs(v, p);       else         xxj::insert(dis[v] ^ dis[p] ^ e[p][i].second);     }   }   int main() {     n = read(), m = read();     for (register int i = 1, u, v, w; i <= m; ++i)       u = read(), v = read(), w = read(), e[u].push_back(pair<int, int>(v, w)),       e[v].push_back(pair<int, int>(u, w));     dfs(1, 0), cout << xxj::query(dis[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct segtree {     using T = long long;     int n;     vector<T> node;     T e() { return (long long)1e18; }     T op(T x, T y) { return min(x, y); }     segtree() : segtree(0) {}     segtree(int _n) {       if (_n <= 1) {         n = _n;       } else {         n = 1 << (32 - __builtin_clz(_n - 1));       }       node.resize(2 * n, e());     }     segtree(vector<T> v) {       if ((int)v.size() <= 1) {         n = (int)v.size();       } else {         n = 1 << (32 - __builtin_clz((int)v.size() - 1));       }       node.resize(2 * n, e());       for (int i = 0; i < (int)v.size(); i++) {         node[i + n] = v[i];       }       for (int i = n - 1; i > 0; i--) {         node[i] = op(node[2 * i], node[2 * i + 1]);       }     }     void update(int k, T v) {       k += n;       node[k] = v;       while (k > 1) {         k /= 2;         node[k] = op(node[2 * k], node[2 * k + 1]);       }     }     T get(int x, int y, int k, int l, int r) {       if (r <= x || y <= l) {         return e();       }       if (x <= l && r <= y) {         return node[k];       }       T vl = get(x, y, 2 * k, l, (l + r) / 2);       T vr = get(x, y, 2 * k + 1, (l + r) / 2, r);       return op(vl, vr);     }     T get(int x, int y) { return get(x, y, 1, 0, n); }     T get(int x) { return node[x + n]; }   };   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int tt;     cin >> tt;     while (tt--) {       int n;       cin >> n;       int k;       cin >> k;       vector<int> a, b;       for (int i = 0; i < n; i++) {         int x;         cin >> x;         if (x > 0) {           a.emplace_back(x);         } else if (x < 0) {           b.emplace_back(-x);         }       }       sort(a.begin(), a.end());       sort(b.begin(), b.end());       long long ans = 0;       for (int loop = 0; loop < 2; loop++) {         segtree seg((int)a.size() + 1);         seg.update(0, 0);         for (int i = 0; i < (int)a.size(); i++) {           long long t = a[i] * 2 + seg.get(max(0, i - k + 1), i + 1);           seg.update(i + 1, t);         }         ans += seg.get((int)a.size());         swap(a, b);       }       if (a.empty()) {         a.emplace_back(0);       }       if (b.empty()) {         b.emplace_back(0);       }       ans -= max(a.back(), b.back());       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int d[101][51][201][2] = {0};   bool used[101][51][201][2] = {false};   int n;   int sz;   string commands;   int rec(int cur, int left, int pos, int dir) {     if (cur == sz) {       d[cur][left][100 + pos][(dir + 1) % 2] = abs(pos);       used[cur][left][100 + pos][(dir + 1) % 2] = true;       return pos;     }     if (used[cur][left][100 + pos][(dir + 1) % 2]) {       return d[cur][left][100 + pos][(dir + 1) % 2];     }     used[cur][left][100 + pos][(dir + 1) % 2] = true;     int res = 0;     for (int i = 0; i <= left; ++i) {       if (cur == sz - 1 && left != 0) {         i = left;       }       int next_pos = pos;       int next_dir = dir;       if (i % 2 == 0) {         if (commands[cur] ==  T ) {           next_dir = -dir;         } else {           next_pos = pos + dir;         }       } else {         if (commands[cur] ==  T ) {           next_pos = pos + dir;         } else {           next_dir = -dir;         }       }       res = max(res, abs(rec(cur + 1, left - i, next_pos, next_dir)));     }     d[cur][left][100 + pos][(dir + 1) % 2] = res;     return res;   }   int main() {     int res;     cin >> commands;     cin >> n;     sz = commands.size();     res = rec(0, n, 0, 1);     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 501;   int main() {     int N, M;     cin >> N >> M;     int z[MAX][MAX] = {0};     for (int i = 0; i < N; ++i)       for (int j = 0; j < M; ++j) {         cin >> z[i][j];       }     int k = min(M, N);     int ans = -1000000000;     int p[MAX][MAX][2] = {0};     int gor[MAX][MAX] = {0};     int ver[MAX][MAX] = {0};     for (int j = 0; j < M; ++j) {       ver[0][j] = z[0][j];       if (j == 0)         gor[0][j] = z[0][j];       else         gor[0][j] = gor[0][j - 1] + z[0][j];     }     for (int i = 1; i < N; ++i) {       gor[i][0] = z[i][0];       ver[i][0] = ver[i - 1][0] + z[i][0];       for (int j = 1; j < M; ++j) {         ver[i][j] = ver[i - 1][j] + z[i][j];         gor[i][j] = gor[i][j - 1] + z[i][j];       }     }     for (int i = 0; i <= N - 3; ++i) {       for (int j = 0; j <= M - 3; ++j) {         p[i][j][1] = z[i][j] + z[i][j + 1] + z[i][j + 2] + z[i + 1][j + 2] +                      z[i + 2][j + 2] + z[i + 2][j + 1] + z[i + 2][j];         if (ans < p[i][j][1]) ans = p[i][j][1];       }     }     for (int i = 0; i <= N - 5; ++i) {       for (int j = 0; j <= M - 5; ++j) {         p[i][j][0] = gor[i][j + 4] - gor[i][j] + z[i][j] + ver[i + 4][j + 4] -                      ver[i][j + 4] + gor[i + 4][j + 3] - gor[i + 4][j] +                      ver[i + 4][j] - ver[i + 1][j] + z[i + 2][j + 1] +                      z[i + 2][j + 2];         if (ans < p[i][j][0]) ans = p[i][j][0];       }     }     for (int r = 7; r <= k; r += 2) {       for (int i = 0; i <= N - r; ++i)         for (int j = 0; j <= M - r; ++j) {           int l = ((r - 1) / 2) % 2;           p[i][j][l] = p[i + 2][j + 2][l] + gor[i][j + r - 1] - gor[i][j] +                        z[i][j] + ver[i + r - 1][j + r - 1] - ver[i][j + r - 1] +                        gor[i + r - 1][j + r - 2] - gor[i + r - 1][j] +                        ver[i + r - 1][j] - ver[i + 1][j] + z[i + 2][j + 1];           if (ans < p[i][j][l]) ans = p[i][j][l];         }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long LLINF = 1e18;   const int INF = 1e9;   const int MOD = 20101009;   const int HMOD = 999959;   const int VMOD = 5000000;   const int MAXN = 2e3 + 10;   const int MAXM = 5e5 + 10;   const int INV = 10050505;   const long long LLINV = 1e18;   const double eps = 1e-3;   int dirx[4] = {-1, 1, 0, 0}, diry[4] = {0, 0, -1, 1};   int n, m;   int r, c;   int limx, limy;   char G[MAXN][MAXN];   int dl[MAXN][MAXN];   int dr[MAXN][MAXN];   void bfs() {     memset(dl, 0x3f3f3f3f, sizeof(dl));     memset(dr, 0x3f3f3f3f, sizeof(dr));     deque<pair<int, int> > que;     que.push_front(make_pair(r, c));     dl[r][c] = dr[r][c] = 0;     while (!que.empty()) {       int x = que.front().first;       int y = que.front().second;       que.pop_front();       for (int i = 0; i < 4; ++i) {         int tx = x + dirx[i];         int ty = y + diry[i];         if (tx < 1 || tx > n || ty < 1 || ty > m) continue;         if (G[tx][ty] ==  * ) continue;         int cl = dl[x][y] + (diry[i] == -1);         int cr = dr[x][y] + (diry[i] == 1);         if (cl < dl[tx][ty] || cr < dr[tx][ty]) {           dl[tx][ty] = cl;           dr[tx][ty] = cr;           if (dirx[i] == 0)             que.push_back(make_pair(tx, ty));           else             que.push_front(make_pair(tx, ty));         }       }     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     scanf( %d%d , &n, &m);     scanf( %d%d , &r, &c);     scanf( %d%d , &limx, &limy);     for (int i = 1; i <= n; ++i) scanf( %s , G[i] + 1);     bfs();     int ans = 0;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         if (G[i][j] ==  * ) continue;         if (dl[i][j] <= limx && dr[i][j] <= limy) ++ans;       }     }     printf( %d n , ans);     return 0;   }