malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long N = (long long)(5 * 1e5 + 10);   void precision(long long a) { cout << setprecision(a) << fixed; }   long long expo(long long a, long long b, long long m) {     long long res = 1;     while (b > 0) {       if (b & 1) res = (res * a) % m;       a = (a * a) % m;       b = b >> 1;     }     return res;   }   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 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 ceil_div(long long a, long long b) {     return a % b == 0 ? a / b : a / b + 1;   }   template <typename T>   istream &operator>>(istream &istream, vector<T> &v) {     for (auto &it : v) {       cin >> it;     }     return istream;   }   bool isPrime(long long n) {     if (n == 1) return false;     if (n == 2) return true;     for (long long i = 2; i * i <= n; i++) {       if (n % i == 0) return false;     }     return true;   }   void rec(long long n) {     cout << (long long)sqrt(n) + (long long)cbrt(n) - (long long)(sqrt(cbrt(n)))          <<   n ;   }   void sol() {     long long n;     cin >> n;     rec(n);   }   int32_t main() {     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);     long long t = 1;     cin >> t;     while (t--) {       sol();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, P[1005], D[1005];   int main() {     scanf( %d , &N);     for (int i = 1; i <= N; i++) {       scanf( %d , &P[i]);     }     D[1] = 1;     for (int i = 2; i <= N; i++) {       int p = P[i];       D[i] = 1;       for (int j = p; j < i; j++) {         D[i] += D[j] + 1;         D[i] %= 1000000007;       }     }     int res = 0;     for (int i = 1; i <= N; i++) {       res += D[i] + 1;       res %= 1000000007;     }     printf( %d n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   char mp[103][103];   int main() {     int i, j, cnt;     scanf( %d , &n);     for (i = 0; i < n; i++) scanf( %s , mp[i]);     cnt = 0;     for (i = 0; i < n; i++) {       for (j = 0; j < n; j++)         if (mp[i][j] ==  . ) break;       if (j != n) cnt++;     }     if (cnt == n) {       for (i = 0; i < n; i++)         for (j = 0; j < n; j++)           if (mp[i][j] ==  . ) {             printf( %d %d n , i + 1, j + 1);             break;           }       return 0;     }     int a, v, c;     cnt = 0;     for (i = 0; i < n; i++) {       for (j = 0; j < n; j++)         if (mp[j][i] ==  . ) break;       if (j != n) cnt++;     }     if (cnt == n) {       for (i = 0; i < n; i++)         for (j = 0; j < n; j++)           if (mp[j][i] ==  . ) {             printf( %d %d n , j + 1, i + 1);             break;           }       return 0;     }     puts( -1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1 << 30;   const long long Inf = 1ll << 60ll;   namespace io {   char buf[(1 << 23)], *p1 = buf, *p2 = buf, c;   long long f;   template <typename T>   T read() {     T x = 0;     f = 0;     c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, (1 << 23), stdin), p1 == p2)              ? EOF              : *p1++);     while (!isdigit(c))       (c ==  - ) && (f = 1),           c = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, (1 << 23), stdin),                             p1 == p2)                    ? EOF                    : *p1++);     while (isdigit(c))       x = x * 10 + (c & 15),       c = (p1 == p2 &&                    (p2 = (p1 = buf) + fread(buf, 1, (1 << 23), stdin), p1 == p2)                ? EOF                : *p1++);     return f ? -x : x;   }   }  // namespace io   const long long N = 200005, mod = 998244353;   long long n, k, fac[N], a[N], inv[N];   long long qpow(long long b, long long p) {     long long res = 1;     while (p) {       if (p & 1) res = res * b % mod;       b = b * b % mod;       p >>= 1ll;     }     return res;   }   long long C(long long x, long long y) {     return fac[x] * inv[y] % mod * inv[x - y] % mod;   }   signed main() {     scanf( %lld%lld , &n, &k);     long long cnt = 0;     fac[0] = inv[0] = 1;     for (long long i = 1; i <= n; ++i)       fac[i] = fac[i - 1] * i % mod, inv[i] = qpow(fac[i], mod - 2);     for (long long i = 1; i <= n; ++i) scanf( %lld , &a[i]);     for (long long i = 1; i < n; ++i)       if (a[i] != a[i + 1]) cnt++;     if (a[1] != a[n]) cnt++;     long long ans = qpow(k, n), v = 0;     for (long long i = 0; i <= cnt / 2; ++i)       (v += qpow(k - 2, cnt - i * 2) * C(cnt, i) % mod * C(cnt - i, i)) %= mod;     v = v * qpow(k, n - cnt) % mod;     printf( %lld n , (ans - v + mod) * (mod / 2 + 1) % mod);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int lsone(long long int p) { return (p & -p); }   string s1, s2;   int main() {     std::ios::sync_with_stdio(false);     cin >> s1;     cin >> s2;     if (s1 == s2)       cout << -1;     else       cout << max(s1.size(), s2.size());   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1 << 30;   int main() {     ios::sync_with_stdio(false);     long long int MOD = 1000000007LL;     string start, end;     int k;     while (cin >> start >> end >> k) {       const int N = static_cast<int>(start.size());       pair<long long int, long long int> dp(make_pair(1LL, 0LL));       for (int i = 0; i < k; ++i) {         pair<long long int, long long int> next;         next.first = (dp.second * (N - 1)) % MOD;         next.second = (dp.first + dp.second * (N - 2)) % MOD;         swap(dp, next);       }       long long int ans = 0LL;       if (start == end) ans += dp.first;       for (int i = 1; i < N; ++i) {         if (start.substr(i) + start.substr(0, i) == end) {           ans += dp.second;           ans %= MOD;         }       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using pii = pair<int, int>;   const int MOD = 1000000007;   int bcj[200010], siz[200010];   stack<pii> res;   void init(int n) {     for (int i = (0); i < (n + 2); i++) bcj[i] = i, siz[i] = 1;   }   int groot(int n) { return (bcj[n] == n) ? n : groot(bcj[n]); }   bool merg(int u, int v) {     u = groot(u), v = groot(v);     if (u == v) return 0;     if (siz[u] > siz[v]) swap(u, v);     res.push({u, v});     bcj[u] = v;     siz[v] += siz[u];     return 1;   }   void redact() {     assert(res.size());     pii k = res.top();     res.pop();     bcj[k.first] = k.first;     bcj[k.second] = k.second;     siz[k.second] -= siz[k.first];   }   void redact(int n) {     while (res.size() != n) redact();   }   struct cmd {     int s, t;   };   int ans[1 << 18];   vector<cmd> queries[1 << 20];   int N;   void insert(int idx, int l, int r, int L, int R, cmd q) {     if (r - l < 0) return;     if (L <= l && r <= R) {       queries[idx].push_back(q);       return;     }     if (R < l || r < L) return;     insert(2 * idx, l, (l + r) / 2, L, R, q);     insert(2 * idx + 1, (l + r) / 2 + 1, r, L, R, q);   }   void dfs(int idx, int l, int r) {     if (r - l < 0) return;     int sz = res.size();     for (cmd& k : queries[idx]) {       merg(k.s, k.t + N);       merg(k.t, k.s + N);       if (groot(k.s) == groot(k.s + N) || groot(k.t) == groot(k.t + N))         return redact(sz);     }     if (r - l == 0) return ans[l] = 1, void();     dfs(2 * idx, l, (l + r) / 2);     dfs(2 * idx + 1, (l + r) / 2 + 1, r);     redact(sz);   }   map<int, int> edges[100005];   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int q;     cin >> N >> q;     init(2 * N + 1);     for (int i = (1); i < ((q) + 1); i++) {       int x, y;       cin >> x >> y;       x--;       y--;       assert(x < y);       if (edges[x][y] == 0)         edges[x][y] = i;       else {         insert(1, 0, q + 3, edges[x][y], i - 1, {x, y});         edges[x][y] = 0;       }     }     for (int i = (0); i < (N); i++)       for (auto k : edges[i])         if (k.second) insert(1, 0, q + 3, k.second, q, {i, k.first});     dfs(1, 0, q + 3);     for (int i = (1); i < ((q) + 1); i++) cout << (ans[i] ?  YES n  :  NO n );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a[150], i, j, best, ans = 10000;     cin >> n;     for (i = 0; i < n; ++i) cin >> a[i];     for (i = 1; i < n - 1; ++i) {       best = 0;       for (j = 1; j < n; ++j)         if (j != i)           best = max(best, a[j] - a[j - 1]);         else {           best = max(best, a[j + 1] - a[j - 1]);           ++j;         }       ans = min(ans, best);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }   const int MAXN = 100000;   int n, MOD, l, r;   int egcd(int x, int y, int &a, int &b) {     if (y == 0) {       a = 1, b = 0;       return x;     }     int g = egcd(y, x % y, b, a);     b -= a * (x / y);     return g;   }   int inv(int x) {     int a, b, g = egcd(x, MOD, a, b);     assert(g == 1);     if (a < 0) a += MOD;     return a;   }   vector<int> p;   typedef struct VAL {     vector<int> a;     int b;     VAL() {       a = vector<int>(((int)(p).size()), 0);       b = 1;     }     VAL(int x) {       a = vector<int>(((int)(p).size()), 0);       for (int i = (0); i < (((int)(p).size())); ++i)         while (x % p[i] == 0) ++a[i], x /= p[i];       b = x;     }   } VAL;   VAL operator*(const VAL &u, const VAL &v) {     VAL ret;     for (int i = (0); i < (((int)(p).size())); ++i) ret.a[i] = u.a[i] + v.a[i];     ret.b = (long long)u.b * v.b % MOD;     return ret;   }   VAL operator/(const VAL &u, const VAL &v) {     VAL ret;     for (int i = (0); i < (((int)(p).size())); ++i) ret.a[i] = u.a[i] - v.a[i];     ret.b = (long long)u.b * inv(v.b) % MOD;     return ret;   }   VAL fact[MAXN + 1];   void precalc() {     {       p.clear();       int x = MOD;       for (int i = 2; i * i <= x; ++i)         if (x % i == 0) {           p.push_back(i);           while (x % i == 0) x /= i;         }       if (x != 1) p.push_back(x);     }     fact[0] = VAL(1);     for (int i = (1); i <= (MAXN); ++i) fact[i] = fact[i - 1] * VAL(i);   }   int pw(int x, int n) {     int ret = 1;     while (true) {       if (n & 1) ret = (long long)ret * x % MOD;       if ((n >>= 1) == 0) return ret;       x = (long long)x * x % MOD;     }   }   int C(int n, int k) {     VAL res = fact[n] / fact[k] / fact[n - k];     int ret = res.b;     for (int i = (0); i < (((int)(p).size())); ++i)       ret = (long long)ret * pw(p[i], res.a[i]) % MOD;     return ret;   }   int ways[MAXN + 1];   void run() {     scanf( %d%d%d%d , &n, &MOD, &l, &r);     precalc();     for (int i = (0); i <= (n); ++i) {       ways[i] = 0;       int la = (l + i + 1) / 2, ra = min(i, (r + i) / 2);       if (la > ra) continue;       if (ra == i) ++ways[i], --ra;       if (la > ra) continue;       ways[i] = (ways[i] + (long long)C(i, la) + MOD - C(i, ra + 1)) % MOD;     }     int ret = 0;     for (int i = (0); i <= (n); ++i)       ret = (ret + (long long)ways[i] * C(n, i)) % MOD;     printf( %d n , ret);   }   int main() {     run();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int const nmax = 100000;   int const modulo = 1000000007;   struct Edge {     int to;     int cost;   };   vector<Edge> g[1 + nmax], g2[1 + nmax];   int seen[1 + nmax], seen2[1 + nmax];   void dfs(int node, bool &fatal, int acc) {     seen[node] = acc;     for (int h = 0; h < g[node].size(); h++) {       Edge e = g[node][h];       if (seen[e.to] == -1)         dfs(e.to, fatal, acc ^ e.cost);       else if (seen[e.to] != (acc ^ e.cost)) {         fatal = true;       }     }   }   void dfs2(int node, bool &fatal, int acc) {     seen2[node] = acc;     for (int h = 0; h < g2[node].size(); h++) {       Edge e = g2[node][h];       if (seen2[e.to] == -1)         dfs2(e.to, fatal, acc ^ e.cost);       else if (seen2[e.to] != (acc ^ e.cost))         fatal = true;     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, k;     cin >> n >> k;     for (int i = 1; i <= n; i++) seen[i] = seen2[i] = -1;     int colors = (n + 1) / 2, colors2 = n / 2;     for (int i = 1; i <= k; i++) {       int x, y;       char ch;       cin >> x >> y >> ch;       int val;       if (ch ==  o )         val = 1;       else         val = 0;       if ((x + y) % 2 == 0) {         int from = fabs(x - y) / 2;         int to = (x + y) / 2;         if (colors < to) to = colors * 2 + !(n % 2) - to;         g[from].push_back({to, val});         g[to].push_back({from, val});       } else {         int from = (fabs(x - y) - 1) / 2;         int to = (x + y) / 2;         if (colors2 < to) to = colors2 * 2 + (n % 2) - to;         g2[from].push_back({to, val});         g2[to].push_back({from, val});       }     }     int result = 1;     bool fatal = false;     dfs(0, fatal, 0);     for (int i = 1; i <= colors; i++)       if (seen[i] == -1) {         dfs(i, fatal, 0);         result = 1LL * result * 2 % modulo;       }     dfs2(0, fatal, 0);     for (int i = 1; i <= colors2; i++)       if (seen2[i] == -1) {         dfs2(i, fatal, 0);         result = 1LL * result * 2 % modulo;       }     if (fatal == false)       cout << result;     else       cout << 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mul(long long a, long long b, long long M) { return a * b % M; }   long long add(long long a, long long b, long long M) { return (a + b) % M; }   vector<vector<long long> > eye(int n) {     vector<vector<long long> > I(n, vector<long long>(n));     for (int i = 0; i < n; ++i) I[i][i] = 1;     return I;   }   vector<vector<long long> > mul(vector<vector<long long> > &A,                                  vector<vector<long long> > &B, long long M) {     int l = A.size(), m = B.size(), n = B[0].size();     vector<vector<long long> > C(l, vector<long long>(n));     for (int i = 0; i < l; ++i)       for (int k = 0; k < m; ++k)         for (int j = 0; j < n; ++j)           C[i][j] = add(C[i][j], mul(A[i][k], B[k][j], M), M);     return C;   }   vector<vector<long long> > pow(vector<vector<long long> > A, long long b,                                  long long M) {     vector<vector<long long> > X = eye(A.size());     for (; b > 0; b >>= 1) {       if (b & 1) X = mul(X, A, M);       A = mul(A, A, M);     }     return X;   }   const long long mod = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(0), cin.tie(0);     long long n, m;     cin >> n >> m;     vector<vector<long long> > M(m, vector<long long>(m));     for (int i = 0; i < m - 1; ++i) M[i][i + 1] = 1;     M[m - 1][0] = M[m - 1][m - 1] = 1;     M = pow(M, n, mod);     long long ans = 0;     for (auto i : M[0]) ans = (ans + i) % mod;     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000000007;   const int N = 100010;   char s[N];   int fac[N], inv[N], sum[N];   long long mpow(long long a, long long b) {     long long ans = 1;     while (b) {       if (b & 1) ans = ans * a % mod;       a = a * a % mod;       b >>= 1;     }     return ans;   }   long long com(int n, int m) {     if (n < m) return 0;     return 1LL * fac[n] * inv[m] % mod * inv[n - m] % mod;   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     scanf( %s , s + 1);     inv[0] = fac[0] = 1;     for (int i = 1; i <= n; i++) {       fac[i] = 1LL * fac[i - 1] * i % mod;       inv[i] = mpow(fac[i], mod - 2);       sum[i] = sum[i - 1] + s[i] -  0 ;     }     long long ans = 0;     for (int i = 1, base = 1; i <= n - m; i++, base = 10LL * base % mod) {       ans = (ans + com(n - i - 1, m - 1) * sum[n - i] % mod * base) % mod;       ans = (ans + com(n - i, m) * (s[n - i + 1] -  0 ) % mod * base) % mod;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N_MAX = 300010;   struct Point {     int x, y;   };   Point points[N_MAX];   int nPoint;   void outerInit() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     auto fi = new ifstream( test.inp );     if (*fi) {       cin.rdbuf(fi->rdbuf());     }   }   void readData() {     cin >> nPoint;     for (int i = 1; i <= nPoint; ++i) {       cin >> points[i].x >> points[i].y;     }   }   void solveData() {     int xMin = INT_MAX, yMin = INT_MAX;     int xMax = INT_MIN, yMax = INT_MIN;     for (int i = 1; i <= nPoint; ++i) {       xMin = min(xMin, points[i].x);       xMax = max(xMax, points[i].x);       yMin = min(yMin, points[i].y);       yMax = max(yMax, points[i].y);     }     int res3 = 0;     for (int i = 1; i <= nPoint; ++i) {       if (points[i].x != xMin && points[i].y != yMin) {         res3 = max(res3, 2 * (points[i].x - xMin + points[i].y - yMin));       }       if (points[i].x != xMin && points[i].y != yMax) {         res3 = max(res3, 2 * (points[i].x - xMin + yMax - points[i].y));       }       if (points[i].x != xMax && points[i].y != yMin) {         res3 = max(res3, 2 * (xMax - points[i].x + points[i].y - yMin));       }       if (points[i].x != xMax && points[i].y != yMax) {         res3 = max(res3, 2 * (xMax - points[i].x + yMax - points[i].y));       }     }     cout << res3;     for (int i = 4; i <= nPoint; ++i) {       cout <<     << 2 * (xMax - xMin + yMax - yMin);     }   }   int main() {     outerInit();     readData();     solveData();   }
#include <bits/stdc++.h>   using namespace std;   bool isPrime(int n) {     if (n <= 1) return false;     if (n <= 3) return true;     if (n % 2 == 0 || n % 3 == 0) return false;     for (int i = 5; i * i <= n; i = i + 6)       if (n % i == 0 || n % (i + 2) == 0) return false;     return true;   }   vector<long long int> prime;   void solve() {     long long int mid, i, j, k, l, m, n,         ans = 0, minn = INT_MAX, maxx = INT_MIN, x, sum = 0, c = 0, cc = 0,         odd = 0, even = 0, q, ab = 0, ba = 0, y, a, b, r, nn, xx;     string ss;     vector<long long int> v, vv;     set<long long int> s;     map<long long int, long long int> mp;     cin >> n;     for (i = 1; i <= sqrt(n); i++) {       if (i * i <= n) {         s.insert(i * i);       }       if (i * i * i <= n) {         s.insert(i * i * i);         continue;       }     }     cout << s.size() << endl;   }   int main() {     int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long inf = 1e9 + 7;   long long tam(long long x) {     long long r = 0;     while (x > 0) {       x /= 10;       r++;     }     return r;   }   map<long long, long long> r[15];   long long pre[15];   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     long long n, k;     cin >> n >> k;     vector<pair<long long, long long> > v(n);     for (long long i = 0; i < n; i++) {       long long aux;       cin >> aux;       v[i].first = tam(aux);       v[i].second = aux % k;     }     pre[1] = 10 % k;     for (long long i = 2; i <= 12; i++) {       pre[i] = (pre[i - 1] * 10) % k;     }     long long res = 0;     for (long long i = 0; i < n; i++) {       long long sz = v[i].first;       long long rest = v[i].second;       r[sz][rest]++;       if ((pre[sz] * rest + rest) % k == 0) {         res--;       }     }     for (long long i = 0; i < n; i++) {       long long rest = v[i].second;       for (long long sz = 1; sz <= 11; sz++) {         long long now = (k - pre[sz] * rest) % k;         while (now < 0) now += k;         res += r[sz][now];       }     }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   bool Primality(long long n) {     if (n < 2) return false;     if (n == 2) return true;     if (n % 2 == 0) return false;     for (long long i = 3; i * i <= n; i = i + 2)       if (n % i == 0) return false;     return true;   }   int main() {     long long n;     cin >> n;     for (long long i = 1; i <= 1000; i++) {       long long pr = (n * i) + 1;       if (!Primality(pr)) {         cout << i <<   n ;         break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool p[10000001];   long h[10000001];   struct S {     long a, c;   } s[1000000];   int n;   int k;   long a[1000001];   int binl(int x) {     if (x == 2) return 0;     if (x > s[k - 1].a) return -1;     int mid = (0 + k - 1) / 2;     int l = 0, r = k - 1;     while (l <= r) {       mid = (l + r) / 2;       if (s[mid].a >= x && s[mid - 1].a < x && mid - 1 >= 0)         return mid;       else if (s[mid].a < x)         l = mid + 1;       else         r = mid - 1;     }     return -1;   }   int binr(int x) {     if (x >= s[k - 1].a) return k - 1;     int mid = (0 + k - 1) / 2;     int l = 0, r = k - 1;     while (l <= r) {       mid = (l + r) / 2;       if (s[mid].a <= x && s[mid + 1].a > x && mid + 1 < k)         return mid;       else if (s[mid].a < x)         l = mid + 1;       else         r = mid - 1;     }     return -1;   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];       h[a[i]]++;     }     for (int i = 2; i <= 10000000; i++) {       if (p[i] == 0) {         s[k].a = i;         s[k].c = 0;         for (int j = i; j <= 10000000; j += i) {           p[j] = 1;           s[k].c += h[j];         }         k++;       }     }     for (int i = 1; i < k; i++) s[i].c += s[i - 1].c;     int m;     long long l, r, ans;     cin >> m;     while (m--) {       cin >> l >> r;       int ll = binl(l);       int rr = binr(r);       if (ll == -1) {         cout << 0 << endl;         continue;       }       cout << s[rr].c - ((ll > 0) ? s[ll - 1].c : 0) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mxn = 1e3 + 5;   int Set(int N, int pos) { return N = N | (1 << pos); }   int reset(int N, int pos) { return N = N & ~(1 << pos); }   bool check(int N, int pos) { return (bool)(N & (1 << pos)); }   struct data {     int U;     int V;     int idx;   };   vector<data> es, em;   vector<int> ans;   int par[mxn];   int unode[100005];   int vnode[100005];   int Find(int p) {     if (p == par[p]) return p;     return par[p] = Find(par[p]);   }   bool merge(int u, int v) {     u = Find(u);     v = Find(v);     if (u == v) return false;     par[v] = u;     return true;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     for (int i = 0; i < mxn; i++) par[i] = i;     int n, m;     cin >> n >> m;     for (int i = 0; i < m; i++) {       int u, v;       char c;       cin >> u >> v >> c;       unode[i] = u;       vnode[i] = v;       if (c ==  S )         es.push_back({u, v, i});       else {         em.push_back({u, v, i});         merge(u, v);       }     }     if (!(n & 1)) {       cout << -1 <<   n ;       return 0;     }     int cnt = 0;     for (auto i : es) {       if (merge(i.U, i.V)) {         ans.push_back(i.idx);         cnt++;       }     }     for (int i = 0; i < mxn; i++) par[i] = i;     for (auto i : ans) merge(unode[i], vnode[i]);     int tt = (n - 1) >> 1;     for (auto i : es) {       if (cnt == tt) break;       if (merge(i.U, i.V)) {         ans.push_back(i.idx);         cnt++;       }     }     if (cnt != tt) {       cout << -1 <<   n ;       return 0;     }     cnt = 0;     for (auto i : em) {       if (cnt == tt) break;       if (merge(i.U, i.V)) {         ans.push_back(i.idx);         cnt++;       }     }     if (cnt != tt) {       cout << -1 <<   n ;       return 0;     }     cout << n - 1 <<   n ;     for (auto i : ans) cout << i + 1 <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, m, i, j, k, sum = 0, cnt = 0, a[101];     cin >> n >> m;     vector<long long int> o;     for (i = 0; i < n; i++) {       cin >> a[i];       sum += a[i];     }     for (i = 0; i < m; i++) {       cin >> j;       j--;       sum -= a[j];       o.push_back(a[j]);     }     sort(o.rbegin(), o.rend());     for (i = 0; i < m; i++) {       if (o[i] < sum)         sum += sum;       else         sum += o[i];     }     cout << sum;   }