malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   namespace red {   inline long long read() {     long long x = 0;     char f = 0, ch;     for (ch = getchar(); (ch <  0  || ch >  9 ) && ch !=  - ; ch = getchar())       ;     if (ch ==  - ) f = 1, ch = getchar();     while (ch >=  0  && ch <=  9 ) {       x = (x << 1) + (x << 3) + ch -  0 ;       ch = getchar();     }     return f ? -x : x;   }   const long long N = 1e5 + 10;   long long T, n;   long long a[N], c[N], pos[N], num;   struct node {     long long l, r, d;   } e[N];   long long tot;   inline void main() {     T = read();     while (T--) {       n = read();       num = tot = 0;       for (long long i = 1; i <= n; ++i) a[i] = read(), c[++num] = a[i];       sort(c + 1, c + num + 1);       for (long long i = 1; i <= n; ++i) {         for (long long j = 1; j <= n; ++j) {           if (a[i] == c[j]) {             a[i] = j;             c[j] = 1e9 + 10;             break;           }         }       }       for (long long pos, i = 1; i <= n; ++i) {         pos = i;         for (long long j = i; j <= n; ++j) {           if (a[j] == i) {             pos = j;             break;           }         }         if (pos == i) continue;         e[++tot].l = i, e[tot].r = pos, e[tot].d = pos - i;         for (long long j = pos; j > i; --j) a[j] = a[j - 1];         a[i] = i;       }       printf( %lld n , tot);       for (long long i = 1; i <= tot; ++i) {         printf( %lld %lld %lld n , e[i].l, e[i].r, e[i].d);       }     }   }   }  // namespace red   signed main() {     red::main();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char c[10][10];   int ans;   int main() {     cin >> c[1] >> c[2] >> c[3] >> c[4] >> c[5] >> c[6] >> c[7] >> c[8];     for (int i = 1; i <= 8; i++) {       int p = 0;       for (int j = 0; j < 8; j++)         if (c[i][j] ==  B ) p++;       if (p == 8) ans++;       p = 0;       for (int j = 1; j <= 8; j++)         if (c[j][i - 1] ==  B ) p++;       if (p == 8) ans++;     }     if (ans != 16)       cout << ans;     else       cout << 8;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 2147483647;   const double PI = 3.141592653589793;   int n, k, l, a[105], used[105], suma, i, j, q, b;   double maxx, minn;   vector<int> wek;   int main() {     scanf( %d %d , &n, &k);     l = n / k;     for (i = 0; i < n; i++) {       scanf( %d , &a[i]);       used[i] = 0;     }     maxx = -INF;     minn = INF;     scanf( %d , &q);     for (j = 0; j < q; j++) {       suma = 0;       for (i = 0; i < l; i++) {         scanf( %d , &b);         b--;         suma += a[b];         used[b] = 1;       }       maxx = max(maxx, suma * 1.0 / l);       minn = min(minn, suma * 1.0 / l);     }     wek.resize(0);     for (i = 0; i < n; i++)       if (!used[i]) wek.push_back(a[i]);     sort(wek.begin(), wek.end());     if (wek.size() == n - k * l) {       printf( %.8lf %.8lf n , minn, maxx);       return 0;     }     suma = 0;     for (i = 0; i < l; i++) suma += wek[i];     maxx = max(maxx, suma * 1.0 / l);     minn = min(minn, suma * 1.0 / l);     suma = 0;     for (i = wek.size() - 1; i >= (int)wek.size() - l; i--) suma += wek[i];     maxx = max(maxx, suma * 1.0 / l);     minn = min(minn, suma * 1.0 / l);     printf( %.8lf %.8lf n , minn, maxx);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const unsigned long long hash1 = 201326611;   const double eps = 1e-8;   const long long INF = 0x3f3f3f3f3f3f3f3f;   const int inf = 0x3f3f3f3f;   const long long mod = 1e9 + 7;   const int N = 1e5 + 10;   const int M = 12;   const int dif = 26;   const double PI = acos(-1.0);   inline void Mod(long long& x) {     if (x >= mod) x -= mod;   }   void BinaryBitset(int n) { cout << bitset<sizeof(int) * 4>(n) << endl; }   struct node {     long long l, r, len;   } p[22];   void init() {     p[1].l = 1;     p[1].r = 9;     p[1].len = 9;     for (int i = 2; i <= 18; i++) {       p[i].l = p[i - 1].l * 10;       p[i].r = p[i - 1].r * 10 + 9;       p[i].len = p[i - 1].len * 10;     }   }   int q;   long long k;   bool isOK(long long x, long long k) {     long long ans = 0;     for (int i = 1; i <= 20; i++) {       if (x > p[i].r) {         long long left = x - p[i].r + 1, right = x - p[i].l + 1;         ans += p[i].len * i * (right + left) / 2;       } else {         long long left = 1, right = x - p[i].l + 1;         ans += (right - left + 1) * i * (left + right) / 2;         break;       }       if (ans >= k) return 1;     }     return ans >= k;   }   long long getsum(long long x) {     long long ans = 0;     for (int i = 1; i <= 20; i++) {       if (x > p[i].r) {         long long left = x - p[i].r + 1, right = x - p[i].l + 1;         ans += p[i].len * i * (right + left) / 2;       } else {         long long left = 1, right = x - p[i].l + 1;         ans += (right - left + 1) * i * (left + right) / 2;         return ans;       }     }     return ans;   }   bool isOK2(long long x, long long k) {     long long ans = 0;     for (int i = 1; i <= 20; i++) {       if (x > p[i].r) {         ans += p[i].len * i;       } else {         long long left = 1, right = x - p[i].l + 1;         ans += (right - left + 1) * i;         break;       }       if (ans >= k) return 1;     }     return ans >= k;   }   long long getsum2(long long x) {     long long ans = 0;     for (int i = 1; i <= 20; i++) {       if (x > p[i].r) {         ans += p[i].len * i;       } else {         long long left = 1, right = x - p[i].l + 1;         ans += (right - left + 1) * i;         return ans;       }     }   }   int main() {     init();     scanf( %d , &q);     while (q--) {       scanf( %lld , &k);       long long left = 1, right = 482720320;       while (left <= right) {         long long mid = (left + right) >> 1;         if (isOK(mid, k))           right = mid - 1;         else           left = mid + 1;       }       k -= getsum(left - 1);       left = 1;       right = 1e10;       while (left <= right) {         long long mid = (left + right) >> 1;         if (isOK2(mid, k))           right = mid - 1;         else           left = mid + 1;       }       k -= getsum2(left - 1);       vector<int> ans;       long long x = left;       while (x) {         ans.push_back(x % 10);         x /= 10;       }       int j = 0, h = ans.size() - 1;       while (j <= h) {         swap(ans[j], ans[h]);         j++;         h--;       }       printf( %d n , ans[k - 1]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<int, int> card;   void init() {     for (int i = 6, j = 1; i < 15; i++, j++) card.insert(make_pair(i, j));   }   int isCard(char num) {     int res = 0;     if (num >=  0  && num <=  9 )       res = num -  0 ;     else {       if (num ==  T )         res = 10;       else if (num ==  J )         res = 11;       else if (num ==  Q )         res = 12;       else if (num ==  K )         res = 13;       else         res = 14;     }     return res;   }   int main() {     char mn;     string s;     cin >> s;     mn = s[0];     cin >> s;     int id[2];     char ch[2];     id[0] = isCard(s[0]);     ch[0] = s[1];     cin >> s;     id[1] = isCard(s[0]);     ch[1] = s[1];     map<int, bool> mp;     mp.insert(make_pair(mn, true));     if (mp.find(ch[0]) != mp.end() && mp.find(ch[1]) == mp.end())       cout <<  YES ;     else if (mp.find(ch[0]) == mp.end() && mp.find(ch[1]) != mp.end())       cout <<  NO ;     else if (ch[0] != ch[1])       cout <<  NO ;     else if (id[0] > id[1])       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n, k;     cin >> n >> k;     vector<int> table(n), d = {119, 18, 93, 91, 58, 107, 111, 82, 127, 123};     for (int i = 0; i < n; ++i) {       string tmp;       cin >> tmp;       reverse(tmp.begin(), tmp.end());       for (int j = 0; j < 7; ++j) {         if (tmp[j] ==  1 ) {           table[i] += (1 << j);         }       }     }     vector<vector<int>> dp(n + 1, vector<int>(k + 1, -1));     vector<vector<int>> par(n + 1, vector<int>(k + 1, -1));     dp[n][0] = 0;     for (int i = n - 1; i >= 0; --i) {       for (int j = 0; j <= k; ++j) {         for (int k = 9; k >= 0; --k) {           int cnt = __builtin_popcount(d[k] ^ table[i]);           if (j >= cnt && (d[k] | table[i]) == d[k] && dp[i + 1][j - cnt] != -1) {             dp[i][j] = k;             par[i][j] = j - cnt;             break;           }         }       }     }     if (dp[0][k] == -1) {       cout << -1 <<   n ;     } else {       int i = 0, j = k;       while (i < n && j >= 0) {         cout << dp[i][j];         j = par[i][j];         ++i;       }       cout <<   n ;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int N = 1000001;     vector<int> count(N);     long long n;     cin >> n;     vector<long long> a(n), ans;     long long sum = 0, i, j, k;     for (i = 0; i < n; i++) cin >> a[i], sum += a[i], count[a[i]]++;     for (i = 0; i < n; i++)       if ((sum - a[i]) % 2 == 0 && (sum - a[i]) / 2 < N &&           (count[(sum - a[i]) / 2] > 1 ||            (count[(sum - a[i]) / 2] == 1 && a[i] != (sum - a[i]) / 2)))         ans.push_back(i + 1);     cout << ans.size() << endl;     for (auto x : ans) cout << x <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const ll M = 1000000007;   const ll M1 = 998244353;   using vl = vector<ll>;   using pll = pair<ll, ll>;   ll power(ll x, ll y) {     if (y == 0) return 1;     ll res = power(x, y / 2);     res = (res * res);     if (y & 1) res = (res * x);     return res;   }   ll powermod(ll x, ll y, ll mod) {     if (y == 0) return 1;     ll res = powermod(x, y / 2, mod);     res = (res * res) % mod;     if (y & 1) res = (res * x) % mod;     return res;   }   ll findxor(ll a) {     switch (a & 3) {       case 0:         return a;       case 1:         return 1;       case 2:         return a + 1;       case 3:         return 0;     }     return -1;   }   int n;   vector<int> visi;   vector<string> gr;   void dfs(int node, vector<int> &rec_visit) {     visi[node] = 1;     rec_visit.push_back(node);     for (int con_node = 0; con_node < n; con_node++) {       if (visi[con_node] || gr[node][con_node] ==  0 ) continue;       dfs(con_node, rec_visit);     }   }   void solve() {     cin >> n;     int ans[n];     for (int i = 0; i < n; i++) cin >> ans[i];     gr.resize(n);     visi.resize(n, 0);     for (int i = 0; i < n; i++) cin >> gr[i];     for (int i = 0; i < n; i++) {       if (visi[i]) continue;       vector<int> rec_visit;       dfs(i, rec_visit);       vector<int> val;       for (int j = 0; j < rec_visit.size(); j++) val.push_back(ans[rec_visit[j]]);       sort(val.begin(), val.end());       sort(rec_visit.begin(), rec_visit.end());       for (int j = 0; j < rec_visit.size(); j++) ans[rec_visit[j]] = val[j];     }     for (int i = 0; i < n; i++) cout << ans[i] <<    ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t = 1;     for (int i = 1; i <= t; i++) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[50], c[50];   int t1 = 0, t2 = 0;   int main() {     cin >> s >> c;     for (int i = 0; i < strlen(s); i += 2) {       if ((s[i] ==  8  && c[i] ==  [ ) || (s[i] ==  [  && c[i] ==  ( ) ||           (s[i] ==  (  && c[i] ==  8 ))         t1++;       else if (s[i] != c[i])         t2++;     }     if (t1 > t2)       cout <<  TEAM 1 WINS ;     else if (t2 > t1)       cout <<  TEAM 2 WINS ;     else       cout <<  TIE ;   }
#include <bits/stdc++.h>   using namespace std;   long long c[110][110];   long long a[110];   long long tmp[110];   long long dp[10][110];   long long gao(long long n) {     memset(dp, 0, sizeof(dp));     long long i, j, k;     long long m = 0;     for (i = 0; i <= 9; i++) m += a[i];     if (m > n) return 0;     for (i = a[0]; i <= n; i++) {       dp[0][i] = c[n][i];     }     for (i = 1; i <= 9; i++)       for (j = 0; j <= n; j++) {         for (k = a[i]; k <= j; k++) {           dp[i][j] =               (dp[i][j] + dp[i - 1][j - k] * c[n - (j - k)][k] % 1000000007) %               1000000007;         }       }     return dp[9][n] % 1000000007;   }   int main() {     long long i, j, m, n;     for (i = 0; i < 110; i++)       for (j = 0; j < 110; j++) {         if (j > i) {           c[i][j] = 0;           continue;         }         if (j == 0)           c[i][j] = 1;         else           c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % 1000000007;       }     while (cin >> n) {       m = 0;       for (i = 0; i <= 9; i++) {         cin >> a[i];         tmp[i] = a[i];         m += a[i];       }       if (m > n) {         cout << 0 << endl;         continue;       }       long long res = 0;       for (long long l = max(1LL, m); l <= n; l++) {         for (i = 0; i <= n; i++) a[i] = tmp[i];         long long ans = 0;         for (i = 1; i <= 9; i++) {           long long tt = a[i];           a[i] = max(a[i] - 1, 0LL);           ans = (ans + gao(l - 1)) % 1000000007;           a[i] = tt;         }         res = (res + ans) % 1000000007;       }       cout << res << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long f[16][16][1 << 17];   int b[16];   long long dp(int x, int Mx, int sum, bool flag) {     if (x == 0) {       return (sum >> Mx) & 1;     }     if (!flag && f[x][Mx][sum] != -1) return f[x][Mx][sum];     int lm = flag ? b[x] : 15;     long long ans = 0;     for (int i = 0; i <= lm; i++) {       int tmp = sum;       if (x <= 4) tmp |= i << ((x - 1) * 4);       ans += dp(x - 1, max(Mx, i), tmp, flag && i == lm);     }     return flag ? ans : f[x][Mx][sum] = ans;   }   long long solve(long long x) {     int p = 0;     memset(b, 0, sizeof(b));     while (x) {       b[++p] = x % 16;       x /= 16;     }     return dp(p, 0, 0, 1);   }   int main() {     int _;     scanf( %d , &_);     memset(f, -1, sizeof(f));     while (_--) {       long long l, r;       scanf( %I64x%I64x , &l, &r);       printf( %I64d n , solve(r) - solve(l - 1));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n;     long double f;     int i;     cin >> n;     long long int m = n;     for (i = 1; n / pow(10, i) >= 1; ++i)       ;     i--;     f = n / pow(10, i);     if (ceil(f) == f) f++;     f = ceil(f);     n = f * pow(10, i);     cout << n - m;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long A[100001], B[100001];   bool valid[100001];   int main() {     ios::sync_with_stdio(0);     int n;     cin >> n;     for (int i = 0; i < n; ++i) cin >> A[i];     for (int i = 0; i < n; ++i) cin >> B[i];     long long ac = 0, bc = 0;     long long mini = (1LL << 62);     for (int i = 0; i < n; ++i) {       ac += A[i];       bc += B[i];       mini = min(mini, ac - bc);     }     for (int i = 0; i < n; ++i) {       valid[i] = mini >= 0;       mini -= A[i] - B[i];     }     mini = (1LL << 62);     ac = bc = 0;     for (int i = 0; i < n; ++i) {       ac += A[n - i - 1];       bc += B[(n - i - 2 + n) % n];       mini = min(mini, ac - bc);     }     for (int i = 0; i < n; ++i) {       assert(mini <= 0);       valid[n - i - 1] |= mini >= 0;       mini -= A[n - i - 1] - B[(n - i - 2 + n) % n];     }     bool first = true;     int ans = 0;     for (int i = 0; i < n; ++i) ans += valid[i];     cout << ans << endl;     for (int i = 0; i < n; ++i)       if (valid[i]) {         if (not first) cout <<    ;         cout << i + 1;         first = false;       }     cout << endl;   }
#include <bits/stdc++.h>   const long long mod = 998244353;   const int kN = 5e3 + 10;   int n, a[kN], lim[kN];   long long f[kN], fac[kN], invfac[kN];   inline int read() {     int f = 1, w = 0;     char ch = getchar();     for (; !isdigit(ch); ch = getchar())       if (ch ==  - ) f = -1;     for (; isdigit(ch); ch = getchar()) {       w = (w << 3) + (w << 1) + (ch ^  0 );     }     return f * w;   }   void Chkmax(int &fir_, int sec_) {     if (sec_ > fir_) fir_ = sec_;   }   void Chkmin(int &fir_, int sec_) {     if (sec_ < fir_) fir_ = sec_;   }   long long QPow(long long x_, long long y_) {     x_ %= mod;     long long ret = 1;     for (; y_; y_ >>= 1ll) {       if (y_ & 1) ret = ret * x_ % mod;       x_ = x_ * x_ % mod;     }     return ret;   }   long long A(long long n_, long long m_) {     if (n_ < 0 || m_ < 0 || m_ > n_) return 0;     return 1ll * fac[n_] * invfac[n_ - m_] % mod;   }   void Prepare() {     n = read();     invfac[0] = fac[0] = 1;     for (int i = 1; i <= n; ++i) {       a[i] = read();       fac[i] = 1ll * fac[i - 1] * i % mod;       invfac[i] = QPow(fac[i], mod - 2);     }     std::sort(a + 1, a + n + 1);     for (int i = 1, j = 0; i <= n; ++i) {       while (j <= n && 2ll * a[j] <= 1ll * a[i]) ++j;       --j;       lim[i] = j;     }   }   int main() {     Prepare();     if (lim[n] != n - 1) {       printf( 0 n );       return 0;     }     f[0] = 1, lim[0] = -1;     for (int i = 1; i <= n; ++i) {       for (int j = 0; j <= lim[i]; ++j) {         f[i] += 1ll * f[j] *                 A(1ll * n - 2ll - lim[j], 1ll * lim[i] - lim[j] - 1ll) % mod;         f[i] %= mod;       }     }     printf( %lld n , f[n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 109;   int n, suma, K, sumb, f[10086][N], ans = 0;   struct node {     int a, b;   } c[N];   bool cmp(const node& a, const node& b) { return a.b > b.b; }   int main() {     scanf( %d , &n);     for (register int i = 1; i <= n; i++) scanf( %d , &c[i].a), suma += c[i].a;     for (register int i = 1; i <= n; i++) scanf( %d , &c[i].b);     sort(c + 1, c + n + 1, cmp);     while (sumb < suma) sumb += c[++K].b;     printf( %d  , K);     memset(f, 128, sizeof(f));     f[0][0] = 0;     for (register int i = 1; i <= n; i++)       for (register int j = sumb; j >= c[i].b; j--)         for (register int k = 1; k <= K; k++)           f[j][k] = max(f[j][k], f[j - c[i].b][k - 1] + c[i].a);     for (register int j = suma; j <= sumb; j++) ans = max(ans, f[j][K]);     printf( %d , suma - ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   pair<long long, long long> a[100005];   long long pymax[100005], pymin[100005];   long long symax[100005], symin[100005];   bool trial(long long x) {     for (int i = 0; i < n; i++) {       symax[i] = pymax[i] = a[i].second - x;       symin[i] = pymin[i] = a[i].second + x;     }     for (int i = 1; i < n; i++) {       pymax[i] = max(pymax[i], pymax[i - 1]);       pymin[i] = min(pymin[i], pymin[i - 1]);     }     for (int i = n - 2; i >= 0; i--) {       symax[i] = max(symax[i], symax[i + 1]);       symin[i] = min(symin[i], symin[i + 1]);     }     int e = 0;     for (int i = 0; i < n; i++) {       while (e < n && a[e].first <= a[i].first + x * 2) {         e++;       }       long long maxv = -1e18, minv = 1e18;       if (i) maxv = max(maxv, pymax[i - 1]), minv = min(minv, pymin[i - 1]);       if (e < n) maxv = max(maxv, symax[e]), minv = min(minv, symin[e]);       if (maxv <= minv) {         return 1;       }     }     return 0;   }   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       int x, y;       scanf( %d %d , &x, &y);       a[i] = pair<long long, long long>(x + y, x - y);       a[i].first *= 2ll;       a[i].second *= 2ll;     }     sort(a, a + n);     long long s = 0, e = 1e10;     while (s != e) {       long long m = (s + e) / 2;       if (trial(m))         e = m;       else         s = m + 1;     }     printf( %.10f , s * 0.5);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a[1007];     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     int ans, min = 10000007, sum = 0;     for (int i = 1; i <= 100; i++) {       sum = 0;       for (int j = 0; j < n; j++) {         if (a[j] > i + 1)           sum += a[j] - i - 1;         else if (a[j] < i - 1)           sum += i - 1 - a[j];       }       if (min > sum) min = sum, ans = i;     }     cout << ans <<     << min << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e6 + 20;   int a[105];   int u[105], res[105];   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 0; i < m; i++) {       scanf( %d , &a[i]);     }     int pos = a[0], ans = 1;     while (ans < m) {       if (a[ans] > pos) {         if (res[pos] == 0) {           if (u[a[ans] - pos]) {             puts( -1 );             return 0;           }           res[pos] = a[ans] - pos;         } else {           if (a[ans] % n != (res[pos] + pos) % n) {             puts( -1 );             return 0;           }         }         u[a[ans] - pos] = 1;       } else {         if (res[pos] == 0) {           if (u[a[ans] + n - pos]) {             puts( -1 );             return 0;           }           res[pos] = a[ans] + n - pos;         } else {           if (a[ans] % n != (res[pos] + pos) % n) {             puts( -1 );             return 0;           }         }         u[a[ans] + n - pos] = 1;       }       pos = a[ans++];     }     for (int i = 1; i <= n; i++) {       if (res[i] == 0) {         for (int j = 1; j <= n; j++) {           if (u[j] == 0) {             res[i] = j;             u[j] = 1;             break;           }         }       }       printf( %d  , res[i]);     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   long long a[10], n, rem[10], par[10], res = N, rem_factors[10], factors[10];   inline bool is_prime(long long u) {     if (u == 1) return false;     if (u == 2) return true;     if (u % 2 == 0) return false;     for (long long i = 3; i * i <= u; i += 2)       if (u % i == 0) return false;     return true;   }   int get(long long u) {     if (u == 1) return 0;     if (is_prime(u)) return 1;     int res = 0;     while (u % 2 == 0) {       u /= 2;       res++;     }     if (u == 1) return res;     if (is_prime(u)) {       return res + 1;     }     for (long long i = 3; i * i <= u; i += 2) {       while (u % i == 0) {         res++;         u /= i;       }     }     if (u > 2) res++;     return res;   }   int PRIME[10];   void backtrack(int idx) {     if (idx == n) {       int val = 0, cnt_par = 0;       for (int i = 0; i < n; i++) {         if (!PRIME[i]) val += rem_factors[i];         cnt_par += (par[i] != -1);       }       if (n - cnt_par > 1)         res = min(res, val + n + 1);       else         res = min(res, val + n);       return;     }     for (int i = idx + 1; i < n; i++) {       if (rem[i] >= a[idx] && a[i] > a[idx] && rem[i] % a[idx] == 0) {         rem[i] /= a[idx];         rem_factors[i] -= factors[idx];         par[idx] = i;         backtrack(idx + 1);         rem_factors[i] += factors[idx];         par[idx] = -1;         rem[i] *= a[idx];       }     }     backtrack(idx + 1);   }   int main() {     ios_base::sync_with_stdio(false);     scanf( %d , &n);     memset(par, -1, sizeof(par));     for (int i = 0; i < n; i++) scanf( %lld , &a[i]);     sort(a, a + n);     for (int i = 0; i < n; i++) rem[i] = a[i];     for (int i = 0; i < n; i++) PRIME[i] = is_prime(a[i]);     for (int i = 0; i < n; i++) {       rem_factors[i] = get(a[i]);       factors[i] = rem_factors[i];     }     backtrack(0);     printf( %d n , res);     return 0;   }