malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   double PI = acos(-1);   double EPS = 1e-7;   int INF = 1000000000;   int MOD = 1000000007;   int MAXINT = 2147483647;   long long INFLL = 1000000000000000000LL;   long long MAXLL = 9223372036854775807LL;   int mx[8] = {-1, 1, 0, 0, -1, -1, 1, 1};   int my[8] = {0, 0, -1, 1, -1, 1, -1, 1};   int x, k, p;   double per;   int lim = (1 << 8) - 1;   double dp[205][235][2][1 << 8];   bool vs[205][235][2][1 << 8];   double go(int pos, int cons, int t, int mask) {     if (vs[pos][cons][t][mask]) return dp[pos][cons][t][mask];     vs[pos][cons][t][mask] = 1;     double &ret = dp[pos][cons][t][mask];     ret = 0.0;     if (pos == 0) {       if (mask == 0) {         if (t == 1)           return ret = 8;         else           return ret = 8 + cons;       } else {         int co = 0;         while (mask % 2 == 0) {           co++;           mask /= 2;         }         return ret = co;       }     }     if (mask < lim) {       ret += (1.0 - per) * go(pos - 1, cons, t, mask + 1);     } else {       if (t == 0)         ret += (1.0 - per) * go(pos - 1, 1, 1, 0);       else         ret += (1.0 - per) * go(pos - 1, cons, 0, 0);     }     bool d = mask & (1 << 7);     if (d) mask -= (1 << 7);     if (d == t) {       ret += per * go(pos - 1, cons + 1, d, 2 * mask);     } else {       ret += per * go(pos - 1, 1, d, 2 * mask);     }     return ret;   }   int main() {     scanf( %d%d%d , &x, &k, &p);     per = (double)p / 100.0;     int mask = 0;     int cons = 0;     bool t = (x & (1 << 8));     for (int(a) = (0); (a) <= (30); (a)++) {       if (a <= 7) {         if (x & (1 << a)) mask += (1 << a);       } else {         if (t && ((x & (1 << a)) > 0)) cons++;         if (t && ((x & (1 << a)) == 0)) break;         if (!t && ((x & (1 << a)) == 0)) cons++;         if (!t && ((x & (1 << a)) > 0)) break;       }     }     printf( %.10lf n , go(k, cons, t, mask));   }
#include <bits/stdc++.h>   using namespace std;   vector<long long> pa, pb;   struct fenw {     vector<long long> fw;     long long n;     void ini(long long pn) {       n = pn;       fw.clear();       fw.resize(n, 0);     }     void ad(long long l, long long x) {       while (l < n) {         fw[l] += x;         l |= (l + 1);       }     }     long long sm(long long l) {       long long r = 0;       while (l >= 0) {         r += fw[l];         l &= (l + 1);         --l;       }       return r;     }   };   fenw fa, fb, fr;   vector<long long> resd;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     long long n;     cin >> n;     pa.resize(n);     pb.resize(n);     for (long long i = 0; i < (n); ++i) cin >> pa[i];     for (long long i = 0; i < (n); ++i) cin >> pb[i];     fa.ini(n);     fb.ini(n);     fr.ini(n);     resd.resize(n);     for (long long i = n - 1; i >= 0; --i) {       long long cc = fa.sm(pa[i]) + fb.sm(pb[i]);       fa.ad(pa[i], 1);       fb.ad(pb[i], 1);       resd[i] += cc;       if (i > 0) resd[i - 1] += resd[i] / (n - i);       resd[i] %= (n - i);     }     for (long long i = 0; i < (n); ++i) {       long long mn = 0;       long long mx = n;       long long md;       while (mx - mn > 1) {         md = (mx + mn) / 2;         if (md - fr.sm(md - 1) <= resd[i])           mn = md;         else           mx = md;       }       fr.ad(mn, 1);       cout << mn <<    ;     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000000007LL;   const int N = 10;   char str[N][N];   int n = 8, ans, way[4][2] = {2, 2, 2, -2, -2, 2, -2, -2};   int flag[N][N][N][N];   void dfs(int x, int y, int u, int v) {     flag[x][y][u][v] = 1;     if (x == u && v == y && str[x][y] !=  # ) {       ans = 1;       return;     }     if (ans) return;     for (int i = 0; i < 4; i++) {       int xx = x + way[i][0];       int yy = y + way[i][1];       if (xx >= 0 && xx < n && yy >= 0 && yy < n) {         for (int j = 0; j < 4; j++) {           int uu = u + way[j][0];           int vv = v + way[j][1];           if (uu >= 0 && uu < n && vv >= 0 && vv < n) {             if (!flag[xx][yy][uu][vv]) {               dfs(xx, yy, uu, vv);             }           }         }       }     }   }   int main() {     int t;     cin >> t;     while (t--) {       int x = -1, y = -1, u = -1, v = -1;       for (int i = 0; i < n; i++) {         cin >> str[i];         for (int j = 0; j < n; j++) {           if (str[i][j] ==  K ) {             if (x == -1) {               x = i;               y = j;             } else               u = i, v = j;             str[i][j] =  . ;           }         }       }       ans = 0;       memset(flag, 0, sizeof(flag));       dfs(x, y, u, v);       puts(ans ?  YES  :  NO );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double maxx(double a, double b) { return a > b ? a : b; }   int minn(int a, int b) { return a < b ? a : b; }   int abss(int a) { return a < 0 ? (-a) : a; }   const double eps = 1e-8, PI = 3.141592653589, INF = 1e7;   int N;   double L, R;   double inpt[30][3];   double dp[1 << 20];   double DP(int, double);   double Get(int, double);   int main() {     scanf( %d%lf%lf , &N, &L, &R);     double ans = L;     for (int i = 0; i < 1 << N; i++) dp[i] = -INF;     dp[0] = L;     for (int i = 1; i <= N; i++)       scanf( %lf%lf%lf , &inpt[i][0], &inpt[i][1], &inpt[i][2]);     for (int mask = 0; mask < 1 << N; mask++) {       ans = maxx(dp[mask], ans);       if (ans > R) {         ans = R;         break;       }       for (int np = 1; np <= N; np++) {         int nxt = 1 << np - 1;         if (mask & nxt) continue;         dp[mask | nxt] = maxx(dp[mask | nxt], dp[mask] + Get(np, dp[mask]));       }     }     printf( %.8f n , ans - L);     return 0;   }   double Get(int i, double stp) {     double x1 = inpt[i][0];     double y1 = inpt[i][1];     double ang = inpt[i][2] * PI / 180;     double dist = sqrt(y1 * y1 + (x1 - stp) * (x1 - stp));     double ang2 = acos((x1 - stp) / dist);     ang2 = PI - ang2 - ang;     double s = dist * sin(ang);     if (ang2 < eps)       s = INF;     else       s /= sin(ang2);     return s;   }
#include <bits/stdc++.h>   using namespace std;   string c;   int main() {     int i, j, k, n, m, l;     scanf( %d%d , &n, &k);     if (n * (n - 1) / 2 <= k) {       puts( no solution );       return 0;     }     for (i = 1; i <= n; i++) printf( %d %d n , 0, i);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t, n, m;   long long now, ans;   char ch[1000039];   int main() {     scanf( %d , &t);     while (t--) {       scanf( %d %s , &m, ch + 1);       n = ans = strlen(ch + 1), now = n - 1;       for (int a = 1; a <= m; a++) {         for (int b = 1, c = n; b < ch[a] -  0 ; b++) {           (ans += now) %= 1000000007;           for (int d = a + 1; d <= c && n < m; d++) {             ch[++n] = ch[d];           }         }         (now *= ch[a] -  0 ) %= 1000000007;         ((--now) += 1000000007) %= 1000000007;       }       printf( %I64d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   int q;   int in[100005], out[100005];   vector<int> g[100005];   long long ans;   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       int u, v;       scanf( %d%d , &u, &v);       if (u < v) swap(u, v);       out[u]++;       in[v]++;       g[v].push_back(u);     }     for (int i = 1; i <= n; i++) ans += 1LL * in[i] * out[i];     printf( %lld n , ans);     scanf( %d , &q);     for (int i = 1; i <= q; i++) {       int x;       scanf( %d , &x);       ans -= 1LL * in[x] * out[x];       out[x] += in[x];       in[x] = 0;       for (int i = 0; i < g[x].size(); i++) {         int v = g[x][i];         ans += out[v] - in[v] - 1;         in[v]++;         out[v]--;         g[v].push_back(x);       }       g[x].clear();       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void c_p_c() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   int32_t main() {     c_p_c();     string str;     getline(cin, str);     vector<long long> vec;     long long z = 1;     for (long long i = 0; i < str.length(); i++) {       if (str[i] ==  1 ) {         z = 0;       } else if (z == 1 && str[i] ==  0 ) {         continue;       }       vec.push_back((long long)str[i] -  0 );     }     long long sig = 1;     long long csz = 0, sz = vec.size();     for (auto ele : vec) {       csz++;       if (sig == 1 && ele == 0) {         sig = 0;         continue;       }       if (sz == csz && sig == 1) {         continue;       }       cout << ele;     }     return 0;   }
#include <bits/stdc++.h>   int arr[500005], st[500005][25], fa[500005][25], bit[500005];   inline int calc(int x, int y) {     if (arr[x] <= arr[y]) return x;     return y;   }   inline int query(int l, int r) {     if (l < 0 || l > r) return 0;     int len = bit[r - l + 1];     return calc(st[l][len], st[r - (1 << len) + 1][len]);   }   int main() {     for (int i = 2; i < 500005; i++) bit[i] = bit[i >> 1] + 1;     int n;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , arr + i);       arr[i + n] = arr[i];     }     for (int i = 0; i < n << 1; i++) {       arr[i] = i - arr[i];       st[i][0] = i;     }     for (int i = 1; i < 22; i++) {       for (int j = 0; j + (1 << i) <= n << 1; j++)         st[j][i] = calc(st[j][i - 1], st[j + (1 << i - 1)][i - 1]);     }     for (int i = 0; i < n << 1; i++) fa[i][0] = query(arr[i], i);     for (int i = 1; i < 20; i++) {       for (int j = 0; j < n << 1; j++) fa[j][i] = fa[fa[j][i - 1]][i - 1];     }     long long ans = 0;     for (int i = n; i < n << 1; i++) {       int x = i;       ans += (arr[i] > i - n + 1) + 1;       for (int j = 19; j >= 0; j--) {         if (arr[fa[x][j]] > i - n + 1) {           x = fa[x][j];           ans += 1 << j;         }       }     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double pi = acos(-1);   struct point {     long double x, y;     point(long double x = 0, long double y = 0) : x(x), y(y) {}     point operator+(const point &o) const { return point(x + o.x, y + o.y); }     point operator-(const point &o) const { return point(x - o.x, y - o.y); }     point &operator+=(const point &o) {       x += o.x, y += o.y;       return *this;     }     point &operator-=(const point &o) {       x -= o.x, y -= o.y;       return *this;     }     long double operator*(const point &o) const { return (x * o.x + y * o.y); }     point operator*(long double c) const { return point(x * c, y * c); }     point &operator*=(long double c) {       x *= c, y *= c;       return *this;     }     long double snorm() { return (x * x + y * y); }   };   point operator*(long double c, point A) { return A * c; }   long double dist(point A, point B) { return sqrt((A - B).snorm()); }   long double dist(point X, point A, point B) {     A -= X, B -= X;     long double t = (A.snorm() - A * B) / (B - A).snorm();     if (t < 0 || t > 1) return sqrt(min(A.snorm(), B.snorm()));     return sqrt((t * (B - A) + A).snorm());   }   int N;   point P, a[100100];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> N >> P.x >> P.y;     cout << fixed << setprecision(10);     int i;     for (i = 1; i <= N; i++) cin >> a[i].x >> a[i].y;     a[N + 1] = a[1];     long double maxd = 0, mind = (1 << 30);     for (i = 1; i <= N; i++) {       maxd = max(maxd, dist(P, a[i]));       mind = min(mind, dist(P, a[i], a[i + 1]));     }     cout << pi * (maxd * maxd - mind * mind) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   const int N = 1e6;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     if (n % 2 == 0) {       cout <<  white n1 2 ;     } else {       cout <<  black n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, flag = 0, i, j;     cin >> a >> b >> c;     for (i = 0; i <= c; i++) {       for (j = 0; j <= c; j++) {         if (a * i + b * j == c) {           flag = 1;           break;         }       }       if (flag == 1) break;     }     if (flag == 1)       cout <<  Yes n ;     else       cout <<  No n ;   }
#include <bits/stdc++.h>   using namespace std;   long long int power(long long int x, long long int y) {     long long int res = 1;     while (y) {       if (y % 2) {         res = (res * x) % 1000000007;       }       y = y >> 1;       x = (x * x) % 1000000007;     }     return res;   }   void solve() {     long long int n;     cin >> n;     long long int ans = 1;     for (long long int i = 0; i < n; i++) {       ans *= 2;     }     ans -= 2;     ans = power(4, ans);     ans *= 6;     ans = ans % 1000000007;     cout << ans <<   n ;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     solve();   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int val, num;   } q[1000005];   char str[1000005];   int len;   void update() {     int len1 = len;     len = 0;     for (int i = 1; i <= len1; i++)       if (q[i].num > 0) {         if (q[i].val == q[len].val)           q[len].num += q[i].num;         else           q[++len] = q[i];       }   }   void work() {     int ans = 0;     while (len > 1) {       ans++;       for (int i = 2; i < len; i++) q[i].num -= 2;       q[1].num--;       q[len].num--;       update();     }     printf( %d n , ans);   }   int main(void) {     scanf( %s , str + 1);     len = strlen(str + 1);     q[0].val = -1;     q[0].num = 0;     for (int i = 1; i <= len; i++) q[i].val = str[i] -  a , q[i].num = 1;     update();     work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     while (scanf( %d%d , &n, &m) == 2) {       map<int, vector<int>> s;       for (int i = 0; i < n; ++i) {         int x;         scanf( %d , &x);         s[x].push_back(i);       }       int flag = 1;       vector<int> ans(m);       for (int i = 0; i < m; ++i) {         int x;         scanf( %d , &x);         if (s.find(x) == s.end()) {           flag = -1;           continue;         }         if (flag != 1) continue;         auto& t = s[x];         if (t.size() == 1)           ans[i] = t[0] + 1;         else           flag = 0;       }       if (flag == -1)         puts( Impossible );       else if (flag == 0)         puts( Ambiguity );       else {         puts( Possible );         for (int i = 0; i < m; ++i) {           printf( %d%c , ans[i],    n [i == m - 1]);         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   int n, m;   vector<pair<long long, int> > v;   vector<int> u[N];   int vis[N];   void dfs(int s) {     if (!vis[s]) {       vis[s] = true;       for (int i = 0; i < u[s].size(); i++) {         dfs(u[s][i]);       }     }   }   int main() {     ios_base ::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n >> m;     long long cnt = 0;     memset(vis, 0, sizeof(vis));     long long x, y;     for (int i = 0; i < n; i++) {       cin >> x;       v.push_back(make_pair(x, i + 1));     }     for (int i = 0; i < m; i++) {       cin >> x >> y;       u[x].push_back(y);       u[y].push_back(x);     }     sort(v.begin(), v.end());     for (int i = 0; i < n; i++) {       if (!vis[v[i].second]) {         dfs(v[i].second);         cnt += v[i].first;       }     }     cout << cnt;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   T max(T a, T b, T c) {     return max(a, max(b, c));   }   template <class T>   T min(T a, T b, T c) {     return min(a, min(b, c));   }   const double PI = 2.0 * acos(0.0);   const int mx[] = {0, 1, 0, -1};   const int my[] = {-1, 0, 1, 0};   int n;   int P[1000050] = {0};   int T[1000050] = {0};   long long F[1000050] = {0};   long long C[1000050] = {0};   long long ans;   map<int, int> S;   map<int, int> R;   void update(long long B[], int x, int value) {     if (x == 0) return;     for (int s = x; s <= n; s += (s & -s)) B[s] += value;   }   long long query(long long B[], int x) {     long long sum = 0;     for (int s = x; s > 0; s -= (s & -s)) sum += B[s];     return sum;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , P + i), S[P[i]]++;     for (map<int, int>::iterator it = S.begin(); it != S.end(); it++)       T[it->second]++;     for (int i = 1; i <= n; i++) update(F, i, T[i] * (i - 1)), update(C, i, T[i]);     ans = 0;     for (int i = n; i >= 1; i--) {       int target = S[P[i]]--, frequency = ++R[P[i]];       update(F, target, -(target - 1));       update(F, target - 1, target - 2);       update(C, target, -1);       update(C, target - 1, 1);       ans += query(F, n) - query(F, frequency) -              (query(C, n) - query(C, frequency)) * (frequency - 1);     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   int64_t f(int64_t a, int64_t b, int64_t c, int64_t l) {     int64_t total = 0;     for (int64_t la = 0ll; la <= l; ++la) {       int64_t x = std::min(a - b - c + la, l - la);       if (x >= 0) total += (x + 1) * (x + 2) / 2ll;     }     return total;   }   int main() {     int64_t a, b, c, l;     std::cin >> a >> b >> c >> l;     int64_t total = (l + 1) * (l + 2) * (l + 3) / 6ll;     total -= f(a, b, c, l);     total -= f(b, a, c, l);     total -= f(c, a, b, l);     std::cout << total <<   n ;     return 0;   }
#include <bits/stdc++.h>   const int MAXN = 1001;   using namespace std;   char s[MAXN + 1], heidi[MAXN + 1];   int main() {     int n, i, poz;     scanf( %s , &s);     n = strlen(s);     i = 0;     poz = 0;     heidi[0] =  h ;     heidi[1] =  e ;     heidi[2] =  i ;     heidi[3] =  d ;     heidi[4] =  i ;     while (i < n && poz < 5) {       if (s[i] == heidi[poz]) poz++;       i++;     }     if (poz == 5)       printf( YES );     else       printf( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int cases;     cin >> cases;     for (int i = 0; i < cases; i++) {       int a, b;       cin >> a >> b;       if (a > b) swap(a, b);       int dis = b - a;       if (dis == 0)         cout << 0 <<   n ;       else if (dis == 1)         cout << 1 <<   n ;       else {         long long int ans = 1;         while (true) {           long long int sum = (ans * (ans + 1)) / 2;           if (sum >= dis) {             if (sum % 2 == dis % 2) break;           }           ans++;         }         cout << ans <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (!b) return a;     return gcd(b, a % b);   }   int main() {     int k;     cin >> k;     long long a;     while (k--) {       cin >> a;       long long g = gcd(a + 1, a * 4);       long long l = (a + 1) * a * 4 / g;       cout << l / (a + 1) + 1 <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char const *argv[]) {     int n, m, xa = 55, xb = -1, ya = 55, yb = -1;     char g[50][50];     cin >> n >> m;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         cin >> g[i][j];         if (g[i][j] ==  * ) {           xa = min(i, xa);           ya = min(j, ya);           xb = max(i, xb);           yb = max(j, yb);         }       }     }     for (int i = xa; i <= xb; i++) {       for (int j = ya; j <= yb; j++) {         cout << g[i][j];       }       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int i, j;     int k, n, s, p;     cin >> k >> n >> s >> p;     cout << int(ceil((ceil(n / (s * 1.0)) * k) / (p * 1.0)));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   char c[3001][3001];   int d[3001][3001];   long long dp(int sx, int sy, int ex, int ey) {     memset(d, 0, sizeof(d));     if (c[sx][sy] !=  # ) d[sx][sy] = 1;     for (int i = sx; i < n; i++) {       for (int j = sy; j < m; j++) {         if (d[i][j] > 0) {           if (i + 1 < n && c[i + 1][j] !=  # ) {             d[i + 1][j] += d[i][j];             if (d[i + 1][j] >= 1000000007) d[i + 1][j] -= 1000000007;           }           if (j + 1 < m && c[i][j + 1] !=  # ) {             d[i][j + 1] += d[i][j];             if (d[i][j + 1] >= 1000000007) d[i][j + 1] -= 1000000007;           }         }       }     }     return d[ex][ey];   }   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> c[i];     }     long long a = dp(0, 1, n - 2, m - 1), b = dp(0, 1, n - 1, m - 2),               c = dp(1, 0, n - 2, m - 1), d = dp(1, 0, n - 1, m - 2);     cout << ((a * d - b * c) % 1000000007 + 1000000007) % 1000000007 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, ans = 0;     long long sum_a = 0, sum_b = 0;     cin >> n;     vector<int> a(n);     for (int i = 0; i < n; ++i) {       cin >> a[i];       sum_a += a[i];     }     cin >> m;     vector<int> b(m);     for (int i = 0; i < m; ++i) {       cin >> b[i];       sum_b += b[i];     }     int i = 0, j = 0;     if (sum_a != sum_b) {       cout << -1;       return 0;     } else {       sum_a = a[0];       sum_b = b[0];       while (j < m && i < n) {         if (sum_a > sum_b) {           j++;           sum_b += b[j];         } else if (sum_a < sum_b) {           i++;           sum_a += a[i];         } else {           ans++;           i++;           j++;           sum_a = a[i];           sum_b = b[j];         }       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int ar[10000];   int main() {     int n, m, i, j, x = 0;     cin >> n >> m;     char a[n][2 * m];     for (i = 0; i < n; i++) {       for (j = 0; j < 2 * m; j++) cin >> a[i][j];     }     for (i = 0; i < n; i++) {       for (j = 0; j < 2 * m; j = j + 2) {         if (a[i][j] ==  1  || a[i][j + 1] ==  1 ) x++;       }     }     cout << x << endl;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {}   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string s, q;     cin >> s >> q;     int index = 1;     for (int i = 0; i < q.size(); i++) {       if (s[index - 1] == q[i]) index++;     }     cout << index <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, s, C[1001][2001];   int main() {     for (int i = 0; i <= 1000; i++) {       C[i][0] = C[i][i] = 1;       for (int j = 1; j < i; j++)         C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % 1000000007;     }     scanf( %d%d%d , &n, &m, &s);     printf( %d n , int(C[n - 1][2 * s] * 1ll * C[m - 1][2 * s] % 1000000007));   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 5;   long long a[maxn], b[maxn];   int n;   long long ans;   inline long long read() {     long long ans = 0;     char ch = getchar();     while (ch <  0  || ch >  9 ) ch = getchar();     while (ch >=  0  && ch <=  9 ) {       ans = ans * 10 + ch -  0 ;       ch = getchar();     }     return ans;   }   long long solve(long long mod) {     long long sol = 0;     int i;     for (i = 0; i < n; i++) b[i] = a[i] % mod;     for (i = 0; i < n; i++) {       sol += min(b[i], mod - b[i]);       if (sol > ans) break;       b[i + 1] = (b[i + 1] + b[i]) % mod;     }     return sol;   }   int main() {     int i;     long long tot;     n = read();     tot = 0;     for (i = 0; i < n; i++) tot += (a[i] = read());     if (tot == 1) {       puts( -1 );       return 0;     }     ans = 1e18;     for (i = 2; 1LL * i * i <= tot; i++)       if (tot % i == 0) {         ans = min(ans, solve(i));         while (tot % i == 0) tot /= i;       }     if (tot > 1) ans = min(ans, solve(tot));     printf( %lld n , ans);     return 0;   }