malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   struct nade {     int pos, tag, sum, l, r;   } tree[600005 * 2];   int n;   void puup(int x) {     if (tree[x * 2].sum > tree[x * 2 + 1].sum) {       tree[x].pos = tree[x * 2].pos;       tree[x].sum = tree[x * 2].sum;     } else {       tree[x].pos = tree[x * 2 + 1].pos;       tree[x].sum = tree[x * 2 + 1].sum;     }   }   void pudo(int x) {     tree[x * 2].tag += tree[x].tag;     tree[x * 2].sum += tree[x].tag;     tree[x * 2 + 1].tag += tree[x].tag;     tree[x * 2 + 1].sum += tree[x].tag;     tree[x].tag = 0;   }   void build(int x, int l, int r) {     tree[x].l = l;     tree[x].r = r;     if (l == r) {       tree[x].pos = l;       return;     }     int mid = (l + r) / 2;     build(x * 2, l, mid);     build(x * 2 + 1, mid + 1, r);     tree[x].pos = tree[x * 2].pos;   }   void add(int l, int r, int val, int x) {     if (tree[x].l >= l && tree[x].r <= r) {       tree[x].sum += val;       tree[x].tag += val;       return;     }     pudo(x);     if (tree[x * 2].r >= l) add(l, r, val, x * 2);     if (tree[x * 2 + 1].l <= r) add(l, r, val, x * 2 + 1);     puup(x);   }   int l[200005], r[200005], v[200005];   struct node {     int x, u, d;     bool b;   } s[200005];   bool cmp(node a, node b) {     if (a.x != b.x) return a.x < b.x;     return a.b < b.b;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d%d%d , &l[i], &v[i], &r[i]);       s[i * 2].x = l[i];       s[i * 2].u = r[i];       s[i * 2].d = v[i];       s[i * 2].b = 0;       s[i * 2 + 1].x = v[i];       s[i * 2 + 1].u = r[i];       s[i * 2 + 1].d = v[i];       s[i * 2 + 1].b = 1;     }     build(1, 1, 3e5 + 1);     sort(s, s + 2 * n, cmp);     int ans = 0, ansp = 0, ansx = 0;     for (int i = 0; i < n * 2; i++) {       add(s[i].d, s[i].u, s[i].b ? -1 : 1, 1);       if (tree[1].sum > ans) {         ans = tree[1].sum;         ansp = tree[1].pos;         ansx = s[i].x;       }     }     printf( %d n , ans);     for (int i = 0; i < n; i++)       if (l[i] <= ansx && ansx <= v[i] && v[i] <= ansp && ansp <= r[i])         printf( %d  , i + 1);   }
#include <bits/stdc++.h>   using namespace std;   using lld = long long int;   int n, m;   int a[200009];   int b[200009];   int c[420009];   int main() {     int t = 1, tv = 0;     int i, j, k;     scanf( %d , &t);     while (t--) {       scanf( %d %d , &n, &m);       b[0] = 0;       bool nom = true;       for (i = 0; i < n; i++) {         scanf( %d , &a[i]);         if (a[i] >= m) {           b[i + 1] = b[i] + 1;         } else {           b[i + 1] = b[i] - 1;         }         if (a[i] == m) {           nom = false;         }       }       bool valid = false;       if (n == 1 && a[0] == m) {         valid = true;         goto HELL;       }       if (!nom && !valid) {         for (i = 200009 - n - 9; i <= 200009 + n + 9; i++) {           c[i] = 0;         }         for (i = 0; i < n; i++) {           if (a[i] >= m) {             if (c[b[i] + 200009] == 1 || c[b[i] + 200009 - 1] == 1) {               valid = true;               goto HELL;             }           }           c[b[i] + 200009] = 1;         }         for (i = 200009 - n - 9; i <= 200009 + n + 9; i++) {           c[i] = 0;         }         for (i = n - 1; i >= 0; i--) {           if (a[i] >= m) {             if (c[b[i + 1] + 200009] == 1 || c[b[i + 1] + 200009 + 1] == 1) {               valid = true;               goto HELL;             }           }           c[b[i + 1] + 200009] = 1;         }       }     HELL:       printf( %s n , valid ?  yes  :  no );     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100500;   const int infi = (1 << 30);   const long long infl = (1LL << 62);   const double eps = 1e-9;   const long long mod = 1000000007LL;   const double pi = acos(-1.0);   int n, k;   int a[maxn], c[maxn];   int main() {     cin >> n >> k;     for (int i = 1; i < n; i++) a[i] = 1;     a[0] = 0;     for (int i = 0; i < k; i++) {       for (int j = 0; j < n; j++) {         int second = int(upper_bound(a, a + n, j - a[j] - 1) - a);         if (second == n) second = n - 1;         c[j] = second;       }       for (int j = 0; j < n; j++) {         a[j] += a[c[j]];       }       for (int j = n - 1; j >= 0; --j) cout << n - c[j] <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> divs[1000009];   bool p[1000009];   vector<int> primes;   void pre() {     for (int i = 2; i <= (1000000); ++i) {       if (!p[i]) {         primes.push_back(i);         for (int j = i; j <= 1000000; j += i) divs[j].push_back(i), p[j] = true;       }     }   }   int L(int x, int p) {     int s = (int)(divs[p]).size();     int tot = (1 << s) - 1;     long long ans = 0;     for (int i = 1; i <= (tot); ++i) {       int cnt = 0;       int var = 1;       for (int j = 0; j < (s); ++j)         if (i & (1 << j)) cnt++, var *= divs[p][j];       if (cnt % 2)         ans += x / var;       else         ans -= x / var;     }     return x - ans;   }   int main() {     cin.sync_with_stdio(0);     cin.tie(0);     cin.exceptions(cin.failbit);     pre();     int q;     cin >> q;     for (int aa = 0; aa < (q); ++aa) {       int x, p, k;       cin >> x >> p >> k;       if (p == 1)         cout << k + x <<   n ;       else {         k += L(x, p);         int l = 1, r = 1e8;         while (l < r) {           int m = (l + r) >> 1;           if (L(m, p) >= k)             r = m;           else             l = m + 1;         }         cout << l <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   ll dx[] = {0, 0, 1, -1};   ll dy[] = {1, -1, 0, 0};   void solve() {     ll n;     cin >> n;     vector<ll> v(n);     for (ll i = 0; i < (n); ++i) cin >> v[i];     vector<pair<ll, ll>> aux(n);     ll i = n - 1;     stack<ll> s;     while (i >= 0) {       while (!s.empty() && s.top() < v[i]) s.pop();       if (s.empty())         aux[i].first = -1;       else         aux[i].first = s.top();       s.push(v[i]);       i--;     }     i = 0;     while (!s.empty()) s.pop();     while (i < n) {       while (!s.empty() && s.top() < v[i]) s.pop();       if (s.empty())         aux[i].second = -1;       else         aux[i].second = s.top();       s.push(v[i]), i++;     }     ll res = 0;     for (ll i = 0; i < (n); ++i) {       if (aux[i].first != -1) res = max(res, aux[i].first ^ v[i]);       if (aux[i].second != -1) res = max(res, aux[i].second ^ v[i]);     }     cout << res <<   n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     ll t = 1;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, i;   double p[2], poly[100005][2], minD = 1e18, maxD = 0, d, answer, lo, hi,                                 EPS = 1e-12, mid1, mid2, x, y, d1, d2;   int main() {     scanf( %d %lf %lf , &n, &p[0], &p[1]);     for (i = 0; i < n; i++) {       scanf( %lf %lf , &poly[i][0], &poly[i][1]);       d = (poly[i][0] - p[0]) * (poly[i][0] - p[0]) +           (poly[i][1] - p[1]) * (poly[i][1] - p[1]);       maxD = max(maxD, d);     }     for (i = 0; i < n; i++) {       lo = 0;       hi = 1;       while (hi - lo > EPS) {         mid1 = lo + (hi - lo) / 3;         mid2 = mid1 + (hi - lo) / 3;         x = poly[i][0] + (poly[(i + 1) % n][0] - poly[i][0]) * mid1;         y = poly[i][1] + (poly[(i + 1) % n][1] - poly[i][1]) * mid1;         d1 = (x - p[0]) * (x - p[0]) + (y - p[1]) * (y - p[1]);         x = poly[i][0] + (poly[(i + 1) % n][0] - poly[i][0]) * mid2;         y = poly[i][1] + (poly[(i + 1) % n][1] - poly[i][1]) * mid2;         d2 = (x - p[0]) * (x - p[0]) + (y - p[1]) * (y - p[1]);         if (d1 < d2)           hi = mid2;         else           lo = mid1;       }       d = d1;       minD = min(minD, d);     }     answer = acos(-1.0) * (maxD - minD);     printf( %.18lf n , answer);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1010;   void solve() {     int n, m;     cin >> n >> m;     vector<vector<long long>> a =         vector<vector<long long>>(n, vector<long long>(m, 0));     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j) cin >> a[i][j];     vector<long long> col(m, 0), row(n, 0);     for (int i = 0; i < m; ++i)       for (int j = 0; j < n; ++j) col[i] += a[j][i];     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j) row[i] += a[i][j];     vector<long long> x(m + 1), y(n + 1);     long long mn = LLONG_MAX;     long long ans = 0;     int ansx = 0;     for (int i = 0; i <= m; ++i) {       long long curx = i * 4;       for (int j = 0; j < m; ++j) {         long long curpos = j * 4 + 2;         long long dx = curx - curpos;         x[i] += dx * dx * col[j];       }       if (x[i] < mn) {         mn = x[i];         ansx = i;       }     }     ans += mn;     mn = LLONG_MAX;     int ansy = 0;     for (int i = 0; i <= n; ++i) {       int cury = i * 4;       for (int j = 0; j < n; ++j) {         long long curpos = j * 4 + 2;         long long dy = cury - curpos;         y[i] += dy * dy * row[j];       }       if (y[i] < mn) {         mn = y[i];         ansy = i;       }     }     ans += mn;     cout << ans <<   n ;     cout << ansy <<     << ansx <<   n ;   }   int main(void) {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int tc = 1;     while (tc--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1LL << 60;   const long long md = 1e9 + 7;   const long double eps = 1e-14;   const int mx = 3010;   int t[mx];   void upd(int p) {     for (++p; p < mx; p += p & -p) ++t[p];   }   int que(int p) {     int res = 0;     for (; p > 0; p -= p & -p) res += t[p];     return res;   }   char zey[mx][mx];   int le[mx][mx], ri[mx][mx];   int solve(vector<int> &a, vector<int> &b) {     int sz = a.size();     if (sz == 0) return 0;     int res = 0;     fill(t, t + sz + 5, 0);     vector<pair<int, int> > bb(sz);     for (int i = (0); i < int(sz); ++i) bb[i] = pair<int, int>(i - b[i] + 1, i);     sort(bb.begin(), bb.end());     int ix = 0;     for (int i = (0); i < int(sz); ++i) {       while (ix < sz && bb[ix].first <= i) upd(bb[ix++].second);       res += que(min(sz, i + a[i])) - i;     }     return res;   }   int main() {     memset(t, 0, sizeof(t));     int n, m;     cin >> n >> m;     for (int i = (0); i < int(n); ++i) scanf(  %s  , zey[i]);     for (int i = (0); i < int(n); ++i) {       le[i][0] = zey[i][0] ==  z ;       ri[i][m - 1] = zey[i][m - 1] ==  z ;     }     for (int i = (0); i < int(n); ++i)       for (int j = (1); j < int(m); ++j)         le[i][j] = zey[i][j] ==  z  ? 1 + le[i][j - 1] : 0;     for (int i = (0); i < int(n); ++i)       for (int j = (m - 1); j-- > int(0);)         ri[i][j] = zey[i][j] ==  z  ? 1 + ri[i][j + 1] : 0;     long long ans = 0;     for (int s = (0); s < int(m + n - 1); ++s) {       vector<int> a, b;       for (int d = (max(0, s - m + 1)); d < int(min(n, s + 1)); ++d) {         if (zey[d][s - d] ==  z ) {           a.push_back(le[d][s - d]);           b.push_back(ri[d][s - d]);         } else {           ans += solve(a, b);           a.clear();           b.clear();         }       }       ans += solve(a, b);     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005, M = 500005;   vector<int> gr[N], path, odd;   pair<int, int> ed[M];   bool us[M];   void GetEulerCircuit(int u) {     while (true) {       while (!gr[u].empty() && us[gr[u].back()]) {         gr[u].pop_back();       }       if (gr[u].empty()) {         break;       }       us[gr[u].back()] = true;       int v = u ^ ed[gr[u].back()].first ^ ed[gr[u].back()].second;       gr[u].pop_back();       GetEulerCircuit(v);     }     path.push_back(u);   }   int main() {     ios_base::sync_with_stdio(false);     cout.tie(0);     int n, m;     scanf( %d %d  , &n, &m);     for (int i = 0; i < m; i++) {       int u, v;       scanf( %d %d  , &u, &v);       ed[i] = make_pair(u, v);       gr[u].push_back(i);       gr[v].push_back(i);     }     for (int u = 1; u <= n; u++) {       if (gr[u].size() % 2) {         odd.push_back(u);       }     }     for (int i = 0; i < odd.size(); i += 2) {       int u = odd[i], v = odd[i + 1];       ed[m] = make_pair(u, v);       gr[u].push_back(m);       gr[v].push_back(m);       m++;     }     if (m % 2) {       ed[m] = make_pair(1, 1);       gr[1].push_back(m);       gr[1].push_back(m);       m++;     }     GetEulerCircuit(1);     for (int i = 0; i < m; i++) {       int u = path[i], v = path[i + 1];       if (i % 2) {         swap(u, v);       }       ed[i] = make_pair(u, v);     }     printf( %d n , m);     for (int i = 0; i < m; i++) {       int u = ed[i].first, v = ed[i].second;       printf( %d %d n , u, v);     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void read(T &x) {     x = 0;     T f = 1;     char c = getchar();     for (; !isdigit(c); c = getchar())       if (c ==  - ) f = -1;     for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);     x *= f;   }   int main() {     int n;     read(n);     for (int i = 1; i <= n; i++) {       int x;       read(x);       cout << x / 6 + (x % 6 == 0 ? 0 : 1) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6;   int q[maxn], fin, razbeg, jump, n;   pair<int, int> ans[maxn];   int sz = 0;   int main() {     cin >> n >> fin >> razbeg >> jump;     for (int i = 0; i < n; i++) cin >> q[i];     q[n] = 0;     q[n + 1] = fin;     n += 2;     sort(q, q + n);     int i = 0, now = 0;     while (i < n - 1)       if (i == n - 2) {         if (fin - now > 0) ans[sz] = make_pair(0, fin - now), sz++;         break;       } else if (q[i + 1] - 1 - now < razbeg) {         cout <<  IMPOSSIBLE ;         return 0;       } else {         if (q[i + 1] - 1 - now > 0)           ans[sz] = make_pair(0, q[i + 1] - 1 - now), sz++;         now = q[i + 1] - 1;         while (1) {           i++;           if (q[i] + 1 - now > jump) {             cout <<  IMPOSSIBLE ;             return 0;           }           if (i == n - 2) {             ans[sz] = make_pair(1, q[i] + 1 - now), sz++, now = q[i] + 1;             break;           } else if (q[i + 1] - 1 - q[i] - 1 >= razbeg) {             ans[sz] = make_pair(1, q[i] + 1 - now), sz++, now = q[i] + 1;             break;           }         }       }     for (int i = 0; i < sz; i++)       if (ans[i].first == 0)         cout <<  RUN   << ans[i].second <<   n ;       else         cout <<  JUMP   << ans[i].second <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long n, q, c[100005], v[100005], f[100005];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> q;     for (int i = 1; i <= n; i++) cin >> v[i];     for (int i = 1; i <= n; i++) cin >> c[i];     while (q--) {       long long a, b, ans = 0, mx = 0, smx = 0;       memset(f, -6, sizeof(f));       cin >> a >> b;       for (int i = 1; i <= n; i++) {         long long cur = max(v[i] * b, f[c[i]] + v[i] * a);         if (c[i] != mx)           cur = max(cur, f[mx] + v[i] * b);         else           cur = max(cur, f[smx] + v[i] * b);         if (cur > f[mx]) {           if (mx != c[i]) smx = mx;           mx = c[i];         } else if (cur > f[smx] && c[i] != mx)           smx = c[i];         f[c[i]] = max(f[c[i]], cur);         ans = max(ans, cur);       }       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int a[4010][4010];   int n, m;   int u[4010], v[4010], sz[4010];   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       scanf( %d%d , &u[i], &v[i]);       a[u[i]][v[i]] = a[v[i]][u[i]] = 1;       sz[u[i]]++;       sz[v[i]]++;     }     int ans = 1e9;     for (int i = 1; i <= m; i++) {       int x = u[i], y = v[i];       for (int j = i + 1; j <= m; j++) {         int c = u[j], d = v[j];         if (x == c && a[y][d] == 1) {           ans = min(ans, sz[x] + sz[y] + sz[d] - 6);         } else if (x == d && a[y][c] == 1) {           ans = min(ans, sz[x] + sz[c] + sz[y] - 6);         } else if (y == c && a[x][d] == 1) {           ans = min(ans, sz[y] + sz[x] + sz[d] - 6);         } else if (y == d && a[x][c] == 1) {           ans = min(ans, sz[y] + sz[x] + sz[c] - 6);         }       }     }     if (ans == 1e9)       cout << -1 << endl;     else       cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXK = 26;   const long long MOD = 1e9 + 7;   int last[MAXK], ord[MAXK];   long long sum, dp[MAXK];   void add(int c) {     sum = (sum - dp[c] + MOD) % MOD;     dp[c] = (dp[c] + sum + 1) % MOD;     sum = (sum + dp[c]) % MOD;   }   int main() {     ios_base::sync_with_stdio(false);     int N, K;     string S;     cin >> N >> K >> S;     memset((last), (-1), sizeof(last));     sum = 0;     for (int _n((int)S.size()), i(0); i < _n; i++) {       int c = S[i] -  a ;       last[c] = i;       add(c);     }     iota(ord, ord + K, 0);     sort(ord, ord + K, [](int a, int b) { return last[a] < last[b]; });     for (int _n(N), i(0); i < _n; i++) {       int c = ord[i % K];       add(c);     }     cout << (sum + 1) % MOD << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC optimize( Ofast )   const int INF = 1e9 + 7;   const long long INF2 = 1e15;   void solve(void) {}   int main(void) {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, l, r, ql, qr;     cin >> n >> l >> r >> ql >> qr;     vector<long long> v(n);     for (int i = 0; i < n; i++) cin >> v[i];     long long total = 0;     vector<long long> left(n + 1), right(n + 1);     for (long long i = 0; i < n; i++) {       total += v[i] * l;       left[i + 1] = total;     }     total = 0;     for (long long i = n - 1; i >= 0; i--) {       total += v[i] * r;       right[i] = total;     }     long long ans = INF, current;     for (long long i = 0; i <= n; i++) {       long long a = i, b = n - i, change;       current = INF;       change = min(a, b);       a -= change;       b -= change;       if (a) {         a--;         current = min(current, a * ql);       } else if (b) {         current = min(current, b * qr);       } else {         current = 0;       }       a = i, b = n - i;       change = min(a, b);       a -= change;       b -= change;       if (b) {         b--;         current = min(current, b * qr);       } else if (a) {         current = min(current, a * ql);       } else {         current = 0;       }       long long temp = 0;       a = i, b = n - i;       if (b) {         b--;         temp += qr * b;       }       if (a) {         a--;         temp += ql * a;       }       current = min(current, temp);       ans = min(ans, current + left[i] + right[i]);     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   int main() {     int n, k, q;     cin >> n >> k >> q;     vector<long long> vec(n + 1);     vector<long long> pq;     map<long long, long long> ar, ans, rev;     for (int i = 1; i <= n; i++) cin >> vec[i], ar[i] = vec[i], rev[vec[i]] = i;     while (q--) {       int a, b;       cin >> a >> b;       if (a == 1) {         pq.push_back(ar[b]);         ans[b] = 1;         if (pq.size() > k) {           sort(pq.begin(), pq.end());           long long dd = rev[pq[0]];           ans[dd] = 0;           pq.erase(pq.begin());         }       } else {         if (ans[b]) {           cout <<  YES n ;         } else           cout <<  NO n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int lowbit(int x) { return x & -x; }   inline int ABS(int x) { return x < 0 ? -x : x; }   inline long long ABS(long long x) { return x < 0 ? -x : x; }   inline void MAX(int &a, int b) {     if (b > a) a = b;   }   inline void MAX(long long &a, long long b) {     if (b > a) a = b;   }   inline void MIN(int &a, int b) {     if (b < a) a = b;   }   inline void MIN(long long &a, long long b) {     if (b < a) a = b;   }   inline void SUM(int &a, int b) { a = (a + b) % 1000000007; }   int fast(int x, int v) {     int ans = 1;     for (; v; v >>= 1, x = (long long)x * x % 1000000007)       if (v & 1) ans = (long long)ans * x % 1000000007;     return ans;   }   long long fast(long long x, long long v) {     long long ans = 1;     for (; v; v >>= 1, x = x * x % 1000000007)       if (v & 1) ans = ans * x % 1000000007;     return ans;   }   inline long long sqr(int x) { return x * x; }   int n, a[300005], l, r, sum;   long long pre[300005], ans;   map<int, int> s;   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       scanf( %d , a + i);       pre[i] = pre[i - 1] + (a[i] < 0 ? 0 : a[i]);       if (!s[a[i]]) s[a[i]] = i;     }     ans = -0x7f7f7f7f;     for (int i = n; i >= 1; --i)       if (s[a[i]] && s[a[i]] != i && pre[i - 1] - pre[s[a[i]]] + a[i] * 2 > ans) {         ans = pre[i - 1] - pre[s[a[i]]] + a[i] * 2;         l = s[a[i]];         r = i;       }     for (int i = l + 1; i <= r - 1; ++i)       if (a[i] < 0) ++sum;     printf( %I64d %d n , ans, sum + l - 1 + n - r);     for (int i = 1; i <= l - 1; ++i) printf( %d  , i);     for (int i = l + 1; i <= r - 1; ++i)       if (a[i] < 0) printf( %d  , i);     for (int i = r + 1; i <= n; ++i) printf( %d  , i);   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 9223372036854775807;   const long long MOD = 1000000007;   const long double PI = acos(-1);   inline long long power(long long a, long long b, long long z = MOD) {     long long res = 1;     a = (a % z);     while (b) {       if (b & 1) res = (res * a) % z;       a = (a * a) % z;       b = b >> 1;     }     return res;   }   inline long long inverse(long long a, long long z = MOD) {     return power(a, z - 2, z);   }   long long extend(long long a, long long b, long long &x, long long &y) {     if (b == 0) {       x = 1;       y = 0;       return a;     }     long long x1, y1;     long long g = extend(b, a % b, x1, y1);     x = y1;     y = x1 - (a / b) * y1;     return g;   }   inline long long mat_power(long long a, long long b, long long c, long long d,                              long long n, long long z = MOD) {     long long a0 = 1, b0 = 0, c0 = 0, d0 = 1;     while (n) {       if (n & 1) {         long long a1 = a0, b1 = b0, c1 = c0, d1 = d0;         a0 = (a1 * a + b1 * c) % z;         b0 = (a1 * b + b1 * d) % z;         c0 = (c1 * a + d1 * c) % z;         d0 = (c1 * b + d1 * d) % z;       }       long long a1 = a, b1 = b, c1 = c, d1 = d;       a = (a1 * a1 + b1 * c1) % z;       b = (a1 * b1 + b1 * d1) % z;       c = (c1 * a1 + d1 * c1) % z;       d = (c1 * b1 + d1 * d1) % z;       n = n >> 1;     }     return c0;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, m;     cin >> n >> m;     int aray[n][m], arr[n][m];     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) cin >> aray[i][j];     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) cin >> arr[i][j];     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (aray[i][j] > arr[i][j]) swap(aray[i][j], arr[i][j]);       }     }     for (int i = 0; i < n; i++) {       for (int j = 1; j < m; j++) {         if (aray[i][j] <= aray[i][j - 1] || arr[i][j] <= arr[i][j - 1]) {           cout <<  Impossible n ;           return 0;         }       }     }     for (int j = 0; j < m; j++) {       for (int i = 1; i < n; i++) {         if (aray[i][j] <= aray[i - 1][j] || arr[i][j] <= arr[i - 1][j]) {           cout <<  Impossible n ;           return 0;         }       }     }     cout <<  Possible n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     map<char, int> mp;     mp[ q ] = 9;     mp[ k ] = 0;     mp[ r ] = 5;     mp[ b ] = 3;     mp[ n ] = 3;     mp[ p ] = 1;     int white = 0, black = 0;     for (int i = 0; i < 8; i++) {       for (int j = 0; j < 8; j++) {         char x;         cin >> x;         if (x >=  A  && x <=  Z ) white += mp[x + 32];         if (x >=  a  && x <=  z ) black += mp[x];       }     }     if (white > black)       cout <<  White  << endl;     else if (white == black)       cout <<  Draw  << endl;     else       cout <<  Black  << endl;     return 0;   }