malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int mo = 998244353;   int fac[300005], inv[300005];   void init() {     fac[0] = inv[0] = inv[1] = 1;     for (int i = (int)(2); i <= (int)(300005 - 1); i++)       inv[i] = 1ll * inv[mo % i] * (mo - mo / i) % mo;     for (int i = (int)(1); i <= (int)(300005 - 1); i++) {       fac[i] = 1ll * fac[i - 1] * i % mo;       inv[i] = 1ll * inv[i - 1] * inv[i] % mo;     }   }   int power(int x, int y) {     int s = 1;     for (; y;) {       if (y & 1) s = 1ll * s * x % mo;       if (y /= 2) x = 1ll * x * x % mo;     }     return s;   }   const int N = 100005;   int freq[N], cnt[N];   void add(int x) {     cnt[freq[x]]--;     cnt[++freq[x]]++;   }   void del(int x) {     cnt[freq[x]]--;     cnt[--freq[x]]++;   }   vector<int> heavy;   int n, m, Q;   int e[N], ans[N];   struct que {     int l, r, k, id;   } q[N];   const int blk = 200;   bool cmpk(que a, que b) {     return pair<int, int>(a.k, a.l - a.r) < pair<int, int>(b.k, b.l - b.r);   }   bool cmpmo(que a, que b) {     return pair<int, int>(a.l / blk, a.r) < pair<int, int>(b.l / blk, b.r);   }   int main() {     init();     scanf( %d%d%d , &n, &m, &Q);     for (int i = (int)(1); i <= (int)(n); i++) {       scanf( %d , &e[i]);       cnt[e[i]]++;     }     for (int i = (int)(1); i <= (int)(m); i++)       if (cnt[i] >= blk) heavy.push_back(i);     for (int i = (int)(1); i <= (int)(Q); i++) {       scanf( %d%d%d , &q[i].l, &q[i].r, &q[i].k);       q[i].id = i;     }     sort(q + 1, q + Q + 1, cmpk);     for (int r = 1; r <= Q;) {       int l = r, kk = q[l].k, res = 1, las = n, v = 1;       for (; r <= Q && kk == q[r].k; r++)         ;       for (int i = (int)(1); i <= (int)(m); i++)         res = 1ll * res * fac[kk + cnt[i]] % mo;       for (int i = (int)(l); i <= (int)(r - 1); i++) {         int len = q[i].r - q[i].l + 1;         for (; las > len; v = 1ll * (1ll * m * kk + n - (--las)) % mo * v % mo)           ;         ans[q[i].id] = 1ll * res * v % mo;       }     }     sort(q + 1, q + Q + 1, cmpmo);     int l = 1, r = 0;     memset(cnt, 0, sizeof(cnt));     ;     cnt[0] = m;     for (int i = (int)(1); i <= (int)(n); i++) add(e[i]);     for (int i = (int)(1); i <= (int)(Q); i++) {       for (; q[i].l < l; del(e[--l]))         ;       for (; q[i].l > l; add(e[l++]))         ;       for (; q[i].r < r; add(e[r--]))         ;       for (; q[i].r > r; del(e[++r]))         ;       int res = 1;       for (int j = (int)(0); j <= (int)(blk - 1); j++)         if (cnt[j]) res = 1ll * res * power(inv[q[i].k + j], cnt[j]) % mo;       for (int j : heavy)         if (freq[j] >= blk) res = 1ll * res * inv[q[i].k + freq[j]] % mo;       ans[q[i].id] = 1ll * ans[q[i].id] * res % mo;     }     for (int i = (int)(1); i <= (int)(Q); i++) printf( %d n , ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)1e6 + 7;   const int MOD = (int)1e9 + 7;   const long long INF = (long long)1e18 + 7;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     vector<int> p(n + 1, 0);     for (int i = 2; i * i <= n; i++)       if (p[i] == 0) {         p[i] = i;         for (int j = i * i; j <= n; j += i)           if (!p[j]) p[j] = i;       }     for (int i = 1; i <= n; i++)       if (!p[i]) p[i] = i;     vector<int> ans;     for (int i = 1; i <= n; i++) ans.push_back(i / p[i]);     sort(ans.begin(), ans.end());     for (int i = 1; i < n; i++) cout << ans[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int k, p;     double s, n;     cin >> k >> n >> s >> p;     for (int i = 0; i < 10000000000000000; i++) {       if (((i * p) / k) >= n / s) {         cout << i;         break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, q, a[300003], near[300003][20], last[300003];   signed main() {     cin >> n >> q;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     for (int i = n; i >= 1; i--) {       for (int k = 0; k < 20; k++) {         near[i][k] = n + 1;         if (((1 << k) & a[i]) && last[k]) near[i][k] = last[k];         for (int j = 0; j < 20; j++) {           if (last[j] && ((a[i] >> j) & 1)) {             near[i][k] = min(near[i][k], near[last[j]][k]);           }         }         if (near[i][k] == n + 1) near[i][k] = i;       }       for (int k = 0; k < 20; k++)         if ((a[i] >> k) & 1) last[k] = i;     }     while (q--) {       int l, r;       cin >> l >> r;       for (int i = 0; i < 20; i++) {         if (((a[r] >> i) & 1) && near[l][i] != l && near[l][i] <= r) {           puts( Shi );           l = r;           break;         }       }       if (l < r) puts( Fou );     }   }
#include<bits/stdc++.h>   using namespace std;   #define    ll    long long int   #define pi              2*acos(0.0)   #define gcd(a,b)        __gcd(a,b)   #define lcm(a,b)        (a*b)/gcd(a,b)   map<ll,ll>mp,mk;   //map<string,ll>mp;   set<ll> s1,s2;   vector<int> v,w;   string s=  ,qq=  ,ss=  ,pp=  ;   char ch;   ll m,n,i,j,l,r,x,t,y,u,g,h,mn,mx,d,z,c,f,e,k,o;   int main ()   {       cin>>t;       while(t--)       {           cin>>n>>k;           for(i=0; i<k-3; i++)               cout<< 1  ;           n=n-k+3;           c=n-2;           o=n/2;           if(n%2)               cout<<n/2<<   <<n/2<<   <<1;           else if(o%2==0)               cout<<n/2<<   <<o/2<<   <<o/2;           else if(o%2)               cout<<c/2<<   <<c/2<<   <<2;           cout<<  n ;       }   }
#include <bits/stdc++.h>   int dx[] = {0, 0, 1, -1, 2, 2, -2, -2, 1, -1, 1, -1};   int dy[] = {1, -1, 0, 0, 1, -1, 1, -1, 2, 2, -2, -2};   using namespace std;   vector<long long int> V, V2, V3, edj[200010];   bitset<200010> color;   long long int root, cnt = 0;   void dfs(long long int n, long long int ck) {     color[n] = true;     for (long long int i : edj[n]) {       if (color[i] == false) {         color[i] = true;         long long int tm = ck ^ 1;         if (tm == 0) {           cnt++;         }         dfs(i, tm);       }     }   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long int tcase = 1;     for (long long int test = 1; test <= tcase; test++) {       long long int n;       cin >> n;       for (long long int i = 0; i < n - 1; i++) {         long long int u, v;         cin >> u >> v;         edj[u].push_back(v);         edj[v].push_back(u);       }       for (long long int i = 1; i <= n; i++) {         if ((long long int)edj[i].size() == 1) {           root = i;           break;         }       }       dfs(root, 0);       long long int ans = cnt;       cnt = 0;       for (long long int i = 0; i <= n; i++) color[i] = false;       root = edj[root][0];       dfs(root, 0);       ans = min(ans, cnt);       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const double pi = 3.141592653589793238463;   int main() {     cin.tie(0);     cin.sync_with_stdio(0);     long long a, b;     cin >> a >> b;     while (a != 0 && b != 0) {       if (a < 2 * b && b < 2 * a) break;       if (a >= 2 * b)         a %= 2 * b;       else         b %= 2 * a;     }     cout << a <<     << b <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int i, j, l, n, k, d, max = 0, gen, e = 0;     long long p;     scanf( %d %d , &n, &k);     vector<vector<int> > v(n);     for (i = 0; i < n; i++) {       scanf( %d , &d);       v[d].push_back(i);       if (d > max) max = d;     }     p = 1;     for (i = 0; i <= max; i++) {       gen = v[i].size();       if (i > 0) e += gen;       if (gen > p || gen <= 0) break;       p = gen;       if (i == 0)         p = k;       else         p = p * (k - 1);     }     if (i <= max)       printf( -1 n );     else {       printf( %d n , e);       for (i = 0; i < max; i++) {         gen = 0;         if (i == 0)           e = k;         else           e = k - 1;         for (j = 0; j < (int)(v[i].size()); j++) {           for (l = gen; l < gen + e && l < (int)(v[i + 1].size()); l++) {             printf( %d %d n , v[i][j] + 1, v[i + 1][l] + 1);           }           gen += e;           if (gen >= v[i + 1].size()) break;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 7;   int n, m, q;   vector<int> E[maxn];   int op[maxn], a[maxn], b[maxn], c[maxn];   int ans[maxn];   bitset<1001> Bit[1001];   bitset<1001> C;   void dfs(int x) {     if (x == 0) {       for (int i = 0; i < E[x].size(); i++) {         ans[E[x][i]] = ans[x];         dfs(E[x][i]);       }     }     if (op[x] == 1) {       int flag = 0;       if (!Bit[a[x]][b[x]]) {         flag = 1;         ans[x]++;         Bit[a[x]][b[x]] = 1;       }       for (int i = 0; i < E[x].size(); i++) {         ans[E[x][i]] = ans[x];         dfs(E[x][i]);       }       if (flag) Bit[a[x]][b[x]] = 0;     }     if (op[x] == 2) {       int flag = 0;       if (Bit[a[x]][b[x]]) {         flag = 1;         ans[x]--;         Bit[a[x]][b[x]] = 0;       }       for (int i = 0; i < E[x].size(); i++) {         ans[E[x][i]] = ans[x];         dfs(E[x][i]);       }       if (flag) Bit[a[x]][b[x]] = 1;     }     if (op[x] == 3) {       ans[x] = ans[x] - Bit[a[x]].count();       Bit[a[x]] ^= C;       ans[x] = ans[x] + Bit[a[x]].count();       for (int i = 0; i < E[x].size(); i++) {         ans[E[x][i]] = ans[x];         dfs(E[x][i]);       }       Bit[a[x]] ^= C;     }     if (op[x] == 4) {       for (int i = 0; i < E[x].size(); i++) {         ans[E[x][i]] = ans[x];         dfs(E[x][i]);       }     }   }   int main() {     scanf( %d%d%d , &n, &m, &q);     for (int i = 1; i <= m; i++) C[i] = 1;     for (int i = 1; i <= q; i++) {       scanf( %d , &op[i]);       if (op[i] == 1) scanf( %d%d , &a[i], &b[i]);       if (op[i] == 2) scanf( %d%d , &a[i], &b[i]);       if (op[i] == 3) scanf( %d , &a[i]);       if (op[i] == 4)         scanf( %d , &a[i]), E[a[i]].push_back(i);       else         E[i - 1].push_back(i);     }     dfs(0);     for (int i = 1; i <= q; i++) printf( %d n , ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   long long a, b, c, i, l, j, x, s, y, ans;   int main() {     cin >> a >> b >> c >> l;     s = 0;     for (i = l + 1; i >= 1; i--) s += i * (i + 1) / 2;     ans = 0;     for (i = 0; i <= l; i++) {       x = a + i;       if (b > x || c > x) continue;       y = min(l - i, x - b - c) + 1;       if (y < 0) y = 0;       ans += (1 + y) * y / 2;     }     for (i = 0; i <= l; i++) {       x = b + i;       if (a > x || c > x) continue;       y = min(l - i, x - a - c) + 1;       if (y < 0) y = 0;       ans += (1 + y) * y / 2;     }     for (i = 0; i <= l; i++) {       x = c + i;       if (a > x || b > x) continue;       y = min(l - i, x - a - b) + 1;       if (y < 0) y = 0;       ans += (1 + y) * y / 2;     }     cout << s - ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 2e6;   long long cnt[MAXN];   signed main() {     long long n, m, k;     ios_base::sync_with_stdio(false);     cin >> n >> m >> k;     vector<long long> f(n);     vector<pair<long long, long long> > s(m);     for (long long i = 0; i < n; i++) cin >> f[i];     for (long long i = 0; i < m; i++) cin >> s[i].first;     for (long long i = 0; i < m; i++) s[i].second = i;     sort(s.begin(), s.end());     reverse(s.begin(), s.end());     fill(cnt, cnt + MAXN, 0);     for (auto ff : f) {       if (ff < MAXN) {         cnt[ff]++;       }     }     long long taken = 0;     bool flag = true;     for (long long i = 0; flag && i < (n + k - 1) / k; i++) {       taken += cnt[i];       long long needed = min(n, (i + 1) * k);       flag &= (taken <= needed);     }     if (!flag) {       cout << -1 << endl;     } else {       long long left = 0, right = m + 1;       while (left + 1 < right) {         long long med = (left + right) / 2;         for (long long i = 0; i < med; i++) {           if (s[i].first < MAXN) {             cnt[s[i].first]++;           }         }         taken = 0;         bool flag = true;         for (long long i = 0; flag && i < (n + k + med - 1) / k; i++) {           taken += cnt[i];           long long needed = min(n + med, (i + 1) * k);           flag &= (taken <= needed);         }         for (long long i = 0; i < med; i++) {           if (s[i].first < MAXN) {             cnt[s[i].first]--;           }         }         if (flag) {           left = med;         } else {           right = med;         }       }       cout << left << endl;       for (long long i = 0; i < left; i++) {         cout << s[i].second + 1 <<    ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int s, v1, v2, t1, t2, i1, i2;     cin >> s >> v1 >> v2 >> t1 >> t2;     i1 = s * v1 + 2 * t1;     i2 = s * v2 + 2 * t2;     if (i1 < i2)       cout <<  First ;     else if (i1 > i2)       cout <<  Second ;     else       cout <<  Friendship ;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 500 + 10;   const int P = 998244353;   int N, X, f[MAXN][MAXN], pw[MAXN][MAXN], binom[MAXN][MAXN];   void add(int& a, int b) { a = a + b >= P ? a + b - P : a + b; }   int dif(int a, int b) { return a - b < 0 ? a - b + P : a - b; }   int main() {     for (int i = (0), iend = (MAXN); i < iend; ++i) {       pw[i][0] = (i > 0);       for (int j = (1), jend = (MAXN); j < jend; ++j)         pw[i][j] = 1ll * pw[i][j - 1] * i % P;     }     binom[0][0] = 1;     for (int i = (1), iend = (MAXN); i < iend; ++i) {       binom[i][0] = 1;       for (int j = (1), jend = (i + 1); j < jend; ++j)         binom[i][j] = binom[i - 1][j - 1], add(binom[i][j], binom[i - 1][j]);     }     for (int i = (1), iend = (MAXN); i < iend; ++i) f[0][i] = 1;     for (int i = (2), iend = (MAXN); i < iend; ++i)       for (int j = (1), jend = (MAXN); j < jend; ++j) {         for (int x = i - 1; x < j; x += i - 1) {           for (int k = (1), kend = (i); k < kend; ++k)             add(f[i][j],                 1ll * binom[i][k] * f[i - k][j - x] % P * pw[i - 1][k] % P);         }         for (int x = 0; x < j; x += i - 1) add(f[i][j], pw[min(i - 1, j - x)][i]);       }     scanf( %d %d , &N, &X);     printf( %d n , f[N][X]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1e5 + 10;   vector<int> e[maxn], re[maxn], List;   int n, m, id[maxn], tt, cnt[maxn], ans;   bool vis[maxn];   void input() {     scanf( %d%d , &n, &m);     for (int u, v, i = 1; i <= m; i++) {       scanf( %d%d , &u, &v);       e[u].push_back(v);       re[v].push_back(u);     }   }   void dfs(int u) {     vis[u] = 1;     for (vector<int>::iterator it = e[u].begin(); it != e[u].end(); it++) {       if (!vis[*it]) {         dfs(*it);       }     }     List.push_back(u);   }   void rdfs(int u, int k) {     id[u] = k;     cnt[k]++;     for (vector<int>::iterator it = re[u].begin(); it != re[u].end(); it++) {       if (!id[*it]) {         rdfs(*it, k);       }     }   }   void scc() {     tt = 0;     for (int i = 1; i <= n; i++)       if (!vis[i]) dfs(i);     reverse(List.begin(), List.end());     for (vector<int>::iterator it = List.begin(); it != List.end(); it++)       if (!id[*it]) {         tt++;         rdfs(*it, tt);       }   }   void bfs(int u) {     queue<int> q;     while (!q.empty()) q.pop();     q.push(u);     vis[u] = 1;     int c = 0, x = 0;     bool ok = 0;     while (!q.empty()) {       u = q.front();       q.pop();       if (cnt[id[u]]) {         c += cnt[id[u]] - 1;         x++;         if (cnt[id[u]] > 1) ok = 1;         cnt[id[u]] = 0;       }       for (vector<int>::iterator it = e[u].begin(); it != e[u].end(); it++) {         if (!vis[*it]) {           vis[*it] = 1;           q.push(*it);         }       }       for (vector<int>::iterator it = re[u].begin(); it != re[u].end(); it++) {         if (!vis[*it]) {           vis[*it] = 1;           q.push(*it);         }       }     }     ans += c + x - 1;     if (ok) ans++;   }   void solve() {     memset(vis, 0, sizeof vis);     for (int i = 1; i <= n; i++)       if (!vis[i]) {         bfs(i);       }     printf( %d , ans);   }   int main() {     input();     scc();     solve();   }
#include <bits/stdc++.h>   using namespace std;   const long long int mod = 1e9 + 7;   const long long int inf = 1e18;   const double EPS = 1E-9;   int n, m;   int main(void) {     cin >> n >> m;     if (m > n) {       int temp = m;       m = n;       n = temp;     }     if (m == 1) {       cout << n << endl;     } else if (m == 2) {       cout << 2 * (2 * (n / 4) + min(n % 4, 2)) << endl;     } else if (m >= 3) {       if ((n == 3 && m == 3) || (n == 3 && m == 5) || (n == 3 && m == 6) ||           (n == 4 && m == 4)) {         if (n == 3 && m == 3) {           cout << 5 << endl;         } else if (n == 3 && m == 5) {           cout << 7 << endl;         } else if (n == 3 && m == 6) {           cout << 7 << endl;         } else {           cout << 8 << endl;         }       } else {         cout << m * n - (m * n) / 2 << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 11111111;   const long long INF = (long long)(1e12);   const long long mod = 998244353;   const double eps = 1e-9;   long long n, mx = -1, inv[N], a[N], k, all, cnt, ans;   map<long long, long long, greater<long long> > M, S;   long long get(long long x) { return (x) * (x + 1) / 2; }   int main() {     ios_base ::sync_with_stdio(false);     cin >> n >> k;     all = (1ll << k) - 1;     ans = get(n);     M[0]++;     for (long long i = 1; i <= n; ++i) {       cin >> a[i];       a[i] ^= a[i - 1];       inv[i] = (all ^ a[i]);       if (M[a[i]] < M[inv[i]]) {         ans -= M[a[i]];         M[a[i]]++;       } else {         ans -= M[inv[i]];         M[inv[i]]++;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename TYPE>   inline TYPE sqr(const TYPE& a) {     return (a) * (a);   }   const int INF = 1000 * 1000 * 1000;   const long double EPS = 1e-9;   const long double PI = 2 * acos(0.0);   const int N = 100100;   int top;   int j;   int a[N];   string ans;   bool f() {     if (j >= top) return false;     if (a[j] == 0) {       ++j;       ans.append( int );       return true;     }     ++j;     ans.append( pair< );     if (!f()) return false;     ans.append( , );     if (!f()) return false;     ans.append( > );     return true;   }   int main() {     int n;     scanf( %d n , &n);     string s;     getline(cin, s);     for (int i = 0; i < int(s.size()); ++i)       if (s[i] ==  t )         a[top++] = 0;       else if (s[i] ==  p )         a[top++] = 1;     if (!f() || j < top) {       puts( Error occurred );     } else {       puts(ans.c_str());     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = 3.1415926535897932238460;   bool arr[361];   void angles() {     for (int i = 3; i < 361; i++)       if ((i - 2) * 180 % i == 0) {         arr[(i - 2) * 180 / i] = true;       }   }   int main() {     int t;     cin >> t;     angles();     while (t--) {       int k;       cin >> k;       if (arr[k])         cout <<  YES               <<   n ;       else         cout <<  NO               <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   bool a[1100][26];   vector<bool> v(1100, false);   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       string s;       cin >> s;       for (auto c : s) a[i][c - 97] = true;     }     for (int i = 0; i < n; i++) {       if (v[i]) continue;       for (int j = i + 1; j < n; j++) {         bool b = true;         for (int g = 0; g < 26; g++)           if (a[i][g] != a[j][g]) b = false;         if (b) {           v[j] = true;         }       }     }     int ans = 0;     for (int i = 0; i < n; i++)       if (!v[i]) ans++;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k;   int c[105];   long long p[105][105], f[105][105][105];   int main() {     scanf( %d %d %d , &n, &m, &k);     for (int i = 1; i <= n; i++) scanf( %d , &c[i]);     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) scanf( %I64d , &p[i][j]);     for (int i = 1; i <= n; i++)       if (c[i]) p[i][c[i]] = 0;     for (int i = 0; i <= n; i++)       for (int j = 0; j <= m; j++)         for (int q = 0; q <= k; q++) f[i][j][q] = 1e16;     if (c[1])       f[1][c[1]][k - 1] = 0;     else       for (int i = 1; i <= m; i++) f[1][i][k - 1] = p[1][i];     for (int i = 1; i < n; i++) {       for (int j = 1; j <= m; j++)         if (c[i] == 0 || j == c[i])           for (int q = k - 1; q >= 0; q--) {             if (q != 0) {               for (int w = 1; w <= m; w++)                 if (j != w)                   f[i + 1][w][q - 1] =                       min(f[i + 1][w][q - 1], f[i][j][q] + p[i + 1][w]);             }             f[i + 1][j][q] = min(f[i + 1][j][q], f[i][j][q] + p[i + 1][j]);           }     }     long long ans = 1e16;     if (c[n]) {       ans = min(ans, f[n][c[n]][0]);     } else       for (int i = 1; i <= m; i++) ans = min(f[n][i][0], ans);     if (ans == 1e16)       printf( -1 );     else       printf( %I64d , ans);     return 0;   }
#include <bits/stdc++.h>   template <class T>   void read(T &x) {     x = 0;     int f = 0;     char ch = getchar();     while (ch <  0  || ch >  9 ) f |= (ch ==  - ), ch = getchar();     while (ch <=  9  && ch >=  0 )       x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();     x = f ? -x : x;     return;   }   const int maxn = 5007;   char c[maxn], a[maxn];   int t[2][2];   int main() {     int n;     read(n);     scanf( %s , c + 1);     scanf( %s , a + 1);     int len = n / 2;     for (int i = 1; i <= n; i++)       if (c[i] ==  1  && a[i] ==  1 )         t[1][1]++;       else if (c[i] ==  1  && a[i] ==  0 )         t[1][0]++;       else if (c[i] ==  0  && a[i] ==  1 )         t[0][1]++;       else         t[0][0]++;     for (int i = 0; i <= len; i++)       for (int j = 0; j <= i; j++) {         if (j > t[1][1]) continue;         int k = i - j;         if (k > t[1][0]) continue;         int re11 = t[1][1] - j;         if (re11 > i) continue;         int gal = i - re11;         if (t[0][1] >= gal) {           int x = j, y = k, z = t[0][1] - gal;           int res = len - i - z;           if (res < 0 || res > t[0][0]) continue;           for (int q = 1; q <= n; q++) {             if (c[q] ==  1  && a[q] ==  1  && x > 0) {               printf( %d  , q);               x--;             }             if (c[q] ==  1  && a[q] ==  0  && y > 0) {               printf( %d  , q);               y--;             }             if (c[q] ==  0  && a[q] ==  1  && z > 0) {               printf( %d  , q);               z--;             }             if (c[q] ==  0  && a[q] ==  0  && res > 0) {               printf( %d  , q);               res--;             }           }           return 0;         }       }     printf( -1 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 40;   void solve() {     long long int n, m, k;     cin >> n >> m >> k;     long long int beg = 1, end = n * m;     long long int fa;     while (beg <= end) {       long long int mid = (beg + end) / 2;       long long int cnt = 0;       for (int i = 1; i <= n; i++) {         cnt += min(m, mid / i);       }       if (cnt >= k) {         end = mid - 1;         fa = mid;       } else         beg = mid + 1;     }     cout << fa <<   n ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int T = 1;     while (T--) {       solve();       if (T) {         char c;       }     }   }