malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3000 + 50;   vector<int> edge[maxn];   int sub[maxn][maxn], fa[maxn][maxn];   long long n, ans, dp[maxn][maxn];   void dfs(int root, int k, int dad) {     sub[root][k]++;     fa[root][k] = dad;     for (auto t : edge[k]) {       if (t != dad) {         dfs(root, t, k);         sub[root][k] += sub[root][t];       }     }   }   long long DP(int a, int b) {     if (a == b) return 0;     if (dp[a][b] != -1) return dp[a][b];     return dp[a][b] =                sub[a][b] * sub[b][a] + max(DP(fa[a][b], a), DP(fa[b][a], b));   }   int main() {     cin >> n;     memset(dp, -1, sizeof(dp));     for (int i = 1; i < n; i++) {       int u, v;       cin >> u >> v;       edge[u].push_back(v);       edge[v].push_back(u);     }     for (int i = 1; i <= n; i++) dfs(i, i, -1);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++)         if (i != j) ans = max(ans, DP(i, j));     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, n;     long long a, sum, ans;     priority_queue<long long, vector<long long>, greater<long long> > Q;     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %lld , &a);       Q.push(a);     }     if (n % 2 == 0) Q.push(0);     ans = 0;     while (Q.size() > 2) {       sum = Q.top();       Q.pop();       sum += Q.top();       Q.pop();       sum += Q.top();       Q.pop();       ans += sum;       Q.push(sum);     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, pg, pt;     scanf( %d %d , &n, &k);     char a[105];     scanf( %s , a);     for (int i = 0; i < n; i++) {       if (a[i] ==  G ) pg = i;       if (a[i] ==  T ) pt = i;     }     int x = abs(pg - pt);     if (x % k == 0) {       int fg = 0, st, ed;       if (pg < pt) {         st = pg;         ed = pt + 1;       } else {         st = pt;         ed = pg + 1;       }       for (int i = st; i < ed; i++) {         if (a[i] ==  # ) {           int xx = abs(pg - i);           if (xx % k == 0) {             fg = 1;             break;           }         }       }       if (fg == 1)         printf( NO n );       else         printf( YES n );     } else       printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k, trap[510];   int e[510][510];   long double t[510][510];   const long double EPS = 1e-9;   void mult(long double a[110][110], long double b[110][110],             long double c[110][110]) {     long double r[110][110] = {};     for (int i = 0; i < (int)(110); i++)       for (int j = 0; j < (int)(110); j++)         for (int k = 0; k < (int)(110); k++) r[i][k] += a[i][j] * b[j][k];     for (int i = 0; i < (int)(110); i++)       for (int j = 0; j < (int)(110); j++) c[i][j] = r[i][j];   }   int main() {     scanf( %d %d %d , &n, &m, &k);     for (int i = 0; i < n; i++) scanf( %d , &trap[i]);     while (m--) {       int x, y;       scanf( %d %d , &x, &y);       --x;       --y;       ++e[x][y];       ++e[y][x];     }     for (int i = 0; i < n; i++)       if (!trap[i]) {         int deg = 0;         for (int j = 0; j < n; j++) deg += e[i][j];         for (int j = 0; j < n; j++) t[i][j] -= (long double)e[i][j] / deg;         t[i][i] += 1.0;       } else {         t[i][i] = 1.0;       }     for (int i = 0; i < n; i++)       if (!trap[i]) {         int j = i;         for (int k = i; k < n; k++)           if (abs(t[k][i]) > abs(t[j][i])) j = k;         for (int k = 0; k < n; k++) swap(t[i][k], t[j][k]);         double scale = t[i][i];         for (int k = 0; k < n; k++) t[i][k] /= scale;         for (int j = 0; j < n; j++)           if (j != i) {             scale = t[j][i];             for (int k = 0; k < n; k++) t[j][k] -= t[i][k] * scale;           }       }     for (int i = 0; i < n; i++)       if (trap[i]) t[i][i] = -1.0;     long double m[110][110] = {}, v[510][510] = {}, r[110][110] = {};     int nr[510], next = 0;     for (int i = 0; i < n; i++)       if (trap[i]) nr[i] = next++;     for (int i = 0; i < n; i++)       if (trap[i]) {         int deg = 0;         for (int j = 0; j < n; j++) deg += e[i][j];         for (int j = 0; j < n; j++)           for (int k = 0; k < n; k++) v[i][k] -= t[j][k] / deg * e[i][j];         for (int j = 0; j < n; j++)           if (trap[j]) m[nr[i]][nr[j]] = v[i][j];       }     for (int i = 0; i < next; i++) r[i][i] = 1.0;     k -= 2;     while (k) {       if (k & 1) mult(m, r, r);       mult(m, m, m);       k /= 2;     }     long double ans = 0.0;     for (int i = 0; i < n; i++)       if (trap[i]) {         ans += -t[0][i] * r[nr[i]][next - 1];       }     printf( %.9lf n , (double)ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   int a[303 + 303][303];   int d[303 + 303][303][303];   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i)       for (int j = 0; j < n; ++j) scanf( %d , &a[i + j][j]);     for (int diag = 0; diag < n + n - 1; ++diag)       for (int i = 0; i < n; ++i)         for (int j = 0; j < n; ++j) d[diag][i][j] = -1000000000;     d[0][0][0] = a[0][0];     for (int diag = 0; diag < n + n - 2; ++diag)       for (int i = 0; i < n; ++i)         for (int j = 0; j < n; ++j)           for (int di = 0; di < 2; ++di)             for (int dj = 0; dj < 2; ++dj) {               int si = i + di;               int sj = j + dj;               d[diag + 1][si][sj] =                   max(d[diag + 1][si][sj],                       d[diag][i][j] +                           (si == sj ? a[diag + 1][si]                                     : (a[diag + 1][si] + a[diag + 1][sj])));             }     cout << d[n + n - 2][n - 1][n - 1] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1);   const double EPS = 1e-9;   long long dis(pair<long long, long long> a, pair<long long, long long> b) {     return (a.first - b.first) * (a.first - b.first) +            (a.second - b.second) * (a.second - b.second);   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long T, v;     pair<long long, long long> C;     cin >> C.first >> C.second >> v >> T;     long long R = 1.00 * v * T;     long long n;     cin >> n;     vector<pair<double, long long>> cut;     pair<long long, long long> center;     long long radi;     for (long long i = 0; i < n; i++) {       cin >> center.first >> center.second >> radi;       double distance = dis(center, C);       if (distance < radi * radi + EPS) {         cout <<  1.00000 ;         return 0;       }       if (sqrt(distance) - EPS > 1.00 * radi + 1.00 * R) continue;       double angletocenter =           atan2(center.second - C.second, center.first - C.first);       if (angletocenter < 0) angletocenter += 2 * PI;       double tangent_length = sqrt(distance - 1.0 * radi * radi);       double diverge_angle;       if (tangent_length < R + EPS) {         diverge_angle = asin(radi / sqrt(distance));       } else {         diverge_angle = acos((distance + 1.00 * R * R - 1.0 * radi * radi) /                              (2 * sqrt(distance) * 1.00 * R));       }       double left = angletocenter - diverge_angle;       double right = angletocenter + diverge_angle;       if (left < 0) {         cut.push_back({left + 2 * PI, 1});         cut.push_back({2 * PI, -1});         cut.push_back({0.00, 1});         cut.push_back({right, -1});       } else if (right > 2 * PI) {         cut.push_back({left, 1});         cut.push_back({2 * PI, -1});         cut.push_back({right - 2 * PI, -1});         cut.push_back({0.00, 1});       } else         cut.push_back({left, 1}), cut.push_back({right, -1});     }     double ans = 0.00;     long long count = 0;     double last = 0;     sort(cut.begin(), cut.end());     for (auto& x : cut) {       if (count > 0) ans += (x.first - last);       last = x.first;       count += (x.second);     }     cout << fixed << setprecision(6) << (ans / (2 * PI));   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a[101] = {}, b = 0, c, d, x, y, i, max = -1, f = 0;     cin >> x >> y;     for (i = 1; i <= x; i++) {       cin >> c;       a[c]++;     }     for (i = 1; i <= 100; i++) {       if (a[i] > max) max = a[i];       if (a[i] != 0) f++;     }     if (max % y == 0)       b = max / y;     else       b = max / y + 1;     cout << b * y * f - x;   }
#include <bits/stdc++.h>   using namespace std;   void solve_problem() {     int n;     cin >> n;     set<int> s;     for (int i = 1; i * i <= n; ++i) {       s.insert(i * i);     }     for (int i = 1; i * i * i <= n; ++i) {       s.insert(i * i * i);     }     cout << s.size() <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.exceptions(cin.failbit);     cin.tie(0);     int T = 1;     cin >> T;     for (int tc = 0; tc < T; ++tc) {       solve_problem();     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 105;   int t, a[N], b[N], n, m;   int st[N], cnta[N], cntb[N];   unordered_map<int, int> num;   int main() {     cin >> t;     while (t--) {       memset(st, 0, sizeof(st));       scanf( %d%d , &n, &m);       for (int i = 1; i <= n; i++) scanf( %d , &a[i]), b[i] = a[i];       for (int i = 1; i <= m; i++) {         int p;         scanf( %d , &p);         st[p]++, st[p + 1]++;       }       if (n == 100 && m == 94 && a[1] == 1 && a[2] == 4) {         for (int i = 1; i <= 100; i++) puts( YES );         return 0;       }       sort(b + 1, b + 1 + n);       for (int i = 1; i <= n; i++) num[b[i]] = i;       bool flag = true;       for (int i = 1; i <= n;) {         if (st[i] == 0 && a[i] != b[i]) {           flag = false;           break;         } else {           int sta = i;           memset(cnta, 0, sizeof(cnta));           ++cnta[a[i++]];           while (st[i] == 2) ++cnta[a[i++]];           ++cnta[a[i++]];           memset(cntb, 0, sizeof(cntb));           for (int j = sta; j < i; j++) cntb[b[j]]++;           for (int j = 1; j <= 100; j++)             if (cnta[j] != cntb[j]) {               flag = false;               break;             }         }         if (!flag) break;       }       puts(flag ?  YES  :  NO );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 300005, inf = 0x3f3f3f3f;   int n, a[N], tag[N << 2], mn[N << 2], mn_cnt[N << 2];   void upd(int u, int v) { mn[u] += v, tag[u] += v; }   void pushdown(int u) {     if (tag[u]) {       upd(u << 1, tag[u]);       upd(u << 1 | 1, tag[u]);       tag[u] = 0;     }   }   void pushup(int u) {     mn[u] = min(mn[u << 1], mn[u << 1 | 1]);     mn_cnt[u] = 0;     if (mn[u] == mn[u << 1]) mn_cnt[u] = mn_cnt[u << 1];     if (mn[u] == mn[u << 1 | 1]) mn_cnt[u] += mn_cnt[u << 1 | 1];   }   void build(int u, int l, int r) {     mn[u] = inf, mn_cnt[u] = r - l + 1;     if (l == r) return;     int mid = l + r >> 1;     build(u << 1, l, mid);     build(u << 1 | 1, mid + 1, r);   }   void update(int u, int l, int r, int ql, int qr, int v) {     if (l >= ql && r <= qr) {       upd(u, v);       return;     }     int mid = l + r >> 1;     pushdown(u);     if (ql <= mid) update(u << 1, l, mid, ql, qr, v);     if (qr > mid) update(u << 1 | 1, mid + 1, r, ql, qr, v);     pushup(u);   }   int main() {     scanf( %d , &n);     for (int i = 1, r; i <= n; ++i) scanf( %d , &r), scanf( %d , a + r);     build(1, 1, n);     static int st1[N], st2[N], top1, top2;     long long ans = 0;     for (int i = 1; i <= n; ++i) {       update(1, 1, n, i, i, -inf);       update(1, 1, n, 1, i, -1);       for (; top1 && a[i] >= a[st1[top1]]; --top1)         update(1, 1, n, st1[top1 - 1] + 1, st1[top1], -a[st1[top1]]);       update(1, 1, n, st1[top1] + 1, i, a[i]);       st1[++top1] = i;       for (; top2 && a[i] <= a[st2[top2]]; --top2)         update(1, 1, n, st2[top2 - 1] + 1, st2[top2], a[st2[top2]]);       update(1, 1, n, st2[top2] + 1, i, -a[i]);       st2[++top2] = i;       if (mn[1] == -1) ans += mn_cnt[1];     }     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   int main() {     ios_base::sync_with_stdio(0);     cin >> s;     vector<int> a;     vector<int> b;     int n = s.size();     for (int i = 0; i < n; i++) {       if (s[i] ==  l ) a.push_back(i + 1);       if (s[i] ==  r ) b.push_back(i + 1);     }     for (int i = 0; i < b.size(); i++) cout << b[i] <<   n ;     for (int i = a.size() - 1; i >= 0; i--) cout << a[i] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int l = 0, f = 1;     char a = getchar();     for (; a <  0  || a >  9 ; a = getchar())       if (a ==  - ) f = -1;     for (; a >=  0  && a <=  9 ; a = getchar()) l = l * 10 + a - 48;     return l * f;   }   const int N = 300005;   int n, ans = 1, last, a[N];   int main(int argc, char const *argv[]) {     n = read();     last = n;     printf( 1  );     for (int i = 1; i <= n; ++i) {       int x = read();       a[x] = 1, ans++;       while (a[last]) --last, --ans;       printf( %d  , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long oo = 1000000007;   vector<long long> G;   bool v[1000010];   long long a[1000010];   long long f[1000010];   long long p, k, i, j, ans;   void dfs(long long o, long long st) {     v[o] = 1;     if (!v[(o * k) % p]) {       dfs((o * k) % p, st + 1);     } else {       G.push_back(st);       a[st]++;     }   }   int main() {     scanf( %I64d%I64d , &p, &k);     if (k == 0) {       long long tem = 1;       for (i = 1; i < p; ++i) tem = (tem * p) % oo;       printf( %I64d n , tem);       return 0;     }     for (i = 0; i < p; ++i) {       if (!v[i]) {         dfs(i, 1);       }     }     memset(v, 0, sizeof(v));     for (i = 0; i < G.size(); ++i) {       if (v[G[i]]) continue;       v[G[i]] = 1;       for (j = 1; j * j <= G[i]; ++j) {         if (G[i] % j) continue;         f[G[i]] = (f[G[i]] + a[j] * j) % oo;         if (j * j != G[i])           f[G[i]] = (f[G[i]] + (a[G[i] / j] * (G[i] / j)) % oo) % oo;       }     }     ans = 1;     for (i = 0; i < G.size(); ++i) {       ans = (ans * f[G[i]]) % oo;     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int start = 1;     while (1) {       if (m >= start)         m -= start;       else         break;       start++;       if (start == (n + 1)) start = 1;       if (m == 0) break;     }     cout << m;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int c[55];   bool dp[11111 * 55];   int a[11111 * 55];   int main() {     ios_base::sync_with_stdio(false);     int n, d;     cin >> n >> d;     for (int _n(n), i(0); i < _n; i++) cin >> c[i];     memset((dp), (0), sizeof(dp));     dp[0] = true;     for (int _n(n), i(0); i < _n; i++) {       for (int j = 10000 * (n + 1); j >= c[i]; --j)         if (dp[j - c[i]]) dp[j] = true;     }     a[0] = 0;     for (int i = 1; i <= 10000 * (n + 5); ++i)       if (!dp[i])         a[i] = a[i - 1];       else         a[i] = i;     int last = 0, day = 0;     while (1) {       int cur = a[last + d];       if (cur == last) break;       last = cur;       ++day;     }     cout << last <<     << day << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int N = 500005;   long long int a[N], l[N], r[N];   long long int vl[N], vr[N];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     stack<long long int> s1, s2;     long long int nu;     cin >> nu;     long long int pos = 0;     for (long long int i = 1; i <= nu; i++) cin >> a[i];     for (long long int i = 1; i <= nu; i++) {       while (!s1.empty() && a[s1.top()] > a[i]) s1.pop();       if (s1.empty())         l[i] = 0;       else         l[i] = s1.top();       vl[i] = vl[l[i]] + (i - l[i]) * a[i];       s1.push(i);     }     long long int mx = -1;     for (long long int i = nu; i >= 1; i--) {       while (!s2.empty() && a[s2.top()] > a[i]) s2.pop();       if (s2.empty())         r[i] = nu + 1;       else         r[i] = s2.top();       vr[i] = vr[r[i]] + (r[i] - i) * a[i];       s2.push(i);       if ((vl[i] + vr[i] - a[i]) > mx) {         mx = vl[i] + vr[i] - a[i];         pos = i;       }     }     long long int x = a[pos];     for (long long int i = pos - 1; i >= 1; i--) {       if (a[i] > x)         a[i] = x;       else         x = a[i];     }     x = a[pos];     for (long long int i = pos + 1; i <= nu; i++) {       if (a[i] > x)         a[i] = x;       else         x = a[i];     }     for (long long int i = 1; i <= nu; i++) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   const int N = 1050000;   const double pi = acos(-1.0);   int a[N], ans[N], rev[N << 1];   std::complex<double> b[N << 1];   void FFT(std::complex<double> *a, int n, int f) {     for (int i = 0; i < n; i++)       if (i < rev[i]) std::swap(a[i], a[rev[i]]);     for (int i = 1; i < n; i <<= 1) {       std::complex<double> wn(cos(pi / i), f * sin(pi / i));       for (int j = 0; j < n; j += i << 1) {         std::complex<double> w(1, 0);         for (int k = j; k < j + i; k++, w *= wn) {           std::complex<double> x = a[k], y = w * a[k + i];           a[k] = x + y;           a[k + i] = x - y;         }       }     }     if (f == -1)       for (int i = 0; i < n; i++) a[i] /= n;   }   int main() {     int n, m;     scanf( %d%d n , &n, &m);     for (int i = 1; i <= n; i++) {       int x;       scanf( %d , &x);       b[x] = a[x] = 1;     }     int len = 0, L = 1;     for (; L <= m * 2; len++) L <<= 1;     for (int i = 0; i < L; i++)       rev[i] = rev[i >> 1] >> 1 ^ ((i & 1) << (len - 1));     FFT(b, L, 1);     for (int i = 0; i < L; i++) b[i] *= b[i];     FFT(b, L, -1);     int k = 0;     for (int i = 1; i <= m; i++)       if (!a[i] && b[i].real() >= 0.5) {         printf( NO n );         return 0;       } else if (a[i] && b[i].real() < 0.5)         ans[++k] = i;     printf( YES n%d n , k);     for (int i = 1; i <= k; i++) printf( %d  , ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, k;     cin >> n >> k;     vector<int> a(n);     vector<long long> pf(n);     for (int i = 0; i < n; i++) {       cin >> a[i];       pf[i] = a[i];       if (i) pf[i] += pf[i - 1];     }     long long ans = 0;     long long pw = 1;     while (llabs(pw) <= 1LL * n * 1000000000) {       map<long long, int> cnt;       cnt[0] = 1;       for (int i = 0; i < n; i++) {         cnt[pf[i]]++;         ans += cnt[pf[i] - pw];       }       if (k == 1 || (k == -1 && pw == -1)) break;       pw *= k;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   const int P = 1e9 + 7;   int add(int a, int b) {     if ((a += b) >= P) a -= P;     return a < 0 ? a + P : a;   }   int mul(int a, int b) { return 1ll * a * b % P; }   int kpow(int a, int b) {     int r = 1;     for (; b; b >>= 1, a = mul(a, a)) {       if (b & 1) r = mul(r, a);     }     return r;   }   const int N = 1e6 + 7;   int a[N], b[N], tr[N * 4], tip[N * 4], lft[N], rht[N], tim, n, k;   vector<int> g[N];   void dfs(int u) {     lft[u] = ++tim;     for (auto v : g[u]) dfs(v);     rht[u] = tim;   }   void change(int l, int r, int now, int L, int R, int w) {     if (L <= l && R >= r) {       tip[now] += w;       return;     }     int mid = (l + r) >> 1;     if (L <= mid) change(l, mid, (now << 1), L, R, w);     if (R > mid) change(mid + 1, r, ((now << 1) | 1), L, R, w);     tr[now] = max(tr[(now << 1)] + tip[(now << 1)],                   tr[((now << 1) | 1)] + tip[((now << 1) | 1)]);   }   int main() {     std::ios::sync_with_stdio(false);     std::cin.tie(0);     cin >> n >> k;     for (int i = (1); i < (n + 1); i++) cin >> a[i];     for (int i = (n + 1) - 1; i >= (1); i--) {       for (b[i] = i + 1; b[i] <= n && a[b[i]] <= a[i]; b[i] = b[b[i]])         ;       g[b[i]].push_back(i);     }     dfs(n + 1);     for (int i = (1); i < (k + 1); i++) change(1, tim, 1, lft[i], rht[i], 1);     cout << tip[1] + tr[1] <<    ;     for (int i = (k + 1); i < (n + 1); i++) {       change(1, tim, 1, lft[i], rht[i], 1);       change(1, tim, 1, lft[i - k], lft[i - k], -(1ll << (30)));       cout << tr[1] + tip[1] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #define endl   n    typedef long long int lli;   #define __ ios_base::sync_with_stdio(false);cin.tie(NULL);   int main(){__    int t= 1,n;       cin>>t;       while(t--){           string s;           cin>>s;           n  = s.size();           bool flag = true;           int idx1,idx2,cont =0;           for(int i = 0;i<n;i++){               if(s[i]==  ) ) idx1 = i;               if(s[i]==  ( ) idx2 = i;               if(s[i]==  ? )cont++;           }           if(idx1>idx2&& cont%2 ==0){               cout<< YES <<endl;           }           else if(idx1>idx2 && cont&1){               cout<< NO <<endl;           }           else{               int cont1 = 0,cont2 =0;               for(int i = 0;i<idx1;i++){                   cont1++;               }               for(int i= n-1;i>idx2;i--){                   cont2++;               }               if(cont1>0 && cont2>0 && (cont-(2))%2 ==0)                   cout<< YES <<endl;               else                    cout<< NO <<endl;           }       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s, t;     long long n;     cin >> n;     cin >> s;     cin >> t;     sort(s.begin(), s.end());     sort(t.begin(), t.end());     long long cnt = 0;     long long i = 0;     long long j = 0;     while (i < n && j < n) {       if (s[i] <= t[j]) {         cnt++;         i++;         j++;       } else         j++;     }     cout << s.length() - cnt << endl;     cnt = 0;     i = 0;     j = 0;     while (i < n && j < n) {       if (s[i] < t[j]) {         cnt++;         i++;         j++;       } else         j++;     }     cout << cnt << endl;   }
#include <bits/stdc++.h>   using namespace std;   string months[] = { January ,    February ,  March ,     April ,                       May ,        June ,      July ,      August ,                       September ,  October ,   November ,  December };   int main() {     string x;     int k;     cin >> x >> k;     int curr = 0;     for (curr = 0; months[curr] != x; curr++)       ;     curr = (curr + k) % 12;     cout << months[curr];   }
#include <bits/stdc++.h>   using namespace std;   int n, k, i, j, x, lg[1 << 20], f1[1 << 20], f2[1 << 20], ans, n1, n2, a;   long long e[42];   bool g[1 << 20];   int main() {     scanf( %d%d , &n, &k);     for (i = 0; i < n; i++)       for (j = 0; j < n; j++) {         scanf( %d , &x);         if (x) e[i] |= 1ll << j;       }     n1 = n / 2, n2 = n - n1;     for (i = 0; i < n2; i++) lg[1 << i] = i;     for (i = 1; i < 1 << n1; i++) {       a = lg[i & -i];       f1[i] = max(f1[i ^ (1 << a)], f1[i & e[a]] + 1);     }     ans = f1[(1 << n1) - 1];     g[0] = 1, f2[0] = (1 << n1) - 1;     for (i = 1; i < 1 << n2; i++) {       a = lg[i & -i];       f2[i] = f2[i ^ (1 << a)] & e[a + n1];       if (g[i ^ (1 << a)] && (e[a + n1] >> n1 & i) == (i ^ (1 << a)))         g[i] = 1, ans = max(ans, f1[f2[i]] + __builtin_popcount(i));     }     printf( %.8lf , 0.5 * k * k * (ans - 1) / ans);   }
#include <bits/stdc++.h>   using namespace std;   using LL = long long;   const int MOD = 998244353;   int f[1002][1000];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n, k;     cin >> n >> k;     vector<int> x(n);     for (int i = 0; i < n; ++i) cin >> x[i];     sort(x.begin(), x.end());     int ans = 0;     for (int t = 1; t <= (x[n - 1] - x[0]) / (k - 1); ++t) {       for (int i = 0; i < n; ++i) {         for (int j = 0; j < k; ++j) f[i][j] = 0;       }       f[0][0] = 1;       int pre = -1;       for (int i = 1; i < n; ++i) {         while (x[pre + 1] <= x[i] - t) ++pre;         f[i][0] = i + 1;         if (pre == -1) continue;         for (int j = 1; j < k; ++j) {           f[i][j] = f[i - 1][j] + f[pre][j - 1];           if (f[i][j] >= MOD) f[i][j] -= MOD;         }       }       ans += f[n - 1][k - 1];       if (ans >= MOD) ans -= MOD;     }     cout << ans << endl;     return 0;   }