malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long double epsilon = 1e-9;   string minus1(const string& str) {     string str1(str);     for (int i = str.size() - 1; i >= 0; i--) {       if (str1[i] !=  0 ) {         str1[i]--;         break;       } else         str1[i] =  9 ;     }     return str1;   }   long long rem(const string& str, long long c) {     long long temp = 0;     for (int i = 0; i < str.size(); i++) {       temp = (temp * 10LL + (long long)(str[i] -  0 )) % c;     }     return temp;   }   long long phi(long long c) {     long long res = 1;     for (long long i = 2; i * i <= c; i++) {       if (c % i == 0) {         c /= i;         res *= (i - 1);         while (c % i == 0) {           c /= i;           res *= i;         }       }     }     if (c > 1) res *= c - 1;     return res;   }   long long rem2(const string& str, long long c) {     long long temp = 0;     long long t2;     for (int i = 0; i < str.size(); i++) {       t2 = (temp * 10LL + (long long)(str[i] -  0 ));       temp = t2 % c + t2 / c;     }     return temp;   }   long long powe(long long a, long long p, long long c) {     long long res = 1;     long long mul = a;     while (p > 0) {       if (p & 1) {         res = (res * mul) % c;       }       mul = (mul * mul) % c;       p >>= 1;     }     return res;   }   long long bruteForce(string B, string N, long long c) {     stringstream ss;     ss << B <<     << N;     long long b, n;     ss >> b >> n;     long long res = (b - 1) % c;     for (int i = 1; i < n; i++) res = (res * b) % c;     if (res == 0) res = c;     return res;   }   long long nod(long long a, long long b) {     if (a < b) swap(a, b);     long long x;     while (b) {       x = a % b;       a = b;       b = x;     }     return a;   }   bool isPow(long long i, long long j) {     if (j == 1) return false;     while (i % j == 0) i /= j;     return i == 1;   }   void fail() {     long long nd;     for (int i = 2; i < 10000; i++) {       for (int j = 1; j < i; j++) {         nd = nod(i, j);         if (isPow(i, nd)) continue;         if (powe(j, phi(i) + 1, i) != j) {           cerr <<  Failed with:   << i <<     << j << endl;           return;         }       }     }   }   int main() {     string n, b;     long long c;     long long e;     int o = 1;     while (cin >> b >> n >> c) {       long long a = rem(minus1(b), c);       long long b2 = rem(b, c);       n = minus1(n);       long long mat[10];       for (int i = 0; i < 10; i++) mat[i] = 1LL;       long long ge, ye;       int idx;       for (int i = n.size() - 1; i >= 0; i--) {         idx = n[i] -  0 ;         mat[idx] = (mat[idx] * b2) % c;         ge = (b2 * b2) % c;         ye = (ge * ge) % c;         ye = (ye * ye) % c;         b2 = (ye * ge) % c;       }       long long re = 1;       for (int i = 0; i < 10; i++) {         for (int j = 0; j < i; j++) re = (re * mat[i]) % c;       }       long long q = (a * re) % c;       if (q == 0) q = c;       cout << q << endl;       o++;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a, b, sum;   int main() {     cin >> n;     b = -1;     sum = 0;     for (int i = 0; i < n; i++) {       cin >> a;       if (a == 0 || (a == b && b != 3)) {         sum++;         b = 0;       } else if (a == 3 && b == 1)         b = 2;       else if (a == 3 && b == 2)         b = 1;       else         b = a;     }     cout << sum << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void umax(T &a, T b) {     if (a < b) a = b;   }   template <class T>   inline void umin(T &a, T b) {     if (a > b) a = b;   }   template <class T>   inline T abs(T a) {     return a > 0 ? a : -a;   }   template <class T>   inline T gcd(T a, T b) {     return __gcd(a, b);   }   template <class T>   inline T lcm(T a, T b) {     return a / gcd(a, b) * b;   }   const int inf = 1e9 + 143;   const long long longinf = 1e18 + 143;   inline int read() {     int x;     scanf(  %d , &x);     return x;   }   const int N = 1e5 + 100;   const int MAX = 1e4 + 100;   int n;   long long x[N];   int c[N];   set<pair<int, int> > reach;   bool taken[N];   int sz = 0;   long long a[N];   priority_queue<pair<long long, int> > q;   long long dist[MAX];   bool used[MAX];   void rebuild() {     sort(a, a + sz);     sz = unique(a, a + sz) - a;     int mod = a[0];     dist[0] = 0;     used[0] = 0;     for (int i = 1; i < mod; i++) {       dist[i] = longinf;       used[i] = 0;     }     q.push(make_pair(0ll, 0));     while (!q.empty()) {       int u = q.top().second;       long long len = -q.top().first;       q.pop();       if (dist[u] < len) continue;       for (int i = 1; i < sz; i++) {         int v = (u + a[i]) % mod;         long long c = a[i];         if (dist[v] > dist[u] + c) {           dist[v] = dist[u] + c;           q.push(make_pair(-dist[v], v));         }       }     }     reach.clear();     for (int i = 0; i < n; i++) {       if (taken[i]) continue;       if (dist[x[i] % mod] <= x[i]) {         reach.insert(make_pair(-c[i], i));       }     }   }   int main() {     long long h;     cin >> h;     n = read();     int m = read();     a[sz++] = read();     for (int i = 0; i < n; i++) {       scanf(  %I64d , x + i);       --x[i];       c[i] = read();     }     rebuild();     while (m--) {       int op = read();       if (op == 1) {         long long x;         scanf(  %I64d , &x);         a[sz++] = x;         rebuild();       } else if (op == 2) {         int id = read() - 1;         int y = read();         if (reach.find(make_pair(-c[id], id)) != reach.end()) {           reach.erase(make_pair(-c[id], id));           c[id] -= y;           reach.insert(make_pair(-c[id], id));         } else {           c[id] -= y;         }       } else if (op == 3) {         if (!reach.size()) {           puts( 0 );         } else {           printf( %d n , -reach.begin()->first);           taken[reach.begin()->second] = true;           reach.erase(reach.begin());         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mx = 1e5 + 5;   int f[mx];   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     vector<pair<int, int>> v;     for (int i = 3; 2 * i <= n; i += 2) {       if (f[i] == 0) {         int c = 0;         for (int j = i; j <= n; j += i) c += !f[j];         for (int j = i, l = -1; j <= n; j += i) {           if ((c & 1) && j == 2 * i) continue;           if (!f[j]) {             if (l == -1)               l = j;             else {               v.push_back({l, j});               l = -1;             }           }           f[j] = 1;         }       }     }     for (int j = 2, l = -1; j <= n; j += 2) {       if (!f[j]) {         if (l == -1)           l = j;         else {           v.push_back({l, j});           l = -1;         }       }     }     cout << v.size() <<   n ;     for (auto x : v) cout << x.first <<     << x.second <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100005;   int n, act;   int t[MAXN];   int last[MAXN], len[MAXN];   int main() {     scanf( %d , &n);     for (int i = 1; i < MAXN; ++i) len[i] = -1;     for (int i = 1; i <= n; ++i) {       scanf( %d , &t[i]);       act = t[i];       if (len[act] == -1) {         len[act] = 0;       } else if (len[act] >= 0) {         if (len[act] == 0)           len[act] = i - last[act];         else if (i - last[act] != len[act])           len[act] = -2;       }       last[act] = i;     }     int counter = 0;     for (int i = 1; i < MAXN; ++i)       if (len[i] >= 0) ++counter;     printf( %d n , counter);     for (int i = 1; i < MAXN; ++i) {       if (len[i] >= 0) {         printf( %d %d n , i, len[i]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int MaxN = 300005;   const long long int mod = 1e9 + 7;   const float pi = 3.1415926535897932384626433832795028;   long long int mcd(long long int a, long long int b) {     if (a == 0) return b;     return mcd(b % a, a);   }   int arr[MaxN];   void solve() {     int N, i, j, p, q;     cin >> N;     for (i = 1; i <= N; i++) {       cin >> arr[i];     }     p = 0, q = N + 1;     for (i = 1; i <= N; i++) {       if (arr[i] >= i - 1) {         p = i;       } else         break;     }     for (i = N; i > 0; i--) {       if (arr[i] >= N - i) {         q = i;       } else         break;     }     if (p >= q)       cout <<  Yes n ;     else       cout <<  No n ;   }   int main() {     long long int t, i;     cin >> t;     for (i = 1; i <= t; i++) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int out = 0, fh = 1;     char jp = getchar();     while ((jp >  9  || jp <  0 ) && jp !=  - ) jp = getchar();     if (jp ==  - ) fh = -1, jp = getchar();     while (jp >=  0  && jp <=  9 ) out = out * 10 + jp -  0 , jp = getchar();     return out * fh;   }   void print(int x) {     if (x >= 10) print(x / 10);     putchar( 0  + x % 10);   }   void write(int x, char c) {     if (x < 0) putchar( - ), x = -x;     print(x);     putchar(c);   }   int phi(int x) {     int res = x;     for (int i = 2; i * i <= x; ++i)       if (x % i == 0) {         res /= i, res *= i - 1;         while (x % i == 0) x /= i;       }     if (x > 1) res /= x, res *= x - 1;     return res;   }   int mul(int a, int b, int Mod) {     long long pr = 1LL * a * b;     if (pr < Mod) return pr;     return pr % Mod + Mod;   }   int fpow(int a, int b, int Mod) {     int res = 1;     while (b) {       if (b & 1) res = mul(res, a, Mod);       a = mul(a, a, Mod);       b >>= 1;     }     return res;   }   int f(int x, int Mod) {     if (x < Mod) return x;     return x % Mod + Mod;   }   const int N = 1e5 + 10;   int n, m, q, Mod[N], k = 0, a[N];   int query(int l, int r, int p) {     if (l == r || p == k) return f(a[l], Mod[p]);     int base = a[l], expo = query(l + 1, r, p + 1);     return fpow(base, expo, Mod[p]);   }   signed main() {     n = read(), m = read();     while (1) {       Mod[++k] = m;       if (m == 1) break;       m = phi(m);     }     for (int i = 1; i <= n; ++i) a[i] = read();     q = read();     for (int i = 1; i <= q; ++i) {       int l = read(), r = read();       int ans = query(l, r, 1) % Mod[1];       write(ans,   n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t[101000], n, h[101000], p[101000];   pair<int, int> w[101000];   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %d , &t[i]);       w[i].first = t[i];       w[i].second = i;     }     sort(w, w + n);     for (int i = n - 1; i >= 0; i--) {       h[i] = ((long long)h[i + 1] * 1337 + t[i]) % 1000000009;     }     p[0] = 1;     for (int i = 1; i <= n; i++) p[i] = (long long)p[i - 1] * 1337 % 1000000009;     vector<pair<int, int> > s;     for (int i = 0; i < n; i++) {       int j = i + 1;       while (j < n && w[j].first == w[i].first) {         int len = w[j].second - w[i].second, start = w[i].second;         long long tmp = h[start] - (long long)h[start + len] * p[len];         tmp -= h[start + len] - (long long)h[start + 2 * len] * p[len];         if (tmp % 1000000009 == 0) s.push_back(pair<int, int>(len, start));         j++;       }     }     sort(s.begin(), s.end());     int first = 0;     for (int i = 0; i < s.size(); i++)       if (s[i].second >= first) {         first = s[i].second + s[i].first;       }     printf( %d n , n - first);     for (int i = first; i < n; i++) printf( %d%c , t[i], i + 1 < n ?     :   n );   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6;   const int inf = 1e9;   const int mod = 1e9 + 7;   const long long INF = 1e18;   long long a00, a01, a10, a11, cnt0, cnt1, cnt01, cnt10, ins = 0, t = -1;   long long p[N];   void get() {     for (int i = 1; i <= ins; ++i) {       cout << 1;     }     if (t == -1) {       for (int i = 0; i < cnt0; ++i) {         cout << 0;       }     } else {       ins++;       for (int i = 0; i < cnt0 - t; ++i) {         cout << 0;       }       cout << 1;       for (int i = cnt0 - t; i < cnt0; ++i) {         cout << 0;       }     }     for (int i = ins + 1; i <= cnt1; ++i) {       cout << 1;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     for (long long a = 1; a * (a - 1) / 2 < 1e11 + 1000; ++a) {       p[a] = a * (a - 1) / 2;     }     cin >> a00 >> a01 >> a10 >> a11;     if (!a00 && !a01 && !a10 && !a11) {       return cout << 0, 0;     }     for (int i = 1; i < N; ++i) {       if (p[i] > a00) {         return cout <<  Impossible , 0;       }       if (a00 == p[i]) {         cnt0 = i;         break;       }     }     for (int i = 1; i < N; ++i) {       if (p[i] > a11) {         return cout <<  Impossible , 0;       }       if (a11 == p[i]) {         cnt1 = i;         break;       }     }     if (!a01 && !a10) {       if (!a00) {         for (int i = 0; i < cnt1; ++i) {           cout << 1;         }         return 0;       }       if (!a11) {         for (int i = 0; i < cnt0; ++i) {           cout << 0;         }         return 0;       }     }     if (cnt0 * cnt1 != a01 + a10) {       return cout <<  Impossible , 0;     }     cnt01 = cnt0 * cnt1;     cnt10 = 0;     for (int i = 1; i <= cnt1; ++i) {       if (cnt01 - cnt0 >= a01) {         cnt01 -= cnt0;         cnt10 += cnt0;         ++ins;       } else {         t = cnt01 - a01;         cnt01 -= t;         cnt10 += t;       }       if (cnt01 == a01 && cnt10 == a10) {         get();         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3e5 + 10;   long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }   long long lcm(long long a, long long b) { return a * b / gcd(a, b); }   long long a[maxn], suf[maxn];   int main() {     long long n, ans = 0;     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = n; i >= 1; i--) suf[i] = gcd(suf[i + 1], a[i]);     for (int i = 1; i <= n; i++) ans = gcd(ans, lcm(a[i], suf[i + 1]));     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e18;   const int MAXN = 5 * 1e5 + 1, MODM = 1e9 + 7;   int n;   vector<int> g[MAXN];   int sz[MAXN];   int pr[MAXN];   int ans[MAXN];   int m1, m2;   int now;   int root = -1;   void dfs(int v, int p = -1) {     sz[v] = 1;     pr[v] = p;     for (auto to : g[v]) {       if (to != p) {         dfs(to, v);         sz[v] += sz[to];       }     }   }   void dfs2(int v, int p = -1) {     int k = m1;     if (sz[now] == m1) k = m2;     ans[v] |= (n - sz[v] - k <= (n / 2));     ans[v] |= (n - sz[now] <= (n / 2));     for (auto it : g[v])       if (it != p) dfs2(it, v);   }   int main() {     ios_base::sync_with_stdio(0);     cin >> n;     for (int i = 0; i < n - 1; i++) {       int a, b;       cin >> a >> b;       g[a].push_back(b);       g[b].push_back(a);     }     dfs(1);     for (int v = 1; v <= n; v++) {       int cnt = 0;       for (auto to : g[v])         if (to != pr[v]) cnt += (sz[to] <= (n / 2));       if (v != 1) cnt += (n - sz[v] <= (n / 2));       ans[v] = (cnt == g[v].size());       if (ans[v]) root = v;     }     if (root == -1) {       for (int i = 0; i < n; i++) cout << 0 <<    ;       return 0;     }     fill(sz, sz + MAXN, 0);     dfs(root);     for (auto it : g[root]) {       if (sz[it] > m1) {         m2 = m1;         m1 = sz[it];       } else         m2 = max(m2, sz[it]);     }     for (auto it : g[root]) {       now = it;       dfs2(it, root);     }     for (int i = 0; i < n; i++) cout << ans[i + 1] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e5;   const long double PI = acos(-1.0);   char d[MAX];   int l[MAX];   int w[MAX];   int pos;   int main() {     long long n;     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n;     long long i;     for (i = 0; i < n; i++) cin >> d[i];     for (i = 0; i < n; i++) cin >> l[i];     while (w[pos] == 0) {       w[pos] = 1;       if (d[pos] ==  > )         pos += l[pos];       else         pos -= l[pos];       if (pos < 0 || pos >= n) {         cout <<  FINITE               <<   n ;         return 0;       }     }     cout <<  INFINITE           <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, k;     cin >> n >> k;     for (int i = 0; i < k; i++) {       if (n % 10 > 0) {         n--;       } else         n /= 10;     }     cout << n;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[100100];   int main() {     int n, m;     scanf( %d %d %s , &n, &m, s);     long long ans = 0, cnt = 1, num = 0;     for (int i = 1; s[i]; i++) {       cnt += s[i] != s[i - 1];     }     ans += cnt * n * (m - 1);     cnt = 1;     for (int i = 1; s[i]; i++) {       if (s[i] != s[i - 1] && (cnt == 1 || s[i] == s[i - 2])) {         cnt++;       } else {         num += cnt * (cnt - 1) / 2;         if (cnt != 1) i--;         cnt = 1;       }     }     num += cnt * (cnt - 1) / 2;     cout << ans - num << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /stack:200000000 )   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   #pragma GCC optimize( unroll-loops )   using namespace std;   template <class A, class B>   ostream& operator<<(ostream& out, const pair<A, B>& a) {     return out <<  (  << a.first <<  ,   << a.second <<  ) ;   }   template <class A>   ostream& operator<<(ostream& out, const vector<A>& v) {     out <<  [ ;     for (int i = 0; i < v.size(); i++) {       if (i) out <<  ,  ;       out << v[i];     }     return out <<  ] ;   }   void solve() {     long long n, x;     cin >> n >> x;     int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     long long sum = 0;     for (int i = 0; i < n; i++) sum += a[i];     if (sum % x != 0)       cout << n <<   n ;     else {       long long res = -1;       long long s = 0;       for (int i = 0; i < n; i++) {         s += a[i];         sum -= a[i];         if (s % x != 0) res = max(res, (long long)i + 1);         if (sum % x != 0) res = max(res, n - i - 1);       }       cout << res <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int q = 1;     cin >> q;     for (int kase = 1; kase <= q; kase++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, s, e;   long long x[5001];   long long a[5001];   long long b[5001];   long long c[5001];   long long d[5001];   long long pd[5001][5001];   long long func(int at, int comp, int left, int right) {     if (comp <= 0 && at != 0) return 0x3f3f3f3f3f3f3f3fll;     if (at == n) return ((comp == 1) ? 0 : 0x3f3f3f3f3f3f3f3fll);     if (pd[at][comp] != -1) return pd[at][comp];     long long ans = 0x3f3f3f3f3f3f3f3fll;     int onlycomp = (comp - left - right);     if (at != s && at != e) {       ans = func(at + 1, comp + 1, left, right) - 2 * x[at] + d[at] + b[at];       if (left) {         ans = min(ans, func(at + 1, comp, left, right) + a[at] + d[at]);         if (onlycomp)           ans = min(ans, func(at + 1, comp - 1, left, right) + a[at] + c[at] +                              2 * x[at]);       }       if (right) {         ans = min(ans, func(at + 1, comp, left, right) + c[at] + b[at]);         if (onlycomp)           ans = min(ans, func(at + 1, comp - 1, left, right) + c[at] + a[at] +                              2 * x[at]);       }       if (onlycomp) {         ans = min(             ans, func(at + 1, comp - 1, left, right) + c[at] + a[at] + 2 * x[at]);         ans = min(ans, func(at + 1, comp, left, right) + b[at] + c[at]);         ans = min(ans, func(at + 1, comp, left, right) + a[at] + d[at]);       }       if (at == n - 1 && comp == 2)         ans = min(             ans, func(at + 1, comp - 1, left, right) + c[at] + a[at] + 2 * x[at]);     } else if (at == s) {       ans = func(at + 1, comp + 1, 1, right) - x[at] + d[at];       if (onlycomp) ans = min(ans, func(at + 1, comp, 1, right) + x[at] + c[at]);       if (at == n - 1 && comp == 1)         ans = min(ans, func(at + 1, comp, 1, right) + c[at] + x[at]);     } else {       ans = func(at + 1, comp + 1, left, 1) - x[at] + b[at];       if (onlycomp) ans = min(ans, func(at + 1, comp, left, 1) + x[at] + a[at]);       if (at == n - 1 && comp == 1)         ans = min(ans, func(at + 1, comp, left, 1) + a[at] + x[at]);     }     return pd[at][comp] = ans;   }   int main() {     scanf( %d %d %d , &n, &s, &e);     s--;     e--;     for (int i = 0; i < n; i++) scanf( %lld , &x[i]);     for (int i = 0; i < n; i++) scanf( %lld , &a[i]);     for (int i = 0; i < n; i++) scanf( %lld , &b[i]);     for (int i = 0; i < n; i++) scanf( %lld , &c[i]);     for (int i = 0; i < n; i++) scanf( %lld , &d[i]);     memset(pd, -1, sizeof pd);     printf( %lld n , func(0, 0, 0, 0));     return 0;   }
#include <bits/stdc++.h>   const int MAXN = 1005;   int a[MAXN];   int cnt[MAXN];   int main() {     int n, k;     while (scanf( %d%d , &n, &k) + 1) {       memset(cnt, 0, sizeof(cnt));       for (int i = 1; i <= n; i++) scanf( %d , &a[i]);       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= n; j++) {           if ((j - i) * k == a[j] - a[i]) {             cnt[i]++;           }         }       }       int mm = 0;       int p = 0;       for (int i = 1; i <= n; i++) {         if (cnt[i] > mm && a[i] - (i - 1) * k > 0) {           mm = cnt[i];           p = i;         }       }       printf( %d n , n - mm);       for (int i = 1; i <= n; i++) {         if ((i - p) * k != a[i] - a[p]) {           if (a[i] - a[p] > (i - p) * k) {             printf( - %d %d n , i, a[i] - a[p] - (i - p) * k);           } else {             printf( + %d %d n , i, (i - p) * k - a[i] + a[p]);           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int kbo[1001];   int main() {     int s, k, i;     scanf( %d%d , &s, &k);     kbo[0] = 0;     kbo[1] = 1;     kbo[2] = 1;     for (i = 3;; i++) {       if (i - k - 1 > 0)         kbo[i] = 2 * kbo[i - 1] - kbo[i - k - 1];       else         kbo[i] = 2 * kbo[i - 1];       if (kbo[i] > s) break;     }     for (int j = 0; j < i; ++j) {     }     int res[100], cnt = 0;     while (s > 0) {       i--;       if (s - kbo[i] >= 0) {         s -= kbo[i];         res[cnt++] = kbo[i];       }     }     if (cnt == 1)       printf( 2 n0 %d , res[0]);     else {       printf( %d n , cnt);       for (int j = 0; j < cnt; j++) printf( %d  , res[j]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10, K = 105, MOD = 998244353;   int p[N][K], dp[N][K], a[N], ans[N] = {1};   int n, k, len;   int sum(int l, int r, int x) {     l = max(l, 1);     r = min(r, n);     return p[r][x] - p[l - 1][x];   }   int main() {     cin >> n >> k >> len;     for (int i = 1; i <= n; i++) {       cin >> a[i];       if (a[i] == -1) a[i]++;       p[i][a[i]]++;       for (int j = 0; j <= k; j++) {         p[i][j] += p[i - 1][j];       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= k; j++) {         if (a[i] == 0 || a[i] == j) {           dp[i][j] = ans[i - 1];           if (sum(i - len + 1, i, j) + sum(i - len + 1, i, 0) == len) {             dp[i][j] -= ans[i - len] - dp[i - len][j];             if (dp[i][j] < 0) dp[i][j] += MOD;             if (dp[i][j] >= MOD) dp[i][j] -= MOD;           }         }       }       for (int j = 1; j <= k; j++) {         ans[i] += dp[i][j];         if (ans[i] >= MOD) ans[i] -= MOD;       }     }     cout << ans[n] <<   n ;   }