malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, m, s, t, d[200005], v[200005], dd[200005], ma[1005][1005], ok = 1, y,                                                                     ans;   int main() {     scanf( %d%d%d%d , &n, &m, &s, &t);     for (int i = 1; i <= m; i++) {       int x, y;       scanf( %d%d , &x, &y);       ma[x][y] = ma[y][x] = 1;     }     for (int i = 1; i <= n; i++) d[i] = 1000000000, v[i] = 0;     d[s] = 0;     for (int i = 1; i <= n; i++) {       int minv = 1000000000, u;       for (int j = 1; j <= n; j++)         if (!v[j] && d[j] < minv) {           minv = d[j];           u = j;         }       v[u] = 1;       for (int k = 1; k <= n; k++)         if (!v[k] && ma[u][k] && d[u] + ma[u][k] < d[k]) d[k] = d[u] + ma[u][k];     }     for (int i = 1; i <= n; i++) dd[i] = 1000000000, v[i] = 0;     dd[t] = 0;     for (int i = 1; i <= n; i++) {       int minv = 1000000000, u;       for (int j = 1; j <= n; j++)         if (!v[j] && dd[j] < minv) {           minv = dd[j];           u = j;         }       v[u] = 1;       for (int k = 1; k <= n; k++)         if (!v[k] && ma[u][k] && dd[u] + ma[u][k] < dd[k])           dd[k] = dd[u] + ma[u][k];     }     for (int i = 1; i < n; i++)       for (int j = i + 1; j <= n; j++)         if (!ma[i][j]) {           if (d[i] + dd[j] + 1 >= d[t] && d[j] + dd[i] + 1 >= d[t]) {             ans++;           }         }     printf( %d , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 7;   struct note {     int x, id;   } q[maxn];   int st[maxn][20], st1[maxn][20], a[maxn], n, dp[maxn];   int head, tail;   void init(int n) {     for (int i = 1; i <= n; i++) st1[i][0] = st[i][0] = a[i];     for (int j = 1; j < 20; j++)       for (int i = 1; i <= n; i++)         if (i + (1 << (j - 1)) <= n)           st[i][j] = min(st[i][j - 1], st[i + (1 << (j - 1))][j - 1]),           st1[i][j] = max(st1[i][j - 1], st1[i + (1 << (j - 1))][j - 1]);   }   int query(int l, int r) {     int len = log2(r - l + 1);     return max(st1[l][len], st1[r - (1 << len) + 1][len]) -            min(st[l][len], st[r - (1 << len) + 1][len]);   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int s, len;     cin >> n >> s >> len;     for (int i = 1; i <= n; i++) cin >> a[i];     init(n);     int l, r, ans;     if (len > n || query(1, len) > s) return cout << -1 << endl, 0;     memset(dp, 0x3f3f3f3f, sizeof(dp));     dp[0] = 0;     q[tail].id = 0, q[tail].x = 0, tail++;     dp[len] = 1;     for (int i = len + 1; i <= n; i++) {       l = 1, r = i - len + 1, ans = -1;       while (l <= r) {         int mid = (l + r) >> 1;         if (query(mid, i) <= s)           r = mid - 1, ans = mid;         else           l = mid + 1;       }       while (head < tail && q[tail - 1].x >= dp[i - len]) tail--;       q[tail].x = dp[i - len], q[tail].id = i - len, tail++;       if (ans != -1) {         while (head < tail && q[head].id < ans - 1) head++;         if (head < tail) dp[i] = min(dp[i], q[head].x + 1);       }     }     if (dp[n] == 0x3f3f3f3f) dp[n] = -1;     cout << dp[n] << endl;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-8;   const int MAXN = 1e2 + 5;   const long long MOD = 1e9 + 7;   int a[1005][3000];   int main() {     int n, s, d;     int maxx = 0;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> s >> d;       for (int j = s; j <= 100000000; j += d) {         if (j > maxx) {           maxx = j;           break;         }       }     }     cout << maxx << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 210003;   double a[N], b[N];   int n;   double checkMa(double x) {     for (int i = 1; i <= n; i++) b[i] = a[i] - x;     double ans = 0, tpans = 0;     for (int i = 1; i <= n; i++) {       tpans += b[i];       if (tpans < 0) tpans = 0;       ans = max(ans, tpans);     }     for (int i = 1; i <= n; i++) b[i] = -b[i];     tpans = 0;     for (int i = 1; i <= n; i++) {       tpans += b[i];       if (tpans < 0) tpans = 0;       ans = max(ans, tpans);     }     return ans;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %lf , &a[i]);     }     double r = 10005, l = -10005;     int times = 100;     while (fabs(r - l) > 1e-13 && times) {       times--;       if (times <= 0) break;       double lm = (2.0 * l + r) / 3.0;       double rm = (2.0 * r + l) / 3.0;       if (checkMa(lm) < checkMa(rm)) {         r = rm;       } else         l = lm;     }     printf( %.10f n , checkMa(l));     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O2 )   using namespace std;   const int MAX = 2e6 + 5;   const long long MAX2 = 11;   const int MOD = 1000000000 + 7;   const long long INF = 2e18;   const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1, 0};   const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1, 0};   const double pi = acos(-1);   const double EPS = 1e-9;   int n, k, x, nw, sz, p[MAX], mx;   string s;   char y[MAX];   int par(int z) {     if (p[z] == z) return z;     return p[z] = par(p[z]);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     for (int i = 1; i <= 2000001; i++) p[i] = i;     cin >> n;     while (n--) {       cin >> s >> k;       sz = s.size() - 1;       while (k--) {         cin >> x;         nw = x;         while (nw <= x + sz) {           y[nw] = s[nw - x];           nw = p[nw] = par(nw + 1);         }         mx = max(mx, x + sz);       }     }     for (int i = 1; i <= mx; i++)       if (y[i])         cout << (char)y[i];       else         cout <<  a ;     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);     putchar(  n );   }   void writep(long long x) {     write(x);     putchar(   );   }   long long const N = 1e6 + 3;   long long n, a[N];   signed main() {     n = read();     long long ans = 0;     for (long long i = 1; i <= n; i++) a[i] = read(), ans += a[i];     if (n == 1) {       writeln(a[1]);       return 0;     }     sort(a + 1, a + n + 1);     if (a[1] <= 0) {       for (long long i = 1; i < n && a[i] <= 0; i++) ans -= 2 * a[i];     } else {       ans -= 2 * a[1];     }     writeln(ans);   }
#include <bits/stdc++.h>   using namespace std;   long long a[2005], b[2005], pos;   int n, m;   inline long long mabs(long long x) { return x > 0 ? x : -x; }   inline bool judge(long long x) {     int p = 1;     for (int i = 1; i <= n; i++) {       while (p <= m && mabs(b[p] - a[i]) + mabs(b[p] - pos) > x) p++;       if (p > m) return false;       p++;     }     return true;   }   int main() {     scanf( %d%d%I64d , &n, &m, &pos);     for (int i = 1; i <= n; i++) scanf( %I64d , &a[i]);     for (int i = 1; i <= m; i++) scanf( %I64d , &b[i]);     sort(a + 1, a + n + 1);     sort(b + 1, b + m + 1);     long long l = 0, r = 3e9, ans = 3e9;     while (l <= r) {       long long mid = (l + r) >> 1;       if (judge(mid)) {         ans = min(ans, mid);         r = mid - 1;       } else         l = mid + 1;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   int n, cnt, sum, len, tlen, tcnt;   int a[26], ans[N], tans[N], id[26], pos[N], tpos[N];   void work1() {     printf( 0 n );     for (int i = 0; i < n; i++)       for (int j = 1; j <= a[i]; j++) printf( %c ,  a  + i);   }   bool cmp(int x, int y) { return a[x] > a[y]; }   int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }   int t, d;   void work(int x, int y) {     int j = 0;     tcnt = tlen = 0;     for (int i = x; i <= cnt; i += x) {       while (j + 1 <= pos[i]) {         j++;         tans[++tlen] = ans[j];       }       if (i % (2 * x) == 0) {         for (int l = 1; l <= y; l++) tans[++tlen] = t;         tpos[++tcnt] = tlen;         for (int l = 1; l <= y; l++) tans[++tlen] = t;       } else         tpos[++tcnt] = tlen;     }     while (j < len) tans[++tlen] = ans[++j];     cnt = tcnt;     for (int i = 1; i <= cnt; i++) pos[i] = tpos[i];     len = tlen;     for (int i = 1; i <= len; i++) ans[i] = tans[i];   }   void work2(int x, int y) {     int j = 0;     tlen = 0;     for (int i = x; i <= cnt; i += x) {       while (j + 1 <= pos[i]) {         j++;         tans[++tlen] = ans[j];       }       for (int l = 1; l <= y; l++) tans[++tlen] = t;     }     while (j < len) tans[++tlen] = ans[++j];     len = tlen;     for (int i = 1; i <= len; i++) ans[i] = tans[i];   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++)       scanf( %d , &a[i]), cnt += a[i] & 1, sum += a[i], id[i] = i;     if (cnt > 1) {       work1();       return 0;     }     sort(id, id + n);     cnt = 0;     for (int i = 0; i < n; i++) {       t = id[i];       if (a[t] & 1) continue;       if (len == 0) {         len = a[t];         cnt = len;         for (int i = 1; i <= len; i++) ans[i] = t, pos[i] = i;         continue;       }       d = gcd(cnt, a[t]);       work(cnt / d, a[t] / d);     }     for (int i = 0; i < n; i++)       if (a[id[i]] & 1) {         t = id[i];         if (len == 0) {           len = a[t];           cnt = len;           for (int i = 1; i <= len; i++) ans[i] = t, pos[i] = i;           continue;         }         d = gcd(cnt, a[t]);         work2(cnt / d, a[t] / d);         cnt = d;       }     printf( %d n , cnt);     for (int i = 1; i <= len; i++) printf( %c ,  a  + ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int OO = 1e9;   const long long INF = 1e18;   const int irand(int lo, int hi) {     return ((double)rand() / (RAND_MAX + 1.0)) * (hi - lo + 1) + lo;   }   const long long lrand(long long lo, long long hi) {     return ((double)rand() / (RAND_MAX + 1.0)) * (hi - lo + 1) + lo;   }   template <typename T>   T getnum() {     int sign = 1;     T ret = 0;     char c;     do {       c = getchar();     } while (c ==     || c ==   n );     if (c ==  - )       sign = -1;     else       ret = c -  0 ;     while (1) {       c = getchar();       if (c <  0  || c >  9 ) break;       ret = 10 * ret + c -  0 ;     }     return sign * ret;   }   inline void ini(int& x) { x = getnum<int>(); }   inline void scani(int& x) { scanf( %d , &x); }   const int N = 1e5 + 5;   int n;   int a[N], b[N];   long long ans = 0;   vector<pair<int, int> > ins;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cout.setf(ios::fixed);     cout.setf(ios::showpoint);     cout.precision(10);     cin >> n;     string str;     cin >> str;     for (int i = 0; i < n; i++) {       a[i + 1] = str[i] -  0 ;     }     cin >> str;     for (int i = 0; i < n; i++) {       b[i + 1] = str[i] -  0 ;     }     int difa = 0, difb = 0;     for (int i = 1; i <= n; i += 1) {       if (i & 1) {         difa += a[i];         difb += b[i];       } else {         difa -= a[i];         difb -= b[i];       }     }     if (difa != difb) {       cout << -1 <<   n ;       return 0;     }     int f = 2;     for (int i = 1; i <= n - 1; i += 1) {       if (f == i) f++;       while (a[i] > b[i]) {         a[i]--;         while (1) {           assert(f <= n);           if ((f - i) & 1) {             if (a[f] == 0) {               f++;             } else {               a[f]--;               break;             }           } else {             if (a[f] == 9) {               f++;             } else {               a[f]++;               break;             }           }         }         ans += f - i;         if (ins.size() < 100000) {           for (int j = f - 1; j >= i; j -= 1) {             if ((j - i) & 1) {               ins.push_back({j, 1});             } else {               ins.push_back({j, -1});             }           }         }       }       while (a[i] < b[i]) {         a[i]++;         while (1) {           assert(f <= n);           if ((f - i) & 1) {             if (a[f] == 9) {               f++;             } else {               a[f]++;               break;             }           } else {             if (a[f] == 0) {               f++;             } else {               a[f]--;               break;             }           }         }         ans += f - i;         if (ins.size() < 100000) {           for (int j = f - 1; j >= i; j -= 1) {             if ((j - i) & 1) {               ins.push_back({j, -1});             } else {               ins.push_back({j, 1});             }           }         }       }     }     cout << ans <<   n ;     for (int i = 0; i < min(100000, (int)ins.size()); i++) {       cout << ins[i].first <<     << ins[i].second <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[100004];   long long d[100004];   int main() {     int n;     scanf( %d , &n);     a[0] = 0;     long long b = 0, c = 0;     for (int i = 1; i <= n; ++i) {       scanf( %lld , &a[i]);       d[i] = a[i] - a[i - 1];       if (d[i] > 0) b += d[i];     }     if (d[1] < 0) c = d[1];     printf( %lld n , (c + b > 0 ? (c + b + 1) / 2 : (c + b) / 2));     int q;     cin >> q;     while (q--) {       int l, r, x;       scanf( %d%d%d , &l, &r, &x);       if (d[l] > 0) b -= d[l];       d[l] += x;       if (d[l] > 0) b += d[l];       d[l] -= x;       if (r < n) {         if (d[r + 1] > 0) b -= d[r + 1];         d[r + 1] -= x;         if (d[r + 1] > 0) b += d[r + 1];         d[r + 1] += x;       }       if (l == 1) {         if (d[1] < 0) c -= d[1];         d[l] += x;         if (d[1] < 0) c += d[1];         d[l] -= x;       }       d[l] += x;       d[r + 1] -= x;       printf( %lld n , (c + b > 0 ? (c + b + 1) / 2 : (c + b) / 2));     }   }
#include <bits/stdc++.h>   using namespace std;   int a[105];   bool b[105][105];   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < m; i++) {       int u, v;       cin >> u >> v;       u--;       v--;       b[u][v] = b[v][u] = true;     }     int ans = -1;     for (int i = 0; i < n; i++)       for (int j = i + 1; j < n; j++)         for (int k = j + 1; k < n; k++)           if (b[i][j] && b[i][k] && b[j][k]) {             if (ans == -1 || a[i] + a[j] + a[k] < ans) ans = a[i] + a[j] + a[k];           }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int solve() {     int n, x;     cin >> n >> x;     vector<int> a(n);     vector<int> index;     for (int(i) = 0; (i) < n; (i)++) {       cin >> a[i];       if (a[i] % x != 0) index.push_back(i);     }     if (index.size() == 0) {       cout <<  -1 n ;       return 0;     }     int s = 0;     for (int(i) = 0; (i) < index.size(); (i)++) {       s += a[index[i]];     }     if (s % x != 0) {       cout << n <<   n ;       return 0;     }     int rez = n;     int q = 0, w = index.size() - 1;     int i = index[0], j = index[index.size() - 1];     while (s % x == 0) {       if (i + 1 < n - j) {         s -= a[i];         rez -= i + 1;         q++;         i = index[q];       } else {         s -= a[j];         rez -= n - j;         w--;         j = index[w];       }     }     cout << rez <<   n ;     return 0;   }   int main() {     int t = 1;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   const int N = 1e5 + 10;   const int MOD = 1e9 + 7;   const int INF = 2e9;   const long long INFLL = 1e18;   const double PI = acos((double)-1);   inline int mult(int a, int b, int p = MOD) { return (1ll * a * b) % p; }   inline int add(int a, int b, int p = MOD) { return (1ll * a + b) % p; }   inline int fpow(long long n, long long k, int p = MOD) {     long long r = 1;     for (; k; k >>= 1) {       if (k & 1) r = r * n % p;       n = n * n % p;     }     return r;   }   inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }   using namespace std;   int s, x1, x2, t1, t2, p, ok;   int f[10000][2];   bool d;   int main() {     ios::sync_with_stdio(false);     cin >> s >> x1 >> x2;     cin >> t1 >> t2;     cin >> p >> ok;     if (ok == -1)       d = 0;     else       d = 1;     int ans = abs(x2 - x1) * t2;     f[p][d] = 0;     if (d == 0) {       for (int i = p - 1; i >= 0; i--) f[i][d] = f[i + 1][d] + t1;       f[0][!d] = f[0][d];       d = !d;       for (int i = 1; i <= s; i++) f[i][d] = f[i - 1][d] + t1;       f[s][!d] = f[s][d];       d = !d;       for (int i = s - 1; i > p; i--) f[i][d] = f[i + 1][d] + t1;     } else {       for (int i = p + 1; i <= s; i++) f[i][d] = f[i - 1][d] + t1;       f[s][!d] = f[s][d];       d = !d;       for (int i = s - 1; i >= 0; i--) f[i][d] = f[i + 1][d] + t1;       f[0][!d] = f[0][d];       d = !d;       for (int i = 1; i < p; i++) f[i][d] = f[i - 1][d] + t1;     }     if (x1 > x2) {       for (int i = x2 + 1; i <= x1; i++) {         if (f[i][0] < (x1 - i) * t2) f[i][0] += s * 2 * t1;         int x = (i - x2) * t1 + f[i][0];         ans = min(ans, x);       }     } else {       for (int i = x2 - 1; i >= x1; i--) {         if (f[i][1] < (i - x1) * t2) f[i][1] += s * 2 * t1;         int x = (x2 - i) * t1 + f[i][1];         ans = min(ans, x);       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   template <typename T>   bool Chkmin(T &x, T y) {     return y < x ? x = y, true : false;   }   template <typename T>   bool Chkmax(T &x, T y) {     return y > x ? x = y, true : false;   }   const int MAXN = 1e6 + 1e3, MAXM = MAXN, oo = 0x3f3f3f3f;   int n, m, tote, S, T;   int head[MAXN], next[MAXM], to[MAXM], dp[MAXN], out[MAXN], pos[MAXN], cur[MAXN];   void AddEdge(int u, int v) {     to[++tote] = v;     next[tote] = head[u];     head[u] = tote;   }   void Init() {     int u, v;     scanf( %d%d , &n, &m);     for (int i = 1, _ = m; i <= _; i++) {       scanf( %d%d , &u, &v);       AddEdge(v, u);       out[u]++;     }     scanf( %d%d , &S, &T);   }   void Solve() {     int u, v, num;     std::deque<int> q, p;     q.push_front(T);     p.push_front(++cur[T]);     memset(dp, 0x3f, sizeof(dp));     dp[T] = 0;     while (!q.empty()) {       u = q.front();       q.pop_front();       num = p.front();       p.pop_front();       if (num != cur[u]) continue;       for (int i = head[u]; i; i = next[i]) {         v = to[i];         out[v]--;         if (out[v] == 0) {           if (Chkmin(dp[v], dp[u])) {             q.push_front(v);             p.push_front(++cur[v]);           }         } else {           if (Chkmin(dp[v], dp[u] + 1)) {             q.push_back(v);             p.push_front(++cur[v]);           }         }       }     }   }   int main() {     Init();     Solve();     if (dp[S] == oo) dp[S] = -1;     printf( %d n , dp[S]);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100001;   int L, n, p, t;   int dp[N], f[N];   int main() {     scanf( %d%d%d%d , &L, &n, &p, &t);     f[0] = -t;     for (int i = 1, j = 0; i <= n; i++, j--) {       int l, r;       scanf( %d%d , &l, &r);       f[i] = f[i - 1];       dp[i] = dp[i - 1];       while (j < i && f[j] + t <= r) {         int x = max(f[j] + t, l), y = dp[j] + (r - x) / p, z = r - (r - x) % p;         if (y > dp[i] || (y == dp[i] && z < f[i])) dp[i] = y, f[i] = z;         j++;       }     }     printf( %d , dp[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long arr[1002][2][102];   long long p10[1002];   long long n, m, k;   long long ans = 0;   void pree() {     p10[0] = 1;     for (long long i = 1; i <= n; ++i) {       p10[i] = p10[i - 1] * 10LL;       p10[i] %= k;     }   }   void solve() {     pree();     arr[0][0][0] = 1;     long long i, j;     long long p;     long long ti;     long long ti2;     for (i = 1; i <= n; ++i) {       for (j = 1; j < k; ++j) {         arr[i][0][j] = (arr[i - 1][1][j] + arr[i - 1][0][j]) % m;       }       arr[i][0][0] = arr[i - 1][0][0];       for (j = 1; j <= 9; ++j) {         ti = j * p10[i - 1];         ti %= k;         for (p = 1; p < k; ++p) {           ti2 = (p + ti) % k;           arr[i][1][ti2] += arr[i - 1][1][p] + arr[i - 1][0][p];           arr[i][1][ti2] %= m;         }         ti2 = ti;         arr[i][1][ti2] += arr[i - 1][0][0];         arr[i][1][ti2] %= m;       }     }     ans = arr[n][1][0];     ti = 9;     ti %= m;     for (i = n - 1; i > 0; --i) {       ans += ti * arr[i][1][0];       ans %= m;       ti *= 10;       ti %= m;     }   }   void MAIN() {     scanf( %I64d %I64d %I64d , &n, &k, &m);     solve();     printf( %I64d n , ans);   }   int main() {     MAIN();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int m;     cin >> m;     set<int> q;     for (int i = 0; i < n; ++i) {       int k;       cin >> k;       for (int j = 0; j < k; ++j) {         int x;         cin >> x;         q.insert(x);       }     }     cout << ((q.size() == m) ?  YES  :  NO ) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k;     cin >> n >> k;     pair<int, int> ar[k];     for (long long i = 0; i < k; i++) {       cin >> ar[i].first >> ar[i].second;     }     set<long long> X, Y;     long long atk, safe;     for (int i = 0; i < k; i++) {       X.insert(ar[i].first);       Y.insert(ar[i].second);       atk = 1ll * X.size() * n + 1ll * Y.size() * n -             1ll * X.size() * 1ll * Y.size();       safe = n * n - atk;       cout << safe <<    ;     }     return 0;   }
#include <bits/stdc++.h>   void answer(const std::vector<std::vector<std::string>>& v) {     for (const auto& r : v) {       const char* separator =   ;       for (const std::string& x : r) {         std::cout << separator << x;         separator =    ;       }       std::cout <<   n ;     }   }   void solve(unsigned k) {     const size_t n = k - 1;     std::vector<std::vector<std::string>> t(n, std::vector<std::string>(n));     for (size_t i = 0; i < n; ++i) {       for (size_t j = 0; j < n; ++j) {         unsigned c = (i + 1) * (j + 1);         do {           t[i][j].push_back( 0  + c % k);           c /= k;         } while (c != 0);         std::reverse(t[i][j].begin(), t[i][j].end());       }     }     answer(t);   }   int main() {     unsigned k;     std::cin >> k;     solve(k);     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, m, h, sum = 0, i;     int s[1000];     double d = 1;     scanf( %d %d %d , &n, &m, &h);     for (i = 0; i < m; i++) {       scanf( %d , &s[i]);       sum += s[i];     }     if (sum < n) {       puts( -1.0 n );       return 0;     }     if (sum - s[h - 1] < n - 1) {       puts( 1.0 n );       return 0;     }     for (i = 0; i < n - 1; i++) {       d *= (double)(sum - s[h - 1] - i) / (sum - i - 1);     }     printf( %.9lf n , 1 - d);     return 0;   }