malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, m, k, t;   int index(int i, int j) { return (i - 1) * m + j; }   int main() {     cin >> n >> m >> k >> t;     int arr[k];     for (int i = 0; i < k; i++) {       int a, b;       cin >> a >> b;       arr[i] = index(a, b);     }     sort(arr, arr + k);     while (t--) {       int a, b;       cin >> a >> b;       int x = index(a, b);       int cnt = 0;       for (int i = 0; i < k; i++) {         int element = arr[i];         if (x > element)           cnt++;         else if (x == element) {           cnt = -1;           break;         } else           break;       }       if (cnt == -1) {         cout <<  Waste  << endl;         continue;       }       int mod = (x - cnt - 1) % 3;       if (mod == 0) cout <<  Carrots  << endl;       if (mod == 1) cout <<  Kiwis  << endl;       if (mod == 2) cout <<  Grapes  << endl;     }     return 0;   }
#include<bits/stdc++.h>   using namespace std;   const int maxn=4e3+100;   typedef long long ll;   ll l[maxn],r[maxn],d[maxn];   int main()   {       int n,m,k;cin>>n>>m>>k;       for(int i=1;i<=m;i++)cin>>l[i]>>r[i];        ll ans=0;       for(int i=1,j=k;j<=n;i++,j++)//枚举第一个区间       {           ll sum=0,w;           memset(d,0,sizeof(d));           for(int p=1;p<=m;p++) {               w = max(0ll, min(r[p], 1ll*j)+1 - max(l[p], 1ll*i));               sum += w;               if(w<r[p]-l[p]+1)d[l[p]+w]++,d[l[p]+k]--,d[r[p]+1]--,d[r[p]+1+k-w]++;           }           for(int q=1;q<=n;q++)d[q]+=d[q-1];           ll imax=0;           for(int q=1;q<=n;q++)d[q]+=d[q-1],imax=max(imax,1ll*d[q]);           ans=max(ans,sum+imax);       }      cout<<ans<<endl;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_BUF_SIZE = 16384;   char BUFOR[MAX_BUF_SIZE];   int BUF_SIZE, BUF_POS;   char ZZZ;   const int MXN = 1000010;   const int C = 262144;   const int INF = 1000000001;   int n, m, h;   int s[MXN];   int sum;   int sh;   void test() {     scanf( %d %d %d , &n, &m, &h);     for (int i = 1; i <= m; i++) {       int tmp;       scanf( %d , &tmp);       if (i == h) sh = tmp;       sum += tmp;     }     if (sum < n) {       printf( -1 n );       return;     }     long double res = 1;     for (int i = sum - sh - n + 2; i <= sum - sh; i++) res = res * i;     for (int i = sum - n + 1; i <= sum - 1; i++) res = res / i;     double rr = res;     printf( %.9lf n , 1 - rr);   }   int main() {     int te = 1;     while (te--) test();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, D;   signed long long A[202020];   int M;   void solve() {     int i, j, k, l, r, x, y;     string s;     cin >> N >> D;     for (i = 0; i < (N); i++) cin >> A[i];     cin >> M;     for (i = 0; i < (M); i++) {       cin >> x;       if (x == A[0] || x == A[N - 1] + 1) {         (void)printf( %.12lf n , atan(1) * 2);         continue;       }       y = lower_bound(A, A + N, x) - A;       if (A[y] == x && A[y - 1] == x - 1) {         (void)printf( %.12lf n , atan(1) * 4);         continue;       }       if (A[y] == x || A[y - 1] == x - 1) {         (void)printf( %.12lf n , atan(1) * 2);         continue;       }       signed long long dif = min(x - A[y - 1] - 1, A[y] - x);       double ret = atan(1.0 / dif);       int L = y - 1;       int R = y;       int ok = 0;       for (j = 20; j >= 0; j--)         if (2 * atan(1.0 / (ok + (1 << j))) >= ret) ok += 1 << j;       while (L >= 0 && R < N) {         int dl = x - (A[L] + 1);         int dr = A[R] - x;         if (max(dl, dr) > ok) break;         if (abs(dl - dr) <= 1) {           ret = 2 * atan(1.0 / max(dl, dr));           break;         }         if (dl < dr)           L--;         else           R++;       }       (void)printf( %.12lf n , ret);     }   }   int main(int argc, char** argv) {     string s;     int i;     if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);     for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s +=   n ;     for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);     cout.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, D, a[105], ans;   int main() {     int T;     cin >> T;     while (T--) {       cin >> N >> D;       for (int i = 1; i <= N; i++) cin >> a[i];       for (int i = 2; i <= N; i++) {         int move = min(a[i], D / (i - 1));         a[1] += move;         D -= move * (i - 1);       }       cout << a[1] << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, t, c;     cin >> n >> t >> c;     int ls = 0;     int ans = 0;     for (int i = 1; i <= n; i++) {       int a;       cin >> a;       if (a > t)         ls = i;       else if (i - ls >= c)         ans++;     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, d, e = 0, all = 0, i = 0;     cin >> a >> b;     c = a;     d = b;     while (c) {       if ((c % 10) > e) {         e = c % 10;       }       c = c / 10;     }     while (d) {       if ((d % 10) > e) {         e = d % 10;       }       d = d / 10;     }     e = e + 1;     while (a) {       all = (a % 10) * pow(e, i) + all;       a = a / 10;       i++;     }     i = 0;     a = b;     while (a) {       all = (a % 10) * pow(e, i) + all;       a = a / 10;       i++;     }     i = 0;     while (all) {       all = all / e;       i++;     }     cout << i << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int r1, c1, r2, c2;   int CB[10][10];   int dr[8] = {1, -1, 1, -1, -2, -2, 2, 2};   int dc[8] = {2, 2, -2, -2, -1, 1, -1, 1};   int main() {     char s[10];     scanf(  %s , s);     r1 = s[0] -  a  + 1;     c1 = s[1] -  0 ;     scanf(  %s , s);     r2 = s[0] -  a  + 1;     c2 = s[1] -  0 ;     CB[r1][c1] = 2;     CB[r2][c2] = 2;     for (int i = r1, j = c1 + 1; j <= 8; j++) CB[i][j] = 1;     for (int i = r1, j = c1 - 1; j > 0; j--) CB[i][j] = 1;     for (int i = r1 + 1, j = c1; i <= 8; i++) CB[i][j] = 1;     for (int i = r1 - 1, j = c1; i > 0; i--) CB[i][j] = 1;     for (int i = 0; i < 8; i++) {       int p = r2 + dr[i];       int q = c2 + dc[i];       if (p > 0 && q > 0 && p < 9 && q < 9) CB[p][q] = 1;     }     for (int i = 0; i < 8; i++) {       int p = r1 + dr[i];       int q = c1 + dc[i];       if (p > 0 && q > 0 && p < 9 && q < 9) CB[p][q] = 1;     }     int cnt = 0;     for (int i = 1; i <= 8; i++) {       for (int j = 1; j <= 8; j++) {         if (CB[i][j] == 0) cnt++;       }     }     printf( %d n , cnt);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, c, d, e;     cin >> a >> b >> c >> d >> e;     if (a == 0 && b == 0 && c == 0 && d == 0 && e == 0)       cout << -1;     else if ((a + b + c + d + e) % 5 != 0)       cout << -1;     else       cout << (a + b + c + d + e) / 5;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, x;     cin >> t;     while (t--) {       cin >> x;       while (x > 0) {         if (x % 3 == 0)           x = x % 3;         else if (x % 7 == 0)           x = x % 7;         else {           x -= 7;           x -= 3;         }       }       if (x == 0)         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const double pi = 3.1415926535;   const double eps = 1e-6;   struct TP {     int x, h, id;   } P[110000];   bool cmp(TP a, TP b) { return a.x < b.x; }   int n, tot, Z[110000], F[110000], num[110000], ans[110000];   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d%d , &P[i].x, &P[i].h);       P[i].id = i;     }     sort(P, P + n, cmp);     for (int i = n - 1; i >= 0; i--) {       int now = P[i].x + P[i].h, all = 1;       while (tot && Z[tot] < now) {         now = max(now, F[tot]);         all += num[tot];         tot--;       }       tot++;       Z[tot] = P[i].x;       F[tot] = now;       num[tot] = all;       ans[P[i].id] = all;     }     for (int i = 0; i < n; i++) printf( %d  , ans[i]);     puts(  );     cin >> n;   }
#include <bits/stdc++.h>   using namespace std;   struct order {     int num;     int pos;   };   bool fun(order a, order b) { return (a.num < b.num); }   int main() {     int n, k, i, j;     cin >> n >> k;     vector<order> a(n);     for (i = 0; i < n; i++) {       cin >> a[i].num;       a[i].pos = i + 1;     }     set<int> s;     sort(a.begin(), a.end(), fun);     i = 0;     while (k - a[i].num >= 0 && i < n) {       k -= a[i].num;       s.insert(a[i].pos);       i++;     }     cout << s.size() << endl;     set<int>::iterator it;     for (it = s.begin(); it != s.end(); it++) cout << *it <<     ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long max(long long a, long long b) { return a > b ? a : b; }   long long min(long long a, long long b) { return a < b ? a : b; }   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   const long long INF = (long long)(1e17);   const double PI = 3.141592653589793;   long long dx[4] = {-1, 0, 1, 0};   long long dy[4] = {0, 1, 0, -1};   string path =  URDL ;   void solve() {     long long n, t, cnt = 0;     cin >> n >> t;     long long arr[n];     long long pre[n];     for (long long& e : arr) cin >> e;     pre[0] = arr[0];     for (long long i = 1; i < n; i++) pre[i] = pre[i - 1] + arr[i];     long long l = 0, r = 0;     long long temp = 0;     while (l < n and r < n) {       if (pre[r] - pre[l] + arr[l] <= t) {         temp = r - l + 1;         r++;       } else {         cnt = max(temp, cnt);         l++;         temp = 0;       }     }     cout << max(cnt, temp) <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(false), cin.tie(NULL);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 1;   map<long long, long long> p;   vector<long long> v;   int n, size;   long long t, k;   int main() {     scanf( %d %lld , &n, &k);     for (int i = 1; i <= n; ++i) {       scanf( %lld , &t);       p[t]++;       v.push_back(t);     }     sort(v.begin(), v.end());     v.erase(unique(v.begin(), v.end()), v.end());     size = v.size();     long long minn = v[0], maxx = v[size - 1], l = 0, r = size - 1;     while (k > 0 && l < r) {       if (p[v[l]] <= p[v[r]]) {         long long sum = (v[l + 1] - v[l]) * p[v[l]];         if (sum <= k) {           k -= sum;           p[v[l + 1]] += p[v[l]];           l++;           minn = v[l];         } else {           minn = v[l] + (k / p[v[l]]);           k = 0;         }       } else {         long long sum = (v[r] - v[r - 1]) * p[v[r]];         if (sum <= k) {           k -= sum;           p[v[r - 1]] += p[v[r]];           r--;           maxx = v[r];         } else {           maxx = v[r] - (k / p[v[r]]);           k = 0;         }       }     }     printf( %lld n , maxx - minn);   }
#include <bits/stdc++.h>   using namespace std;   long long n = 0, k[10000001], a, b, c;   void nhap() { cin >> a >> b >> c; }   void solve() {     k[n] = a + b + c;     n++;     k[n] = a * b * c;     n++;     k[n] = (a + b) * c;     n++;     k[n] = a * (b + c);     n++;     k[n] = a + b * c;     n++;     k[n] = a * b + c;     n++;     sort(k, k + n);     cout << k[n - 1];   }   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     nhap();     solve();   }
#include <bits/stdc++.h>   using namespace std;   long long n, m;   int gcd(int x, int y) {     if (y == 0) return x;     return gcd(y, x % y);   }   int main() {     cin >> n >> m;     string x, y;     cin.ignore();     getline(cin, x);     getline(cin, y);     int lenx = (int)x.length(), leny = (int)y.length();     int g = gcd(lenx, leny);     long long lcm = (long long)lenx * leny / g;     long long ans = lcm;     int **o = new int *[26];     for (int i = 0; i < 26; ++i) {       o[i] = new int[g];     }     for (int i = 0; i < 26; ++i)       for (int j = 0; j < g; ++j) o[i][j] = 0;     for (int i = 0; i < leny; ++i) {       o[y[i] -  a ][i % g]++;     }     for (int i = 0; i < lenx; ++i) {       ans -= (long long)o[x[i] -  a ][i % g];     }     for (int i = 0; i < 26; ++i) delete[] o[i];     delete[] o;     cout << (n * lenx) / lcm * ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 8e5 + 10;   struct Node {     int sum;     int free;     int carry;     Node() {       sum = 0;       free = 1;       carry = 0;     }     Node(int x) {       sum = x;       if (x == 0) {         free = 1;         carry = 0;       } else {         free = 0;         carry = x - 1;       }     }     Node(int sum_, int free_, int carry_) {       sum = sum_;       free = free_;       carry = carry_;     }     friend Node conq(const Node &l, const Node &r) {       if (l.carry <= r.free) {         return Node(l.sum + r.sum, l.free + r.free - l.carry, r.carry);       } else {         return Node(l.sum + r.sum, l.free, r.carry + l.carry - r.free);       }     }   };   namespace ST {   int cnt = 0;   int a[N];   Node t[4 * N];   void pull(int v) { t[v] = conq(t[2 * v + 1], t[2 * v + 2]); }   void build(int v, int l, int r) {     if (l + 1 == r) {       t[v] = Node();     } else {       int m = (r + l) >> 1;       build(2 * v + 1, l, m);       build(2 * v + 2, m, r);       pull(v);     }   }   void init() { build(0, 0, N); }   void add(int v, int l, int r, int pos, int val) {     if (l + 1 == r) {       cnt += val;       a[l] += val;       t[v] = Node(a[l]);     } else {       int m = (r + l) >> 1;       if (pos < m) {         add(2 * v + 1, l, m, pos, val);       } else {         add(2 * v + 2, m, r, pos, val);       }       pull(v);     }   }   void query(int v, int l, int r, int ql, int qr, Node &ans) {     if (r <= ql || qr <= l) {       return;     } else if (ql <= l && r <= qr) {       ans = conq(ans, t[v]);     } else {       int m = (r + l) >> 1;       query(2 * v + 1, l, m, ql, qr, ans);       query(2 * v + 2, m, r, ql, qr, ans);     }   }   int ok(int pref) {     Node ans;     query(0, 0, N, 0, pref + 1, ans);     return ans.carry == 0 && ans.sum == cnt;   }   void add(int pos, int val) { add(0, 0, N, pos, val); }   int solve() {     int l = -1;     int r = N - 1;     while (r - l > 1) {       int m = (r + l) >> 1;       if (ok(m)) {         r = m;       } else {         l = m;       }     }     assert(ok(r));     if (l > 0) assert(!ok(l));     return r;   }   }  // namespace ST   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     ST::init();     int n, k, q;     cin >> n >> k >> q;     set<pair<int, int>> s;     while (q--) {       int x, y;       cin >> x >> y;       int pos = y + abs(x - k);       if (!s.count({x, y})) {         ST::add(pos, 1);         s.insert({x, y});       } else {         ST::add(pos, -1);         s.erase({x, y});       }       cout << max(0, ST::solve() - n) <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0), cout.tie(0);     int n, p;     cin >> n >> p;     vector<int> a(n);     for (auto &x : a) {       cin >> x;     }     sort(a.begin(), a.end());     vector<int> ans;     for (int x = 1; x <= 2000; x++) {       int streak = 0, candies = x;       bool OK = true;       for (int i = 0; i < n; i++) {         if (candies + streak < a[i]) {           OK = false;           break;         }         if (candies >= a[i]) {           streak++;           continue;         }         if (streak >= p) {           OK = false;           break;         }         int dif = a[i] - candies;         candies += dif;         streak -= dif;         streak++;       }       if (streak >= p) {         OK = false;       }       if (OK) {         ans.push_back(x);       }     }     cout << ans.size() <<   n ;     for (auto &x : ans) {       cout << x <<    ;     }     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 0x3f3f3f3f;   int dp[1010][1010];   char s1[1010], s2[1010];   int main() {     scanf( %s%s , s1 + 1, s2 + 1);     int n = strlen(s1 + 1);     int m = strlen(s2 + 1);     for (int i = 1; i <= n; i++) dp[i][0] = i;     for (int i = 1; i <= m; i++) dp[0][i] = i;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         if (s1[i] == s2[j])           dp[i][j] = dp[i - 1][j - 1];         else           dp[i][j] = min(min(dp[i - 1][j], dp[i][j - 1]), dp[i - 1][j - 1]) + 1;       }     }     printf( %d n , dp[n][m]);     int x = n, y = m;     while (x != 0 || y != 0) {       if (y != 0 && dp[x][y] == dp[x][y - 1] + 1)         printf( INSERT %d %c n , x + 1, s2[y--]);       else if (x != 0 && dp[x][y] == dp[x - 1][y] + 1)         printf( DELETE %d n , x--);       else if (s1[x--] != s2[y--])         printf( REPLACE %d %c n , x + 1, s2[y + 1]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n, x;     cin >> n >> x;     long long cnt = 0;     for (int i = 1; i <= (int)(n); ++i) {       if (x % i == 0) {         if ((x / i) <= n) {           cnt++;         }       }     }     cout << cnt;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void Freopen() {     freopen(          title           .in ,          r , stdin);     freopen(          title           .out ,          w , stdout);   }   int read() {     int g = 0, f = 1;     char ch = getchar();     while (ch <  0  ||  9  < ch) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while ( 0  <= ch && ch <=  9 ) {       g = g * 10 + ch -  0 ;       ch = getchar();     }     return g * f;   }   const int N = 2e5 + 5;   const int INF = 1e9;   struct Edge {     int to, ne, w;   } e[N << 1];   int h[N], cnt, size[N], vis[N], a[N], rt, ans1, n;   double d[N], su, sd, ans2;   void add(int x, int y, int w) {     e[++cnt] = Edge{y, h[x], w};     h[x] = cnt;   }   void dfs(int x, int fa, int s) {     size[x] = 1;     int maxn = 0;     for (int i = h[x]; i; i = e[i].ne) {       int y = e[i].to;       if (vis[y] || y == fa) continue;       dfs(y, x, s), size[x] += size[y];       maxn = max(maxn, size[y]);     }     maxn = max(maxn, s - size[x]);     if (maxn <= (s >> 1)) rt = x;   }   void calc(int x, int fa, int anc, int w) {     su += pow(w, 1.5) * a[x], d[anc] += pow(w, 0.5) * 1.5 * a[x];     for (int i = h[x]; i; i = e[i].ne) {       int y = e[i].to;       if (y == fa) continue;       calc(y, x, anc, w + e[i].w);     }   }   void solve(int x, int s) {     dfs(x, 0, s), x = rt, dfs(x, 0, s);     if (vis[x]) return;     vis[x] = 1, su = sd = 0;     for (int i = h[x]; i; i = e[i].ne) {       int y = e[i].to;       d[y] = 0;       calc(y, x, y, e[i].w);       sd += d[y];     }     if (su < ans2) ans1 = x, ans2 = su;     for (int i = h[x]; i; i = e[i].ne) {       int y = e[i].to;       if (sd - d[y] * 2 >= 0) continue;       solve(y, size[y]);       break;     }   }   signed main() {     n = read();     for (int i = 1; i <= n; i++) a[i] = read();     for (int i = 1; i < n; i++) {       int x = read(), y = read(), w = read();       add(x, y, w), add(y, x, w);     }     ans2 = 1e20;     solve(1, n);     return cout << ans1 <<     << fixed << setprecision(20) << ans2, signed();   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x, mx = -1, n, res = -1;     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &x);       if (x - mx > 1 && res == -1) res = i + 1;       mx = max(mx, x);     }     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 2000 + 10;   const long double One = 1e6;   long double EPS = 1e-9;   struct pro {     int sp, bp, st, bt;     long double failp;   } d[MAX];   struct Case {     long double point, penalty;     Case() {       point = -1e10;       penalty = 1e10;     }     Case(long double a, long double b) {       point = a;       penalty = b;     }   } f[MAX][MAX];   int operator<(const Case& a, const Case& b) {     if (abs(a.point - b.point) > EPS)       return a.point < b.point;     else       return a.penalty > b.penalty;   }   int operator<(const pro& a, const pro& b) {     return a.bt * (1 - a.failp) * b.failp + (a.bt + b.bt) * (1 - b.failp) <            b.bt * (1 - b.failp) * a.failp + (a.bt + b.bt) * (1 - a.failp);   }   int n, t;   int main() {     int i, j;     scanf( %d%d , &n, &t);     for ((i) = (1); (i) <= (n); ++(i))       scanf( %d%d%d%d , &d[i].sp, &d[i].bp, &d[i].st, &d[i].bt),           cin >> d[i].failp;     sort(d + 1, d + n + 1);     f[0][0] = Case(0, 0);     Case ans;     for (i = 1; i <= n; ++i)       for (j = 0; j <= t; ++j) {         f[i][j] = max(f[i][j], f[i - 1][j]);         if (j + d[i].st > t) continue;         f[i][j + d[i].st] =             max(f[i][j + d[i].st],                 Case(f[i - 1][j].point + d[i].sp, f[i - 1][j].penalty + d[i].st));         if (j + d[i].st + d[i].bt > t) continue;         f[i][j + d[i].st + d[i].bt] =             max(f[i][j + d[i].st + d[i].bt],                 Case(f[i - 1][j].point + d[i].sp + d[i].bp * (1 - d[i].failp),                      f[i - 1][j].penalty * d[i].failp + d[i].st +                          (j + d[i].bt) * (1 - d[i].failp)));       }     for (j = 0; j <= t; ++j) ans = max(ans, f[n][j]);     cout.setf(ios::fixed);     cout << setprecision(9) << ans.point <<     << ans.penalty << endl;     return 0;   }
#include <bits/stdc++.h>   const long long mod = 1000000007;   using namespace std;   vector<long long> child0, child1, claw;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n;     cin >> n;     vector<long long> a(n);     long long max = 0;     for (int i = 0; i < n; i++) {       cin >> a[i];       if (a[i] > max) max = a[i];     }     child0.resize(max + 1);     child1.resize(max + 1);     claw.resize(max + 1);     child0[0] = 1;     child0[1] = 1;     child0[2] = 3;     child1[0] = 0;     child1[1] = 1;     child1[2] = 1;     claw[0] = 0;     claw[1] = 0;     claw[2] = 1;     for (int i = 3; i < max; i++) {       claw[i] = (child1[i - 1] + claw[i - 3]) % mod;       child0[i] = (child0[i - 1] + 2 * child1[i - 1]) % mod;       child1[i] = (child0[i - 1]) % mod;     }     for (int i = 0; i < n; i++) {       cout << (4 * claw[a[i] - 1]) % mod <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long power(long long a, long long b) {     if (b == 0)       return 1;     else if (b % 2 == 0)       return (power(a, b / 2) * power(a, b / 2)) % 998244353;     else       return (a * power(a, b / 2) * power(a, b / 2)) % 998244353;   }   int main() {     long long n, num, ma, cnt = 0;     map<long long, pair<long long, long long> > mp;     vector<pair<long long, long long> > v;     cin >> n;     for (long long i = 1; i <= n; i++) {       cin >> num;       if (mp[num].first == 0) mp[num].first = i;       mp[num].second = i;     }     for (auto it = mp.begin(); it != mp.end(); it++)       v.push_back({it->second.first, it->second.second});     sort(v.begin(), v.end());     ma = v[0].second;     for (long long i = 1; i < v.size(); i++) {       if (v[i].first > ma) {         cnt++;         ma = v[i].second;       } else         ma = max(ma, v[i].second);     }     cout << power(2, cnt);   }
#include <bits/stdc++.h>   using namespace std;   int n, k, ans, a[2000];   int main() {     cin >> n >> k;     ans = k;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++)       for (int j = i + 1; j < n; j++) ans = max(ans, k / a[i] * a[j] + k % a[i]);     cout << ans;     return 0;   }