malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using LL = long long;   using pii = pair<int, int>;   const int mod = 998244353;   const int inf = 0x3f3f3f3f;   const int N = 2e5 + 10;   int n, m, a[N];   LL sum[N], fac[N], rev[N];   LL pow_mod(LL x, int p) {     LL s = 1;     while (p) {       if (p & 1) s = s * x % mod;       x = x * x % mod;       p >>= 1;     }     return s;   }   LL C(int n, int m) { return fac[n] * rev[m] % mod * rev[n - m] % mod; }   LL solve(int A, int d) {     int p = lower_bound(a, a + n, d) - a;     int q = n - p;     if (q < A) return 0;     LL ret1, ret2;     if (q > A) {       ret1 = C(n, q) * C(q - 1, A) % mod * (q - A) % mod *              ((sum[n] - sum[p] + mod) % mod) % mod * fac[p] % mod * fac[A] % mod *              fac[q - 1 - A] % mod;     } else {       ret1 = 0;     }     if (p) {       ret2 = C(n, q + 1) * C(q, A) % mod * (q + 1 - A) % mod * sum[p] % mod *              fac[p - 1] % mod * fac[A] % mod * fac[q - A] % mod;     } else {       ret2 = 0;     }     LL ret = (ret1 + ret2) % mod;     return ret * rev[n] % mod;   }   int main() {     int x, y;     scanf( %d %d , &n, &m);     for (int i = (0); i < (n); ++i) scanf( %d , a + i);     sort(a, a + n);     fac[0] = 1;     for (int i = (1); i < (n + 1); ++i) {       fac[i] = fac[i - 1] * i % mod;     }     rev[n] = pow_mod(fac[n], mod - 2);     for (int i = (n); i > (0); --i) rev[i - 1] = rev[i] * i % mod;     sum[0] = 0;     for (int i = (0); i < (n); ++i) {       sum[i + 1] = (sum[i] + a[i]) % mod;     }     while (m--) {       scanf( %d %d , &x, &y);       printf( %lld n , solve(x, y));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int input;     vector<int> ret;     cin >> input;     for (int i = 1; i < input; i += 2) {       ret.push_back(i + 1);       ret.push_back(i);     }     if (ret.empty() || ret.size() != input) ret = {-1};     for (auto &d : ret) {       cout << d <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   double ans[1024 * 1024], l, r, x[20], y[20], a[20], cosA[20], sinA[20], maxi;   int main() {     scanf( %d %lf %lf , &n, &l, &r);     maxi = l;     for (int i = 0; i < n; i++) {       scanf( %lf %lf %lf , &x[i], &y[i], &a[i]);       cosA[i] = cos(a[i] * 3.14159265359 / 180);       sinA[i] = sin(a[i] * 3.14159265359 / 180);     }     int maxiMask = 1 << n;     for (int i = 0; i < maxiMask; i++) ans[i] = l;     for (int i = 0; i < maxiMask; i++) {       double curAns = ans[i];       for (int j = 0; j < n; j++) {         int newPotPos = 1 << j;         if (!(newPotPos & i)) {           double vx = curAns - x[j];           double vy = -y[j];           double nvx = vx * cosA[j] - vy * sinA[j];           double nvy = vx * sinA[j] + vy * cosA[j];           double pAns = x[j] - y[j] * nvx / nvy;           int newPos = newPotPos ^ i;           if (nvy >= 0.0) {             ans[newPos] = r;             maxi = r;           } else {             ans[newPos] = max(ans[newPos], pAns);             maxi = max(maxi, ans[newPos]);           }         }       }     }     maxi = min(maxi, r);     printf( %.11lf , maxi - l);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, count = 0, count1 = 0, ans = 0, i, ma;     cin >> n;     long long int a[n];     for (i = 0; i < n; i++) {       cin >> a[i];     }     ma = a[0];     for (i = 0; i < n; i++) {       if (a[i] > ma) {         ma = a[i];       }     }     for (i = 0; i < n; i++) {       count = ma - a[i];       ans = ans + count;     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   bool ok(int a, int b) {     int c = 0;     for (int i = 0; i < 4; i++) {       if ((a % 10) != (b % 10)) c++;       if (c > 1) return false;       a /= 10;       b /= 10;     }     return true;   }   int getlow(int a, int m) {     for (int i = m; i <= 2011; i++)       if (ok(a, i)) return i;     return -1;   }   int main() {     int n;     scanf( %d , &n);     int p = 1000;     vector<int> v;     for (int i = 0; i < n; i++) {       int t;       scanf( %d , &t);       t = getlow(t, p);       p = t;       if (t == -1) {         printf( No solution n );         return 0;       }       v.push_back(t);     }     for (int i = 0; i < n; i++) printf( %d n , v[i]);   }
#include <bits/stdc++.h>   using namespace std;   inline void read(register int *n) {     register char c;     *n = 0;     do {       c = getchar();     } while (c <  0  || c >  9 );     do {       *n = c -  0  + *n * 10;       c = getchar();     } while (c >=  0  && c <=  9 );   }   long long C[2048][2048], fac[1000001], dfac[1000001], D[2048][2048];   long long pmod(long long x, long long y) {     if (y == 0) return 1;     if (y % 2) return pmod(x, y - 1) * x % 1000000007;     long long r = pmod(x, y / 2);     return r * r % 1000000007;   }   long long calc(long long n, long long k, long long c = 0) {     long long res = 0;     for (register int i = (0); i < (int)(k + 1); ++i) {       long long tmp = C[k][i] * pmod(i + c, n);       tmp %= 1000000007;       if (i % 2)         res -= tmp;       else         res += tmp;       res %= 1000000007;     }     return res;   }   inline long long binom(long long n, long long r) {     if (r < 0 || r > n) return 0;     long long res = 1;     res = res * fac[n] % 1000000007;     res = res * dfac[r] % 1000000007;     res = res * dfac[n - r] % 1000000007;     return res;   }   int main() {     for (register int i = (0); i < (int)(1000001); ++i)       fac[i] = (i ? fac[i - 1] * i : 1) % 1000000007,       dfac[i] = pmod(fac[i], 1000000007 - 2);     for (register int i = (0); i < (int)(2048); ++i)       for (register int j = (0); j < (int)(i + 1); ++j)         C[i][j] = (j == 0 || j == i) ? 1 : (C[i - 1][j - 1] + C[i - 1][j]);     for (register int i = (0); i < (int)(2048); ++i)       for (register int j = (0); j < (int)(2048); ++j)         if (i == 0)           D[i][j] = j == 0;         else if (j <= 1)           D[i][j] = j;         else           D[i][j] = (j * D[i - 1][j] + D[i - 1][j - 1]) % 1000000007;     int n, m, k;     cin >> n >> m >> k;     if (m == 1) {       cout << pmod(k, n) << endl;       return 0;     }     long long res = 0;     for (register int x = (1); x < (int)(min(k, n) + 1); ++x)       for (int y = 0; y <= x; y++)         if (x * 2 - y <= k) {           long long tmp = binom(k, x * 2 - y);           tmp = tmp * binom(x * 2 - y, x - y) % 1000000007;           tmp = tmp * binom(x, x - y) % 1000000007;           tmp = tmp * D[n][x] % 1000000007;           tmp = tmp * D[n][x] % 1000000007;           tmp = tmp * fac[x] % 1000000007;           tmp = tmp * fac[x] % 1000000007;           tmp = tmp * pmod(y, n * (m - 2));           res = (res + tmp) % 1000000007;         }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     long long int n, x, ans = 0, i;     cin >> n;     for (i = 0; i < n; i++) {       cin >> x;       ans += (i + 1) * x;     }     ans -= (((n - 1) * (n)) / 2);     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int a, b, c;   int main() {     scanf( %d %d %d n , &a, &b, &c);     if (a == b && c == 0)       printf( YES n );     else if ((a != b && c == 0) || (a > b && c > 0) || (a < b && c < 0))       printf( NO n );     else {       if ((b - a) % c == 0)         printf( YES n );       else         printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_L = 3000;   int T[MAX_L][MAX_L];   int last[MAX_L], z[MAX_L];   ;   char s[MAX_L], p[MAX_L];   int main() {     int Ls, Lp, is, ip, k, i, j, r;     scanf( %s%s , &s, &p);     Ls = strlen(s);     Lp = strlen(p);     for (i = 0; s[i]; i++) {       is = i;       ip = 0;       while (s[is] && p[ip]) {         while (s[is] && p[ip] && s[is] != p[ip]) is++;         if (s[is] == p[ip]) {           is++;           ip++;         }       }       if (!p[ip]) {         last[i] = is - 1;         z[i] = is - i - Lp;       } else         last[i] = -1;     }     if (last[0] != -1) T[last[0]][z[0]] = 1;     for (i = 0; i < Ls - 1; i++)       for (k = 0; k <= i + 1; k++) {         j = i + 1;         T[j][k] = max(T[j][k], T[i][k]);         T[j][k + 1] = max(T[j][k + 1], T[i][k]);         if (last[j] != -1) {           r = last[j];           T[r][k + z[j]] = max(T[r][k + z[j]], T[i][k] + 1);         }       }     i = Ls - 1;     for (j = 0; j <= Ls; j++) printf( %d  , T[i][j]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int v0, v1, v2, vm, a0, a1, a2;     bool err = true;     scanf( %d%d%d%d , &v2, &v1, &v0, &vm);     for (int i = v0; i <= v0 * 2; i++) {       for (int j = v1; j <= v1 * 2; j++) {         for (int k = v2; k <= v2 * 2; k++) {           if (vm <= i && vm <= j && vm <= k && i < j && j < k && vm * 2 >= i &&               vm * 2 < j) {             a0 = k;             a1 = j;             a2 = i;             err = false;             break;           }         }       }     }     if (err) {       printf( -1 n );     } else {       printf( %d n%d n%d n , a0, a1, a2);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 5;   int main() {     int n;     cin >> n;     string s;     cin >> s;     queue<int> D, R;     for (int i = 0; i < n; i++) {       if (s[i] ==  D ) D.push(i);       if (s[i] ==  R ) R.push(i);     }     while (D.size() && R.size()) {       if (D.front() < R.front()) {         R.pop();         D.push(D.front() + n);         D.pop();       } else {         D.pop();         R.push(R.front() + n);         R.pop();       }     }     cout << (D.size() ?  D  :  R ) << endl;     return 0;   }
#include <bits/stdc++.h>   const double eps = 1e-19;   const double PI = acos(-1.0);   const int INF = 1000 * 1000 * 1000 + 7;   const int MAXN = 300005;   using namespace std;   int n, m;   int ans[MAXN];   vector<int> g[MAXN];   bool used[MAXN];   void dfs(int v) {     int kol = 0;     for (int j = 0; j < (int)g[v].size(); j++)       if (ans[v] == ans[g[v][j]]) kol++;     if (kol > 1) {       ans[v] ^= 1;       for (int j = 0; j < (int)g[v].size(); j++) {         dfs(g[v][j]);       }     }   }   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < m; i++) {       int ta, tb;       scanf( %d %d , &ta, &tb);       ta--;       tb--;       g[ta].push_back(tb);       g[tb].push_back(ta);     }     memset(ans, 0, sizeof ans);     for (int i = 0; i < n; i++) dfs(i);     for (int i = 0; i < n; i++) printf( %d , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1510, INF = 1e9 + 9;   int n, s, m, k, last[N], a[N], dp[N][N];   bool check(int x) {     memset(dp, 0, sizeof dp);     for (int i = 0; i < n; i++) {       int val = 0;       for (int j = last[i]; j <= i; j++) val += a[j] <= x;       for (int j = 1; j <= m; j++)         dp[i + 1][j] = max(dp[i][j], dp[last[i]][j - 1] + val);     }     return k <= dp[n][m];   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n >> s >> m >> k;     for (int i = 0; i < n; i++) cin >> a[i];     fill(last, last + n, n + 1);     while (s--) {       int l, r;       cin >> l >> r;       for (int i = --l; i < r; i++) last[i] = min(last[i], l);     }     int l = 0, r = INF;     while (r - l > 1) {       int mid = l + r >> 1;       check(mid) ? r = mid : l = mid;     }     cout << (r == INF ? -1 : r) << endl;   }
#include <bits/stdc++.h>   using namespace std;   struct Node {     pair<int, int> A;     int x, y;     Node() {}     Node(pair<int, int> A, int x, int y) {       this->A = A;       this->x = x;       this->y = y;     }   };   char s[1001][1001];   int sp[10], cur, ans[10];   Node heap[1000001];   void swap(Node& a, Node& b) {     Node t = a;     a = b;     b = t;   }   bool cmp(Node a, Node b) {     int val_a = a.A.first / sp[a.A.second];     int val_b = b.A.first / sp[b.A.second];     if (val_a != val_b)       return val_a < val_b;     else if (a.A.second != b.A.second)       return a.A.second < b.A.second;     else       return a.A.first < b.A.first;   }   void push(Node x) {     int now = cur++;     heap[now] = x;     while (now > 1) {       int par = now / 2;       if (cmp(heap[now], heap[par]))         swap(heap[now], heap[par]);       else         break;       now = par;     }     return;   }   Node pop() {     Node ret = heap[1];     heap[1] = heap[--cur];     int now = 1;     while (now * 2 < cur) {       int l = now * 2, r = now * 2 + 1, t;       if (r == cur) r = l;       if (cmp(heap[l], heap[r]))         t = l;       else         t = r;       if (cmp(heap[t], heap[now]))         swap(heap[t], heap[now]);       else         break;       now = t;     }     return ret;   }   int dx[4] = {1, 0, 0, -1};   int dy[4] = {0, 1, -1, 0};   int main() {     int n, m, p;     cur = 1;     scanf( %d %d %d , &n, &m, &p);     for (int i = 1; i <= p; i++) scanf( %d , &sp[i]);     for (int i = 0; i < n; i++) scanf( %s , s[i]);     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         if (s[i][j] >=  0  && s[i][j] <=  9 ) {           push(Node(pair<int, int>(0, s[i][j] -  0 ), i, j));         }       }     while (cur > 1) {       Node now = pop();       pair<int, int> A = now.A;       int x = now.x, y = now.y;       int cnt = A.first, who = A.second;       for (int i = 0; i < 4; i++) {         int nx = x + dx[i], ny = y + dy[i];         if (nx < 0 || ny < 0 || nx >= n || ny >= m || s[nx][ny] !=  . ) continue;         s[nx][ny] =  0  + who;         push(Node(pair<int, int>(cnt + 1, who), nx, ny));       }     }     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         if (s[i][j] >=  0  && s[i][j] <=  9 ) {           ans[s[i][j] -  0 ]++;         }       }     for (int i = 1; i <= p; i++) printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int len(int n) {     if (n < 10) return 0;     return 1 + len(n / 10);   }   int main() {     int n, l;     long long sum = 0, z = 1;     cin >> n;     l = len(n);     for (int x = 0; x < l; x++) z *= 10;     while (n > 0) {       sum += (n - z + 1) * (l + 1);       n = z - 1;       z /= 10;       l--;     }     cout << sum << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005, mod = 1000000007;   int n, m, T, q, f[6];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       int x;       scanf( %d , &x);       for (int j = 1; j <= 4; j++) {         if ((j & 1) == (x & 1)) f[j]++;       }       for (int j = 2; j <= 4; j++) f[j] = max(f[j], f[j - 1]);     }     printf( %d n , f[4]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[200005];   long double b[200005];   int n;   long double dp1[200005], dp2[200005];   long double check(long double val) {     int i;     for (i = 0; i < n; i++) b[i + 1] = a[i] - val;     dp1[1] = b[1];     long double ans = b[1];     for (i = 2; i <= n; i++) {       dp1[i] = max(dp1[i - 1], (long double)0) + b[i];       ans = max(ans, dp1[i]);     }     for (i = 0; i <= n + 1; i++) b[i + 1] = -b[i + 1];     ans = max(ans, b[1]);     dp2[1] = b[1];     for (i = 2; i <= n; i++) {       dp2[i] = max(dp2[i - 1], (long double)0) + b[i];       ans = max(ans, dp2[i]);     }     return ans;   }   int main() {     scanf( %d , &n);     int i;     for (i = 0; i < n; i++) scanf( %d , &a[i]);     long double lo, hi;     lo = -(1e4);     hi = 1e4;     long double eps = 1e-12;     while (lo < hi - eps) {       long double mid1, mid2;       mid1 = (2 * lo + hi) / 3;       mid2 = (lo + hi * 2) / 3;       long double sol1, sol2;       sol1 = check(mid1);       sol2 = check(mid2);       if (sol1 < sol2 - eps) {         hi = mid2;       } else {         lo = mid1;       }     }     cout << fixed << setprecision(9) << check(lo) << endl;   }
#include <bits/stdc++.h>   using namespace std;   template <class T, class U>   void ckmin(T &a, U b) {     if (a > b) a = b;   }   template <class T, class U>   void ckmax(T &a, U b) {     if (a < b) a = b;   }   int N, M;   bitset<1013> grid[1013];   int dn[1013][1013], rt[1013][1013];   int upd[1013][1013];   int x = -1, y = -1;   int ans = 998244353;   void check(int sx, int sy) {     for (auto i = (0); i < (N + 1); i++) {       for (auto j = (0); j < (M + 1); j++) {         upd[i][j] = 0;       }     }     int cx = x, cy = y;     while (true) {       upd[cx][cy]++;       upd[cx + sx][cy]--;       upd[cx][cy + sy]--;       upd[cx + sx][cy + sy]++;       if (grid[cx + sx][cy]) {         cx++;         continue;       }       if (grid[cx][cy + sy]) {         cy++;         continue;       }       break;     }     for (auto i = (0); i < (N); i++) {       for (auto j = (0); j < (M); j++) {         if (i) upd[i][j] += upd[i - 1][j];         if (j) upd[i][j] += upd[i][j - 1];         if (i && j) upd[i][j] -= upd[i - 1][j - 1];         if (upd[i][j] && !grid[i][j]) return;         if (!upd[i][j] && grid[i][j]) return;       }     }     ckmin(ans, sx * sy);   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> N >> M;     for (auto i = (0); i < (N); i++) {       string temps;       cin >> temps;       for (auto j = (0); j < (M); j++) {         grid[i][j] = (temps[j] ==  X );       }     }     for (auto i = (N)-1; i >= (0); i--) {       for (auto j = (M)-1; j >= (0); j--) {         if (grid[i][j]) {           x = i;           y = j;         }       }     }     for (auto i = (0); i < (N); i++) {       for (auto j = (0); j < (y); j++) {         if (grid[i][j]) {           cout <<  -1 n ;           return 0;         }       }     }     for (auto i = (0); i < (N); i++) {       for (auto j = (M)-1; j >= (0); j--) {         rt[i][j] = (grid[i][j] ? 1 + rt[i][j + 1] : 0);       }     }     for (auto i = (0); i < (M); i++) {       for (auto j = (N)-1; j >= (0); j--) {         dn[j][i] = (grid[j][i] ? 1 + dn[j + 1][i] : 0);       }     }     int dy = rt[x][y], dx = dn[x][y];     for (auto i = (x); i < (x + dx); i++) {       for (auto j = (y); j < (y + dy); j++) {         if (!grid[i][j]) {           cout <<  -1 n ;           return 0;         }       }     }     check(dx, dy);     check(dx, 1);     check(1, dy);     for (auto i = (0); i < (dy); i++) {       if (grid[x + dx][y + i]) {         check(dx, dy - i);         break;       }     }     for (auto i = (0); i < (dx); i++) {       if (grid[x + i][y + dy]) {         check(dx - i, dy);         break;       }     }     if (ans == 998244353) {       cout <<  -1 n ;       return 0;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 7;   const int sz = 10;   map<int, int> mp[11];   int n, k;   unsigned long long a[maxn], ans;   unsigned long long fac[13];   int main() {     fac[0] = 1;     for (int i = 1; i <= 10; i++) fac[i] = 10LL * fac[i - 1];     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) {       scanf( %llu , &a[i]);       for (int j = 1; j <= 10; j++) {         int now = (a[i] * fac[j]) % k;         mp[j][now]++;       }     }     for (int i = 1; i <= n; i++) {       int len = 0;       unsigned long long now = a[i];       while (now) {         now /= 10;         len++;       }       int res = a[i] % k;       int p = 0;       if (res == 0) {         int need = 0;         if ((a[i] * fac[len]) % k == need) {           ans += mp[len][need] - 1;         } else {           ans += mp[len][need];         }       } else {         int need = k - res;         if ((a[i] * fac[len]) % k == need) {           ans += mp[len][need] - 1;         } else {           ans += mp[len][need];         }       }     }     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int mx = 1123;   int limit[26];   const long long mod = 1e9 + 7;   int n;   string s;   struct Node {     int maxstr, minpart;     long long ways;     Node(int maxstr, int minpart, long long ways)         : maxstr(maxstr), minpart(minpart), ways(ways){};     Node() {       ways = -1;       minpart = 1e9;     }   };   Node dp[mx];   Node ways(int on = 0) {     if (on == n) {       return {0, 0, 1};     }     Node &ans = dp[on];     if (ans.ways == -1) {       ans.ways = 0;       int maxsz = 1e9;       for (int i = on; i < n; i++) {         maxsz = min(maxsz, limit[s[i] -  a ]);         if (i - on + 1 <= maxsz) {           auto r = ways(i + 1);           ans.ways += r.ways;           ans.minpart = (i != n - 1) + min(ans.minpart, r.minpart);           ans.maxstr = max(ans.maxstr, max(i - on + 1, r.maxstr));         }       }     }     ans.ways = (ans.ways) % mod;     return ans;   }   int main() {     cin >> n;     cin >> s;     for (int i = 0; i < 26; i++) {       cin >> limit[i];     }     auto ans = ways();     cout << ans.ways << endl;     cout << ans.maxstr << endl;     cout << ans.minpart + 1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   void FLASH() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   void SETF() {     cout.ios_base::setf(ios_base::fixed);     cerr.ios_base::setf(ios_base::fixed);   }   void UNSETF() {     cout.ios_base::unsetf(ios_base::fixed);     cerr.ios_base::unsetf(ios_base::fixed);   }   bool sortinrev(const pair<long long int, long long int> &a,                  const pair<long long int, long long int> &b) {     return (a.first > b.first);   }   long long int A[1000000];   long long int B[1000000];   map<int, vector<int> > node;   int main() {     FLASH();     long long int t;     cin >> t;     while (t--) {       string s;       long long int n;       cin >> n >> s;       if (n == 2) {         if (s[0] >= s[1])           cout <<  NO  << endl;         else           cout <<  YES  << endl << 2 << endl << s[0] <<     << s[1] << endl;       } else {         cout <<  YES  << endl;         cout << 2 << endl;         cout << s[0] <<    ;         for (long long int i = 1; i < n; i++) cout << s[i];         cout << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int x[6];   int m[6];   int w[6];   int h, uh;   int main() {     x[0] = 500;     for (int i = 0; i < 5; i++) {       cin >> m[i];       if (i) x[i] = x[i - 1] + 500;     }     for (int i = 0; i < 5; i++) cin >> w[i];     cin >> h >> uh;     int score = 0;     for (int i = 0; i < 5; i++) {       int bla = 3 * x[i] / 10;       score += max(bla, (x[i] * (250 - m[i])) / 250 - 50 * w[i]);     }     cout << score + 100 * h - 50 * uh << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MM = 1005;   const long long MOD = 1000000007;   int vis[MM][MM] = {0};   int n, m, k;   bool judge(int x, int y) {     if (x - 1 >= 0 && y - 1 >= 0) {       if (vis[x - 1][y - 1] && vis[x - 1][y] && vis[x][y - 1]) return true;     }     if (x - 1 >= 0 && y + 1 < m) {       if (vis[x - 1][y + 1] && vis[x - 1][y] && vis[x][y + 1]) return true;     }     if (x + 1 < n && y - 1 >= 0) {       if (vis[x + 1][y - 1] && vis[x][y - 1] && vis[x + 1][y]) return true;     }     if (x + 1 < n && y + 1 < m) {       if (vis[x + 1][y + 1] && vis[x + 1][y] && vis[x][y + 1]) return true;     }     return false;   }   int main() {     int ans = 0, flag = 0;     scanf( %d%d%d , &n, &m, &k);     for (int i = 0; i < k; i++) {       int x, y;       scanf( %d%d , &x, &y);       x--;       y--;       vis[x][y] = 1;       if (!flag && judge(x, y)) {         ans = i + 1;         flag = 1;       }     }     if (!flag)       puts( 0 );     else       printf( %d n , ans);     return 0;   }