malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   constexpr int N = 3e3 + 1;   int a[N], dp[N][N], nxt[N], prv[N], lst[N];   int main() {     cin.tie(0), ios::sync_with_stdio(0);     int t, n;     cin >> t;     while (t--) {       cin >> n;       for (int i = 0; i < n; ++i) {         cin >> a[i], --a[i];       }       memset(lst, -1, n * sizeof *lst);       n = unique(a, a + n) - a;       memset(prv, -1, n * sizeof *prv);       memset(nxt, 127, n * sizeof *nxt);       for (int i = 0; i < n; ++i) {         if (lst[a[i]] != -1) {           prv[i] = lst[a[i]];           nxt[lst[a[i]]] = i;         }         lst[a[i]] = i;       }       for (int le = 2; le <= n; ++le)         for (int i = 0; i + le <= n; ++i) {           int j = i + le - 1;           dp[i][j] = max(dp[i + 1][j], dp[i][j - 1]);           bool use_j = 0;           if (a[i] != a[j]) {             int cnti = 0, cntj = 0;             for (int z = nxt[i]; z <= j; z = nxt[z]) ++cnti;             for (int z = prv[j]; z >= i; z = prv[z]) ++cntj;             use_j = cntj < cnti;           }           if (!use_j) {             for (int z = nxt[i]; z <= j; z = nxt[z]) {               dp[i][j] = max(dp[i][j], dp[i + 1][z - 1] + dp[z][j] + 1);             }           } else {             for (int z = prv[j]; z >= i; z = prv[z]) {               dp[i][j] = max(dp[i][j], dp[i][z] + dp[z + 1][j - 1] + 1);             }           }         }       cout << n - dp[0][n - 1] - 1 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   int main() {     char t[50], s[50];     scanf( %s , t);     int l = strlen(t), k = l / 2, j = 0;     if (l % 2 == 0) {       k = l / 2 - 1;     }     for (int i = 0; i < l; i++) {       s[i] = t[k];       j++;       if (i % 2 == 0) {         k = k + j;       } else {         k = k - j;       }     }     for (int i = 0; i < l; i++) {       printf( %c , s[i]);     }   }
#include <bits/stdc++.h>   using namespace std;   #pragma comment(linker,  /stack:200000000 )   #pragma GCC optimize( Ofast )   #pragma GCC target(         sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native )   #pragma GCC optimize( -ffloat-store )   const long long INF = 9e18;   const long long N = 998244353;   const double eps = 1e-9;   const auto start_time = std::chrono::high_resolution_clock::now();   void zark() {}   void solve() {     long long n, k;     cin >> n >> k;     vector<long long> a(n), b(n);     for (long long i = (0); i < (n); i++) cin >> a[i];     for (long long i = (0); i < (n); i++) cin >> b[i];     sort((a).begin(), (a).end());     sort((b).begin(), (b).end());     long long s = 0;     long long i = 0, j = n - 1, cnt = 0;     while (cnt < k && i < n && j >= 0) {       if (a[i] < b[j])         s += b[j], cnt++, j--, i++;       else         break;     }     for (long long ii = i; ii < n; ii++) s += a[ii];     cout << s <<   n ;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long t;     cin >> t;     while (t--) solve();     zark();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[4][4];   int main() {     for (int i = 0; i < 4; i++) {       for (int j = 0; j < 4; j++) {         cin >> a[i][j];       }     }     int flag = 0;     if (a[0][3] == 1) {       if (a[0][0] == 1 || a[0][1] == 1 || a[0][2] == 1 || a[1][0] == 1 ||           a[2][1] == 1 || a[3][2] == 1) {         cout <<  YES  << endl;         flag = 1;         return 0;       }     }     if (a[1][3] == 1) {       if (a[1][0] == 1 || a[1][1] == 1 || a[1][2] == 1 || a[0][2] == 1 ||           a[2][0] == 1 || a[3][1] == 1) {         cout <<  YES  << endl;         flag = 1;         return 0;       }     }     if (a[2][3] == 1) {       if (a[2][0] == 1 || a[2][1] == 1 || a[2][2] == 1 || a[0][1] == 1 ||           a[1][2] == 1 || a[3][0] == 1) {         cout <<  YES  << endl;         flag = 1;         return 0;       }     }     if (a[3][3] == 1) {       if (a[3][0] == 1 || a[3][1] == 1 || a[3][2] == 1 || a[0][0] == 1 ||           a[1][1] == 1 || a[2][2] == 1) {         cout <<  YES  << endl;         flag = 1;         return 0;       }     }     if (flag == 0) cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long t1, t2, t0, a, b, c, d, x1, x2, lo, mid, hi, ans;   int fun(long long x1, long long x2) {     return (x1 * t1 + x2 * t2 >= t0 * (x1 + x2));   }   void fun2(long long x1, long long x2) {     long long pt = (t1 * x1 + t2 * x2) * (a + b);     long long et = (t1 * a + t2 * b) * (x1 + x2);     if (pt < et) {       a = x1;       b = x2;     }     if (pt == et && (a + b) < (x2 + x1)) {       a = x1;       b = x2;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin >> t1 >> t2 >> x1 >> x2 >> t0;     a = 0;     b = x2;     if (t1 == t2) {       cout << x1 <<     << x2;       return 0;     }     for (int i(0), _n(x1 + 1); i < _n; ++i) {       lo = 0;       hi = x2 + 1, ans = 1061109567LL;       while (lo < hi) {         mid = lo + hi;         mid /= 2;         if (fun(i, mid)) {           hi = mid;           ans = min(ans, mid);         } else           lo = mid + 1;       }       if (ans != 1061109567LL) fun2(i, ans);     }     cout << a <<     << b;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, m;     cin >> n >> m;     vector<string> v;     vector<string> res;     for (int i = 0; i < n; i++) {       string s;       cin >> s;       v.push_back(s);     }     bool flag = 0;     string t =   , pal =   ;     for (int i = 0; i < v.size(); i++) {       string s = v[i];       t = s;       reverse(s.begin(), s.end());       auto it = find(v.begin(), v.end(), s);       if (it != v.end()) {         if (*it == t) {           flag = 1;           pal = t;           continue;         }         res.push_back(v[i]);         v.erase(it);       }     }     string out =   ;     for (auto x : res) {       out += x;     }     string p = out;     if (flag) out += pal;     reverse(p.begin(), p.end());     out += p;     cout << out.length() <<   n ;     cout << out;   }
#include <bits/stdc++.h>   using namespace std;   struct SCIENT {     int index;     int k;     int inv;     long long a[200009];   } sc[3];   vector<pair<int, int> > v;   int K[3];   int dynam[2100][2100][3];   int recurse(int k1, int k2, int which) {     int last;     if (k1 == K[1] && k2 == K[2])       last = INT_MIN;     else if (which == 0)       last = sc[which + 1].a[k1 + 1];     else       last = sc[which + 1].a[k2 + 1];     if (dynam[k1][k2][which] != -1) return dynam[k1][k2][which];     if (k1 == 0 && k2 == 0) return dynam[k1][k2][which] = 0;     if (k1 == 0) {       return dynam[k1][k2][which] = recurse(k1, k2 - 1, 1) + (sc[2].a[k2] < last);     }     if (k2 == 0) {       return dynam[k1][k2][which] = recurse(k1 - 1, k2, 0) + (sc[1].a[k1] < last);     }     int p1 = recurse(k1 - 1, k2, 0) + (sc[1].a[k1] < last);     int p2 = recurse(k1, k2 - 1, 1) + (sc[2].a[k2] < last);     if (p1 < p2) {       return dynam[k1][k2][which] = p1;     } else {       return dynam[k1][k2][which] = p2;     }   }   int reconstruct(int k1, int k2, int which) {     if (k1 == 0 && k2 == 0) return 0;     int last;     if (k1 == K[1] && k2 == K[2])       last = INT_MIN;     else if (which == 0)       last = sc[which + 1].a[k1 + 1];     else       last = sc[which + 1].a[k2 + 1];     if (k1 == 0) {       v.push_back(make_pair(sc[2].a[k2], 2));       return reconstruct(k1, k2 - 1, 1) + (sc[2].a[k2] < last);     }     if (k2 == 0) {       v.push_back(make_pair(sc[1].a[k1], 1));       return reconstruct(k1 - 1, k2, 0) + (sc[1].a[k1] < last);     }     int p1 = dynam[k1 - 1][k2][0] + (sc[1].a[k1] < last);     int p2 = dynam[k1][k2 - 1][1] + (sc[2].a[k2] < last);     if (p1 < p2) {       v.push_back(make_pair(sc[1].a[k1], 1));       reconstruct(k1 - 1, k2, 0);       return p1;     } else {       v.push_back(make_pair(sc[2].a[k2], 2));       reconstruct(k1, k2 - 1, 1);       return p2;     }   }   int main() {     int N;     scanf( %d , &N);     memset(dynam, 0xff, sizeof(dynam));     for (int i = 1; i <= N; i++) {       long long k, a, x, y, m;       cin >> k >> a >> x >> y >> m;       K[i] = k;       sc[i].k = k;       sc[i].index = i;       sc[i].a[1] = a;       sc[i].inv = 0;       for (int j = 2; j <= k; j++) sc[i].a[j] = (sc[i].a[j - 1] * x + y) % m;       reverse(sc[i].a + 1, sc[i].a + k + 1);     }     int n = recurse(sc[1].k, sc[2].k, 2);     reconstruct(sc[1].k, sc[2].k, 2);     cout << n << endl;     for (int i = 0; i < v.size(); i++) {       cout << v[i].first <<     << v[i].second << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 998244353;   const long long N = 2005;   void init() {}   long long n, m, k;   long long dp[N][N];   void solve() {     scanf( %lld%lld%lld , &n, &m, &k);     dp[1][0] = m;     for (long long i = 2; i <= n; i++) {       for (long long j = 0; j < i; j++) {         dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;         if (j) dp[i][j] = (dp[i][j] + dp[i - 1][j - 1] * (m - 1) % MOD) % MOD;       }     }     printf( %lld n , dp[n][k]);   }   signed main() {     long long TTT = 1;     while (TTT--) {       init();       solve();     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int T, t, a, b, n, k, temp;     scanf( %d , &T);     for (t = 0; t < T; t++) {       scanf( %d%d%d , &a, &b, &n);       k = 0;       while (a <= n) {         if (a > b) {           temp = a;           a = b;           b = temp;         }         a += b;         k++;       }       printf( %d n , k);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int chr[1000006];   long long int freq[1000006];   long long int Z[2000006];   void Zalgo(int end) {     int l = 1, r = 1;     for (int i = 2; i < end; ++i) {       if (r > i) {         int pre = Z[i - l + 1];         if (pre + i < r) {           Z[i] = pre;         } else {           l = i;           while (r < end && chr[r] == chr[r - i + 1] &&                  freq[r] == freq[r - i + 1]) {             ++r;           }           Z[i] = r - l;         }       } else {         l = r = i;         while (r < end && chr[r] == chr[r - i + 1] &&                freq[r] == freq[r - i + 1]) {           ++r;         }         Z[i] = r - l;       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, m;     string s, t;     cin >> n >> m;     chr[0] = -1;     freq[0] = 0;     int index = 1;     for (int i = 1; i <= n; ++i) {       string s;       cin >> s;       if (s[s.size() - 1] -  a  == chr[index - 1]) {         freq[index - 1] += stoi(s, nullptr, 10);       } else {         chr[index] = s[s.size() - 1] -  a ;         freq[index] += stoi(s, nullptr, 10);         ++index;       }     }     int mid = index;     chr[index] = -1;     freq[index++] = 0;     for (int i = 1; i <= m; ++i) {       string s;       cin >> s;       if (s[s.size() - 1] -  a  == chr[index - 1]) {         freq[index - 1] += stoi(s, nullptr, 10);       } else {         chr[index] = s[s.size() - 1] -  a ;         freq[index] += stoi(s, nullptr, 10);         ++index;       }     }     reverse(chr, chr + index);     reverse(freq, freq + index);     mid = index - mid - 1;     index--;     Zalgo(index);     long long int ans = 0;     chr[index] = -1;     freq[index] = 0;     for (int i = mid + 1; i <= index; ++i) {       if (Z[i] == mid - 1 && chr[0] == chr[i - 1] && freq[0] <= freq[i - 1]) {         if (mid == 1) {           ans += freq[i - 1] - freq[0] + 1;         } else {           ++ans;         }       } else if (Z[i] == mid - 2 && chr[0] == chr[i - 1] &&                  freq[0] <= freq[i - 1] && chr[mid - 1] == chr[i + mid - 2] &&                  freq[mid - 1] <= freq[i + mid - 2]) {         ++ans;       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int arr[100005];   int dp[100005];   int main() {     int n;     cin >> n;     arr[0] = -2000;     for (long long i = 1; i < n + 1; i++) {       cin >> arr[i];       dp[i] = 1e9;     }     dp[0] = 0;     int pay = 0;     for (long long i = 1; i < n + 1; i++) {       int x = upper_bound(arr, arr + i, arr[i] - 1) - arr;       x--;       dp[i] = min(dp[i], dp[x] + 20);       x = upper_bound(arr, arr + i, arr[i] - 90) - arr;       x--;       dp[i] = min(dp[i], dp[x] + 50);       x = upper_bound(arr, arr + i, arr[i] - 1440) - arr;       x--;       dp[i] = min(dp[i], dp[x] + 120);       cout << dp[i] - pay <<   n ;       pay = dp[i];     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 5;   int n;   string s[maxn];   map<int, pair<int, int>> mp;   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cin >> n;     int correct = 0;     for (int i = 0; i < n; i++) {       cin >> s[i];       int balance = 0;       int min_balance = 0;       for (char c : s[i]) {         if (c ==  ( ) {           balance++;         } else {           balance--;         }         min_balance = min(min_balance, balance);       }       if (min_balance >= 0) {         if (balance == 0) {           correct++;         } else {           mp[balance].first++;         }       } else {         if (min_balance == balance) {           mp[-balance].second++;         }       }     }     int res = correct / 2;     for (auto& it : mp) {       res += min(it.second.first, it.second.second);     }     cout << res <<   n ;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   int n, a[200005];   long double eps = 1e-11, b[200005], s[200005];   long double f(long double first) {     long double mn = 0, ans = 0;     for (int i = 1; i <= n; i++) {       b[i] = -first + a[i];       s[i] = s[i - 1] + b[i];       ans = max(ans, abs(s[i] - mn));       mn = min(mn, s[i]);     }     mn = 0;     for (int i = 1; i <= n; i++) {       ans = max(ans, abs(s[i] - mn));       mn = max(mn, s[i]);     }     return ans;   }   int32_t main() {     ios_base ::sync_with_stdio(0);     cin.tie();     cout.tie();     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     long double l = -1e9, r = 1e9;     for (int i = 1; i <= 200; i++) {       long double mid1 = (l * 2 + r) / 3, mid2 = (l + r * 2) / 3;       if (f(mid1) > f(mid2))         l = mid1;       else if (f(mid1) < f(mid2))         r = mid2;       else         l = mid1, r = mid2;     }     cout << fixed << setprecision(7) << f(l);   }
#include <bits/stdc++.h>   using namespace std;   int cnt[1000010] = {};   void pre() {     for (int i = 1; i < 1000010; i++) {       for (int j = i; j < 1000010; j += i) {         cnt[j]++;       }     }   }   long long int tree[2 * 1000010];   int n;   void build() {     for (int i = n - 1; i > 0; i--) {       tree[i] = tree[i << 1] + tree[(i << 1) | 1];     }   }   void update(int idx, long long int val) {     tree[idx + n] = val;     for (int i = idx + n; i > 0; i >>= 1) {       tree[i >> 1] = tree[i] + tree[i ^ 1];     }   }   long long int query(int l, int r) {     long long int ans = 0;     l += n;     r += n;     for (; l < r; l >>= 1, r >>= 1) {       if (l & 1) {         ans += tree[l];         l++;       }       if (r & 1) {         r--;         ans += tree[r];       }     }     return ans;   }   int main() {     pre();     int m;     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) {       scanf( %lld , &tree[n + i]);     }     build();     set<int> s;     for (int i = 0; i < n; i++) {       if (tree[n + i] > 2) {         s.insert(i);       }     }     while (m--) {       int t, l, r;       scanf( %d %d %d , &t, &l, &r);       l--;       r--;       if (t == 2) {         printf( %lld n , query(l, r + 1));       } else {         l--;         vector<int> v;         if (s.empty()) {           continue;         }         if (s.upper_bound(l) == s.end()) {           continue;         }         int idx = *s.upper_bound(l);         while (idx <= r) {           s.erase(idx);           long long int x = tree[n + idx];           update(idx, (long long int)cnt[x]);           if (cnt[x] > 2) {             v.push_back(idx);           }           if (s.empty()) {             break;           }           if (s.upper_bound(l) == s.end()) {             break;           }           idx = *s.upper_bound(l);         }         for (int u : v) {           s.insert(u);         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 5e3 + 10, MOD = 1e9 + 7;   int n, ans, l = -1, r = 1e4 + 10, mid, mark[MAXN];   pair<int, int> a[MAXN];   bool first;   vector<int> adj[MAXN];   inline int Dis(int i, int j) {     return abs(a[i].first - a[j].first) + abs(a[i].second - a[j].second);   }   inline void Make(int mid) {     memset(mark, 0ll, sizeof(mark));     for (int i = 0; i < n; i++) adj[i].clear();     for (int i = 0; i < n; i++)       for (int j = i + 1; j < n; j++)         if (Dis(i, j) > mid) adj[i].push_back(j), adj[j].push_back(i);   }   inline void DFS(int v) {     for (auto u : adj[v]) {       if (!mark[u])         mark[u] = 3 ^ mark[v], DFS(u);       else         first &= (mark[v] != mark[u]);     }   }   inline bool Check(int mid) {     Make(mid);     ans = first = 1;     for (int i = 0; i < n; i++)       if (!mark[i]) mark[i] = 1, ans <<= 1, ans %= MOD, DFS(i);     return first;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;     while (r - l > 1) {       mid = (l + r) >> 1;       if (Check(mid))         r = mid;       else         l = mid;     }     Check(r);     cout << r <<   n  << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, m;       cin >> n >> m;       int a[n], b[n];       for (int i = 0; i < n; i++) cin >> a[i];       for (int i = 0; i < n; i++) cin >> b[i];       sort(a, a + n);       sort(b, b + n);       int j = 0, k = n - 1;       while (m--) {         if (a[j] < b[k]) swap(a[j], b[k]);         j++;         k--;       }       int sum = 0;       for (int i = 0; i < n; i++) sum = sum + a[i];       cout << sum << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 300500;   int n, m, q;   vector<int> g[maxn];   bool used[maxn];   int p[maxn], sz[maxn], diameter[maxn];   int maxi, maxiV;   void dfs(int v, int depth, int p) {     if (depth > maxi) {       maxi = depth;       maxiV = v;     }     for (size_t i = 0; i < g[v].size(); i++) {       int to = g[v][i];       if (to != p) dfs(to, depth + 1, v);     }   }   int findLongestWay(int v) {     maxi = -1;     dfs(v, 0, -1);     maxi = -1;     dfs(maxiV, 0, -1);     return maxi;   }   void init() {     for (int i = 1; i <= n; i++) p[i] = i, sz[i] = 1, diameter[i] = 0;   }   int getSet(int v) {     if (p[v] == v) return v;     return p[v] = getSet(p[v]);   }   void unionSets1(int x, int y) {     x = getSet(x);     y = getSet(y);     if (sz[x] > sz[y]) swap(x, y);     sz[y] += sz[x];     p[x] = y;   }   int rad(int x) { return (diameter[x] + 1) / 2; }   void unionSets2(int x, int y) {     x = getSet(x);     y = getSet(y);     if (x == y) return;     if (sz[x] > sz[y]) swap(x, y);     sz[y] += sz[x];     p[x] = y;     diameter[y] = max(rad(x) + rad(y) + 1, max(diameter[x], diameter[y]));   }   int query(int x) { return diameter[getSet(x)]; }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     ;     cin >> n >> m >> q;     init();     for (int i = 1; i <= m; i++) {       int x, y;       cin >> x >> y;       g[x].push_back(y);       g[y].push_back(x);       unionSets1(x, y);     }     for (int i = 1; i <= n; i++) {       int pp = getSet(i);       if (!used[pp]) {         used[pp] = 1;         diameter[pp] = findLongestWay(i);       }     }     while (q--) {       int t, x, y;       cin >> t;       if (t == 2) {         cin >> x >> y;         unionSets2(x, y);       } else {         cin >> x;         printf( %d n , query(x));       }     }   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1000010;   const double eps = 1e-6;   const double pi = 4 * atan(1);   long long n, a[N], k, res = 1e18;   int solve() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     if (n == 2)       cout <<  1  << endl;     else if (n == 3)       cout <<  2  << endl;     else {       long long x = 2, y = 3, k = 2;       res = y;       while (res < n) {         if (x + y > n) break;         res = x + y;         x = y;         y = res;         k++;       }       cout << k << endl;     }     return 0;   }   int main() { return solve(); }
#include <bits/stdc++.h>   using namespace std;   int n;   char s[1001001];   int p[1001001] = {1};   int v[10][1001001], deg[1001001];   int Rand() { return rand() * rand(); }   int main() {     scanf( %s , s);     n = strlen(s);     for (int i = 1; i <= n; i++) {       p[i] = p[i - 1] * 10 % 7;     }     int rlt = 0;     reverse(s, s + n);     for (int i = 0; s[i]; i++) {       int c = s[i] -  0 ;       rlt = (rlt + p[i] * c) % 7;       v[c][deg[c]++] = i;     }     while (rlt) {       int x = rand() % 9 + 1;       int y = rand() % 9 + 1;       if (x == y || !deg[x] || !deg[y]) {         continue;       }       int tx = Rand() % deg[x];       int ty = Rand() % deg[y];       swap(v[x][tx], v[y][ty]);       s[v[x][tx]] = x +  0 ;       s[v[y][ty]] = y +  0 ;       rlt = rlt + (p[v[x][tx]] - p[v[y][ty]]) * (x - y);       rlt %= 7;       if (rlt < 0) rlt += 7;     }     reverse(s, s + n);     puts(s);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t, ans, tot = 1, n, temp;   bool flag, u[9];   struct none {     long long a;     int sum;   } f[9];   bool cmy(none f1, none f2) { return f1.a > f2.a; }   long long fuck(long long x) {     int back = 0;     for (long long i = 2; i * i <= x; i++)       while (x % i == 0) {         back++;         x /= i;       }     if (x != 1) back++;     if (back > 1) back++;     return back;   }   void init() {     long long x;     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %I64d , &f[i].a);     sort(f + 1, f + 1 + n, cmy);   }   void work() {     for (int i = 1; i <= n; i++) ans += f[i].sum;     for (int i = 1; i < n; i++) {       long long x = f[i].a;       while (1) {         temp = -1;         flag = false;         t = 0;         for (int j = i + 1; j <= n; j++)           if ((!u[j]) && (x % f[j].a == 0) && f[j].sum - 1 > temp) {             if (temp == -1) temp++;             t = j;             flag = true;             ans -= (f[j].sum - 1 - temp);             temp = f[j].sum - 1;           }         if (!flag) break;         x /= f[t].a;         tot++;         u[t] = true;         if (f[t].sum == 1) ans--;       }     }     if (tot < n) ans++;     printf( %d n , ans);   }   int main() {     init();     for (int i = 1; i <= n; i++) f[i].sum = fuck(f[i].a);     work();   }