malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 5050;   long long a[maxn];   long long c[maxn];   long long tag[maxn];   long long number[maxn];   int main() {     long long i, j, k, n, m;     while (scanf( %lld%lld , &n, &k) != EOF) {       memset(tag, 0, sizeof(tag));       for (i = 1; i <= n; i++) {         scanf( %lld , &a[i]);         tag[a[i]]++;       }       for (i = 1; i <= 5000; i++) number[i] = 1;       bool flag = true;       for (i = 1; i <= 5000; i++)         if (tag[i] > k) {           flag = false;           break;         }       if (!flag)         printf( NO n );       else {         long long cnt = 1;         for (i = 1; i <= 5000; i++) {           for (j = 1; j <= 5000; j++)             if (a[j] == i) {               c[j] = cnt;               cnt++;               if (cnt > k) cnt = 1;             }         }         printf( YES n );         for (i = 1; i <= n; i++) printf( %lld  , c[i]);         printf(  n );       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, piles[100000], q;     cin >> n;     cin >> q;     piles[0] = q;     for (int i = int(1); i < int(n); i++) {       cin >> q;       piles[i] = piles[i - 1] + q;     }     cin >> m;     for (int i = int(0); i < int(m); i++) {       cin >> q;       int ans = upper_bound(piles, piles + n, q) - piles;       if (ans > 0 && piles[ans - 1] == q) ans--;       ans++;       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math,O3 )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx )   using namespace std;   template <class T>   istream& operator>>(istream& is, vector<T>& v) {     for (auto& x : v) {       is >> x;     }     return is;   }   template <class T>   ostream& operator<<(ostream& os, vector<T>& v) {     for (auto& x : v) {       os << x <<    ;     }     return os;   }   const int N = (1 << 20) + 1;   vector<pair<int, int>> eulerWalk(vector<vector<pair<int, int>>>& gr, int nedges,                                    int src = 0) {     int n = ((int)(gr.size()));     static vector<int> D(N), its(N), eu(N);     D.clear(), D.resize(n);     its.clear(), its.resize(n);     eu.clear(), eu.resize(nedges);     static vector<pair<int, int>> s;     s = {make_pair(src, -1)};     static vector<pair<int, int>> ret;     ret.clear();     D[src]++;     while (!s.empty()) {       auto x = s.back();       int y, e, &it = its[x.first], end = ((int)(gr[x.first].size()));       if (it == end) {         ret.push_back(x);         s.pop_back();         continue;       }       tie(y, e) = gr[x.first][it++];       if (!eu[e]) {         D[x.first]--, D[y]++;         eu[e] = 1;         s.emplace_back(y, e);       }     }     for (int x : D)       if (x < 0 || ((int)(ret.size())) != nedges + 1) return {};     return {ret.rbegin(), ret.rend()};   }   vector<vector<pair<int, int>>> graph(N);   vector<pair<int, int>> cycle;   bool valid(int k, const vector<pair<int, int>>& pearls) {     graph.clear();     graph.resize((1 << k));     int src;     for (int i = 0; i < ((int)(pearls.size())); ++i) {       int u = (pearls[i].first & ((1 << k) - 1));       int v = (pearls[i].second & ((1 << k) - 1));       graph[u].emplace_back(v, i);       graph[v].emplace_back(u, i);       src = u;     }     cycle = eulerWalk(graph, pearls.size(), src);     return !cycle.empty() && cycle.back().first == src;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int n;     cin >> n;     vector<pair<int, int>> pearls(n);     for (auto& p : pearls) {       cin >> p.first >> p.second;     }     int res = 20;     while (!valid(res, pearls)) {       --res;     }     cout << res <<   n ;     for (int i = 0; i < n; ++i) {       int u = (pearls[i].first & ((1 << res) - 1));       int v = (pearls[i].second & ((1 << res) - 1));       pearls[i] = make_pair(u, v);     }     for (int i = 1; i <= n; ++i) {       auto curr = cycle[i];       int prev_node = cycle[i - 1].first;       int curr_edge = curr.second;       if (pearls[curr_edge].first == prev_node &&           pearls[curr_edge].second == curr.first) {         cout << 2 * curr_edge + 1 <<     << 2 * curr_edge + 2 <<    ;       } else {         cout << 2 * curr_edge + 2 <<     << 2 * curr_edge + 1 <<    ;       }     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void read_file(bool outToFile = true) {}   int n, m;   int A[1000 + 9][1000 + 9];   long long K, sum;   int mrk = 0, to;   int vis[1000 + 9][1000 + 9] = {0};   int di[] = {1, 0, -1, 0};   int dj[] = {0, 1, 0, -1};   set<int> usedAs[1000 + 9][1000 + 9];   bool valid(int i, int j) { return 0 <= i && i < n && 0 <= j && j < m; }   bool flood(int i, int j) {     if (!valid(i, j) || vis[i][j] == mrk || A[i][j] < to) return false;     sum -= to;     vis[i][j] = mrk;     usedAs[i][j].insert(to);     if (sum == 0) return true;     for (int d = 0; d < 4; d++)       if (flood(i + di[d], j + dj[d])) return true;     return false;   }   int main() {     read_file();     while (scanf( %d %d n , &n, &m) != EOF) {       scanf( %lld , &K);       for (int i = 0; i < n; i++)         for (int j = 0; j < m; j++) scanf( %d , &A[i][j]), usedAs[i][j].clear();       bool done = false;       memset(vis, 0, sizeof vis);       for (int i = 0; i < n && !done; i++) {         for (int j = 0; j < m && !done; j++) {           if (K % A[i][j] == 0 && K / A[i][j] <= n * m) {             if (usedAs[i][j].count(A[i][j])) continue;             mrk++;             to = A[i][j];             sum = K;             if (flood(i, j)) done = true;           }         }       }       if (!done) {         printf( NO n );         continue;       }       printf( YES n );       for (int i = 0; i < n; i++)         for (int j = 0; j < m; j++) A[i][j] = vis[i][j] == mrk ? to : 0;       for (int i = 0; i < n; i++)         for (int j = 0; j < m; j++) printf( %d%c , A[i][j],    n [j == m - 1]);     }   }
#include <bits/stdc++.h>   int a[100005];   inline int max(int x, int y) { return x > y ? x : y; }   int main() {     int ans = 0, n, Max, Min, Maxpos, Minpos;     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     int l = 1, r = 1;     while (r <= n && a[r] == a[1]) r++;     if (r == n + 1) return !printf( %d , n);     if (a[r] > a[1])       Max = a[r], Maxpos = r, Min = a[1], Minpos = r - 1;     else       Max = a[1], Maxpos = r - 1, Min = a[r], Minpos = r;     while (l <= r && r <= n) {       while (r < n && a[r + 1] >= Min && a[r + 1] <= Max) {         r++;         if (a[r] == Max)           Maxpos = r;         else           Minpos = r;       }       r++;       ans = max(ans, r - l);       if (r > n) break;       if (a[r] > Max) {         l = Minpos + 1;         Min = Max, Minpos = Maxpos;         Max = a[r], Maxpos = r;       }       if (a[r] < Min) {         l = Maxpos + 1;         Max = Min, Maxpos = Minpos;         Min = a[r], Minpos = r;       }     }     printf( %d , ans);   }
#include <bits/stdc++.h>   using namespace std;   long long int n, m, sol = 1;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     if (n > m) swap(n, m);     if (((n % 10) + 1 <= 2 && n % 10 >= 1 && m % 10 >= 5) || (abs(n - m) > 10))       return cout << 0, 0;     else {       for (long long int i = n + 1; i <= m; i++) sol = (sol * (i % 10)) % 10;     }     cout << sol;     return 0;   }
#include <bits/stdc++.h>   const int oo = 0x3f3f3f3f;   const double PI = acos(-1.0);   const double EPS = 1e-8;   using namespace std;   int read() {     int d, f = 1;     char c;     while (!isdigit(c = getchar()))       if (c ==  - ) f = -1;     d = c ^  0 ;     while (isdigit(c = getchar())) d = (d * 10) + (c ^  0 );     return d * f;   }   void rekt() {     puts( YES );     exit(0);   }   int main() {     int n;     while (cin >> n) {       int x0 = read(), y0 = read();       pair<long long, char> dir[8];       for (int i = 0; i < 8; ++i) dir[i].first = 1000000000000000000ll;       for (int i = 0; i < n; ++i) {         char c[2];         scanf( %s , c);         int x = read(), y = read();         if (y == y0) {           if (x < x0 && x0 - x < dir[0].first)             dir[0].first = x0 - x, dir[0].second = c[0];           else if (x > x0 && x - x0 < dir[1].first)             dir[1].first = x - x0, dir[1].second = c[0];         } else if (x == x0) {           if (y < y0 && y0 - y < dir[2].first)             dir[2].first = y0 - y, dir[2].second = c[0];           else if (y > y0 && y - y0 < dir[3].first)             dir[3].first = y - y0, dir[3].second = c[0];         } else if (abs(x - x0) == abs(y - y0)) {           if (x < x0 && y < y0 && x0 - x < dir[4].first)             dir[4].first = x0 - x, dir[4].second = c[0];           else if (x > x0 && y < y0 && x - x0 < dir[5].first)             dir[5].first = x - x0, dir[5].second = c[0];           else if (x < x0 && y > y0 && x0 - x < dir[6].first)             dir[6].first = x0 - x, dir[6].second = c[0];           else if (x > x0 && y > y0 && x - x0 < dir[7].first)             dir[7].first = x - x0, dir[7].second = c[0];         }       }       for (int i = 0; i < 4; ++i)         if (dir[i].second ==  R  || dir[i].second ==  Q ) rekt();       for (int i = 4; i < 8; ++i)         if (dir[i].second ==  B  || dir[i].second ==  Q ) rekt();       puts( NO );     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(2)   using namespace std;   inline int read() {     char c = getchar();     int x = 0;     bool f = 0;     for (; !isdigit(c); c = getchar()) f ^= !(c ^ 45);     for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);     if (f) x = -x;     return x;   }   int n, m, a[205], b[205], res;   vector<int> v[205], tmp[205];   signed main() {     n = read(), m = read();     for (register int i = (1); i <= (n); ++i) a[i] = read();     for (register int i = (1); i <= (m); ++i) b[i] = read();     for (register int i = (1); i <= (n); ++i)       for (register int j = (1); j <= (m); ++j) v[i].push_back(j);     for (register int p = (9); p >= (0); --p) {       bool ok = 1;       for (register int i = (1); i <= (n); ++i) {         int x = a[i];         if (!(x >> p & 1)) continue;         tmp[i].clear();         for (int j = 0; j < v[i].size(); ++j) {           int y = b[v[i][j]];           if (!(y >> p & 1)) tmp[i].push_back(v[i][j]);         }         if (tmp[i].size() == 0) {           ok = 0;           break;         }       }       if (!ok)         res += (1 << p);       else         for (register int i = (1); i <= (n); ++i)           if (a[i] >> p & 1) v[i] = tmp[i];     }     cout << res;     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:16777216 )   using namespace std;   const int M = 1000000007;   int t;   int n, k;   string s;   int dp[1001][1002][2];   int get(int it, int d, bool complete, bool zero) {     if (it == 0) return complete;     if (zero && dp[it][d][complete] != -1) return dp[it][d][complete];     long long ret = 0;     int to = zero ? 9 : s[n - it] -  0 ;     for (int i = 0; i <= to; i++) {       bool nxtZero = zero || (i < to);       bool nxtComplete = complete || ((i == 4 || i == 7) && (d <= k));       int nxtD = min((i == 4 || i == 7) ? 1 : d + 1, 1001);       ret += get(it - 1, nxtD, nxtComplete, nxtZero);     }     ret %= M;     if (zero) dp[it][d][complete] = ret;     return ret;   }   bool correct() {     int prev = -1;     for (int i = 0, _n = (n); i < _n; ++i)       if (s[i] ==  4  || s[i] ==  7 ) {         if (prev != -1 && i - prev <= k) return true;         prev = i;       }     return false;   }   void solution() {     cin >> t >> k;     memset((dp), (-1), sizeof((dp)));     while (t--) {       cin >> s, n = (int)((s).size());       int ret = get(n, 1001, 0, 0);       ret -= correct();       cin >> s, n = (int)((s).size());       ret = get(n, 1001, 0, 0) - ret;       if (ret >= M) ret %= M;       if (ret < 0) ret += M;       cout << ret << endl;     }   }   int main() {     solution();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int aray[100002];   int main() {     int i, j, k, a, b, x, n, y, p, q, len, mx = 0, s = 1;     scanf( %d , &n);     for (i = 0; i < n; i++) {       scanf( %d , &aray[i]);     }     p = 0;     q = 0;     s = 0;     for (i = 1; i < n; i++) {       a = aray[i] - aray[i - 1];       if (a) {         if (p == a) {           s = q;         }         q = i;         p = a;       }       len = i - s + 1;       if (len > mx) mx = len;     }     cout << mx;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[30010], n;   bool vis[30010];   void print(vector<int> v) {     for (int i = 0; i < v.size(); i++) printf( %d  , v[i]);     printf(  n );   }   bool check(vector<int> v) {     if (!v.size()) return false;     if (v.size() == 1 || v.size() == 2) return true;     int d = v[1] - v[0];     for (int i = 2; i < v.size(); i++)       if (v[i] - v[i - 1] != d) return false;     return true;   }   bool solve(int l, int r) {     vector<int> v1, v2;     for (int i = 1; i <= n; i++) vis[i] = 0;     int d = a[r] - a[l];     int last = -1, get = a[l];     for (int i = 1; i <= n; i++)       if (a[i] == get)         get += d, v1.push_back(a[i]), last = i;       else         vis[i] = 1;     for (int i = 1; i <= n; i++)       if (vis[i]) v2.push_back(a[i]);     if (check(v2)) {       print(v1), print(v2);       return true;     }     vis[last] = 1, v1.pop_back(), v2.clear();     for (int i = 1; i <= n; i++)       if (vis[i]) v2.push_back(a[i]);     if (check(v2)) {       print(v1), print(v2);       return true;     }     return false;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     if (n == 2)       printf( %d n%d , a[1], a[2]);     else if (!solve(1, 2) && !solve(2, 3) && !solve(1, 3))       printf( No solution );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, w;   long long ans;   double a[100010], b[100010];   struct node {     int f, x, v;     double a, b;   } sh[100010];   double m_abs(double x) {     if (x < 0)       return -x;     else       return x;   }   bool cmp(node x, node y) { return (x.a < y.a || (x.a == y.a && x.b > y.b)); }   void m_sort(int l, int r) {     if (l == r) return;     int mid;     mid = (l + r) / 2;     m_sort(l, mid);     m_sort(mid + 1, r);     int ll, rr, now;     now = 0;     ll = l;     rr = mid + 1;     while (ll <= mid && rr <= r) {       if (a[ll] < a[rr]) {         now++;         b[now] = a[ll];         ll++;       } else {         now++;         b[now] = a[rr];         rr++;         ans += (long long)mid - ll + 1;       }     }     for (int i = ll; i <= mid; i++) {       now++;       b[now] = a[i];     }     for (int i = rr; i <= r; i++) {       now++;       b[now] = a[i];     }     for (int i = 1; i <= now; i++) {       a[l + i - 1] = b[i];     }   }   int main() {     scanf( %d%d , &n, &w);     for (int i = 1; i <= n; i++) {       scanf( %d%d , &sh[i].x, &sh[i].v);       if (sh[i].x > 0) sh[i].f = 1;     }     for (int i = 1; i <= n; i++) {       if (sh[i].f == 0) {         sh[i].a = m_abs((sh[i].x * 1.0) / ((sh[i].v + w) * 1.0));         sh[i].b = m_abs((sh[i].x * 1.0) / ((sh[i].v - w) * 1.0));       } else {         sh[i].b = m_abs((sh[i].x * 1.0) / ((sh[i].v - w) * 1.0));         sh[i].a = m_abs((sh[i].x * 1.0) / ((sh[i].v + w) * 1.0));       }     }     sort(sh + 1, sh + 1 + n, cmp);     for (int i = 1; i <= n; i++) a[i] = sh[i].b;     m_sort(1, n);     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int nm = 100010;   const long long inf = 1000000000000000ll;   int n;   long long a[nm], b[nm];   pair<long long, int> dau[nm], cuoi[nm];   int main() {     scanf( %d , &n);     long long x1, x2;     scanf( %I64d%I64d , &x1, &x2);     for (int i = 1; i <= n; ++i) {       scanf( %I64d%I64d , &a[i], &b[i]);       dau[i] = make_pair(a[i] * x1 + b[i], i);       cuoi[i] = make_pair(a[i] * x2 + b[i], i);     }     sort(dau + 1, dau + n + 1);     sort(cuoi + 1, cuoi + n + 1);     int j = 0;     long long xxx = -inf;     for (int i = 1; i <= n; ++i) {       while (j + 1 < i && cuoi[j + 1].first < cuoi[i].first) {         j++;         xxx = max(xxx, a[cuoi[j].second] * x1 + b[cuoi[j].second]);       }       if (xxx > a[cuoi[i].second] * x1 + b[cuoi[i].second]) {         printf( YES n );         return 0;       }     }     printf( NO n );   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   T getint() {     T x = 0, p = 1;     char ch;     do {       ch = getchar();     } while (ch <=    );     if (ch ==  - ) p = -1, ch = getchar();     while (ch >=  0  && ch <=  9 ) x = x * 10 + ch -  0 , ch = getchar();     return x * p;   }   mt19937 gen(chrono::system_clock::now().time_since_epoch().count());   template <typename T1, typename T2>   bool umin(T1 &x, const T2 &y) {     if (x > y) return x = y, true;     return false;   }   template <typename T1, typename T2>   bool umax(T1 &x, const T2 &y) {     if (x < y) return x = y, true;     return false;   }   const int maxn = (int)3e5 + 10;   const int inf = (int)1e9 + 5;   const int mod = (int)1e9 + 7;   const long long llinf = (long long)1e18 + 5;   const long double pi = acos(-1.0);   int nxt[maxn * 30][2];   int f[maxn * 30];   int sz = 1;   int v[maxn], t[maxn];   void add(int x, int d) {     int v = 1;     for (int i = 29; i >= 0; --i) {       int b = (x >> i & 1);       if (nxt[v][b] == 0) nxt[v][b] = ++sz;       v = nxt[v][b];       f[v] += d;     }   }   int get(int x) {     int v = 1;     int res = 0;     for (int i = 29; i >= 0; --i) {       int b = (x >> i & 1);       if (f[nxt[v][b]] > 0) {         v = nxt[v][b];       } else {         res |= 1 << i;         v = nxt[v][b ^ 1];       }     }     return res;   }   int main() {     ios_base::sync_with_stdio(0);     int n;     cin >> n;     for (int i = 1; i <= n; ++i) {       cin >> v[i];     }     for (int i = 1; i <= n; ++i) {       cin >> t[i];       add(t[i], 1);     }     for (int i = 1; i <= n; ++i) {       int z = get(v[i]);       cout << z <<    ;       add(z ^ v[i], -1);     }     return 0;   }
#include <bits/stdc++.h>   #pragma warning(disable : 4996)   using namespace std;   bool inBound(int x) { return x >= 0 && x < 30001; }   int main() {     std::ios::sync_with_stdio(0);     std::cin.tie(0);     std::cout.tie(0);     int n, d;     cin >> n >> d;     int mx = 30000;     vector<int> gems(mx + 1, 0);     for (int i = 0; i < n; i++) {       int temp;       cin >> temp;       gems[temp]++;     }     vector<vector<int> > dp;     dp.resize(mx + 1, vector<int>(500, 0));     for (int i = mx; i >= d; i--) {       for (int prev = 0; prev < 500; prev++) {         dp[i][prev] = gems[i];         int prevJump = d + prev - 250;         int nextPos = i + prevJump;         int choice1 =             (inBound(nextPos - 1) && prev - 1 >= 0 && (prevJump - 1) > 0)                 ? dp[nextPos - 1][prev - 1]                 : 0;         int choice2 =             (inBound(nextPos) && (prevJump) > 0) ? dp[nextPos][prev] : 0;         int choice3 =             (inBound(nextPos + 1) && prev + 1 < 500 && (prevJump + 1) > 0)                 ? dp[nextPos + 1][prev + 1]                 : 0;         dp[i][prev] += max(choice1, max(choice2, choice3));       }     }     cout << dp[d][250] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   char s[555555];   int t[555555];   int n, a, b, T;   int getAns() {     for (int i = 0; i + 1 < n - 1 - i; i++) {       swap(t[i + 1], t[n - 1 - i]);     }     if (t[0] > T) {       return 0;     }     int ct = t[0];     int ans = 1;     for (int i = 1; i < n; i++) {       ct += a + t[i];       if (ct <= T) {         ans = i + 1;       }     }     if (ans == n) {       return ans;     }     long long wt = t[0];     int bi = n - 1;     while (wt + a + t[bi] <= T) {       wt += a + t[bi];       bi--;     }     ans = max(ans, n - bi);     for (int i = 1; i + 1 < n; i++) {       wt += 2 * a + t[i];       while (wt > T && bi + 1 < n) {         bi++;         wt -= a + t[bi];       }       if (wt > T) {         break;       }       ans = max(ans, i + n - bi);     }     return ans;   }   int main() {     scanf( %d , &n);     scanf( %d%d , &a, &b);     scanf( %d , &T);     scanf(  n%s , s);     for (int i = 0; i < n; i++) {       t[i] = 1;       if (s[i] ==  w ) {         t[i] += b;       }     }     cout << max(getAns(), getAns());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f, MOD = 1e9 + 7;   const int n_ = 3010;   long long gcd(long long a, long long b) { return (a ? gcd(b % a, a) : b); }   long long power(long long a, long long n) {     long long p = 1;     while (n > 0) {       if (n % 2) {         p = p * a;       }       n >>= 1;       a *= a;     }     return p;   }   long long power(long long a, long long n, long long mod) {     long long p = 1;     while (n > 0) {       if (n % 2) {         p = p * a;         p %= mod;       }       n >>= 1;       a *= a;       a %= mod;     }     return p % mod;   }   int n, dp[n_][3], a[n_][3];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (int j = 0; j < 3; j++) {       for (int i = 0; i < n; i++) cin >> a[i][j];     }     dp[0][1] = -INF;     for (int i = 0; i < n; i++) {       dp[i + 1][1] = max(dp[i][0] + a[i][0], dp[i][1] + a[i][1]);       dp[i + 1][0] = max(dp[i][1] + a[i][2], dp[i][0] + a[i][1]);     }     cout << dp[n][1] <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   long long dp[1005][2005];   int main() {     int n, m, k;     cin >> n >> m >> k;     for (int i = 1; i <= max(m, n); i++) {       for (int j = 0; j <= i; j++) {         if (j == 1) {           dp[i][j] = i;           continue;         }         dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];         dp[i][j] %= mod;       }     }     cout << 1LL * dp[n - 1][2 * k] * dp[m - 1][2 * k] % mod;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 8e6 + 7, mod = 998244353, root = 3;   long long x[N], n, m, i, j, ma, mb, inv, res, b[N], ans[N], L, R[N];   long long pow_mod(long long x, long long n) {     long long res = 1;     while (n) {       if (n & 1) res = 1LL * x * res % mod;       x = 1LL * x * x % mod;       n >>= 1;     }     return res;   }   void ntt(long long* x, long long type) {     for (long long i = 0; i < n; ++i)       if (i < R[i]) swap(x[i], x[R[i]]);     for (long long i = 1; i < n; i <<= 1) {       long long wn = pow_mod(root, type == 1 ? (mod - 1) / (i << 1)                                              : (mod - 1 - (mod - 1) / (i << 1)));       for (long long p = i << 1, j = 0; j < n; j += p) {         long long w = 1;         for (long long k = 0; k < i; ++k, w = 1LL * wn * w % mod) {           long long l = x[j + k], r = 1LL * x[j + k + i] * w % mod;           x[j + k] = (l + r) % mod;           x[j + k + i] = (l - r + mod) % mod;         }       }     }   }   void fpow(long long sz) {     ntt(ans, 1);     ntt(x, 1);     while (sz) {       if (sz & 1) {         for (long long i = 0; i < n; i++) ans[i] = 1ll * ans[i] * x[i] % mod;       }       for (long long i = 0; i < n; i++) x[i] = 1ll * x[i] * x[i] % mod;       sz >>= 1;     }     ntt(ans, -1);   }   int32_t main() {     ans[0] = 1;     long long sz, k, tx;     cin >> sz >> k;     for (long long i = 1; i <= k; i++) {       scanf( %d , &tx);       x[tx] = 1;     }     for (m = 200000 * 9 + 7, n = 1; n <= m; n <<= 1) L++;     for (i = 0; i < n; ++i) R[i] = (R[i >> 1] >> 1) | ((i & 1) << L - 1);     fpow(sz / 2);     long long cnt = 0;     inv = pow_mod(n, mod - 2);     for (long long i = 0; i < n; i++)       cnt =           (cnt + (ans[i] % mod * inv % mod) * (ans[i] % mod * inv % mod) % mod) %           mod;     cout << cnt << endl;   }