malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline bool ckmin(T &a, const T &b) {     return b < a ? a = b, 1 : 0;   }   template <typename T>   inline bool ckmax(T &a, const T &b) {     return a < b ? a = b, 1 : 0;   }   const int N = 3e5 + 10, P = 998244353;   int n, c[N];   int add(int first) { return first >= P ? first - P : first; }   int sub(int first) { return first < 0 ? first + P : first; }   int qpow(int a, int b) {     int res = 1;     for (; b; b >>= 1, a = 1ll * a * a % P)       if (b & 1) res = 1ll * res * a % P;     return res;   }   int main() {     scanf( %d , &n);     int m = 0;     for (int i = 1; i <= n; i++) {       int first;       scanf( %d , &first);       c[first]++;       m += first;     }     c[m] = sub(c[m] - 1);     int inv = 1ll * m * (n - 1) % P * qpow(n, P - 2) % P;     int f0 = 0, f1 = 0, ans = 0;     for (int i = 0; i <= m; i++) {       ans = sub(ans - 1ll * c[i] * f1 % P);       swap(f0, f1);       f1 = sub(1ll * f0 * sub(add(m + 1ll * n * i % P) - 2ll * i % P) % P -                1ll * i * (n - 1) % P * f1 % P);       f1 = add(f1 + inv);       f1 = 1ll * f1 * qpow(m - i, P - 2) % P;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, a[100001], b[100001];   map<long long, long long> cntup;   map<long long, long long> cntdown;   long long ans;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n;     long long x = (n + 1) / 2;     for (long long i = 1; i <= n; ++i) {       cin >> a[i] >> b[i];       cntup[a[i]]++;       if (a[i] != b[i]) cntdown[b[i]]++;     }     bool ok = false;     ans = (long long)(1e18);     for (long long i = 1; i <= n; ++i) {       if (cntup[a[i]] + cntdown[a[i]] >= x) {         long long curans = x - cntup[a[i]];         if (curans < 0) curans = 0;         ans = min(ans, curans);         ok = 1;       }       if (cntup[b[i]] + cntdown[b[i]] >= x) {         long long curans = x - cntup[b[i]];         if (curans < 0) curans = 0;         ans = min(ans, curans);         ok = 1;       }     }     if (!ok) {       cout << -1;       return 0;     }     cout << (ans == (long long)(1e18) ? -1 : ans);   }
#include <bits/stdc++.h>   using namespace std;   int i, j, k, sm, mx, mn, res, n;   int a, b;   void read() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     cin >> a >> b;   }   void solve() {     i = a;     j = b;     while (i) {       mx = max(mx, i % 10);       i /= 10;     }     while (j) {       mx = max(mx, j % 10);       j /= 10;     }     mx++;     i = 0;     while (a || b || k) {       i *= 10;       i += (a % 10 + b % 10 + k) % mx;       k = (a % 10 + b % 10 + k) / mx;       a /= 10;       b /= 10;       res++;     }     cout << res;   }   int main() {     read();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(void) {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     long long all = 0;     long long ans = 0;     for (long long i = 0; i < n; i++) {       long long x;       cin >> x;       ans = max(ans, x);       all += x;     }     n = n - 1;     long long round = 0;     while (true) {       if (all > 0) {         round++;         all -= n;       } else         break;     }     cout << max(round, ans) <<   n ;     return (0);   }
#include <bits/stdc++.h>   using namespace std;   int b[200005];   int arr[200005];   int cnt[200005];   vector<int> v[200005];   int main() {     ios_base::sync_with_stdio();     cin.tie(0);     int n, m;     cin >> n >> m;     for (int i = 1; i <= n; i++) v[i].clear();     memset(cnt, 0, sizeof(cnt));     for (int i = 1; i <= n; i++) {       cin >> arr[i];       cnt[arr[i]]++;     }     int ans = 0;     sort(arr + 1, arr + n + 1);     for (int i = 1; i <= m; i++) cin >> b[i];     for (int i = m; i >= 1; i--) {       cnt[i] += cnt[i + 1];       ans = max(ans, (int)ceil(1.0 * cnt[i] / b[i]));     }     for (int i = 1; i <= n; i++) {       v[i % ans].push_back(arr[i]);     }     cout << ans << endl;     for (int i = 0; i < ans; i++) {       int len = v[i].size();       cout << len <<    ;       for (int j = 0; j < len; j++) {         cout << v[i][j] <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int mp[510][510], uss[510][510] = {0}, n, m, siz[510] = {0}, gnu[510][510], p,                     f[510] = {0};   int main() {     int ans = 0;     cin >> n >> m >> p;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         scanf( %1d , &mp[i][j]);         if (mp[i][j] == 1) {           gnu[i][siz[i]] = j;           siz[i]++;         }       }       if (siz[i] == 0)         continue;       else         ans = ans + gnu[i][siz[i] - 1] - gnu[i][0] + 1;     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < siz[i]; j++) {         for (int k = j; k < siz[i]; k++) {           uss[i][siz[i] - (k - j) - 1] =               max(uss[i][siz[i] - (k - j) - 1],                   gnu[i][siz[i] - 1] - gnu[i][0] - (gnu[i][k] - gnu[i][j]));         }       }       uss[i][siz[i]] = gnu[i][siz[i] - 1] - gnu[i][0] + 1;     }     for (int i = 0; i < n; i++) {       if (!siz[i]) continue;       for (int j = p; j >= 0; j--) {         for (int k = 0; k <= siz[i]; k++) {           if (j - k >= 0) f[j] = max(f[j], f[j - k] + uss[i][k]);         }       }     }     cout << ans - f[p];   }
#include <bits/stdc++.h>   using namespace std;   inline long long mod(long long n, long long m) {     long long ret = n % m;     if (ret < 0) ret += m;     return ret;   }   long long gcd(long long a, long long b) {     return (b == 0LL ? a : gcd(b, a % b));   }   long long exp(long long a, long long b, long long m) {     if (b == 0LL) return 1LL;     if (b == 1LL) return mod(a, m);     long long k = mod(exp(a, b / 2, m), m);     if (b & 1LL) {       return mod(a * mod(k * k, m), m);     } else       return mod(k * k, m);   }   long long k;   bool ok(long long x, vector<long long>& v) {     long long cur = 0;     long long tot = 1;     long long some = 0;     for (long long i = 0; i < (long long)v.size(); i++) {       if (tot > k) return 0;       long long fim = (i == (long long)v.size() - 1) ? -1 : 0;       if (cur + v[i] + fim <= x) {         cur += v[i] + fim;       } else {         cur = v[i] + fim;         if (cur > x) return 0;         tot++;       }     }     if (tot > k) return 0;     return 1;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     cin >> k;     vector<long long> v;     string s;     long long tot = 0;     while (cin >> s) {       long long tam = 0;       for (long long i = 0; i < (long long)s.size();) {         while (i < (long long)s.size() and s[i] !=  - ) {           tam++;           i++;         }         if (i < (long long)s.size()) {           tam++;           v.push_back(tam);           tam = 0;           i++;         }       }       if (tam) v.push_back(tam + 1);     }     for (long long x : v) tot += x;     long long l = 1, r = tot;     long long ans = tot;     while (l <= r) {       long long mid = (l + r) / 2;       if (ok(mid, v)) {         ans = mid;         r = mid - 1;       } else         l = mid + 1;     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long dx[] = {-1, 0, 1, 0};   long long dy[] = {0, 1, 0, -1};   long long spf[10];   long long dist[1001];   void sieve() {     long long i, j;     for (i = 0; i < 10; i++) spf[i] = i;     for (i = 4; i < 10; i += 2) spf[i] = 2;     for (i = 3; i * i < 10; i++) {       if (spf[i] == i) {         for (j = i * i; j < 10; j += i) {           if (spf[j] == j) spf[j] = i;         }       }     }   }   bool isvowel(char c) {     switch (c) {       case  a :       case  e :       case  i :       case  o :       case  u :       case  y :         return true;       default:         return false;     }   }   bool cmp(pair<long long, long long> x, pair<long long, long long> y) {     return x.first > y.first;   }   long long isPrime(long long n) {     for (long long i = 2; i <= sqrt(n); i++) {       if (n % i == 0) {         return i;       }     }     return n;   }   long long sum(long long n) {     long long ans = 0;     while (n > 0) {       long long d = n % 10;       ans += d;       n /= 10;     }     return ans;   }   vector<long long> adj[5001];   vector<long long> adj1[5001];   long long vis[1001];   long long sub[1001];   long long dist1[1001];   long long vis1[1001];   long long cnt;   void bfs(long long node) {     vis[node] = 1;     queue<long long> q;     q.push(node);     dist[node] = 0;     while (!q.empty()) {       long long curr = q.front();       q.pop();       for (auto child : adj[curr]) {         if (!vis[child]) {           vis[child] = 1;           dist[child] = dist[curr] + 1;           q.push(child);         }       }     }   }   long long dfs(long long node) {     vis[node] = 1;     long long curr_size = 1;     for (auto child : adj[node]) {       if (!vis[child]) {         curr_size += dfs(child);       }     }     sub[node] = curr_size;     return curr_size;   }   struct x {     long long b;     long long c;     long long d;   };   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long t;     t = 1;     while (t--) {       long long n;       cin >> n;       long long a[2 * n + 1];       for (long long i = 1; i <= 2 * n; i++) {         cin >> a[i];       }       long long ans = 0;       for (long long i = 1; i < 2 * n; i += 2) {         long long j;         for (j = i + 1; j <= 2 * n; j++) {           if (a[i] == a[j]) {             break;           }         }         for (; j > i + 1; j--) {           swap(a[j], a[j - 1]);           ans++;         }       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char *argv[]) {     double m, R, res[100005], tmp = 0;     cin >> m >> R;     res[0] = 2;     res[1] = 2 + sqrt(2);     for (int i = 2; i <= 100000; i++) res[i] = 2 * (i - 1) + 2 * sqrt(2);     tmp += m * res[0];     if (m == 1)       printf( %.9lf , R * tmp);     else {       for (int i = 1; i <= m - 1; i++) {         tmp += 2 * (m - i) * res[i];       }       printf( %.9lf n , R * tmp / (m * m));     }     return EXIT_SUCCESS;   }
#include <bits/stdc++.h>   using namespace std;   int n, T;   int t[5005];   double p[5005];   double f[5005][5005];   double res;   double fastpow(double a, int b) {     if (!b) return 1;     double res = fastpow(a, b / 2);     if (b % 2) return res * res * a;     return res * res;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> T;     for (int i = 1; i <= n; i++) {       cin >> p[i] >> t[i];       p[i] = (1 - p[i] / 100.0);     }     f[0][0] = 1;     for (int i = 1; i <= n; i++) {       double pw = fastpow(p[i], t[i] - 1);       for (int j = 1; j <= T; j++) {         double s = f[i][j - 1];         s = f[i][j - 1];         if (j - 1 >= t[i]) s -= f[i - 1][j - t[i] - 1] * pw;         s *= p[i];         if (j >= t[i]) s += f[i - 1][j - t[i]] * pw * p[i];         s += f[i - 1][j - 1] * (1 - p[i]);         res += s;         f[i][j] = s;       }     }     cout << setprecision(10) << fixed << res <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1005;   int n, a[MAXN];   vector<int> ans;   int main() {     scanf( %d , &n);     ans.reserve(n);     for (int i = 1; i <= n; ++i) scanf( %d , &a[i]);     a[n + 1] = 1;     for (int i = 1; i <= n; ++i)       if (a[i + 1] == 1) ans.push_back(a[i]);     printf( %d n , int(ans.size()));     for (int i = 0; i < int(ans.size()); ++i) printf( %d  , ans[i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long powm(long long base, long long exp, long long mod = 1000000007) {     long long ans = 1;     while (exp) {       if (exp & 1) ans = (ans * base) % mod;       exp >>= 1, base = (base * base) % mod;     }     return ans;   }   void fastscan(int &x) {     register int c = getchar();     x = 0;     for (; (c < 48 || c > 57); c = getchar())       ;     for (; c > 47 && c < 58; c = getchar()) {       x = (x << 1) + (x << 3) + c - 48;     }   }   const int N = 7e4 + 5;   const int M = 10;   vector<string> data;   long long root, NEW;   struct node {     long long nxt[10], cnt;   } trie[1000000];   void insert(string str) {     long long v = root;     for (int i = 0; i < (str).size(); i++) {       long long x = str[i] -  0 ;       if (trie[v].nxt[x]) {         v = trie[v].nxt[x];         trie[v].cnt++;         continue;       }       trie[v].nxt[x] = ++NEW;       v = trie[v].nxt[x];       trie[v].cnt++;     }   }   void go(string str) {     for (int k = 0; k < (str).size(); k++) {       insert(str.substr(k, (str).size() - k));     }   }   long long query(string str) {     long long v = root, depth = 0;     for (int i = 0; i < (str).size(); i++) {       depth++;       long long x = str[i] -  0 ;       if (trie[trie[v].nxt[x]].cnt) {         v = trie[v].nxt[x];         continue;       }       return depth;     }     return 1000111000111000111LL;   }   void del(string str) {     long long v = root;     for (int i = 0; i < (str).size(); i++) {       long long x = str[i] -  0 ;       if (trie[v].nxt[x]) {         v = trie[v].nxt[x];         trie[v].cnt--;         continue;       }       break;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n;     string str;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> str;       go(str);       data.push_back(str);     }     for (int i = 0; i < n; i++) {       str = data[i];       for (int k = 0; k < (str).size(); k++) {         del(str.substr(k, (str).size() - k));       }       string cmp =  9999999999 ;       for (int k = 0; k < (str).size(); k++) {         string y = str.substr(k, (str).size() - k);         long long tmp = query(y);         if (tmp == 1000111000111000111LL) continue;         string z = y.substr(0, tmp);         if ((z).size() < (cmp).size()) cmp = z;       }       go(str);       cout << cmp << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   using ld = long double;   using ll = long long;   void solve() {     int n;     cin >> n;     vector<int> v(n);     vector<pair<int, int>> a(n);     for (int i = 0; i < n; i++) {       cin >> v[i];       a[i] = {v[i], i};     }     sort(a.begin(), a.end());     vector<int> p(n);     int j = 0;     unordered_multiset<int> next;     for (int i = 0; i < n; i++) {       if (i > 0 && a[i].first != a[i - 1].first) {         j++;       }       p[a[i].second] = j;       next.insert(j);     }     unordered_map<int, int> d;     vector<int> dp1(n), dp2(n), dp3(n), cnt(n);     for (int i = 0; i < n; i++) {       if (next.count(p[i])) {         next.erase(next.find(p[i]));       }       if (d.count(p[i] - 1)) {         if (!d.count(p[i])) {           dp2[i] = max(dp2[i], dp1[d[p[i] - 1]] + 1);           if (!next.count(p[i] - 1)) {             dp2[i] = max(dp2[i], dp2[d[p[i] - 1]] + 1);           }         }         if (!next.count(p[i] - 1)) {           dp3[i] = max(dp3[i], dp2[d[p[i] - 1]] + 1);         }         dp3[i] = max(dp3[i], dp1[d[p[i] - 1]] + 1);       }       if (d.count(p[i])) {         dp3[i] = max(dp3[i], dp3[d[p[i]]] + 1);         dp2[i] = max(dp2[i], dp2[d[p[i]]] + 1);         dp1[i] = dp1[d[p[i]]] + 1;       } else {         dp1[i] = 1;       }       dp2[i] = max(dp2[i], dp1[i]);       dp3[i] = max(dp3[i], dp2[i]);       d[p[i]] = i;     }     cout << n - *max_element(dp3.begin(), dp3.end()) <<   n ;   }   int main() {     int n;     cin >> n;     while (n--) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int INF = 0x3f3f3f3f;   const ll LINF = 0x3f3f3f3f3f3f3f3fLL;   const double EPS = 1e-8;   const int MOD = 1000000007;   const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};   const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1},             dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};   template <typename T, typename U>   inline bool chmax(T &a, U b) {     return a < b ? (a = b, true) : false;   }   template <typename T, typename U>   inline bool chmin(T &a, U b) {     return a > b ? (a = b, true) : false;   }   struct IOSetup {     IOSetup() {       cin.tie(nullptr);       ios_base::sync_with_stdio(false);       cout << fixed << setprecision(20);     }   } iosetup;   void solve() {     int n, k;     cin >> n >> k;     if (n % 2 == 0) {       n += 2;     } else {       for (int i = 3; i <= n; i += 2) {         if (n % i == 0) {           n += i;           break;         }       }     }     --k;     cout << 2LL * k + n <<   n ;   }   int main() {     int t;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 6e4, maxm = 2e6;   int g[maxm];   int a[maxn], L[maxn], R[maxn], dp[maxn], ans[maxn];   int n, m, i, j, k;   int main() {     scanf( %d%d , &n, &m);     for (i = 1; i <= 1e6; i++) g[i] = g[i - 1] ^ i;     for (i = 1; i <= n; i++) scanf( %d , &a[i]);     for (i = 1; i <= m; i++) scanf( %d%d , &L[i], &R[i]);     for (i = 1; i <= n; i++) {       dp[i - 1] = 0;       for (j = i; j <= n; j++) {         dp[j] = g[max(a[i], a[j])] ^ g[min(a[i], a[j]) - 1];         dp[j] = max(dp[j], dp[j - 1]);       }       for (j = 1; j <= m; j++)         if (L[j] <= i) ans[j] = max(ans[j], dp[R[j]]);     }     for (i = 1; i <= m; i++) printf( %d n , ans[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mxn = 200001, mxk = 8;   int n, m, k;   pair<int, int> a[mxn];   int first[mxk];   int dp[1 << mxk], p[1 << mxk];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m >> k;     for (int i = 1; i <= n; i++) {       cin >> a[i].first >> a[n + i].first;       a[i].first--, a[i].second = i, a[n + i].second = -i;     }     sort(a + 1, a + 2 * n + 1);     memset(dp, 0xcf, sizeof(dp));     dp[0] = 0;     for (int i = 1; i <= 2 * n; i++) {       swap(dp, p);       memset(dp, 0xcf, sizeof(dp));       int x = find(first, first + k, a[i].second > 0 ? 0 : -a[i].second) - first;       first[x] = max(0, a[i].second);       int z = 0;       for (int j = 0; j < k; j++) z |= !first[j] << j;       for (int j = 0; j < (1 << k); j++)         if (!(j & z))           for (int l = 0; l < 2; l++) {             dp[j] = max(dp[j],                         p[j ^ (l << x)] + (a[i].first - a[i - 1].first) *                                               ((__builtin_popcount(j) & 1) ^ l));           }     }     cout << *max_element(dp, dp + (1 << k)) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   void solve() {     int n, m;     cin >> n >> m;     vector<string> f(n);     for (int i = 0; i < n; ++i) {       cin >> f[i];     }     vector<int> v(m);     for (int j = 1; j < m; ++j) {       for (int i = 1; i < n; ++i) {         if (f[i - 1][j] ==  X  && f[i][j - 1] ==  X ) {           v[j] = 1;         }       }     }     for (int i = 1; i < m; ++i) {       v[i] += v[i - 1];     }     int q;     cin >> q;     for (int i = 0; i < q; ++i) {       int a, b;       cin >> a >> b;       if (v[b - 1] - v[a - 1] > 0) {         cout <<  NO n ;       } else {         cout <<  YES n ;       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     solve();   }
#include <bits/stdc++.h>   using namespace std;   int a[13], t, ans;   const int P = 1e9 + 7;   int qp(int a, int b) {     int r = 1;     for (; b; b >>= 1, a = a * 1ll * a % P)       if (b & 1) r = r * 1ll * a % P;     return r;   }   void dfs(int x, int y, bool b) {     if (x == t) {       if (b)         ans = (ans + qp(2, y - 1)) % P;       else         ans = (ans - qp(2, y - 1)) % P;       return;     }     ++x, dfs(x, y / a[x], !b), dfs(x, y, b);   }   int main() {     int x, y, i;     scanf( %d%d , &x, &y);     if (y % x) return puts( 0 ), 0;     y /= x, x = y;     for (i = 2; i * i <= y; ++i)       if (!(y % i)) {         a[++t] = i;         do y /= i;         while (!(y % i));       }     if (y > 1) a[++t] = y;     dfs(0, x, 1), printf( %d , (ans + P) % P);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int NMAX = 100000 + 5;   const int MMAX = 2000 + 5;   const int INF = 1000000000;   const int BS = 1000000000 + 7;   const long long INFLL = 1000000000ll * 1000000000ll;   const long double eps = 1e-6;   int main(int argc, char** argv) {     if (argc > 1 && strcmp(argv[1],  seland ) == 0) {       freopen( input.txt ,  r , stdin);       freopen( output.txt ,  w , stdout);     }     ios::sync_with_stdio(false);     cin.tie();     cout.tie();     long long ans[2] = {0};     int cnt[2][2] = {0};     string s;     int index = 0;     cin >> s;     for (auto c : s) {       c -=  a ;       cnt[c][index % 2]++;       ans[0] += cnt[c][(index + 1) % 2];       ans[1] += cnt[c][index % 2];       index++;     }     cout << ans[0] <<     << ans[1] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   long long int n;   long long int v[N];   vector<long long int> a, b;   long long int solve(const vector<long long int> &vet) {     long long int max_so_far = INT_MIN, max_ending_here = 0;     for (int i = 0; i < vet.size(); i++) {       max_ending_here = max_ending_here + vet[i];       if (max_so_far < max_ending_here) max_so_far = max_ending_here;       if (max_ending_here < 0) max_ending_here = 0;     }     return max_so_far;   }   int main() {     scanf( %lld , &n);     for (int i = 0; i < n; ++i) {       scanf( %lld , &v[i]);     }     for (int i = 1; i < n; ++i) {       a.push_back(abs(v[i] - v[i - 1]) * ((i & 1) ? 1 : -1));       b.push_back(abs(v[i] - v[i - 1]) * ((i & 1) ? -1 : 1));     }     printf( %lld n , max(solve(a), solve(b)));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long md = 1e9 + 7;   int main() {     cout.precision(12);     iostream::sync_with_stdio(0);     cin.tie(0), cout.tie(0);     const int MX = 1e6 + 1;     vector<int> pr(MX, 1);     vector<int> o;     for (int i = 2; i < MX; i++) {       if (!pr[i]) continue;       o.push_back(i);       for (long long j = i * 1ll * i; j < MX; j += i) pr[j] = 0;     }     long long n, x, y;     cin >> n >> x >> y;     unordered_map<long long, long long> q;     vector<long long> a(n);     for (int i = 0; i < n; i++) {       cin >> a[i];       long long c = a[i];       for (int j : o) {         if (j * 1ll * j > a[i]) break;         if (a[i] % j) continue;         while (a[i] % j == 0) a[i] /= j;         q[j]++;       }       if (a[i] != 1) q[a[i]]++;       a[i] = c;     }     long long mx = 0;     for (auto i : q) mx = max(mx, i.second);     if (x <= y) {       cout << (n - mx) * x <<   n ;       return 0;     }     long long ans = (n - q[2]) * y;     for (auto i : q) {       if (i.second <= q[2]) continue;       long long res = 0;       bool ch = 1;       for (long long e : a) {         long long d = (i.first - (e % i.first)) % i.first;         res += min(x, y * d);         if (res > ans) {           ch = 0;           break;         }       }       if (ch) ans = min(ans, res);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, a, b;     cin >> n >> m >> a >> b;     int q = m * a;     if (q < b) {       cout << n * a;     } else {       int v = n / m;       n -= v * m;       cout << v * b + min(b, n * a);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int n = s.length();     int l = n, r = n;     bool found = false;     for (int i = 0; i < n; i++) {       if (found == false && s[i] >  a ) {         found = true;         l = i;       }       if (found == true && s[i] ==  a ) {         r = i;         break;       }     }     for (int i = l; i < r; i++) {       s[i] = (char)((int)s[i] - 1);     }     if (l != n)       cout << s;     else {       s[n - 1] =  z ;       cout << s;     }     return 0;   }