malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T sqr(const T& x) {     return x * x;   }   template <class T>   inline void updMin(T& a, const T& b) {     if (b < a) a = b;   }   template <class T>   inline void updMax(T& a, const T& b) {     if (b > a) a = b;   }   vector<string> a;   int cross(int i, int j) {     int neq = 0;     for (int t = 0; t < 6; t++) {       if (a[i][t] != a[j][t]) neq++;     }     return (neq + 1) / 2;   }   int main() {     int n;     cin >> n;     a.resize(n);     for (int i = 0; i < n; i++) {       cin >> a[i];     }     if (n == 1) {       cout << 6 <<   n ;     } else {       int ans = 6;       for (int i = 0; i < n; i++) {         for (int j = i + 1; j < n; j++) {           ans = min(ans, cross(i, j) - 1);         }       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, n, c0, c1, h, cc0 = 0, cc1 = 0;     cin >> t;     cout << endl;     for (int i = 0; i < t; i++) {       cin >> n >> c0 >> c1 >> h;       cout << endl;       string ali;       cin >> ali;       bitset<1001> ss(ali);       cc1 = ss.count();       cc0 = n - cc1;       int min_d = (cc1 * c1) + (cc0 * c0);       if (c0 < c1) {         int maliyet = cc1 * c0 + cc0 * c0 + cc1 * h;         min_d = min(min_d, maliyet);       } else {         int maliyet = cc1 * c1 + cc0 * c1 + cc0 * h;         min_d = min(min_d, maliyet);       }       cout << endl << min_d << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;       typedef long double ld;   const long long inf = 1100000000000000000;   #define maxn 200050   #define mod 1000000007 //998244353    #define int long long    #define PB push_back   #define F first   #define S second   #define vi vector<int>   #define rep(i,a,b)  for( int i = a; i < b; i++ )   #define rep1(i,a,b) for( int i = a; i <= b; i++)   #define repd(i,a,b) for( int i = a; i >= b; --i)   #define sz(x) (int)((x).size())     #define all(c) (c).begin(),(c).end()   #define allr(v) v.rbegin(),v.rend()   #define mem(a,x) memset(a,x,sizeof(a))   #define dbg(a) cout << #a <<   is   << (a); cout <<   n ;   template <class T> void PR(T a[], int n, int x = 0) { for ( int i = x; i < n; i++ ) cout << a[i] <<    ; cout<<   n  ; }   template <class T> void PR(vector <T> v) { for ( T i : v ) cout << i <<     ; cout <<   n ; }   template <class T> void PR(set <T> s) { for ( T i : s ) cout << i <<     ; cout <<   n ; }   template <class T> void PR(multiset <T> s) { for ( T i : s ) cout << i <<     ; cout <<   n  ; }   const long double PI=3.141592653589793238462643383279502884197169399375105820974944;   //...   void solve(){    int n, k; cin>>n>>k;    string s =   ;    rep(i, 0, k){     rep(j, i, k){      s += (j+ a );      if(j != k-1)       s += (i+ a );     }    }    int m = sz(s);    rep(i, 0, n)     cout<<s[i%m];   }      signed main(){       ios_base::sync_with_stdio(false), cin.tie(nullptr);    int T=1;// cin>>T;        while(T--){           solve();cout<<  n ;       }       return 0;   }
#include <bits/stdc++.h>   struct V {     int a, b;     int wybor;   };   std::vector<int> v[507];   V prev[507][507][2];   int odl[507][507][2];   bool odw[507][507][2];   std::queue<V> Q;   int wynik[1000007][2];   int main() {     int N, M;     scanf( %d%d , &N, &M);     int a, b;     for (int i = 0; i < M; i++) {       scanf( %d%d , &a, &b);       v[a].push_back(b);       v[b].push_back(a);     }     Q.push({1, N, 0});     odw[1][N][0] = true;     while (!Q.empty()) {       V ter = Q.front();       Q.pop();       if (ter.a == N && ter.b == 1 && ter.wybor == 0) break;       if (ter.a == ter.b && ter.wybor == 0) continue;       a = ter.a, b = ter.b;       if (ter.wybor == 0) {         for (auto it : v[a]) {           if (!odw[it][b][1]) {             odw[it][b][1] = true;             odl[it][b][1] = odl[ter.a][ter.b][ter.wybor] + 1;             prev[it][b][1] = ter;             Q.push({it, b, 1});           }         }       } else {         for (auto it : v[b]) {           if (!odw[a][it][0]) {             odw[a][it][0] = true;             odl[a][it][0] = odl[ter.a][ter.b][ter.wybor] + 1;             prev[a][it][0] = ter;             Q.push({a, it, 0});           }         }       }     }     if (odl[N][1][0] == 0) {       printf( -1 );       return 0;     }     int wyn = odl[N][1][0] / 2;     auto ter = V{N, 1, 0};     wynik[wyn][1] = 1;     while (ter.a != 0) {       wynik[odl[ter.a][ter.b][ter.wybor] / 2][ter.wybor] =           ter.wybor ? ter.b : ter.a;       ter = prev[ter.a][ter.b][ter.wybor];     }     printf( %d n , wyn);     for (int i = 0; i <= wyn; i++) printf( %d  , wynik[i][0]);     printf(  n );     for (int i = 0; i <= wyn; i++) printf( %d  , wynik[i][1]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   #pragma GCC target( avx2 )   #pragma GCC optimization( O3 )   #pragma GCC optimization( unroll-loops )   const long long INFll = 1e18;   const int INFint = 1e9;   const long long MOD = 1e9 + 7;   void needForSpeed() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   bool isPrime(long long a) {     if (a < 2) return 0;     for (long long i = 2; i <= sqrt(a); i++)       if (a % i == 0) return 0;     return 1;   }   long long binpow(long long base, long long pow, long long mod = INFll) {     if (pow == 0)       return 1;     else if (pow % 2)       return base * binpow(base, pow - 1, mod) % mod;     else {       long long p = binpow(base, pow / 2LL, mod);       return p * p % mod;     }   }   template <class T>   void PR_VEC(const vector<T> &vec) {     cout <<  size(  << vec.size() <<  ):[   ;     if (vec.size() == 0) {       cout <<  !EMPTY!  ] n ;       return;     }     cout << vec[0] <<    ;     for (int i = 1; i < vec.size(); ++i) cout <<   ,    << vec[i] <<    ;     cout <<   ] n ;   }   int solve() {     long long n, m, ans;     cin >> n >> m;     string s;     cin >> s;     ans = n * (m - 1LL);     for (int i = 1; i < n; ++i) {       if (s[i] != s[i - 1]) ans += n * (m - 1LL);     }     int len = 1;     for (int i = 1; i < n; ++i) {       if (len == 1) {         if (s[i] != s[i - 1]) {           len = 2;         } else {           continue;         }       } else {         if (s[i] != s[i - 2]) {           ans -= (len * (len - 1LL)) / 2LL;           if (s[i] == s[i - 1])             len = 1;           else             len = 2;         } else {           ++len;         }       }     }     ans -= (len * (len - 1LL)) / 2LL;     cout << ans;     return 0;   }   int main() {     needForSpeed();     int tests = 1;     while (tests--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, ans;     scanf( %d %d , &a, &b);     for (ans = 0; a > 0 && b > 0; ans++) {       if (a > b) swap(a, b);       if (b == 1) break;       a++, b -= 2;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   using namespace std;   int add(int a, int b) {     long long x = a + b;     if (x >= 998244353) x -= 998244353;     if (x < 0) x += 998244353;     return x;   }   long long mul(long long a, long long b) { return (a * b) % 998244353; }   long long pw(long long a, long long b) {     long long ans = 1;     while (b) {       if (b & 1) ans = (ans * a) % 998244353;       a = (a * a) % 998244353;       b >>= 1;     }     return ans;   }   int n;   long long dp[2][1000002];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     dp[1][0] = 1;     dp[0][0] = 1;     for (int i = 1; i <= n; ++i) {       int x = (i - 1);       if (x % 2 == 0) {         int par = (1 + x / 2) % 2;         dp[par][i] = mul(dp[!par][x / 2], dp[0][x / 2]);       } else {         for (int j = x / 2; j <= 1 + x / 2; j++) {           int par = (1 + j) % 2;           dp[par][i] = mul(dp[!par][j], dp[0][i - j - 1]);         }       }     }     cout << (dp[1][n] + dp[0][n]) % 998244353;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100 + 2;   int main() {     int n, m;     cin >> n >> m;     int ind = 0;     int x[3], y[3];     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         char s;         cin >> s;         if (s ==  * ) {           x[ind] = i;           y[ind] = j;           ind++;         }       }     }     int a, b;     if (x[0] == x[1]) {       a = x[2];     } else if (x[0] == x[2]) {       a = x[1];     } else {       a = x[0];     }     if (y[0] == y[1]) {       b = y[2];     } else if (y[0] == y[2]) {       b = y[1];     } else {       b = y[0];     }     cout << a + 1 <<     << b + 1;   }
#include <bits/stdc++.h>   using namespace std;   string s;   int main() {     long long n, x, y, br = 0, k = 0;     cin >> n >> x >> y;     cin >> s;     for (long i = 0; i < n; i++) {       if (s[i] ==  0 ) {         if (i == 0) {           br++;         } else if (s[i - 1] !=  0 ) {           br++;         }       }     }     long long sol = min(br * y, (br - 1) * x + y);     if (sol < 0) {       sol = br * y;     }     cout << sol << endl;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, a, b, v[2100][2100];   int k, d[2100][2100], x, y;   bool solve(int x, int y, int k) {     int l = max(1, x - k), r = min(x + k, n), t;     for (int i = l; i <= r; i++) {       t = k - abs(i - x);       if (y - t > 0 && !v[i][y - t]) {         a = i;         b = y - t;         return 1;       }       if (y + t <= m && !v[i][y + t]) {         a = i;         b = y + t;         return 1;       }     }     return 0;   }   int main() {     cin >> n >> m >> k;     for (int i = 0; i < k; i++) {       cin >> x >> y;       for (int j = -2; j <= 2; j++)         for (int k = -2; k <= 2; k++) {           if (x + j < 1 || x + j > n || y + k < 1 || y + k > m) continue;           d[x][y] = max(d[x][y], d[x + j][y + k] - abs(j) - abs(k));         }       while (!solve(x, y, d[x][y])) d[x][y]++;       v[a][b] = 1;       cout << a <<     << b << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, f = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = (x << 1) + (x << 3) + c -  0 ;       c = getchar();     }     return x * f;   }   const int maxn = 305;   int n, a[maxn][maxn];   int dp[maxn << 1][maxn][maxn];   int main() {     n = read();     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) a[i][j] = read();     memset(dp, 0x8f, sizeof(dp));     dp[0][1][1] = a[1][1];     for (int i = 1; i <= 2 * n - 2; i++)       for (int j = max(1, i + 2 - n); j <= min(i + 1, n); j++)         for (int k = max(1, i + 2 - n); k <= min(i + 1, n); k++) {           dp[i][j][k] = max(max(dp[i - 1][j - 1][k - 1], dp[i - 1][j - 1][k]),                             max(dp[i - 1][j][k - 1], dp[i - 1][j][k]));           dp[i][j][k] += a[j][i - j + 2];           if (j != k) dp[i][j][k] += a[k][i - k + 2];         }     printf( %d n , dp[2 * n - 2][n][n]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     long long int num, ans = INT_MAX, temp, multi1 = INT_MAX, multi2 = INT_MAX;     cin >> num;     for (long long int i = 1; i <= sqrt(num); i++) {       if (num % i == 0) {         temp = num / i;         if (abs(i - temp) < ans) ans = abs(i - temp), multi1 = i, multi2 = temp;       }     }     cout << multi1 <<     << multi2;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     int d[n];     d[0] = a[0];     map<int, int> even, odd;     even[d[0]]++;     odd[0]++;     long long int c = 0;     for (int i = 1; i < n; i++) {       d[i] = a[i] ^ d[i - 1];       if (i % 2 == 0) {         even[d[i]]++;         if (even.find(d[i]) != even.end()) c += even[d[i]] - 1;       } else {         odd[d[i]]++;         if (odd.find(d[i]) != odd.end()) c += odd[d[i]] - 1;       }     }     cout << c;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, t, m, n;     cin >> t;     int arr[t];     for (i = 0; i < t; i++) {       int sum = 0, k = 0;       cin >> n >> m;       int arr1[n];       for (int j = 0; j < n; j++) {         cin >> arr1[j];         if (j != 0) sum += arr1[j];       }       k = arr1[0];       while (k < m) {         if (sum != 0) {           k++;           sum--;         } else           break;       }       arr[i] = k;     }     for (i = 0; i < t; i++) cout << arr[i] <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   vector<long long int> small;   vector<long long int> large;   long long int largest(long long int digits, long long int sum) {     long long int i;     if (digits == 0) return sum;     for (i = 9; i >= 0; i--) {       if (sum >= i) {         large.push_back(i);         sum = sum - i;         break;       }     }     return largest(digits - 1, sum);   }   long long int smallest(long long int digits, long long int sum) {     long long int i;     if (digits == 0) return sum;     for (i = 0; i <= 9; i++) {       if (sum >= i && ((sum - i) <= 9 * (digits - 1))) {         small.push_back(i);         sum = sum - i;         break;       }     }     return smallest(digits - 1, sum);   }   int main() {     long long int i, j, t, n, m, temp, sum1, sum;     cin >> n >> sum;     sum1 = sum;     for (i = 1; i <= 9; i++) {       if (sum >= i && ((sum - i) <= 9 * (n - 1))) {         small.push_back(i);         sum = sum - i;         break;       }     }     temp = smallest(n - 1, sum);     if (temp > 0 || sum1 == 0) {       if (sum1 == 0 && n == 1)         cout << 0 <<    ;       else         cout << -1 <<    ;     } else {       for (i = 0; i < small.size(); i++) cout << small[i];       cout <<    ;     }     temp = largest(n, sum1);     if (temp > 0 || sum1 == 0) {       if (sum1 == 0 && n == 1)         cout << 0 << endl;       else         cout << -1 << endl;     } else {       for (i = 0; i < large.size(); i++) cout << large[i];       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1e9 + 7;   long long n, m, k;   long long mpow(long long b, long long e) {     if (e == 0) return 1;     if (e == 1) return b % MOD;     long long tmp = mpow(b, e / 2) % MOD;     tmp = tmp * tmp % MOD;     if (e % 2) tmp = tmp * (b % MOD) % MOD;     return tmp;   }   int main() {     cin >> n >> m >> k;     if (n % 2 != m % 2 && k == -1)       cout << 0 << endl;     else {       long long r = mpow(2, n - 1) % MOD;       r = mpow(r, m - 1) % MOD;       cout << r << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int segtree[4 * ((24 * 3600) + 100)], lazy[4 * ((24 * 3600) + 100)];   void propagate(int root, int l, int r) {     segtree[root] += lazy[root];     if (l != r) {       lazy[2 * root + 1] += lazy[root];       lazy[2 * root + 2] += lazy[root];     }     lazy[root] = 0;   }   int query(int root, int l, int r, int a, int b) {     if (b < l || r < a) return 0;     propagate(root, l, r);     if (a <= l && r <= b) return segtree[root];     int mid = (l + r) / 2;     return max(query(2 * root + 1, l, mid, a, b),                query(2 * root + 2, mid + 1, r, a, b));   }   void update(int root, int l, int r, int a, int b, int val) {     if (b < l || r < a) return;     if (a <= l && r <= b) {       lazy[root] += val;       return;     }     int mid = (l + r) / 2;     update(2 * root + 1, l, mid, a, b, val);     update(2 * root + 2, mid + 1, r, a, b, val);     propagate(2 * root + 1, l, mid);     propagate(2 * root + 2, mid + 1, r);     segtree[root] = max(segtree[2 * root + 1], segtree[2 * root + 2]);   }   int n, M, T, h, m, s;   int main() {     scanf( %d %d %d , &n, &M, &T);     vector<int> resp;     int user = 0;     int ult = -1;     for (int i = 0; i < n; i++) {       scanf( %d:%d:%d , &h, &m, &s);       int ini = h * 3600 + m * 60 + s;       int fim = ini + T - 1;       int val = query(0, 0, ((24 * 3600) + 100), ini, fim);       if (val < M) {         user++;         resp.push_back(user);         update(0, 0, ((24 * 3600) + 100), ini, fim, 1);       } else {         update(0, 0, ((24 * 3600) + 100), max(ult + 1, ini), fim, 1);         resp.push_back(user);       }       ult = fim;     }     if (query(0, 0, ((24 * 3600) + 100), 0, ((24 * 3600) + 100)) != M)       printf( No solution n );     else {       printf( %d n , user);       for (int i = 0; i < resp.size(); i++) {         printf( %d n , resp[i]);       }     }   }
#include <bits/stdc++.h>   using namespace std;   void Read(int &x) {     char c;     while (c = getchar(), c != EOF)       if (c >=  0  && c <=  9 ) {         x = c -  0 ;         while (c = getchar(), c >=  0  && c <=  9 ) x = x * 10 + c -  0 ;         ungetc(c, stdin);         return;       }   }   int m, n, a[100000 + 10], b[100000 * 2 + 10], f[100000 + 10], x;   void read() {     Read(m), Read(n);     int i;     for (i = 1; i <= n; i++) Read(a[i]), b[i] = a[i];     for (i = 1; i <= n; i++) b[n + i] = b[i] + m;   }   bool check(int x) {     int i;     f[0] = -0x7fffffff;     f[1] = 1;     for (i = 2; i <= n; i++) {       f[i] = -0x7fffffff;       if (f[i - 1] >= a[i] - 1) f[i] = a[i] + x;       if (f[i - 1] >= a[i] - x - 1) f[i] = max(f[i], a[i]);       if (f[i - 2] >= a[i] - x - 1) f[i] = max(f[i], a[i - 1] + x);     }     if (f[n] + x >= m) return 1;     f[1] = 1 + x, f[2] = max(1 + x, a[2]);     if (a[2] - a[1] - 1 > x + x) return 0;     for (i = 3; i <= n; i++) {       f[i] = -0x7fffffff;       if (f[i - 1] >= a[i] - 1) f[i] = a[i] + x;       if (f[i - 1] >= a[i] - x - 1) f[i] = max(f[i], a[i]);       if (f[i - 2] >= a[i] - x - 1) f[i] = max(f[i], a[i - 1] + x);     }     if (f[n] >= min(m, m + a[2] - x - 1)) return 1;     return 0;   }   int Divide_Conqure(int l, int r) {     int mid;     while (l < r) {       mid = (l + r) >> 1;       if (check(mid))         r = mid;       else         l = mid + 1;     }     return l;   }   void solve() {     int i, mx, p;     mx = b[n + 1] - b[n];     p = 1;     for (i = 2; i <= n; i++)       if (b[i] - b[i - 1] > mx) {         mx = b[i] - b[i - 1];         p = i;       }     a[1] = 1;     for (i = 2; i <= n; i++) {       a[i] = a[i - 1] + b[p + 1] - b[p];       p++;     }     printf( %d n , Divide_Conqure(0, mx - 1));   }   int main() {     read();     if (n == 1) {       printf( %d n , m - 1);       return 0;     }     solve();   }
#include <bits/stdc++.h>   using namespace std;   bool isp[300005];   void sv() {     long long i, j;     memset(isp, true, sizeof(isp));     isp[1] = false;     for (i = 2; i * i < 300005; i++) {       if (isp[i]) {         for (j = i * i; j < 300005; j += i) isp[j] = false;       }     }   }   long long powr(long long a, long long b) {     long long res = 1;     while (b) {       if (b & 1) res = (res * a) % 1000000007;       a = (a * a) % 1000000007;       b >>= 1;     }     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n, i, j, a[300005], x, y;     map<long long, vector<long long> > mp;     cin >> n;     for (i = 0; i < n; i++) {       cin >> a[i];       mp[a[i]].push_back(i);     }     long long ans = 0;     auto it = mp.begin();     while (it != mp.end()) {       (it->second).push_back(n);       it++;     }     auto itr = mp.begin();     while (itr != mp.end()) {       long long l = (itr->second).size();       for (i = l - 1; i > 0; i--) {         if ((itr->second)[i] != (itr->second)[i - 1] + 1) {           long long tmp = (itr->second)[i] - (itr->second)[0] - 1;           if (tmp > ans) {             ans = tmp;           } else             break;         }       }       itr++;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const int N = 1e6 + 5;   const int K = (1 << 17) + 10;   const long long int INF = 2e18 + 500;   const int inf = 0x7fffffff;   const int SQRT = 500;   const int lgN = 20;   int main(int argc, char const *argv[]) {     cin.sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     stack<int> S;     int ans = 0;     int req = 0;     for (int i = 0; i < 2 * n; i++) {       string s;       cin >> s;       if (s[0] ==  a ) {         int x;         cin >> x;         S.push(x);       } else {         req += 1;         if (S.size() == 0) {           continue;         } else {           int x = S.top();           if (x == req) {             S.pop();           } else {             ans += 1;             S = stack<int>();           }         }       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[31];   int main() {     long long t, n;     long long q = 0;     cin >> t;     for (int i = 0; i <= 29; i++) {       a[i] = pow(2, i);     }     for (int i = 1; i <= t; i++) {       cin >> n;       if (n % 2 == 0) {         q = (n + 1) * (n / 2);       } else {         q = ((n / 2) + 1) * n;       }       for (int i = 0; i <= 29; i++) {         if (a[i] <= n) {           q = q - (a[i] * 2);         } else {           break;         }       }       cout << q << endl;       q = 0;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int mpow(int base, int exp);   void solve() {     long long int n;     cin >> n;     vector<long long int> v(n);     vector<long long int> cnt(2 * n + 1, 0);     for (long long int i = 0; i < (n); i++) {       cin >> v[i];       cnt[v[i]]++;     }     vector<long long int> out;     for (long long int i = 0; i < (n); i++) {       out.push_back(v[i]);       bool flag = true;       for (long long int j = v[i] + 1; j <= 2 * n; j++) {         if (cnt[j] == 0) {           out.push_back(j);           cnt[j]++;           flag = false;           break;         }       }       if (flag) {         cout << -1 <<   n ;         return;       }     }     for (auto i : out) cout << i <<    ;     cout <<   n ;     ;   }   int main() {     int t;     cin >> t;     while (t--) solve();     return 0;   }   int mpow(int base, int exp) {     base %= 1000000007;     int result = 1;     while (exp > 0) {       if (exp & 1) result = ((long long int)result * base) % 1000000007;       base = ((long long int)base * base) % 1000000007;       exp >>= 1;     }     return result;   }
#include <bits/stdc++.h>   const int N = 1 << 20;   int n, m, lim;   char s[22][100005];   int64_t a[N], b[N];   void fwt(int64_t* a, int f) {     for (int i = 1; i < lim; i <<= 1)       for (int j = 0; j < lim; j += i << 1)         for (int k = 0; k < i; ++k) {           int64_t x = a[j + k], y = a[j + k + i];           a[j + k] = x + y >> f;           a[j + k + i] = x - y >> f;         }   }   int main() {     scanf( %d%d , &n, &m);     lim = 1 << n;     for (int i = 0; i < lim; ++i)       b[i] = std::min(__builtin_popcount(i), n - __builtin_popcount(i));     for (int i = 0; i < n; ++i) {       scanf( %s , s[i]);       for (int j = 0; j < m; ++j) s[i][j] ^=  0 ;     }     for (int i = 0; i < m; ++i) {       int p = 0;       for (int j = 0; j < n; ++j) p |= s[j][i] << j;       ++a[p];     }     fwt(a, 0), fwt(b, 0);     for (int i = 0; i < lim; ++i) a[i] *= b[i];     fwt(a, 1);     std::cout << *std::min_element(a, a + lim) << std::endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 105;   int n;   int a[maxn];   int p;   double dp[maxn][maxn];   double release(int x) {     double res = 1;     for (register double i = x + 1; i <= n; i++) {       res *= (i - x);       res /= i;     }     return res;   }   signed main() {     scanf( %d , &n);     for (register int i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     scanf( %d , &p);     dp[0][0] = 1;     for (register int i = 1; i <= n; i++) {       for (register int j = n - 1; j >= 0; j--) {         for (register int k = p - a[i]; k >= 0; k--) {           dp[j + 1][k + a[i]] += dp[j][k];         }       }     }     double ans = 0;     for (register int i = 1; i <= n; i++) {       for (register int j = 0; j <= p; j++) {         if (dp[i][j]) {           ans += dp[i][j] * release(i);         }       }     }     printf( %.10lf n , ans);     return 0;   }