malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int N;   pair<int, int> a[200002 + 1];   int min(int a, int b) { return a > b ? b : a; }   int abs(int a) { return a < 0 ? -a : a; }   int main() {     cin >> N;     N *= 2;     int b;     for (int i = 0; i < N; i++) {       cin >> b;       a[i] = {b, i};     }     sort(a, a + N);     long long ans = a[0].second + a[1].second;     for (int i = 2; i < N; i += 2) {       ans += min(abs(a[i - 2].second - a[i].second) +                      abs(a[i - 1].second - a[i + 1].second),                  abs(a[i - 1].second - a[i].second) +                      abs(a[i - 2].second - a[i + 1].second));     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<char> a;   int x, y, n;   void update(pair<int, int> &pos, int i, int d) {     if (a[i] ==  U )       pos.second += d;     else if (a[i] ==  D )       pos.second -= d;     else if (a[i] ==  R )       pos.first += d;     else       pos.first -= d;   }   bool ok(pair<int, int> pos, int len) {     int d = abs(x - pos.first) + abs(y - pos.second);     if (d <= len && d % 2 == len % 2) return true;     return false;   }   bool can(int len) {     pair<int, int> pos = make_pair(0, 0);     for (int i = len; i < a.size(); i++) update(pos, i, 1);     int l = 0, r = len;     while (1) {       if (ok(pos, len)) return true;       if (n == r) break;       update(pos, l++, 1);       update(pos, r++, -1);     }     return false;   }   int main() {     cin >> n;     cin.ignore();     for (int i = 0; i < n; i++) {       char temp;       cin >> temp;       a.push_back(temp);     }     cin >> x >> y;     if (!ok(make_pair(0, 0), n))       cout << -1 << endl;     else {       int l = -1, r = n;       while (r - l > 1) {         int len = (r + l) / 2;         if (can(len))           r = len;         else           l = len;       }       cout << r << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void chkmin(T &a, T b) {     if (a > b) a = b;   }   template <class T>   inline void chkmax(T &a, T b) {     if (a < b) a = b;   }   int main() {     int N, x, M, y, d, len1, len2, len, r1, r2, r, i;     long long ans;     scanf( %d%d%d%d , &N, &x, &M, &y);     if (N < M) {       swap(x, y);       swap(N, M);     }     d = abs(x - y);     ans = N + M + 1 - max(min(M, N - d), 0);     for (i = 1; i <= N; i++) {       if (i <= d)         len1 = d - i + 1;       else         len1 = i - d;       len2 = 1;       r1 = d + i;       r2 = M;       len = max(len1, len2);       r = min(r1, r2);       ans += 2 * max(0, r - len + 1);       if (len1 <= r2) ans--;       if (r1 <= r2) ans -= 2;     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   const int N = 1e5 + 5;   const int M = 1e3 + 10;   const int mod = 9973;   using namespace std;   long long m, n, x, y, l, r, t, a1, r1, a2, r2;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   void e_gcd(long long a, long long b, long long &g, long long &x, long long &y) {     if (b == 0) {       x = 1, y = 0, g = a;       return;     } else {       e_gcd(b, a % b, g, y, x);       y -= (a / b) * x;     }   }   inline long long crt() {     long long ans, sum = 0, g, x, y;     e_gcd(a1, a2, g, x, y);     if ((r2 - r1) % g != 0) return 0;     t = (r2 - r1) / g;     x *= t;     t = a2 / g;     x = (x % t + t) % t;     ans = r1 + a1 * x;     t = abs(a1 * a2 / g);     l = max(l, max(r1, r2));     if (l > r) return 0;     if (ans <= r) sum += (r - ans) / t + 1;     if (ans < l) sum -= (l - ans - 1) / t + 1;     return sum;   }   int main() {     scanf( %I64d%I64d%I64d%I64d%I64d%I64d , &a1, &r1, &a2, &r2, &l, &r);     printf( %I64d n , crt());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   unsigned int dp[N];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, cnt = 0;     cin >> n;     string s;     cin >> s;     if (n % 2 == 1) {       cout << 0 <<   n ;       return 0;     }     dp[0] = 1;     for (int i = 0; i < n; i++) {       if (s[i] !=  ? )         cnt++;       else {         for (int j = (i + 1) / 2; j > 0; j--) dp[j] = dp[j] + dp[j - 1];       }     }     unsigned int ans = dp[n / 2];     for (int i = 0; i < n / 2 - cnt; i++) ans *= 25;     cout << ans <<   n ;   }
#include <bits/stdc++.h>   long long arr[100005];   using namespace std;   int main() {     cin.tie(0);     std::ios::sync_with_stdio(false);     ;     int n;     cin >> n;     for (int i = 0; i < n; cin >> arr[i++])       ;     sort(arr, arr + n);     cout << arr[n - 1] <<    ;     for (int i = 1; i < n - 1; i++) {       cout << arr[i] <<    ;     }     cout << arr[0];   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int j, t, n, m = 0, i;     unsigned long long p = 0, q = 0;     char a[1000001];     cin >> a;     n = strlen(a);     for (j = 0; j < n; j++) {       if (a[j] ==  ^ ) {         break;       }     }     for (i = j - 1; i >= 0; i--) {       if ((a[i] >=  1 ) && (a[i] <=  9 )) {         t = abs(j - i);         p += (t * ((int)a[i] - 48));       }     }     for (i = j + 1; i < n; i++) {       if ((a[i] >=  1 ) && (a[i] <=  9 )) {         t = abs(j - i);         q += (t * ((int)a[i] - 48));       }     }     if (p == q) {       cout <<  balance  << endl;     } else if (p > q) {       cout <<  left  << endl;     } else {       cout <<  right  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   double b[100005];   struct node {     double he, cheng;   } a[100005 * 4];   node merge(node a, node b) {     node c;     c.cheng = a.cheng * b.cheng;     c.he = a.he + a.cheng * (b.he - 1);     return c;   }   void build(int x, int l, int r) {     if (l == r) {       a[x].he = 1 + b[l];       a[x].cheng = b[l];       return;     }     int mid = (l + r) / 2;     build(x * 2, l, mid);     build(x * 2 + 1, mid + 1, r);     a[x] = merge(a[x * 2], a[x * 2 + 1]);   }   void modify(int x, int l, int r, int wh, double val) {     if (l == r) {       a[x].cheng = val;       a[x].he = 1 + val;       return;     }     int mid = (l + r) / 2;     if (mid >= wh)       modify(x * 2, l, mid, wh, val);     else       modify(x * 2 + 1, mid + 1, r, wh, val);     a[x] = merge(a[x * 2], a[x * 2 + 1]);   }   node query(int x, int l, int r, int tx, int ty) {     if (l >= tx && r <= ty) return a[x];     int mid = (l + r) / 2;     if (mid >= tx && mid < ty)       return merge(query(x * 2, l, mid, tx, ty),                    query(x * 2 + 1, mid + 1, r, tx, ty));     if (mid >= tx)       return query(x * 2, l, mid, tx, ty);     else       return query(x * 2 + 1, mid + 1, r, tx, ty);   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       double x, y;       scanf( %lf%lf , &x, &y);       double t = x / y;       b[i] = (1 - t) / t;     }     build(1, 1, n);     while (m--) {       int type;       scanf( %d , &type);       if (type == 1) {         int wh;         scanf( %d , &wh);         double x, y;         scanf( %lf%lf , &x, &y);         double t = x / y;         t = (1 - t) / t;         modify(1, 1, n, wh, t);       } else {         int x, y;         scanf( %d%d , &x, &y);         printf( %.10lf n , 1.0 / query(1, 1, n, x, y).he);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 50010;   const int inf = 1e9;   inline int read() {     int p = 0;     int f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       p = p * 10 + ch -  0 ;       ch = getchar();     }     return p * f;   }   struct node {     int x, y, d, c, next;   } edge[N << 4];   int len, first[N];   void ins(int x, int y, int c, int d) {     len++;     edge[len].x = x;     edge[len].y = y;     edge[len].c = c;     edge[len].d = d;     edge[len].next = first[x];     first[x] = len;     len++;     edge[len].x = y;     edge[len].y = x;     edge[len].c = 0;     edge[len].d = -d;     edge[len].next = first[y];     first[y] = len;   }   bool v[N];   int d[N];   queue<int> q;   int pre[N], pos[N];   int s, t;   bool bfs() {     while (!q.empty()) q.pop();     q.push(s);     memset(d, -63, sizeof(d));     d[s] = 0;     memset(v, 0, sizeof(v));     v[s] = 1;     while (!q.empty()) {       int x = q.front();       for (int k = first[x]; k != -1; k = edge[k].next) {         int y = edge[k].y;         if (d[y] < d[x] + edge[k].d && edge[k].c) {           d[y] = d[x] + edge[k].d;           pos[y] = x;           pre[y] = k;           if (!v[y]) {             v[y] = 1;             q.push(y);           }         }       }       q.pop();       v[x] = 0;     }     return d[t] >= 0;   }   int n, a[N];   int main() {     len = 1;     memset(first, -1, sizeof(first));     n = read();     for (int i = 1; i <= n; i++) a[i] = read();     int ss = 2 * n + 1;     s = ss + 1;     t = s + 1;     ins(s, ss, 4, 0);     for (int i = 1; i <= n; i++) {       ins(ss, i + n, 1, 0);       ins(i + n, i, 1, 1);       ins(i, t, 1, 0);     }     for (int i = 1; i <= n; i++) {       int cnt = 0;       for (int j = i + 1; j <= n; j++)         if ((a[i] - a[j] == 1) && cnt < 1) {           ins(i, j + n, inf, 0);           cnt++;         }       cnt = 0;       for (int j = i + 1; j <= n; j++)         if ((a[i] - a[j] == -1) && cnt < 1) {           ins(i, j + n, inf, 0);           cnt++;         }       cnt = 0;       for (int j = i + 1; j <= n; j++)         if ((a[i] % 7 == a[j] % 7) && cnt < 1) {           ins(i, j + n, inf, 0);           cnt++;         }       ins(i + n, i, inf, 0);     }     int ans = 0;     while (bfs()) {       for (int i = t; i != s; i = pos[i])         ans += edge[pre[i]].d, edge[pre[i]].c--, edge[pre[i] ^ 1].c++;     }     return printf( %d n , ans), 0;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 14;   const int INF = 0x3f3f3f3f;   int N, M;   vector<int> G[Maxn + 5];   void addedge(int u, int v) { G[u].push_back(v), G[v].push_back(u); }   int f[(1 << Maxn) + 5];   pair<int, int> last[(1 << Maxn) + 5];   int lasts[(1 << Maxn) + 5];   bool go[Maxn + 3][Maxn + 3][(1 << Maxn) + 3];   int lastnode[Maxn + 3][Maxn + 3][(1 << Maxn) + 3];   inline int lowbit(int x) { return x & (-x); }   inline int bitcount(int x) {     int ret = 0;     while (x) ret++, x -= lowbit(x);     return ret;   }   int main() {     scanf( %d %d , &N, &M);     for (int i = 1; i <= M; i++) {       int u, v;       scanf( %d %d , &u, &v);       addedge(u, v);     }     memset(f, 0x3f, sizeof f);     for (int u = 1; u <= N; u++)       for (auto v : G[u]) go[u][v][0] = true, lastnode[u][v][0] = u;     for (int s = 0; s < (1 << N); s++)       for (int i = 1; i <= N; i++)         for (int j = 1; j <= N; j++) {           if ((s & (1 << (i - 1))) || (s & (1 << (j - 1))) || i == j ||               !go[i][j][s])             continue;           for (auto k : G[j]) {             if (s & (1 << (k - 1)) || k == i && s == 0) continue;             int t = s ^ (1 << (j - 1));             if (!go[i][k][t]) go[i][k][t] = true, lastnode[i][k][t] = j;           }         }     f[1] = 0;     for (int s = 0; s < (1 << N); s++)       for (int t = s; t; t = (t - 1) & s) {         int lst = s ^ t;         int cnt = bitcount(t) + 1;         if (f[lst] + cnt >= f[s]) continue;         for (int u = 1; u <= N; u++) {           if (!(lst & (1 << (u - 1)))) continue;           for (int v = 1; v <= N; v++) {             if (!(lst & (1 << (v - 1)))) continue;             if (go[u][v][t]) {               f[s] = f[lst] + cnt;               last[s] = make_pair(u, v);               lasts[s] = t;             }           }         }       }     if (f[(1 << N) - 1] == INF) {       puts( -1 );       return 0;     }     printf( %d n , f[(1 << N) - 1]);     int t = (1 << N) - 1;     while (t != 1) {       int lst = lasts[t];       int x = last[t].first, y = last[t].second;       t ^= lst;       while (lst) {         int z = lastnode[x][y][lst];         printf( %d %d n , y, z);         lst ^= (1 << (z - 1));         y = z;       }       printf( %d %d n , x, y);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int T, cnt = 0;     cin >> T;     while (T--) {       long long int k, n, a, b;       cin >> k >> n >> a >> b;       k -= n * a;       if (k > 0)         cout << n <<   n ;       else {         k = -k;         long long int dif = a - b;         long long int turns = (k + dif) / dif;         if (turns > n)           cout <<  -1 n ;         else           cout << n - turns <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 510000;   char s[maxn];   int n, maxtime;   int house;   bool ok(int need) {     int time = 0, candy = need, total = house;     int p = 0, q = 0;     int i;     for (i = 0; i < n; i++) {       p += (s[i] ==  H );       q += (s[i] ==  S );       if (p == total && (q + need) >= house) break;     }     if (!(p == total && (q + need) >= house)) return 0;     if (2 * (i + 1) - 1 <= maxtime) return 1;     for (int i = 0; i < n; i++) {       if (!total) return time <= maxtime;       if (++time > maxtime) return 0;       if (s[i] ==  S ) {         candy++;       } else if (s[i] ==  H ) {         if (candy) {           candy--;           total--;           continue;         }         int h2 = 0, k = 0, j;         for (j = i; j < n; j++) {           if (s[j] ==  H )             k++, h2++;           else if (s[j] ==  S )             k--, s[j] =  . ;           if (k == 0) break;         }         if (k) return 0;         time += 2 * (j - i);         time--;         candy += h2;         i--;       }     }     return time <= maxtime;   }   char str[maxn];   int main() {     while (scanf( %d%d , &n, &maxtime) != EOF) {       scanf( %s , str);       house = 0;       for (int i = 0; i < n; i++) {         house += (str[i] ==  H );       }       int l = 0, r = n;       int ans = -1;       while (l <= r) {         int m = (l + r) >> 1;         memcpy(s, str, sizeof s);         if (ok(m)) {           r = m - 1;           ans = m;         } else           l = m + 1;       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int f[505][505], g[505][505], a[505], b[505], id[505], xinyue, n, m, vis[505],       ed;   int cmp(int x, int y) { return b[x] < b[y]; }   void dfs(int n, int m) {     if (!n) return;     if (g[n][m] == 1) vis[n] = 1, m--;     dfs(n - 1, m);   }   int main() {     scanf( %d , &xinyue);     while (xinyue--) {       scanf( %d%d , &n, &m);       for (int i = 0; i <= n; i++) {         for (int t = 0; t <= m; t++) {           f[i][t] = -1;         }       }       f[0][0] = 0;       memset(g, 0, sizeof(g));       for (int i = 1; i <= n; i++) scanf( %d%d , &a[i], &b[i]), id[i] = i;       sort(id + 1, id + n + 1, cmp);       for (int i = 1; i <= n; i++) {         for (int t = 0; t <= min(i, m); t++) {           if (f[i - 1][t] != -1) f[i][t] = f[i - 1][t] + b[id[i]] * (m - 1);           g[i][t] = 0;           if (t && f[i - 1][t - 1] + a[id[i]] + b[id[i]] * (t - 1) > f[i][t] &&               f[i - 1][t - 1] != -1) {             f[i][t] = f[i - 1][t - 1] + a[id[i]] + b[id[i]] * (t - 1);             g[i][t] = 1;           }         }       }       memset(vis, 0, sizeof(vis));       dfs(n, m);       printf( %d n , m + (n - m) * 2);       ed = 0;       for (int i = 1; i <= n; i++) {         if (vis[i]) {           ed++;           if (ed == m) {             ed = id[i];             break;           }           printf( %d  , id[i]);         }       }       for (int i = 1; i <= n; i++) {         if (!vis[i]) {           printf( %d %d  , id[i], -id[i]);         }       }       printf( %d n , ed);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, a[200], b[200];     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) cin >> b[i];     int j;     for (int i = 0; i < n; i++) {       for (j = 1; j < n; j++) {         if ((a[i] - b[0] + m) % m != (a[(j + i) % n] - b[j] + m) % m) break;       }       if (j == n) {         cout <<  YES ;         return 0;       }     }     cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   struct business {     int num;     int dif;   };   bool compare(business x, business y) { return (x.dif < y.dif); }   int main() {     int n;     int x;     cin >> n;     vector<business> A(n + 1);     for (int i = 1; i <= n; i++) {       cin >> x;       A[i].num = i;       A[i].dif = x;     }     sort(A.begin(), A.end(), compare);     int triple = 0, p1 = 0, p2 = 0;     for (int i = 1; i < n; i++) {       if (A[i].dif == A[i + 1].dif)         if (p1 == 0) {           p1 = i;           if (i <= n - 2)             if (A[i + 1].dif == A[i + 2].dif) {               triple = i;               break;             }         } else {           p2 = i;           if (i <= n - 2)             if (A[i + 1].dif == A[i + 2].dif) triple = i;           break;         }     }     if ((triple == 0) && (p2 == 0))       cout <<  NO n ;     else {       cout <<  YES n ;       if (triple != 0) {         for (int i = 1; i <= n; i++) cout << A[i].num <<    ;         cout << endl;         for (int i = 1; i <= n; i++) {           if (i == triple) {             cout << A[i].num <<     << A[i + 2].num <<     << A[i + 1].num <<    ;             i += 2;           } else             cout << A[i].num <<    ;         }         cout << endl;         for (int i = 1; i <= n; i++) {           if (i == triple) {             cout << A[i + 2].num <<     << A[i + 1].num <<     << A[i].num <<    ;             i += 2;           } else             cout << A[i].num <<    ;         }         cout << endl;       } else {         for (int i = 1; i <= n; i++) cout << A[i].num <<    ;         cout << endl;         for (int i = 1; i <= n; i++) {           if (i == p1) {             cout << A[i + 1].num <<     << A[i].num <<    ;             i++;           } else             cout << A[i].num <<    ;         }         cout << endl;         for (int i = 1; i <= n; i++) {           if (i == p2) {             cout << A[i + 1].num <<     << A[i].num <<    ;             i++;           } else             cout << A[i].num <<    ;         }         cout << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     string s;     cin >> n;     cin >> s;     vector<long long> cnts(60, 0);     long long k = 0;     for (long long i = 0; i < n; i++) {       if (cnts[s[i] - 65] == 0) k++;       cnts[s[i] - 65]++;     }     for (long long i = 0; i < 60; i++) cnts[i] = 0;     long long l = 0;     long long r = -1;     long long res = 100001;     long long cnt = 0;     while (r < n) {       if (cnt < k) {         r++;         if (r == n) break;         cnts[s[r] - 65]++;         if (cnts[s[r] - 65] == 1) cnt++;       } else if (cnt == k) {         res = min(res, r - l + 1);         cnts[s[l] - 65]--;         if (cnts[s[l] - 65] == 0) cnt--;         l++;       }     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string Scale, left, right, rest_elements;     int Slash;     cin >> Scale;     Slash = Scale.find( | );     left = Scale.substr(0, Slash);     right = Scale.substr(Slash + 1, Scale.size());     cin >> rest_elements;     for (auto i : rest_elements)       if (left.size() <= right.size())         left += i;       else         right += i;     cout << (left.size() == right.size() ? left +  |  + right :  Impossible )          << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 50050;   vector<int> e[MAX];   vector<int> ee[MAX];   int c[MAX][555];   int vis[MAX];   int n, k;   void solve(int indx) {     c[indx][0] = 1;     vis[indx] = 1;     for (int i = 0; i < e[indx].size(); i++) {       if (vis[e[indx][i]] == 1) continue;       int cindx = e[indx][i];       ee[indx].push_back(cindx);       solve(cindx);       for (int j = 0; j <= k; j++) {         if (c[cindx][j] == 0) break;         c[indx][j + 1] += c[cindx][j];       }     }   }   long long solve1() {     long long ans = 0;     for (int i = 1; i <= n; i++) {       long long ret = 0;       for (int j = 0; j < ee[i].size(); j++) {         for (int K = 1; K < k; K++) {           long long first = 0, second = 0;           first = c[ee[i][j]][K - 1];           second = c[i][k - K] - c[ee[i][j]][k - K - 1];           ret += (first * second);         }       }       ans += ret / 2;       ans += c[i][k];     }     return ans;   }   int main() {     cin >> n >> k;     for (int i = 0; i < n - 1; i++) {       int x, y;       cin >> x >> y;       e[x].push_back(y);       e[y].push_back(x);     }     solve(1);     cout << solve1() << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007ll;   vector<int> adj[100005];   vector<pair<int, int> > grop[100005];   int now;   int weig[100005];   int bu[100005];   int flag[100005];   pair<int, int> dfs(int u) {     if (flag[u]) return make_pair(0, 0);     flag[u] = 1;     pair<int, int> res = make_pair(0, 0);     for (int i = 0; i < adj[u].size(); i++) {       pair<int, int> tem = dfs(adj[u][i]);       res.first += tem.first;       res.second += tem.second;     }     res.first += weig[u];     res.second += bu[u];     grop[now].push_back(make_pair(weig[u], bu[u]));     return res;   }   long long dp[100005];   int main() {     int n, m, w;     scanf( %d %d %d , &n, &m, &w);     for (int i = 1; i <= n; i++) scanf( %d , &weig[i]);     for (int i = 1; i <= n; i++) scanf( %d , &bu[i]);     for (int i = 1; i <= m; i++) {       int a, b;       scanf( %d %d , &a, &b);       adj[a].push_back(b);       adj[b].push_back(a);     }     for (int i = 1; i <= n; i++) {       if (flag[i]) continue;       now++;       pair<int, int> tem = dfs(i);       grop[now].push_back(tem);     }     for (int i = 1; i <= now; i++) {       for (int j = w; j > 0; j--) {         for (int k = 0; k < grop[i].size(); k++) {           if (grop[i][k].first > j) continue;           dp[j] = max(dp[j], grop[i][k].second + dp[j - grop[i][k].first]);         }       }     }     long long res = 0;     for (int i = 0; i <= w; i++) res = max(res, dp[i]);     printf( %I64d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   int C[1005][1005];   void build() {     C[0][0] = 1;     for (int i = 1; i <= 1000; i++) {       C[i][0] = 1;       for (int j = 1; j <= 1000; j++) {         C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;       }     }   }   int main() {     build();     int n, m, k;     scanf( %d%d%d , &n, &m, &k);     if (2 * k > n - 1 || 2 * k > m - 1) {       printf( 0 n );     } else {       printf( %d n , 1LL * C[n - 1][2 * k] * C[m - 1][2 * k] % mod);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long read() {     long long x = 0;     char ch = getchar();     bool f = 0;     for (; !isdigit(ch); ch = getchar())       if (ch ==  - ) f = 1;     for (; isdigit(ch); ch = getchar()) x = x * 10 + ch -  0 ;     return f ? -x : x;   }   void write(long long x) {     if (x < 0) putchar( - ), x = -x;     if (x >= 10) write(x / 10);     putchar(x % 10 +  0 );   }   void writeln(long long x) {     write(x);     puts(  );   }   void writep(long long x) {     write(x);     putchar(   );   }   const int N = 100005;   int n, S[N], a[N], top;   char s[N];   int main() {     scanf( %s , s + 1);     n = strlen(s + 1);     for (int i = (int)(1); i <= (int)(n); i++) {       if (s[i] ==  + )         a[i] = 1;       else         a[i] = 0;     }     for (int i = (int)(1); i <= (int)(n); i++) {       S[++top] = a[i];       if (top > 1 && S[top - 1] == a[i]) top -= 2;     }     if (top)       puts( No );     else       puts( Yes );   }