malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 60;   int n, l;   char s[maxn][maxn], t[maxn];   bool eq(int x, int i, int j) {     for (int k = 0; k < l; k++) {       if (s[x][i] != t[j]) return false;       i = (i + 1) % l;       j = (j + 1) % l;     }     return true;   }   int dist(int x, int j) {     for (int i = 0; i < l; i++)       if (eq(x, i, j)) return i;     return -1;   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %s , s[i]);     l = strlen(s[0]);     strcpy(t, s[0]);     int ans = 0x3f3f3f3f;     for (int j = 0; j < l; j++) {       int t = 0;       for (int x = 0; x < n; x++) {         int d = dist(x, j);         if (d == -1) {           printf( -1 n );           return 0;         }         t += d;       }       if (t < ans) ans = t;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, p[1000001];   long long ans;   int main() {     scanf( %d%d , &n, &k);     if (k == 1) {       printf( 3 );       return 0;     }     for (int i = 1; i <= n; i++) p[i] = i;     for (int i = 2; i <= n; i++)       if (p[i] == i)         for (int j = i; j <= n; j += i) p[j] -= p[j] / i;     sort(p + 1, p + 1 + n);     for (int i = 1; i <= k + 2; i++) ans += p[i];     printf( %I64d , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int num[10010];   int dp[1 << 18];   int bad[1 << 18];   int g[100][100];   int tmp[1 << 18];   string s;   int get(int l, int r) {     int t = 0;     for (int i = l; i <= r; ++i) {       t |= 1 << (s[i] -  a );     }     return t;   }   int main() {     int n, p;     scanf( %d%d , &n, &p);     cin >> s;     memset(num, 0, sizeof(num));     memset(g, 0, sizeof(g));     memset(bad, 0, sizeof(bad));     for (int i = 0; i < s.size(); ++i) {       num[s[i] -  a ]++;     }     for (int i = 0; i < p; ++i) {       for (int j = 0; j < p; ++j) {         scanf( %d , &g[i][j]);       }     }     for (int i = 0; i < p; ++i) {       for (int j = 0; j < p; ++j) {         if (g[i][j]) continue;         memset(tmp, 0, sizeof(tmp));         int l = -1;         for (int k = 0; k < s.size(); ++k) {           if (s[k] -  a  == i || s[k] -  a  == j) {             if (l == -1) {               l = k;             } else {               int a = s[l] -  a , b = s[k] -  a ;               if ((a == i || a == j) && (b == i || b == j)) {                 if ((a == i && b == j) || (b == j && a == i)) {                   int m = get(l + 1, k - 1);                   tmp[m] = 1;                 }                 l = k;               }             }           }         }         for (int ii = 0; ii < (1 << p); ++ii) {           if ((ii & (1 << i)) || (ii & (1 << j))) continue;           for (int k = 0; k < p; ++k) {             if (k == i || k == j) continue;             tmp[ii | (1 << k)] |= tmp[ii];           }           if (tmp[ii]) bad[ii] = tmp[ii];         }       }     }     memset(dp, 0, sizeof(dp));     dp[0] = 1;     int ans = 0;     for (int i = 0; i < (1 << p); ++i) {       if (bad[i]) continue;       for (int j = 0; j < p; ++j) {         if ((1 << j) & i) {           if (dp[i ^ (1 << j)]) dp[i] = 1;         }       }       if (dp[i]) {         int s = 0;         for (int j = 0; j < p; ++j) {           if ((1 << j) & i) s += num[j];         }         ans = max(ans, s);       }     }     printf( %d n , n - ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     scanf( %lld , &n);     if (n == 1 || n == 2) {       puts( -1 );       return 0;     }     if (n & 1) {       n -= 1;       n /= 2;       printf( %lld %lld n , 2 * n * n + 2 * n, 2 * n * n + 2 * n + 1);     } else {       n /= 2;       printf( %lld %lld n , n * n - 1, n * n + 1);     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int s, a, b, c;     cin >> s >> a >> b >> c;     double x = 0.0, y = 0.0, z = 0.0;     if (a || b || c) {       x = s * a / (double)(a + b + c);       y = s * b / (double)(a + b + c);       z = s * c / (double)(a + b + c);     }     printf( %.12f %.12f %.12f , x, y, z);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int x = 0;     int f = 1, ch = getchar();     for (; !isdigit(ch) && ch != EOF; ch = getchar())       if (ch ==  - ) f = -1;     for (; isdigit(ch); ch = getchar()) x = (x << 3) + (x << 1) + (ch ^  0 );     return x * f;   }   const int N = 500005;   int n, La, Lb, Lc, smx[N];   struct card {     int b, c;   };   vector<card> d[N];   long long ans, sum[N];   int main() {     n = read(), La = read(), Lb = read(), Lc = read();     for (register int i = 1; i <= n; ++i) {       int a = min(La, read()), b = min(Lb, read()), c = min(Lc, read());       d[a].push_back((card){b, c});       smx[b] = max(smx[b], c);     }     for (register int i = Lb - 1; i; --i) smx[i] = max(smx[i], smx[i + 1]);     for (register int i = 1; i <= Lb; ++i) sum[i] = sum[i - 1] + smx[i];     int mxb = 0, mxc = 0, k = Lb + 1;     for (register int x = La; x; --x) {       for (register int i = 0; i < d[x].size(); ++i) {         int y = d[x][i].b, z = d[x][i].c;         mxb = max(mxb, y), mxc = max(mxc, z);         while (k > mxb + 1 && smx[k - 1] < mxc) --k;       }       k = max(k, mxb + 1);       ans += 1ll * (Lc - mxc) * (Lb - k + 1) + 1ll * Lc * (k - mxb - 1) -              sum[k - 1] + sum[mxb];     }     printf( %lld , ans);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string a, b;     cin >> a;     cin >> b;     int lena = a.length(), lenb = b.length();     if (lena != lenb)       cout <<  NO ;     else {       int count = 0;       char old1, old2;       for (int i = 0; i < lena && count < 3; i++) {         if (a[i] != b[i]) {           count++;           if (count == 1) {             old1 = b[i];             old2 = a[i];           }           if (count == 2 && (a[i] != old1 || b[i] != old2)) count = 3;         }       }       if (count == 2)         cout <<  YES ;       else         cout <<  NO ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   int ans;   map<int, int> f;   int main() {     cin >> s;     int n = s.length();     f[0] = 1;     int cur = 0;     for (int i = 1; i < n; i++) {       if (s[i] == s[i - 1]) {         f[cur]++;       } else {         f[i]++;         cur = i;       }     }     while (f.size() > 1) {       int _min = 10000000;       for (auto i = f.begin(); i != f.end(); ++i) {         if (i == f.begin() || next(i) == f.end())           cur = i->second;         else           cur = ceil(i->second / 2.0);         _min = min(_min, cur);       }       ans += _min;       for (auto i = f.begin(); i != f.end(); ++i) {         cur = _min;         auto ci = i;         if (i == f.begin() || next(i) == f.end()) {           i->second -= cur;         } else {           i->second -= cur + cur;         }         ci = i;       }       for (auto i = f.begin(); i != f.end();) {         auto ci = i;         ++i;         if (ci->second < 1) f.erase(ci);       }       if (f.size())         for (auto it = f.begin(); it != prev(f.end());) {           if (s[it->first] == s[next(it)->first]) {             next(it)->second += it->second;             auto cit = it;             ++it;             f.erase(cit);           } else             ++it;         }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   pair<long double, long double> a[100005];   long double isum = 0, min1 = 1000000000000, isum1, t[100005],               min2 = 1000000000000, min3 = 1000000000000, min4 = 1000000000000,               min5 = 1000000000000;   int i, j;   long long ax, ay, bx, by, tx, ty, n, x[100005], y[100005], h, k;   bool used[100005];   int main() {     cin >> ax >> ay >> bx >> by >> tx >> ty >> n;     for (i = 0; i < 100005; i++) used[i] = 0;     for (i = 0; i < n; i++) {       cin >> x[i];       cin >> y[i];     }     a[n].first = 0;     a[n].second = 0;     for (i = 0; i < n; i++) {       t[i] = sqrt((tx - x[i]) * (tx - x[i]) + (ty - y[i]) * (ty - y[i]));       a[i].first =           sqrt((ax - x[i]) * (ax - x[i]) + (ay - y[i]) * (ay - y[i])) - t[i];       a[i].second =           sqrt((bx - x[i]) * (bx - x[i]) + (by - y[i]) * (by - y[i])) - t[i];       isum += 2 * t[i];     }     sort(a, a + n);     for (i = 0; i < n; i++) {       min2 = min(min2, a[i].first);     }     for (i = 0; i < n; i++) {       if (a[i].first == min2) {         h = i;         break;       }     }     for (i = 0; i < n; i++) {       if (i != h) min3 = min(min3, a[i].first);     }     for (i = 0; i < n; i++) {       min4 = min(min4, a[i].second);     }     for (i = 0; i < n; i++) {       if (a[i].second == min4) {         k = i;         break;       }     }     for (i = 0; i < n; i++) {       if (i != k) min5 = min(min5, a[i].second);     }     if (h != k) {       min1 = min(min1, min2 + min4);     } else {       min1 = min(min1, min2 + min5);       min1 = min(min1, min3 + min4);       min1 = min(min1, min3 + min5);     }     for (i = 0; i < n; i++) min1 = min(a[i].first, min1);     for (i = 0; i < n; i++) min1 = min(a[i].second, min1);     cout << fixed << setprecision(12) << isum + min1;   }
#include <bits/stdc++.h>   using namespace std;   const char nl =   n ;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, v1, v2, t1, t2;     cin >> n >> v1 >> v2 >> t1 >> t2;     if (n * v1 + t1 * 2 < n * v2 + t2 * 2)       cout <<  First  << nl;     else if (n * v1 + t1 * 2 > n * v2 + t2 * 2)       cout <<  Second  << nl;     else       cout <<  Friendship  << nl;   }
#include <bits/stdc++.h>   using namespace std;   void swap(long long &a, long long &b) {     auto tm = a;     a = b;     b = tm;   }   const long long mod = 1000000009;   const long long mod2 = 998244353;   const long long INF = (1LL << 20) - 1;   const long long N = 2e5 + 25;   long long n, m, a, b;   vector<long long> v[N];   set<long long> c, d;   bool vt[N];   void dfs1(long long x) {     vt[x] = 1;     for (auto &(i) : (v[x])) {       if (i == b) {         c.insert(x);         continue;       }       if (vt[i] == 0) dfs1(i);     }   }   void dfs2(long long x) {     vt[x] = 1;     for (auto &(i) : (v[x])) {       if (i == a) {         d.insert(x);         continue;       }       if (vt[i] == 0) dfs2(i);     }   }   void bheja_fry() {     c.clear();     d.clear();     cin >> n >> m >> a >> b;     for (long long(i) = (0); (i) < (n + 1); ++(i)) {       v[i].clear();       vt[i] = 0;     }     long long x, y;     for (long long(i) = (0); (i) < (m); ++(i)) {       cin >> x >> y;       v[x].push_back(y);       v[y].push_back(x);     }     long long ct1 = 0, ct2 = 0;     dfs1(a);     for (long long(i) = (0); (i) < (n + 1); ++(i)) vt[i] = 0;     dfs2(b);     queue<long long> q;     for (auto &(i) : (v[b])) {       if (c.find(i) == c.end()) q.push(i);     }     for (long long(i) = (0); (i) < (n + 1); ++(i)) vt[i] = 0;     vt[b] = 1;     while (!q.empty()) {       x = q.front();       q.pop();       if (vt[x]) continue;       ct1++;       vt[x] = 1;       for (auto &(i) : (v[x])) {         if (vt[i] == 0) q.push(i);       }     }     for (auto &(i) : (v[a])) {       if (d.find(i) == d.end()) q.push(i);     }     for (long long(i) = (0); (i) < (n + 1); ++(i)) vt[i] = 0;     vt[a] = 1;     while (!q.empty()) {       x = q.front();       q.pop();       if (vt[x]) continue;       ct2++;       vt[x] = 1;       for (auto &(i) : (v[x])) {         if (vt[i] == 0) q.push(i);       }     }     cout << ct1 * ct2;   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long t = 1;     cin >> t;     for (long long(i) = (1); (i) < (t + 1); ++(i)) {       bheja_fry();       if (i < t) cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   void rd(int &x) {     x = 0;     int f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch <=  9  && ch >=  0 ) x = x * 10 + ch -  0 , ch = getchar();     x *= f;   }   void lrd(long long &x) {     x = 0;     int f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch <=  9  && ch >=  0 ) x = x * 10 + ch -  0 , ch = getchar();     x *= f;   }   const int INF = 1e9;   const long long LINF = 1e18;   const int inf = 1e5 + 10;   using namespace std;   int T;   long long n;   int m, a[inf];   int cnt[100];   map<int, int> S;   int sta[100], top;   int main() {     rd(T);     int now = 1;     for (int i = 0; i <= 30; i++) S[now] = i, now *= 2;     while (T--) {       lrd(n);       rd(m);       memset(cnt, 0, sizeof(cnt));       long long sum = 0;       for (int i = 1; i <= m; i++) rd(a[i]), cnt[S[a[i]]]++, sum += a[i];       if (sum < n)         printf( -1 n );       else {         int now = 0;         top = 0;         while (n) {           if (n & 1) {             if (cnt[now])               cnt[now]--;             else               sta[++top] = now;           }           now++;           n /= 2;         }         int ans = 0;         for (int i = 1; i <= top;) {           for (int j = 0; j < sta[i]; j++) cnt[j + 1] += cnt[j] / 2, cnt[j] %= 2;           for (int j = sta[i]; j <= 99; j++) {             if (cnt[j]) {               ans += j - sta[i];               cnt[j]--;               for (int k = sta[i]; k < j; k++) cnt[k]++;               while (i <= top && sta[i] <= j) i++;               break;             }           }         }         printf( %d n , ans);       }     }     return 0;   }
#include<bits/stdc++.h>   using namespace std;   #define lp(i,a,n) for(i=a;i<n;i++)   #define ld(i,a,n) for(i=n-1;i>=a;i--)   #define ll long long   #define dd double   #define mod 10000007   #define inf 1e18   #define inp(t) cin>>t; while(t--)   int main(){    int t;    ios::sync_with_stdio(false);    inp(t){     ll n,i,j,k;     cin>>n;     int arr[n];     lp(i,0,n)     cin>>arr[i];     int ans;     int sm=accumulate(arr,arr+n,0);     int chk=1;     lp(i,0,n){      k=n-i;      int val;      if(sm%k==0)      val=sm/k;      else      continue;      int smm=0;      lp(j,0,n){       smm+=arr[j];       if(smm<val)       continue;       else if(smm==val&&j!=n-1){        smm=0;        continue;       }       else if(smm==val&&j==n-1){        chk=0;        ans=i;        break;       }       else{        smm=0;        break;       }                    }      if(chk==0)       break;     }     cout<<ans<<endl;          }          }
#include <bits/stdc++.h>   using namespace std;   int n;   double V1;   double V2[100005];   double L[100005];   double D[100005];   double X[100005];   bool check(double T) {     bool ok1 = false;     bool ok1b = false;     bool ok2 = false;     bool ok2b = false;     double l = 0;     double r = 1000000;     vector<pair<double, double> > V;     V.clear();     for (int i = 1; i <= n; i++) {       if (D[i] == 1 && !ok1) {         if (L[i] <= V2[i] * T) {           ok1 = true;         } else {           double TS = T - L[i] / (V1 + V2[i]);           double MS = 1 / (V1 - V2[i]) - V2[i] / (V1 * V1 - V2[i] * V2[i]);           if (TS < 0) continue;           ok1b = true;           double x;           if (TS > MS * 10000000)             x = 1000000;           else             x = TS / MS;           if (x < 1) x = 0;           if (X[i] > l) l = X[i];           if (X[i] + x < r) r = X[i] + x;           V.push_back(make_pair(X[i], X[i] + x));         }       }     }     for (int i = 1; i <= n; i++) {       if (D[i] == 2 && !ok2) {         if (L[i] <= V2[i] * T) {           ok2 = true;         } else {           double TS = T - L[i] / (V1 + V2[i]);           double MS = 1 / (V1 - V2[i]) - V2[i] / (V1 * V1 - V2[i] * V2[i]);           if (TS < 0) continue;           ok2b = true;           double x;           if (TS > MS * 10000000)             x = 1000000;           else             x = TS / MS;           if (x < 1) x = 0;           if (X[i] - x > l) l = X[i] - x;           if (X[i] < r) r = X[i];           for (int j = 0; j < V.size(); j++)             if ((V[j].first <= X[i] && X[i] <= V[j].second) ||                 (V[j].first <= (X[i] - x) && (X[i] - x) <= V[j].second)) {               return true;             }         }       }     }     return ((ok1 && ok2b) || (ok2 && ok1b) || (ok1 && ok2));   }   int main() {     cin >> n >> V1;     for (int i = 1; i <= n; i++) {       cin >> X[i] >> V2[i] >> D[i];       if (D[i] == 1)         L[i] = X[i];       else         L[i] = 1000000 - X[i];     }     double l = 0;     double r = 10000000;     while (0.0000001 <= r - l) {       double m = (l + r) / 2;       if (check(m))         r = m - 0.00000001;       else         l = m + 0.00000001;     }     printf( %0.8f n , r);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> pat[100000];   int main() {     int num, way;     scanf( %d%d , &num, &way);     set<pair<int, int> > se;     for (int i = 0; i < way; i++) {       int za, zb;       scanf( %d%d , &za, &zb);       za--;       zb--;       pat[za].push_back(zb);       pat[zb].push_back(za);       se.insert(make_pair(za, zb));       se.insert(make_pair(zb, za));     }     if (num <= 9) {       vector<int> vec;       for (int i = 0; i < num; i++) {         vec.push_back(i);       }       for (;;) {         bool f = true;         for (int i = 0; i < way; i++) {           if (se.find(make_pair(vec[i], vec[(i + 1) % num])) != se.end()) {             f = false;             break;           }         }         if (f) {           for (int i = 0; i < way; i++) {             printf( %d %d n , vec[i] + 1, vec[(i + 1) % num] + 1);           }           return 0;         }         if (!next_permutation(vec.begin(), vec.end())) {           printf( -1 n );           return 0;         }       }     }     vector<pair<int, int> > ans;     int now = 0;     set<int> rem;     for (int i = 1; i < num; i++) {       rem.insert(i);     }     for (int i = 0; i < num - 9; i++) {       set<int>::iterator it = rem.begin();       for (;;) {         if (se.find(make_pair(now, (*it))) == se.end()) {           ans.push_back(make_pair(now, (*it)));           now = *it;           rem.erase(it);           break;         }         it++;       }     }     set<int>::iterator it = rem.begin();     vector<int> vec;     for (int i = num - 8; i < num; i++) {       vec.push_back((*it));       it++;     }     for (;;) {       bool f = true;       for (int i = 0; i < 7; i++) {         if (se.find(make_pair(vec[i], vec[i + 1])) != se.end()) {           f = false;           break;         }       }       if (se.find(make_pair(ans[ans.size() - 1].second, vec[0])) != se.end() ||           se.find(make_pair(vec[vec.size() - 1], ans[0].first)) != se.end()) {         f = false;       }       if (f) {         ans.push_back(make_pair(ans[ans.size() - 1].second, vec[0]));         for (int i = 0; i < 7; i++) {           ans.push_back(make_pair(vec[i], vec[i + 1]));         }         ans.push_back(make_pair(vec[vec.size() - 1], ans[0].first));         break;       }       if (!next_permutation(vec.begin(), vec.end())) {         abort();         return 0;       }     }     for (int i = 0; i < way; i++) {       printf( %d %d n , ans[i].first + 1, ans[i].second + 1);     }   }
#include <bits/stdc++.h>   using namespace std;   string s1, s2;   int a, b;   int nxt[205], cnt[205];   int main() {     scanf( %d%d , &a, &b);     cin >> s1 >> s2;     for (int i = 0; i < s2.size(); i++) {       int pos = i;       for (int r = 0; r < s1.size(); r++) {         if (s2[pos] == s1[r]) {           pos++;           if (pos == s2.size()) cnt[i]++, pos = 0;         }       }       nxt[i] = pos;     }     int ans = 0;     int poss = 0;     for (int i = 1; i <= a; i++) ans += cnt[poss], poss = nxt[poss];     cout << ans / b;   }
#include <bits/stdc++.h>   using namespace std;   const int Maxn = 7005;   const int Maxm = 1000006;   int n, m;   int a[Maxn], b[Maxn], c[Maxn], d[Maxn], e[Maxn];   int mn[Maxn], mx[Maxn];   bool has[Maxm];   vector<int> tk;   int main() {     scanf( %d %d , &n, &m);     for (int i = 0; i < m; i++) {       scanf( %d %d %d , &a[i], &b[i], &c[i]);       if (a[i] == 1)         scanf( %d %d , &d[i], &e[i]);       else {         mn[b[i]] = mx[b[i]] = c[i];         int tomin = 0, tomax = 0;         for (int l = b[i] + 1; l <= n; l++) {           while (1 << tomin <= mn[l - 1] - 1) tomin++;           mn[l] = mn[l - 1] - 1 + tomin + 1;           while (1 << tomax <= mx[l - 1] - 1) tomax++;           mx[l] = mx[l - 1] - 1 + tomax + 1 + (mx[l - 1] == 1 << tomax);         }         for (int j = 0; j < i; j++)           if (b[i] <= b[j] && max(mn[b[j]], c[j]) <= min(mx[b[j]], d[j]) &&               !has[e[j]]) {             has[e[j]] = true;             tk.push_back(e[j]);           }         printf( %d n , tk.size());         for (int i = 0; i < tk.size(); i++) has[tk[i]] = false;         tk.clear();       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   struct Node {     int pos, val, sit;   } a[305];   bool cmp(Node x, Node y) {     if (x.val == y.val) {       return x.pos > y.pos;     }     return x.val < y.val;   }   bool cmp2(Node x, Node y) { return x.pos < y.pos; }   int main() {     int T;     std::cin >> T;     while (T--) {       cin >> n >> m;       for (int i = 1; i <= m; i++) {         scanf( %d , &a[i].val);         a[i].pos = i;       }       sort(a + 1, a + 1 + m, cmp);       for (int i = 1; i <= m; i++) {         a[i].sit = i;       }       sort(a + 1, a + 1 + m, cmp2);       int ans = 0;       for (int i = 2; i <= m; i++) {         for (int j = i - 1; j >= 1; j--) {           if (a[j].sit < a[i].sit) ans++;         }       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INTINF = 0x3f3f3f3f;   const long long INF = 0x3f3f3f3f3f3f3f3f;   const int MAXN = 55;   const int MAXM = (1 << 20) + 1;   long long dp[MAXM], C[MAXN][MAXN];   int n, m;   char a[MAXN][MAXN];   double ans = 0;   int count(long long x) {     int res = 0;     while (x) x &= (x - 1), res++;     return res;   }   void init() {     for (int i = 0; i <= m; i++)       for (int j = C[i][0] = 1; j <= i; j++)         C[i][j] = C[i - 1][j - 1] + C[i - 1][j];   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %s , a[i]);     m = strlen(a[0]);     init();     for (long long i = 0; i < n; i++)       for (long long j = 0; j < i; j++) {         int same_bit = 0;         for (int k = 0; k < m; k++)           if (a[i][k] == a[j][k]) same_bit |= 1 << k;         dp[same_bit] |= (1ll << i) | (1ll << j);       }     for (int s = (1 << m) - 1; ~s; s--)       for (int i = 0; i < m; i++)         if ((1 << i) & s) dp[s ^ (1 << i)] |= dp[s];     for (int s = 0; s < (1 << m); s++) {       ans += (double)count(dp[s]) / n / C[m][count(s)];     }     printf( %.10lf n , ans);     return 0;   }