malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAX = 5005;   int main() {     ios::sync_with_stdio(false);     int n;     cin >> n;     vector<int> a(MAX);     for (int i = 0; i < n; i++) {       int k;       cin >> k;       a[k]++;     }     vector<int> p(MAX);     for (int i = 2; i < MAX; i++) {       if (p[i] == 0) {         p[i] = i;         for (int j = i + i; j < MAX; j += i) {           if (p[j] == 0) p[j] = i;         }       }     }     vector<vector<int>> s(MAX, vector<int>(MAX));     for (int i = 2; i < MAX; i++) {       int x = i;       while (x > 1) {         s[i][p[x]]++;         x /= p[x];       }       for (int j = 0; j < MAX; j++) {         s[i][j] += s[i - 1][j];       }     }     long long int res = 0;     for (int i = 0; i < MAX; i++) {       for (int j = 0; j < MAX; j++) {         res += (long long int)a[i] * s[i][j];       }     }     vector<int> c(MAX);     int l = 0;     int r = MAX;     for (int j = MAX - 1; j >= 2; j--) {       int xx = 0;       int maxx = 0;       int maxv = -1;       for (int i = l; i < r; i++) {         if (i == l || s[i][j] == s[i - 1][j]) {           xx += a[i];         } else {           xx = a[i];         }         if (xx > maxx) {           maxx = xx;           maxv = s[i][j];         }       }       if (maxx * 2 > n) {         int cnt = 0;         for (int q = l; q < r; q++) {           cnt += a[q];           if (s[q][j] < maxv) {             res += (long long int)(maxv - 2 * s[q][j]) * a[q];           } else {             res -= (long long int)maxv * a[q];           }         }         res += (long long int)(n - cnt) * maxv;         while (s[l][j] != maxv) {           l++;         }         while (s[r - 1][j] != maxv) {           r--;         }       } else {         xx = 0;         for (int i = r - 1; i >= l; i--) {           xx += a[i];           if (xx * 2 >= n) {             int v = s[i][j];             int cnt = 0;             for (int q = l; q < r; q++) {               cnt += a[q];               if (s[q][j] < v) {                 res += (long long int)(v - 2 * s[q][j]) * a[q];               } else {                 res -= (long long int)v * a[q];               }             }             res += (long long int)(n - cnt) * v;             break;           }         }         break;       }     }     cout << res <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 222222;   const int mod = 1e9 + 7;   long long n;   int main() {     cin >> n;     for (long long i = 1; i * (i + 1) <= n * 2; ++i) {       long long x = n - (i * (i + 1) / 2);       long long t = sqrt(x * 2);       for (long long j = t - 10; j <= t + 10; ++j)         if (j > 0 && j * (j + 1) == x * 2) return cout <<  YES , 0;     }     cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct rec {     double x, y;   } v, p, w1, w2, m1, m2, p_, m;   double eps = 1e-10;   inline rec operator+(rec a, rec b) { return (rec){a.x + b.x, a.y + b.y}; }   inline rec operator-(rec a, rec b) { return (rec){a.x - b.x, a.y - b.y}; }   double mul(rec a, rec b, rec c) {     return (b.x - a.x) * (c.y - a.y) - (c.x - a.x) * (b.y - a.y);   }   double dist(rec a, rec b) {     return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));   }   bool line(rec a, rec b, rec c) {     return fabs(dist(a, c) + dist(b, c) - dist(a, b)) < eps;   }   bool cross(rec a, rec b, rec c, rec d, int k) {     if (!k && line(a, b, c) && line(a, b, d)) return 0;     if (line(a, b, c) || line(a, b, d) || line(c, d, a) || line(c, d, b))       return 1;     return mul(a, c, b) * mul(a, b, d) > eps && mul(c, a, d) * mul(c, d, b) > eps;   }   rec point(rec a, rec b, rec c, rec d) {     double t1 = mul(a, c, b), t2 = mul(a, b, d);     return (rec){(c.x * t2 + d.x * t1) / (t1 + t2),                  (c.y * t2 + d.y * t1) / (t1 + t2)};   }   rec turn(rec a, double th) {     return (rec){a.x * cos(th) - a.y * sin(th), a.x * sin(th) + a.y * cos(th)};   }   rec oppo(rec c, rec a, rec b) {     rec h = point(a, b, c, c + turn(b - a, acos(-1.0) / 2));     return h + (h - c);   }   int main() {     cin >> v.x >> v.y >> p.x >> p.y >> w1.x >> w1.y >> w2.x >> w2.y >> m1.x >>         m1.y >> m2.x >> m2.y;     if (!cross(v, p, w1, w2, 1) && !cross(v, p, m1, m2, 0)) {       puts( YES );       return 0;     }     p_ = oppo(p, m1, m2);     if (cross(v, p_, m1, m2, 0)) {       m = point(v, p_, m1, m2);       if (!cross(p, m, w1, w2, 1) && !cross(m, v, w1, w2, 1)) {         puts( YES );         return 0;       }     }     puts( NO );   }
#include <bits/stdc++.h>   using namespace std;   long long read() {     char ch = getchar();     long long f = 1, x = 0;     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return f * x;   }   const long long MAXN = 2e5 + 10;   long long n;   long long a[MAXN];   long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }   signed main() {     long long t = read();     while (t--) {       n = read();       for (long long i = 1; i <= n; i++) {         a[i] = read();       }       long long g = 0;       for (long long i = 30; i >= 0; i--) {         long long cnt = 0;         for (long long j = 1; j <= n; j++) {           if ((1 << i) & a[j]) {             cnt++;           }         }         if (cnt) {           if (!g) {             g = cnt;           } else {             g = gcd(g, cnt);           }         }       }       if (!g) {         for (long long i = 1; i <= n; i++) {           printf( %d  , i);         }         puts(  );       } else {         for (long long i = 1; i * i < g; i++) {           if (g % i == 0) {             printf( %d  , i);           }         }         for (long long i = sqrt(g); i; i--) {           if (g % i == 0) {             printf( %d  , g / i);           }         }         puts(  );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   T prod(const T &a, const T &b, const T &mod) {     return ((a % mod) * (b % mod)) % mod;   }   template <typename T>   T pow_(const T &a, const T &b) {     if (!b) return 1;     T p = pow_(a, b / 2);     p *= p;     return (b % 2) ? (p * a) : p;   }   template <typename T>   T modpow(const T &a, const T &b, const T &mod) {     if (!b) return 1;     T p = modpow(a, b / 2);     p = prod(p, p);     return (b % 2) ? (prod(p, a)) : p;   }   template <typename T>   T max(const T &a, const T &b, const T &c) {     return max(a, max(b, c));   }   template <typename T>   T min(const T &a, const T &b, const T &c) {     return min(a, min(b, c));   }   template <typename T>   void dbg(const vector<T> &a, int l, int r) {     for (long long int i = l; i <= r; i++) cout << a[i] <<    ;     cout << endl;   }   template <typename T>   void dbg(const vector<T> &a) {     for (long long int i = 0; i <= a.size() - 1; i++) cout << a[i] <<    ;     cout << endl;   }   long long int search(long long int num, vector<long long int> &a) {     long long int l = 0, r = a.size() - 1;     while (l < r) {       long long int mid = (l + r + 1) / 2;       if (a[mid] <= num)         l = mid;       else         r = mid - 1;     }     return l;   }   vector<long long int> a, b;   void check(long long int num, long long int &ansa, long long int &ansb) {     long long int cnta = search(num, a) + 1;     long long int cntb = search(num, b) + 1;     if (a[0] > num) cnta = 0;     if (b[0] > num) cntb = 0;     long long int reta = cnta * 2 + (a.size() - cnta) * 3;     long long int retb = cntb * 2 + (b.size() - cntb) * 3;     if (ansa - ansb < reta - retb) {       ansa = reta;       ansb = retb;     } else if (ansa - ansb == reta - retb) {       if (ansa < reta) {         ansa = reta;         ansb = retb;       }     }     if (ansa == -1) {       ansa = reta;       ansb = retb;     }   }   void main_() {     long long int n, m;     scanf( %lld , &n);     a.resize(n);     for (long long int i = 0; i <= n - 1; i++) scanf( %lld , &a[i]);     scanf( %lld , &m);     b.resize(m);     for (long long int i = 0; i <= m - 1; i++) scanf( %lld , &b[i]);     sort(a.begin(), a.end());     sort(b.begin(), b.end());     long long int ansa = -1, ansb = -1;     for (long long int i = 0; i <= n - 1; i++) {       check(a[i] - 1, ansa, ansb);       check(a[i], ansa, ansb);       check(a[i] + 1, ansa, ansb);     }     for (long long int i = 0; i <= m - 1; i++) {       check(b[i] - 1, ansa, ansb);       check(b[i], ansa, ansb);       check(b[i] + 1, ansa, ansb);     }     cout << ansa <<  :  << ansb << endl;   }   int main() {     { main_(); }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 50005;   const long long UP = 2.2e9;   long long num[maxn], sum[maxn];   int cnt, wei[15];   inline void init() {     long long up = 0, pre = 0, x = 0, cut = 0;     cnt = 0;     int flag = 0;     for (int k = 1; k <= 9; ++k) {       cut = x;       x = x * 10 + 9;       long long xx = x - cut;       for (int i = 1; i <= xx; ++i) {         up += pre + i * k;         num[++cnt] = pre + i * k;         if (up >= UP) {           flag = 1;           break;         }       }       if (flag) break;       pre += (x - x / 10) * k;     }     sum[0] = 0;     sum[1] = num[1];     for (int i = 1; i <= cnt; ++i) sum[i] = sum[i - 1] + num[i];   }   int main() {     init();     int t, n, k, flag;     scanf( %d , &t);     while (t--) {       scanf( %d , &n);       for (k = 1; k <= cnt; ++k)         if (n <= sum[k]) break;       n -= sum[k - 1];       flag = 0;       for (int i = 1; i <= k; ++i) {         int t = i, j = 0;         while (t) {           wei[++j] = t % 10;           t /= 10;         }         for (int l = j; l >= 1; --l) {           --n;           if (n == 0) {             flag = 1;             printf( %d n , wei[l]);             break;           }         }         if (flag) break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     string s;     cin >> s;     int a[26];     fill(a, a + 26, 0);     for (int(i) = (0); (i) < (s.length()); (i)++) {       a[s[i] -  a ]++;     }     int ans = 0;     for (int(i) = (0); (i) < (26); (i)++)       if (a[i] & 1) ans++;     if (ans & 1 || ans == 0)       cout <<  First ;     else       cout <<  Second ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int f(int k) {     int p = 1;     while ((p * (p + 1)) / 2 < k) p++;     if (k == (p * (p + 1)) / 2) return 0;     p--;     return (p * (p + 1)) / 2;   }   int main() {     int n;     int p = 1;     cin >> n;     int k = int((sqrt((8 * n) + 1)) + 1) / 2;     cout << k << endl;     vector<int> a[k + 1];     for (int j = 2; j <= k; j++)       for (int i = 1; i < j; i++) {         a[i].push_back(p);         a[j].push_back(p);         p++;       }     if (f(n))       for (int i = f(n) + 1; i <= n; i++) {         a[1].push_back(i);         a[2].push_back(i);       }     for (int i = 1; i <= k; i++) {       for (int j = 0; j < a[i].size(); j++) cout << a[i][j] <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b;     while (cin >> a >> b) {       if (a == 0 && b == 0)         cout <<  NO  << endl;       else {         if (abs(a - b) == 1 || a == b)           cout <<  YES  << endl;         else           cout <<  NO  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100010;   int n, k, p;   int odd[N], even[N], po, pe;   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     cin >> n >> k >> p;     for (int i = 0; i < n; ++i) {       int x;       cin >> x;       if (x & 1)         odd[po++] = x;       else         even[pe++] = x;     }     int no = po, ne = pe;     int more = no - (k - p);     if (k > n || no < k - p || more & 1 || pe + more / 2 < p)       cout <<  NO  << endl;     else {       cout <<  YES  << endl;       int tot_odd = min(k - p, k - 1);       for (int i = 0; i < tot_odd; ++i) cout << 1 <<     << odd[--po] << endl;       int tot_even = min(p, k - 1 - tot_odd);       int use_even = min(tot_even, pe);       for (int i = 0; i < use_even; ++i) cout << 1 <<     << even[--pe] << endl;       for (int i = use_even; i < tot_even; ++i)         cout << 2 <<     << odd[--po] <<     << odd[--po] << endl;       int t = po + pe;       cout << t;       while (po) cout <<     << odd[--po];       while (pe) {         cout <<     << even[--pe];       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 505, M = 300005;   int a[N][N];   int main() {     int n, k;     scanf( %d%d , &n, &k);     int res = n * k - n + 1, rp = n - k + 1;     int ans = 0;     int k1 = 0;     for (int i = (1); i <= (n); i++) {       ans += res;       for (int j = (1); j <= (k - 1); j++) a[i][j] = ++k1;       for (int j = (k); j <= (n); j++) a[i][j] = res++;     }     printf( %d n , ans);     for (int i = (1); i <= (n); i++) {       for (int j = (1); j <= (n); j++) printf( %d  , a[i][j]);       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<long long int, long long int>::iterator it;   vector<pair<long long int, long long int> > v;   map<long long int, long long int> mp;   int main() {     long long int n;     scanf( %lld , &n);     for (long long int i = 0; i < n; i++) {       long long int l, r;       scanf( %lld%lld , &l, &r);       mp[l]++, mp[r + 1]--;     }     for (it = mp.begin(); it != mp.end(); it++) {       v.push_back(make_pair(it->first, it->second));     }     sort(v.begin(), v.end());     long long int sum = 0;     for (long long int i = 0; i < v.size(); i++) {       sum += v[i].second;       if (sum > 2) {         printf( NO n );         return 0;       }     }     printf( YES n );   }
#include <bits/stdc++.h>   using namespace std;   struct fast_ios {     fast_ios() {       cin.tie(nullptr), ios::sync_with_stdio(false),           cout << fixed << setprecision(20);     };   } fast_ios_;   string solve(string S) {     const int N = S.length();     int L = N;     while (L % 2 == 0) L /= 2;     while (L < N) {       for (int i = 0; i < N; i += L * 2) {         if (S.substr(i, L) > S.substr(i + L, L)) {           for (int j = (0), j_end_ = (L); j < j_end_; j++)             swap(S[i + j], S[i + j + L]);         }       }       L *= 2;     }     return S;   }   int main() {     string A, B;     cin >> A >> B;     cout << (solve(A) == solve(B) ?  YES  :  NO ) <<   n ;   }
#include <bits/stdc++.h>   #include <climits>   #define F first   #define S second   #define all(v) v.begin(),v.end()   #define li long int   #define lli long long int   #define pb push_back   #define loop(a,b,i) for(lli i=a ; i<b ; i++)   #define rev_loop(a,b,i) for(lli i=a ; i>=b ; i--)   #define MAX(a,b) (a>b)?a:b   #define lele(arr, n) loop(0,n,i) cin>>arr[i];   #define VAL 10005   #define N 1005      using namespace std;      void solve(){       int n;       cin>>n;       long int arr[2*n], mx=0;       loop(0, 2*n, i){            cin>>arr[i];           if(arr[i] > arr[mx]) mx = i;       }       int i;       bool flag;       for(i=0 ; i<2*n ; i++){                      // O(n)           if(i == mx) continue;           multiset<int> tmp;           loop(0, 2*n, j){                        // O(n)               if(j == i || j == mx) continue;               tmp.insert(arr[j]);           }           long int lastMx = arr[mx], curMx;           flag=true;           while(!tmp.empty()){               curMx = *tmp.rbegin();               tmp.erase(tmp.find(curMx));               if(tmp.find(lastMx - curMx) == tmp.end()){                   flag = false;                   break;               }               tmp.erase(tmp.find(lastMx - curMx));               lastMx = curMx;           }           if(flag) break;       }       if(!flag){            cout<< NO n ;           return;       }       cout<< YES n ;       cout<<arr[mx] + arr[i]<<endl;       cout<<arr[mx]<<   <<arr[i]<<endl;       multiset<int> tmp;       loop(0, 2*n, j){                        // O(n)           if(j == i || j == mx) continue;           tmp.insert(arr[j]);       }       long int lastMx = arr[mx];       while(!tmp.empty()){           long int x = *tmp.rbegin(), y = *tmp.find(lastMx - x);           cout<<x<<   <<y<<  n ;           tmp.erase(tmp.find(x));           tmp.erase(tmp.find(lastMx - x));           lastMx = x;       }       return;   }      int main()    {        int t;       cin>>t;       while(t--){           solve();       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int f = 1, x = 0;     char ch;     do {       ch = getchar();       if (ch ==  - ) f = -1LL;     } while (ch <  0  || ch >  9 );     do {       x = x * 10 + ch -  0 ;       ch = getchar();     } while (ch >=  0  && ch <=  9 );     return f * x;   }   template <class T>   inline void chmax(T &a, T b) {     if (a < b) a = b;   }   template <class T>   inline void chmin(T &a, T b) {     if (a > b) a = b;   }   inline void swap(int &a, int &b) {     int c = a;     a = b;     b = c;   }   using namespace std;   const int N = 233;   const int P = 1e9 + 7;   const int mod = 1e9 + 7;   inline long long qpow(long long a, long long b) {     long long q = 1;     while (b) {       if (b & 1) q = q * a % P;       a = a * a % P;       b >>= 1;     }     return q;   }   inline long long gtinv(long long x) { return qpow(x, P - 2); }   long long a[N][N];   int e[N][N];   inline long long sub(long long a, long long b) {     if (a < b) return a - b + P;     return a - b;   }   long long det(int n) {     long long ans = 1;     for (int i = (1); i <= (n); ++i) {       bool fg = 0;       for (int j = (i); j <= (n); ++j)         if (a[j][i] != 0) {           for (int k = (i); k <= (n); ++k) swap(a[i][k], a[j][k]);           if (j != i) ans = -ans;           fg = 1;           break;         }       if (!fg) return 0;       for (int j = (i + 1); j <= (n); ++j) {         long long tmp = -a[j][i] * qpow(a[i][i], P - 2) % P;         for (int k = (i); k <= (n); ++k) a[j][k] = (a[j][k] + tmp * a[i][k]) % P;       }     }     for (int i = (1); i <= (n); ++i) ans = ans * a[i][i] % P;     if (ans < 0) ans += P;     return ans;   }   int n;   long long ans[N], inv[N], g[N], w[N];   long long c[N];   int main() {     n = read();     for (int i = (1); i <= (n - 1); ++i) {       int u = read(), v = read();       e[u][v] = e[v][u] = 1;     }     for (int x = (0); x <= (n); ++x) {       for (int i = (0); i <= (n); ++i) a[i][i] = 0;       for (int i = (1); i <= (n); ++i) {         for (int j = (1); j <= (n); ++j) {           if (i == j) continue;           a[i][j] = e[i][j] ? -x : -1;           a[i][i] -= a[i][j];         }       }       ans[x] = det(n - 1);     }     inv[0] = inv[1] = 1;     for (int i = 2; i <= n; i++) inv[i] = mod - (inv[mod % i] * (mod / i)) % mod;     g[0] = g[1] = 1;     for (int i = 2; i <= n; i++) g[i] = g[i - 1] * inv[i] % mod;     for (int i = 0; i <= n; i++) w[i] = qpow(i, n);     for (int i = n; i >= 0; i--) {       for (int j = 0; j <= i; j++) {         if (j & 1) {           c[i] -= g[j] * g[i - j] % mod * ans[i - j] % mod;           if (c[i] < 0) c[i] += mod;         } else {           c[i] += g[j] * g[i - j] % mod * ans[i - j] % mod;           if (c[i] >= mod) c[i] -= mod;         }       }       for (int j = 1; j <= n; j++) {         ans[j] -= c[i] * w[j] % mod;         if (ans[j] < 0) ans[j] += mod;         w[j] = w[j] * inv[j] % mod;       }     }     for (int i = (0); i <= (n - 1); ++i) printf( %lld  , c[i]);     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int ans[200002] = {0};   void fill() {     for (int i = 0; i < 200002; i++) ans[i] = 1e7;   }   int main() {     fill();     int n;     cin >> n;     int arr[200002];     queue<int> q;     stack<int> st;     for (int i = 0; i < n; i++) {       cin >> arr[i];       if (arr[i] == 0) q.push(i), st.push(i);     }     for (int i = 0; i < n; i++) {       if (q.size() != 0) {         if (q.front() >= i)           ans[i] = q.front() - i;         else {           q.pop();           if (q.size() != 0) ans[i] = q.front() - i;         }       }     }     for (int i = n - 1; i >= 0; i--) {       if (st.size() != 0) {         if (st.top() <= i)           ans[i] = min(ans[i], i - st.top());         else {           st.pop();           if (st.size() != 0) ans[i] = min(ans[i], i - st.top());         }       }     }     for (int i = 0; i < n; i++) cout << ans[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 998244353;   long long n, m, l, r;   long long binpow(long long a, long long b) {     long long res = 1;     while (b) {       if (b & 1) res = res * a % mod;       a = a * a % mod;       b >>= 1;     }     return res % mod;   }   long long inv(long long a) { return binpow(a, mod - 2); }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0), cout.tie(0);     cin >> n >> m >> l >> r;     long long sz = n * m;     if (sz & 1) {       cout << binpow(r - l + 1, sz);     } else {       cout << (inv(2) * (binpow(r - l + 1, sz) + (((r - l + 1) % 2) ? 1 : 0))) %                   mod;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 1;   void solve() {     long long int n, x, ans = 1, p = -1, q = -1, c;     cin >> n;     set<long long int> s;     long long int a[n];     for (long long int i = 0; i < n; i++) cin >> a[i], s.insert(a[i]);     for (long long int i = 0; i < n; i++) {       for (long long int j = 0; j < 32; j++) {         c = 1;         if (s.find(a[i] - (1 << j)) != s.end()) {           q = a[i] - (1 << j);           c++;         }         if (s.find(a[i] + (1 << j)) != s.end()) {           q = a[i] + (1 << j);           c++;         }         if (c == 3) {           cout << 3 <<   n ;           cout << a[i] - (1 << j) <<     << a[i] <<     << a[i] + (1 << j);           return;         }         if (c == 2) p = a[i];         ans = max(ans, c);       }     }     cout << ans <<   n ;     if (ans == 2) cout << p <<     << q;     if (ans == 1) cout << a[0];   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int hh, mm, h, d, c, n;     cin >> hh >> mm;     cin >> h >> d >> c >> n;     float a;     if (h % n == 0)       a = (h / n) * c;     else       a = (h / n + 1) * c;     float b;     int tim = hh * 60 + mm;     if (tim <= 1200) {       h += (1200 - tim) * d;       float rate = (float)c * 4 / 5;       if (h % n == 0) {         b = (h / n) * rate;       } else         b = (h / n + 1) * rate;     } else {       float rate = (float)c * 4 / 5;       if (h % n == 0)         b = (h / n) * rate;       else         b = (h / n + 1) * rate;     }     cout << fixed << setprecision(4) << min(a, b);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, k, m, d, x, ans;     cin >> n >> k >> m >> d;     ans = m;     for (int i = 2; i <= d && (k * i - k + 1) <= n; i++) {       x = (n / ((i * k) - (k - 1)));       x = min(x, m);       ans = max(ans, x * i);     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, num[64];   string s[64];   int number(string s1, string s2) {     if (s1 == s2) return 0;     for (int i = 1; i < s1.length(); i++) {       string tail = s1.substr(0, i);       string head = s1.substr(i, s1.length() - i);       if (head + tail == s2) return i;     }     return -1;   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> s[i];     int mn = 2e9;     for (int i = 1; i <= n; i++) {       int ans = 0;       for (int j = 1; j <= n; j++) {         int num = number(s[j], s[i]);         if (num == -1) {           cout << -1;           return 0;         }         ans += num;       }       mn = min(mn, ans);     }     cout << mn;   }