malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long N = 2e5 + 10, inf = 1e18;   struct SegTree {     long long l[N << 2], r[N << 2];     long long mn[N << 2], tag[N << 2];     inline void push_up(long long i) { mn[i] = min(mn[i << 1], mn[i << 1 | 1]); }     inline void push_down(long long i) {       mn[i << 1] += tag[i];       mn[i << 1 | 1] += tag[i];       tag[i << 1] += tag[i];       tag[i << 1 | 1] += tag[i];       tag[i] = 0;     }     void build(long long i, long long x, long long y) {       l[i] = x;       r[i] = y;       if (x == y) return;       build(i << 1, x, (x + y) >> 1);       build(i << 1 | 1, ((x + y) >> 1) + 1, y);     }     void update(long long i, long long x, long long y, long long k) {       if (l[i] >= x && r[i] <= y) {         mn[i] += k;         tag[i] += k;         return;       }       push_down(i);       if (r[i << 1] >= x) update(i << 1, x, y, k);       if (l[i << 1 | 1] <= y) update(i << 1 | 1, x, y, k);       push_up(i);     }     long long query(long long i, long long x, long long y) {       if (l[i] >= x && r[i] <= y) return mn[i];       push_down(i);       long long ans = inf;       if (r[i << 1] >= x) ans = min(ans, query(i << 1, x, y));       if (l[i << 1 | 1] <= y) ans = min(ans, query(i << 1 | 1, x, y));       push_up(i);       return ans;     }   };   SegTree dis1, dis2;   long long n, m, cnt, u[N << 2], v[N << 2], c[N << 2], f[N], dfn[N], siz[N],       dep[N];   vector<pair<long long, long long> > edge[N];   long long dfs(long long u, long long sum, long long depth) {     cnt++;     dep[u] = depth;     dfn[u] = cnt;     siz[u] = 1;     dis1.update(1, dfn[u], dfn[u], sum);     dis2.update(1, dfn[u], dfn[u], sum + f[u]);     for (long long i = 0; i < edge[u].size(); i++)       siz[u] += dfs(edge[u][i].first, sum + edge[u][i].second, dep[u] + 1);     return siz[u];   }   int main() {     scanf( %lld%lld , &n, &m);     dis1.build(1, 1, n);     dis2.build(1, 1, n);     for (long long i = 1; i <= n - 1; i++) {       scanf( %lld%lld%lld , &u[i], &v[i], &c[i]);       edge[u[i]].push_back(make_pair(v[i], c[i]));     }     for (long long i = n; i <= 2 * n - 2; i++) {       scanf( %lld%lld%lld , &u[i], &v[i], &c[i]);       f[u[i]] = c[i];     }     dfs(1ll, 0ll, 1ll);     while (m--) {       long long op, x, y;       scanf( %lld%lld%lld , &op, &x, &y);       if (op == 1) {         if (x <= n - 1) {           dis1.update(1ll, dfn[v[x]], dfn[v[x]] + siz[v[x]] - 1, y - c[x]);           dis2.update(1ll, dfn[v[x]], dfn[v[x]] + siz[v[x]] - 1, y - c[x]);           c[x] = y;         } else {           dis2.update(1ll, dfn[u[x]], dfn[u[x]], y - f[u[x]]);           f[u[x]] = y;         }       } else {         if (dfn[x] <= dfn[y] && dfn[x] + siz[x] - 1 >= dfn[y]) {           printf( %lld n , dis1.query(1ll, dfn[y], dfn[y]) -                                dis1.query(1ll, dfn[x], dfn[x]));         } else {           printf( %lld n , dis2.query(1ll, dfn[x], dfn[x] + siz[x] - 1) -                                dis1.query(1ll, dfn[x], dfn[x]) +                                dis1.query(1ll, dfn[y], dfn[y]));         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ii = pair<int, int>;   const int MOD(1e9 + 7);   const int MAXN(1e5 + 11);   int n, first, z, a, l;   int main() {     scanf( %d%d%d%d%d , &n, &first, &z, &a, &l);     int ans = 0;     for (int ptr = 0; ptr < n;) {       if (ptr)         ptr += max(0, first - l);       else         ptr += first;       first += a;       first = min(first, z);       ++ans;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-7;   const int MX = 1111 * 1111 * 2;   int n, m;   const double pi = acos(-1.0);   int len, res[MX], mx;   struct Complex {     double r, i;     Complex(double r = 0, double i = 0) : r(r), i(i){};     Complex operator+(const Complex &rhs) {       return Complex(r + rhs.r, i + rhs.i);     }     Complex operator-(const Complex &rhs) {       return Complex(r - rhs.r, i - rhs.i);     }     Complex operator*(const Complex &rhs) {       return Complex(r * rhs.r - i * rhs.i, i * rhs.r + r * rhs.i);     }   } va[MX], vb[MX], ve[MX], vc[MX];   void rader(Complex F[], int len) {     int j = len >> 1;     for (int i = 1; i < len - 1; ++i) {       if (i < j) swap(F[i], F[j]);       int k = len >> 1;       while (j >= k) {         j -= k;         k >>= 1;       }       if (j < k) j += k;     }   }   void FFT(Complex F[], int len, int t) {     rader(F, len);     for (int h = 2; h <= len; h <<= 1) {       Complex wn(cos(-t * 2 * pi / h), sin(-t * 2 * pi / h));       for (int j = 0; j < len; j += h) {         Complex E(1, 0);         for (int k = j; k < j + h / 2; ++k) {           Complex u = F[k];           Complex v = E * F[k + h / 2];           F[k] = u + v;           F[k + h / 2] = u - v;           E = E * wn;         }       }     }     if (t == -1)       for (int i = 0; i < len; ++i) F[i].r /= len;   }   void Conv(Complex a[], Complex b[], int len) {     FFT(a, len, 1);     FFT(b, len, 1);     for (int i = 0; i < len; ++i) a[i] = a[i] * b[i];     FFT(a, len, -1);     for (int i = 0; i < len; ++i) a[i].r = (a[i].r > 0.5);   }   void init(Complex *a, Complex *b) {     for (int i = 0; i < len; i++) a[i].i = 0, a[i].r = b[i].r;   }   void _init(Complex *a) {     for (int i = 0; i < len; i++) a[i].i = 0;   }   void Out(int a) {     if (a > 9) Out(a / 10);     putchar(a % 10 +  0 );   }   void print(Complex *a) {     for (int i = 0; i < len; i++) printf( %d  , (int)(a[i].r + 0.5));     cout << endl;   }   void gao() {     len = 1;     while (len < mx) len <<= 1;     ve[0].r = 1;     while (m) {       if (m & 1) {         init(vc, va);         Conv(ve, va, len);         _init(ve);         init(va, vc);         if (m == 1) break;       }       init(vb, va);       Conv(va, vb, len);       _init(va);       m >>= 1;     }     for (int i = 0; i < len; ++i) res[i] = ve[i].r + 0.5;     for (int i = 0; i < len; i++)       if (res[i]) Out(i), putchar(   );     cout << endl;   }   int main() {     while (cin >> n >> m) {       int maxn = 0;       for (int i = 0; i < n; i++) {         int x;         scanf( %d , &x);         maxn = max(maxn, x);         va[x].r = 1;         va[x].i = 0;       }       mx = maxn * m + 1;       gao();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 10009;   const int D = 5001;   int n;   vector<vector<pair<int, int>>> hs(N, vector<pair<int, int>>());   vector<vector<pair<int, int>>> vs(N, vector<pair<int, int>>());   vector<vector<int>> ds(N, vector<int>());   class FenwickTree {    public:     FenwickTree(int n) { arr.assign(n + 1, 0); }     int rsq(int a) {       int res = 0;       for (; a; a -= LSOne(a)) {         res += arr[a];       }       return res;     }     int rsq(int a, int b) { return rsq(b) - (a == 1 ? 0 : rsq(a - 1)); }     void update(int a, int c) {       for (; a < arr.size(); a += LSOne(a)) {         arr[a] += c;       }     }       private:     vector<int> arr;     int LSOne(int a) { return ((a) & (-a)); }   };   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n;     for (int i = 0; i < n; ++i) {       int x1, y1, x2, y2;       cin >> x1 >> y1 >> x2 >> y2;       x1 += D;       x2 += D;       y1 += D;       y2 += D;       if (x1 == x2) {         vs[x1].emplace_back(min(y1, y2), max(y1, y2));       } else {         hs[y1].emplace_back(min(x1, x2), max(x1, x2));       }     }     long long res = 0;     for (int i = 1; i < N; ++i)       for (auto h : hs[i]) {         int l = h.first;         int r = h.second;         for (int j = 0; j < N; ++j) ds[j].clear();         FenwickTree ft(N);         for (int x = l; x <= r; ++x)           for (auto v : vs[x]) {             if (v.first <= i && v.second > i) {               ft.update(x, 1);               ds[v.second].push_back(x);             }           }         for (int y = i + 1; y < N; y++) {           for (auto h : hs[y]) {             int s = ft.rsq(h.first, h.second);             res += (s * (s - 1)) / 2ll;           }           for (int v : ds[y]) {             ft.update(v, -1);           }         }       }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   stack<int> s;   int a[(int)(1e+6) * 5];   bool b[(int)(1e+6) * 5];   int main() {     ios_base::sync_with_stdio(0);     int n, i, t, x;     cin >> n;     for (i = 1; i <= n; i++) cin >> a[i];     cin >> t;     while (t > 0) cin >> x, b[x] = 1, t--;     for (i = n; i > 0; i--) {       x = -1;       if (!s.empty()) x = s.top();       if (x != -1 && !b[i] && a[i] == a[x])         a[x] *= -1, s.pop();       else         s.push(i);     }     if (!s.empty()) {       cout <<  NO ;       return 0;     }     cout <<  YES n ;     for (i = 1; i <= n; i++) cout << a[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 0x3f3f3f3f;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long test;     test = 1;     while (test--) {       int a, b, c, d;       cin >> a >> b >> c >> d;       int misha = max((3 * a) / 10.0, a - (a * c) / 250.0);       int vasya = max((3 * b) / 10.0, b - (b * d) / 250.0);       if (misha == vasya) {         cout <<  Tie  << endl;       } else if (misha > vasya) {         cout <<  Misha  << endl;       } else if (misha < vasya) {         cout <<  Vasya  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-8;   const double pi = acos(-1.0);   const int inf = 2147483647;   int n, w;   int a[1005];   bool first;   int MIN;   void output(int x) {     if (first)       first = false;     else       printf(   );     if (x == MIN)       x = 0;     else if (x == 0)       x = MIN;     printf( %d , x + 1);   }   int main() {     scanf( %d%d , &n, &w);     int total = 0;     MIN = 0;     for (int i = 0; i < n; i++) {       scanf( %d , &a[i]);       total += a[i];       if (a[MIN] > a[i]) MIN = i;     }     first = true;     if (w >= a[MIN] && w <= total) {       printf( Yes n );       swap(a[0], a[MIN]);       output(0);       total = total - w;       for (int i = 1; i < n && total; i++) {         while (total && a[i]) {           total--;           a[i]--;           output(i);           output(i);         }       }       output(0);       a[0]--;       for (int i = 0; i < n; i++) {         while (a[i]) {           a[i]--;           output(i);           output(i);         }       }       printf(  n );     } else if (w > total || n == 1) {       printf( No n );     } else if (w <= 1) {       printf( No n );     } else {       printf( Yes n );       swap(a[0], a[MIN]);       output(0);       total = total - w;       for (int i = 1; i < n && total; i++) {         int limit = (i == 1 ? 1 : 0);         while (total && a[i] > limit) {           total--;           a[i]--;           output(i);           output(i);         }       }       output(0);       a[0]--;       output(1);       while (a[0] >= w - 1) {         output(0);         output(0);         a[0]--;       }       output(1);       while (a[0]) {         output(0);         output(0);         a[0]--;       }       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n], b[n], c = 0, d = 0, e = 0, i;     for (i = 0; i < n; i++) {       cin >> a[i] >> b[i];       if (a[i] > b[i])         c++;       else if (b[i] > a[i])         d++;       else         e++;     }     if (c > d)       cout <<  Mishka  << endl;     else if (d > c)       cout <<  Chris  << endl;     else       cout <<  Friendship is magic!^^  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MM = 600005;   const long long MOD = 1000000007;   double a[MM], sum[MM];   char s[MM];   int main() {     sum[0] = a[0] = 0;     for (int i = 1; i < MM; i++) {       a[i] = a[i - 1] + 1.0 / i;       sum[i] = sum[i - 1] + a[i];     }     scanf( %s , s + 1);     int L = strlen(s + 1);     double ans = 0;     for (int j = 1; j <= L; j++) {       if (s[j] ==  I  || s[j] ==  E  || s[j] ==  A  || s[j] ==  O  ||           s[j] ==  U  || s[j] ==  Y )         ans += (sum[L] - sum[L - j]) - (sum[j - 1]);     }     printf( %.9lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, p, out[1010];   struct node {     int v, c;   };   vector<node> e[1010];   int t1[1010], t2[1010], r[1010], k;   void dfs(int i, int fa, int mi) {     if (e[i].size() == 0) {       t1[k] = fa;       t2[k] = i;       r[k] = mi;       k++;       return;     }     mi = min(e[i][0].c, mi);     dfs(e[i][0].v, fa, mi);   }   int main() {     while (cin >> n >> p) {       int u;       node a;       memset(out, 0, sizeof(out));       for (int i = 0; i <= n; i++) e[i].clear();       for (int i = 0; i < p; i++) {         scanf( %d%d%d , &u, &a.v, &a.c);         e[u].push_back(a);         out[u]++;         out[a.v]--;       }       k = 0;       for (int i = 1; i <= n; i++)         if (out[i] == 1) dfs(i, i, 99999999);       printf( %d n , k);       for (int i = 0; i < k; i++) printf( %d %d %d n , t1[i], t2[i], r[i]);     }   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int p = 0, q = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) ch ==  -  ? q = -1 : 0, ch = getchar();     while (ch >=  0  && ch <=  9 ) p = p * 10 + ch -  0 , ch = getchar();     return p * q;   }   long long readll() {     long long p = 0, q = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) ch ==  -  ? q = -1 : 0, ch = getchar();     while (ch >=  0  && ch <=  9 ) p = p * 10 + ch -  0 , ch = getchar();     return p * q;   }   bool cmp(int x, int y) { return x > y; }   int power(long long a, int b) {     long long c = 1;     while (b) {       if (b & 1) c = c * a % 998244353;       a = a * a % 998244353;       b >>= 1;     }     return c;   }   int n, a[300005], pre[300005];   int main() {     n = read();     for (int i = 1; i <= n; i++) a[i] = read();     sort(a + 1, a + 1 + n, cmp);     for (int i = 1; i <= n; i++) pre[i] = (pre[i - 1] + a[i]) % 998244353;     for (int k = 1; k <= n; k++) {       int low = (n - k) / k;       long long ans = 0;       for (int j = 1; j <= low; j++)         ans = (ans + 1ll * (pre[(j + 1) * k] - pre[j * k]) * j) % 998244353;       ans = (ans + 1ll * (pre[n] - pre[low * k + k]) * (low + 1)) % 998244353;       printf( %I64d%s ,              (ans * power(n, 998244353 - 2) % 998244353 + 998244353) % 998244353,              k == n ?   n  :    );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5;   int n, m, head[N], cnt, dep[N], fa[N], pid[N];   long long c[N], val[N];   bool vis[N], use[N];   struct edge {     int to, nxt, id;   } e[N << 1];   void finish() {     cout <<  YES n ;     for (int i = 1; i <= m; ++i) cout << val[i] <<   n ;     exit(0);   }   void dfs(int u) {     vis[u] = 1;     for (int i = head[u]; i; i = e[i].nxt)       if (!vis[e[i].to]) {         fa[e[i].to] = u;         dep[e[i].to] = dep[u] + 1;         pid[e[i].to] = e[i].id;         use[e[i].id] = 1;         dfs(e[i].to);       }     if (u != 1) {       val[pid[u]] = c[u];       c[fa[u]] -= c[u];       c[u] = 0;     }   }   void dfs2(int u) {     for (int i = head[u]; i; i = e[i].nxt)       if (!use[e[i].id] && (dep[e[i].to] - dep[u]) % 2 == 0) {         assert(dep[e[i].to] > dep[u]);         int fh = dep[u] % 2;         long long dlt = c[1] / 2;         if (fh == 1) dlt *= -1;         val[e[i].id] = dlt;         c[u] -= dlt, c[e[i].to] -= dlt;         for (int v = e[i].to; v != 1; v = fa[v]) {           val[pid[v]] += c[v];           c[fa[v]] -= c[v];           c[v] = 0;         }         assert(!c[1]);         finish();       }     for (int i = head[u]; i; i = e[i].nxt)       if (use[e[i].id] && dep[e[i].to] > dep[u]) dfs2(e[i].to);   }   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n >> m;     for (int i = 1; i <= n; ++i) cin >> c[i];     for (int i = 1; i <= m; ++i) {       int u, v;       cin >> u >> v;       e[++cnt] = (edge){v, head[u], i}, head[u] = cnt;       e[++cnt] = (edge){u, head[v], i}, head[v] = cnt;     }     dfs(1);     if (c[1] % 2 == 0) {       if (c[1])         dfs2(1);       else         finish();     }     cout <<  NO n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<string> split(const string& s, char c) {     vector<string> v;     stringstream ss(s);     string x;     while (getline(ss, x, c)) v.push_back(move(x));     return move(v);   }   void err(vector<string>::iterator it) {}   template <typename T, typename... Args>   void err(vector<string>::iterator it, T a, Args... args) {     cerr << it->substr((*it)[0] ==    , it->length()) <<   =   << a <<   n ;     err(++it, args...);   }   int N, M;   int S[300013];   set<int> flv[300013];   vector<int> adj[300013];   int ans = 1;   int color[300013];   void dfs(int n, int p = 0) {     set<int> s;     int cur = 1;     for (int x : flv[n]) {       if (color[x]) {         s.insert(color[x]);       }     }     for (int x : flv[n]) {       if (!color[x]) {         while (s.count(cur)) cur++;         color[x] = cur++;       }     }     for (int v : adj[n]) {       if (v != p) {         dfs(v, n);       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> N >> M;     for (int i = 1; i <= N; i++) {       cin >> S[i];       ans = max(ans, S[i]);       for (int j = 0; j < S[i]; j++) {         int k;         cin >> k;         flv[i].insert(k);       }     }     for (int i = 1; i < N; i++) {       int u, v;       cin >> u >> v;       adj[u].push_back(v);       adj[v].push_back(u);     }     dfs(1);     cout << ans << endl;     for (int i = 1; i <= M; i++) {       cout << (color[i] ? color[i] : 1) <<    ;     }     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int q;     unsigned long long int n;     cin >> q;     for (int i = 0; i < q; i++) {       cin >> n;       if (n < 4) {         cout << 4 - n << endl;       } else {         if (n % 2 == 0) {           cout << 0 << endl;         } else {           cout << 1 << endl;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T abs(T t) {     return t < 0 ? -t : t;   }   const long long modn = 1000000007;   inline long long mod(long long x) { return x % modn; }   const int N = 1000009;   int a[N], t[N];   int gcd(int a, int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int A, B, n;   long long memo[N][2][2];   long long solve(int i, bool on, bool first) {     if (i == n) return (first && on) ? 100000000000000000ll : 0ll;     if (!on && t[i] == 2) return 100000000000000000ll;     long long &r = memo[i][on][first];     if (r != -1) return r;     if (on)       r = min(solve(i, false, first), solve(i + 1, true, first) + A);     else       r = solve(i + 1, false, first) + (t[i] == 1 ? B : 0ll);     return r;   }   void add_ps(set<int> &p, int x) {     for (int i = 2; i * i <= x; i++) {       if (!(x % i)) p.insert(i);       while (!(x % i)) x /= i;     }     if (x > 1) p.insert(x);   }   int main() {     int i;     scanf( %d %d %d , &n, &A, &B);     for (i = 0; i < n; i++) scanf( %d , &a[i]);     set<int> p;     for (i = -1; i <= 1; i++) add_ps(p, a[0] + i), add_ps(p, a[n - 1] + i);     long long ans = LLONG_MAX;     for (int x : p) {       for (i = 0; i < n; i++)         if ((a[i] % x) == 0)           t[i] = 0;         else if (!((a[i] + 1) % x) || !((a[i] - 1) % x))           t[i] = 1;         else           t[i] = 2;       memset(memo, -1, sizeof memo);       long long cur = 0;       for (i = 0; i < n; i++) {         ans = min(ans, cur + solve(i, true, !i));         if (t[i] == 1)           cur += B;         else if (t[i] == 2)           break;       }     }     printf( %I64d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   string solve(string s) {     if (s.size() & 1) {       return s;     }     string a = solve(s.substr(0, s.size() / 2));     string b = solve(s.substr(s.size() / 2));     if (a < b) {       return a.append(b);     } else {       return b.append(a);     }   }   int main() {     string s, t;     cin >> s >> t;     cout << (solve(s) == solve(t) ?  YES  :  NO ) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int c[500];   int main() {     string s, t;     int n, i, j, k;     cin >> s >> t;     bool ok = 1;     vector<pair<char, char> > ans;     n = s.length();     vector<char> v(500,  0 );     for (i = 0; i < n; i++) {       if (s[i] == t[i]) {         if (c[s[i]] == -2) ok = 0;         c[s[i]] = -1;         continue;       } else if (c[s[i]] == -1 || c[t[i]] == -1) {         ok = 0;       } else if (!c[s[i]] && !c[t[i]]) {         ans.push_back({s[i], t[i]});         c[s[i]] = -2;         v[s[i]] = t[i];         c[t[i]] = -2;         v[t[i]] = s[i];       } else if (c[s[i]] == -2 && c[t[i]] == -2) {         if (v[s[i]] != t[i] || v[t[i]] != s[i]) ok = 0;       } else         ok = 0;     }     if (!ok) return cout << -1, 0;     cout << ans.size() << endl;     for (i = 0; i < ans.size(); i++) {       cout << ans[i].first <<     << ans[i].second << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     string ans;     cin >> s;     int i = 0;     int j = 0;     while (i < s.size() & j < 3) {       if (j == 0) {         if (s[i] ==  f ) {           ans =  ftp:// ;           i = 3;         } else {           ans =  http:// ;           i = 4;         }         j = 1;       }       if (j == 1) {         int temp = i;         while (s[i + 1] !=  r  || s[i + 2] !=  u ) {           i++;         }         ans += s.substr(temp, i + 1 - temp);         ans +=  .ru ;         i = i + 3;         j = 2;       }       if (j == 2) {         if (s.size() - i) {           ans +=  / ;           ans += s.substr(i, s.size() - i);           i = s.size();         }       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200100;   const long long OO = 1e18;   const int oo = 2e9;   const int md = 998244353;   set<int> st;   set<int>::iterator ite;   int sto, n, p[N], obr = 1, ans = 0, mul[N], q, psm[N];   bool mrk[N];   int mult(int x, int y) { return (1ll * x * y) % md; }   int sum(int x, int y) {     x += y;     if (x >= md) x -= md;     return x;   }   int sub(int x, int y) {     x -= y;     if (x < 0) x += md;     return x;   }   int binpow(int x, int po) {     int res = 1;     while (po > 0) {       if (po & 1) res = mult(res, x);       x = mult(x, x);       po >>= 1;     }     return res;   }   int calc(int l, int r) {     int up = sub(psm[r - 1], (l - 2 < 0 ? 0 : psm[l - 2]));     up = mult(up, binpow(mul[l - 1], md - 2));     int down = mult(mul[r], binpow(mul[l - 1], md - 2));     return mult(up, binpow(down, md - 2));   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> q;     sto = binpow(100, md - 2);     mul[0] = 1;     mrk[1] = 1;     psm[0] = 1;     for (int i = 1; i <= n; i++) {       cin >> p[i];       p[i] = mult(p[i], sto);       mul[i] = mult(mul[i - 1], p[i]);       psm[i] = sum(psm[i - 1], mul[i]);     }     ans = calc(1, n);     st.clear();     st.insert(1);     st.insert(n + 1);     for (; q; q--) {       int ps;       cin >> ps;       if (!mrk[ps]) {         st.insert(ps);         ite = st.find(ps);         int lf = *prev(ite);         int rt = (*next(ite)) - 1;         ans = sub(ans, calc(lf, rt));         ans = sum(ans, calc(lf, ps - 1));         ans = sum(ans, calc(ps, rt));       } else {         ite = st.find(ps);         int lf = *prev(ite);         int rt = (*next(ite)) - 1;         ans = sum(ans, calc(lf, rt));         ans = sub(ans, calc(lf, ps - 1));         ans = sub(ans, calc(ps, rt));         st.erase(ite);       }       mrk[ps] ^= 1;       cout << ans <<   n ;     }     return 0;   }