malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 3e3 + 100;   const long long mod = 1e9 + 7;   const long long inf = 1e18;   long long n, dsu[maxn], sz[maxn], t[maxn], a[maxn], mx, s, ans;   pair<long long, pair<long long, long long> > e[maxn];   void init() {     mx = 0;     for (long long i = 1; i <= n; i++) {       dsu[i] = i;       sz[i] = 1;       t[i] = a[i] + sz[i];       mx = max(mx, t[i]);     }   }   long long root(long long v) {     if (dsu[v] == v) return v;     return root(dsu[v]);   }   bool Union(long long v, long long u) {     long long x = root(v), y = root(u);     if (x == y) return 1;     if (sz[x] < sz[y]) swap(x, y);     sz[x] += sz[y];     t[x] += t[y];     mx = max(mx, t[x]);     dsu[y] = x;     return 0;   }   bool isval(long long x) {     init();     for (long long i = 0; i < n - 1; i++) {       if (e[i].first < x) {         Union(e[i].second.first, e[i].second.second);       }     }     return (mx <= s);   }   int main() {     long long v, u, c;     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     ;     cin >> n;     for (long long i = 0; i < n - 1; i++) {       cin >> e[i].second.first >> e[i].second.second >> e[i].first;     }     for (long long i = 1; i <= n; i++) {       cin >> a[i];       s += a[i];     }     long long l = 0, r = 2e4, mid;     while (r - l > 1) {       mid = (l + r) / 2;       if (isval(mid))         l = mid;       else         r = mid;     }     cout << l;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mn = 1e6 + 10;   const long long mod = 998244353;   int a[100], t[100];   string s[100];   int dp[21][1 << 20];   int main() {     int n, m;     scanf( %d , &n);     for (int i = 0; i < n; i++) scanf( %d , a + i);     sort(a, a + n, greater<int>());     scanf( %d , &m);     for (int i = 0; i < m; i++) cin >> s[i] >> t[i];     for (int i = m - 1; i >= 0; i--) {       if (s[i] ==  p ) {         for (int j = 1; j < 1 << m; j++) {           int l = __builtin_ctz(j);           if (t[i] == 1)             dp[i][j] = a[l] + dp[i + 1][j - (1 << l)];           else             dp[i][j] = -a[l] + dp[i + 1][j - (1 << l)];         }       } else {         if (t[i] == 1) {           for (int j = 0; j < 1 << m; j++) {             dp[i][j] = dp[i + 1][j];             for (int k = 0; k < m; k++)               if ((j >> k) & 1) {                 dp[i][j] = max(dp[i][j], dp[i + 1][j - (1 << k)]);               }           }         } else {           for (int j = 0; j < 1 << m; j++) {             dp[i][j] = dp[i + 1][j];             for (int k = 0; k < m; k++)               if ((j >> k) & 1) {                 dp[i][j] = min(dp[i][j], dp[i + 1][j - (1 << k)]);               }           }         }       }     }     printf( %d , dp[0][(1 << m) - 1]);   }
#include <bits/stdc++.h>   int min(int a, int b) { return a > b ? b : a; }   int max(int a, int b) { return a < b ? b : a; }   int main() {     int n, a, b, c, d, i, pos;     int sum, next;     while (~scanf( %d , &n)) {       int ans = 0;       for (i = 1; i <= 4; i++) {         scanf( %d%d%d%d , &a, &b, &c, &d);         a = min(a, b);         b = max(a, b);         c = min(c, d);         d = max(c, d);         if (a + c <= n) {           ans = 1;           pos = i;           next = a;         }       }       if (ans)         printf( %d %d %d n , pos, next, n - next);       else         printf( -1 n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   unsigned long long l, r, x, y;   unsigned long long gcd(unsigned long long a, unsigned long long b) {     while (b > 0) {       unsigned long long t = b;       b = a % b;       a = t;     }     return a;   }   int main() {     cin >> l >> r >> x >> y;     if (x == y) {       if (x >= l && x <= r) {         cout << 1;         return 0;       }     }     unsigned long long number = 0;     l = 1 + ((l - 1) / x);     l *= x;     for (unsigned long long i = l; i * i <= x * y; i += x) {       unsigned long long p = x * y / i;       if (p * i == x * y && p >= l && p <= r && i <= r) {         if (gcd(p, i) == x) {           number += 2;           if (i == p) number--;         }       }     }     cout << number;   }
#include <bits/stdc++.h>   using namespace std;   long long i, j, k, l, n, m, c, d, a[2005][2005], b[10005], f, mod = 1e9 + 7;   vector<long long> v;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> n;     a[0][0] = 1;     for (i = 1; i <= n; i++)       for (j = 0; j <= i; j++) {         if (j - 1 < 0)           k = 0;         else           k = a[j - 1][i - 1];         a[j][i] = (k + a[j + 1][i - 1]) % mod;       }     for (i = n + 1; i <= 2 * n; i++)       for (j = 0; j <= n - (i - 1) % n - 1; j++) {         if (j - 1 < 0)           k = 0;         else           k = a[j - 1][i - 1];         a[j][i] = (k + a[j + 1][i - 1]) % mod;       }     for (i = 1; i <= 2 * n; i++) {       for (j = 0; j <= n; j++) b[i] = (b[i] + a[j][i]) % mod;     }     k = 0;     for (i = 1; i <= 2 * n; i = i + 2) k = (k + b[i]) % mod;     cout << k;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     string s;     cin >> n;     getline(cin, s);     while (n--) {       getline(cin, s);       bool L = false, M = false;       if (s.length() < 5) {         cout <<  OMG>.< I don t know!  << endl;         continue;       }       if (s.substr(0, 5) ==  miao. ) {         M = true;       }       if (s.substr(s.length() - 5) ==  lala. ) {         L = true;       }       if (M && L) {         cout <<  OMG>.< I don t know!  << endl;       } else if (M) {         cout <<  Rainbow s  << endl;       } else if (L) {         cout <<  Freda s  << endl;       } else {         cout <<  OMG>.< I don t know!  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t;     t = 1;     while (t--) {       int n;       cin >> n;       int a[n + 1];       a[1] = 0;       for (int i = 2; i <= n; i++) cin >> a[i];       vector<int> v;       v.push_back(n);       n = a[n];       v.push_back(n);       while (n != 1) {         v.push_back(a[n]);         n = a[n];       }       reverse(v.begin(), v.end());       for (auto x : v) cout << x <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios::sync_with_stdio(false);     long long n;     cin >> n;     set<long long> s = {-2, -1};     vector<long long> arr(n, 0);     while (n--) {       long long x;       cin >> x;       --x;       if ((*prev(s.end())) > x && (*prev(prev(s.end()))) < x)         ++arr[(*prev(s.end()))];       if ((*prev(s.end())) < x) --arr[x];       s.insert(x);     }     cout << (max_element(arr.begin(), arr.end()) - arr.begin() + 1) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int s[105], d[105], c[105];   int ans[105] = {0};   vector<pair<int, int>> v;   int main() {     int tc;     tc = 1;     while (tc--) {       int n, m;       cin >> n >> m;       int flag = 1;       for (int i = 1; i <= m; i++) {         cin >> s[i] >> d[i] >> c[i];         if (d[i] - s[i] < c[i]) flag = 0;         ans[d[i]] = m + 1;         v.push_back({i, d[i]});       }       if (flag == 0) {         cout << -1 <<   n ;         continue;       }       sort(v.begin(), v.end(), [](pair<int, int> &a, pair<int, int> &b) {         return a.second < b.second;       });       flag = 1;       for (int i = 0; i < m; i++) {         int now = v[i].first;         int cnt = 0;         for (int j = s[now]; j < d[now] and cnt < c[now]; j++) {           if (ans[j] == 0) {             ans[j] = now;             cnt++;           }         }         if (cnt < c[now]) {           flag = 0;           break;         }       }       if (flag == 0)         cout << -1 <<   n ;       else {         for (int i = 1; i <= n; i++) cout << ans[i] <<    ;         cout <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   int t, n, m, a[3005] = {0};   string ans[3005];   vector<pair<string, int> > v[3005];   map<string, int> mp;   map<int, string> mp1;   vector<string> v1[3005];   int F(int x, int vis[]) {     int i, i1, i2, idx;     for (i = 0; i < v1[x].size(); i++) {       string s = v1[x][i];       i1 = mp[s];       if (!vis[i1]) {         vis[i1] = 1;         if (a[i1] < 0 || F(a[i1], vis)) {           a[i1] = x;           ans[x] = s;           return 1;         }       }     }     return 0;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     int i, j, k, x, y, vis[3005] = {0};     string s1, s2;     cin >> n;     int cc = 1;     memset(a, -1, sizeof a);     for (i = 0; i < n; i++) {       cin >> s1 >> s2;       string temp = s1.substr(0, 3), temp1 = s1.substr(0, 2) + s2[0];       if (mp[temp] == 0) mp[temp] = cc++;       if (mp[temp1] == 0) mp[temp1] = cc++;       v[mp[temp]].push_back({temp1, i});       mp1[mp[temp]] = temp;     }     for (i = 1; i < cc; i++) {       s2 = mp1[i];       if (v[i].size() == 1) {         k = v[i][0].second;         s1 = v[i][0].first;         v1[k].push_back(s1);         v1[k].push_back(s2);         continue;       }       for (j = 0; j < v[i].size(); j++) {         s1 = v[i][j].first;         k = v[i][j].second;         v1[k].push_back(s1);       }     }     m = mp.size();     for (i = 0; i < n; i++) {       for (j = 0; j < m + 2; j++) vis[j] = 0;       if (F(i, vis))         continue;       else {         cout <<  NO ;         return 0;       }     }     cout <<  YES n ;     for (i = 0; i < n; i++) cout << ans[i] <<   n ;     cerr <<   n           <<  Time elapsed :  << clock() * 1000.0 / CLOCKS_PER_SEC <<   ms n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, k, a[100100], sum = 0, Min = 1e6;   int main() {     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) {       if (a[i] < 0 && k) a[i] *= -1, k--;       Min = min(Min, abs(a[i]));       sum += a[i];     }     if (k & 1) sum -= Min * 2;     cout << sum;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 0x3f3f3f3f, MOD = 1e9 + 7;   long long power(long long a, long long n) {     long long p = 1;     while (n > 0) {       if (n % 2) {         p = p * a;       }       n >>= 1;       a *= a;     }     return p;   }   long long power(long long a, long long n, long long mod) {     long long p = 1;     while (n > 0) {       if (n % 2) {         p = p * a;         p %= mod;       }       n >>= 1;       a *= a;       a %= mod;     }     return p % mod;   }   void swap(char *a, char *b) {     char temp = *a;     *a = *b;     *b = temp;   }   long long int nCr(int n, int r) {     long long int C[r + 1];     memset(C, 0, sizeof(C));     C[0] = 1;     for (int i = 1; i <= n; i++) {       for (int j = min(i, r); j > 0; j--) C[j] = (C[j] + C[j - 1]);     }     return C[r];   }   long long int countDer(int n) {     int der[n + 1];     der[0] = 1;     der[1] = 0;     der[2] = 1;     for (int i = 3; i <= n; ++i) der[i] = (i - 1) * (der[i - 1] + der[i - 2]);     return der[n];   }   int digitsum(long long a) {     int ans = 0;     while (a > 0) {       ans = ans + a % 10;       a = a / 10;     }     return ans;   }   int count(long long a) {     int temp = 0;     while (a > 0) {       a = a / 10;       temp++;     }     return temp;   }   int main() {     int n;     cin >> n;     char s[n];     for (int i = 0; i < n; i++) cin >> s[i];     sort(s, s + n);     for (int i = 0; i < n; i++) cout << s[i];     cout << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 1005, maxD = 10, oo = 1e9;   int Len, dp[maxN][maxN];   int t[maxN][maxN], s[maxN], tool[maxN];   int n, perm[maxN], cost[maxD], cnt[maxN][maxD], lost[maxN];   bool flag = 0;   inline void solve(int i, int j, int d) {     int jp = 0, sum = 0;     for (int d2 = 0; d2 < maxD; d2++) {       int td = cnt[j][d2];       int fl = (d + 1 + d2) >= 10;       jp += fl * td;       sum += td * cost[(d + 1 + d2) % 10];       td = cnt[n][d2] - cnt[j][d2];       if (d2 == 0 && d == 0 && flag) td -= lost[n] - lost[j];       fl = (d + d2) >= 10;       jp += fl * td;       sum += td * cost[(d + d2) % 10];     }     dp[i + 1][jp] = max(dp[i + 1][jp], dp[i][j] + sum);     return;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     string r;     cin >> r;     int sz = r.size();     for (int i = 0; i < sz; i++) {       if (r[i] ==  ? )         s[sz - i - 1] = -1;       else         s[sz - i - 1] = r[i] -  0 ;     }     Len = max(Len, sz);     cin >> n;     for (int i = 0; i < n; i++) {       string tmp;       cin >> tmp;       int cz = tmp.size();       for (int j = 0; j < cz; j++) t[i][cz - j - 1] = tmp[j] -  0 ;       Len = max(Len, cz);       tool[i] = cz;     }     for (int i = 0; i < maxD; i++) cin >> cost[i];     dp[0][0] = 0;     for (int j = 1; j <= n; j++) dp[0][j] = -oo;     for (int i = 1; i < maxN; i++)       for (int j = 0; j < maxN; j++) dp[i][j] = -oo;     for (int i = 0; i < n; i++) perm[i] = i;     for (int i = 0; i < Len; i++) {       for (int j = 1; j <= n; j++) {         for (int d = 0; d < maxD; d++) cnt[j][d] = cnt[j - 1][d];         int d = t[perm[j - 1]][i];         cnt[j][d]++;         lost[j] = lost[j - 1];         if (tool[perm[j - 1]] <= i) lost[j]++;       }       if (i >= sz) flag = true;       for (int j = 0; j <= n; j++) {         if (s[i] != -1)           solve(i, j, s[i]);         else {           int st = 0;           if (i == sz - 1) st = 1;           for (int d = st; d < maxD; d++) solve(i, j, d);         }       }       vector<int> vc;       for (int d = maxD - 1; d >= 0; d--)         for (int j = 0; j < n; j++)           if (t[perm[j]][i] == d) vc.push_back(perm[j]);       for (int j = 0; j < n; j++) perm[j] = vc[j];     }     int ans = 0;     for (int j = 0; j <= n; j++) ans = max(ans, dp[Len][j] + j * cost[1]);     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e6 + 7;   const int INF = 0x7fffffff;   long long c[maxn], s[maxn];   long long a[maxn], num[maxn];   int main() {     long long n, x, y;     while (cin >> n >> x >> y) {       long long ans = n * x;       memset(num, 0, sizeof(num));       for (int i = 1; i <= n; i++) {         cin >> a[i];         num[a[i]]++;       }       c[0] = s[0] = 0;       for (int i = 1; i <= 2e6; i++) {         c[i] = c[i - 1] + num[i];         s[i] = s[i - 1] + i * num[i];       }       long long p = (x + y - 1) / y;       for (int i = 2; i <= 1e6; i++) {         long long cur = 0;         for (int j = i; j <= 1e6 + i && cur < ans; j += i) {           int l = j - i, r = j;           int k = r - p;           k = max(k, l);           long long temp = (c[r] - c[k]) * j - (s[r] - s[k]);           cur += temp * y;           cur += (c[k] - c[l]) * x;         }         ans = min(ans, cur);       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct st {     int x, y;     bool operator<(const st o) const { return y < o.y || (y == o.y && x < o.x); }   };   long long a[1000000][2];   long long n, m, x, y;   long long M[1000000][2];   int main() {     cin >> n >> m;     cin >> M[0][0] >> M[0][1];     for (int i = 0; i < (int)(n); i++) {       for (int j = 0; j < (int)(2); j++) {         cin >> a[i][j];       }     }     for (int i = 1; i < 2 * n; i++) {       for (int j = 0; j < (int)(2); j++) {         M[i][j] = 2 * (a[(i - 1) % n][j]) - M[i - 1][j];       }     }     cout << M[m % (2 * n)][0] <<     << M[m % (2 * n)][1];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int yee[6][3] = {{0, 1, 2}, {1, 0, 2}, {1, 2, 0},                    {2, 1, 0}, {2, 0, 1}, {0, 2, 1}};   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n, x;     cin >> n >> x;     n %= 6;     cout << yee[n][x] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a, b, c, d, n;   int main() {     while (~scanf( %I64d%I64d%I64d%I64d%I64d , &n, &a, &b, &c, &d)) {       long long mi = min(b - c, min(a - d, a + b - c - d)),                 ma = max(b - c, max(a - d, a + b - c - d));       long long num1 = min(n - ma, n), num2 = max(1 - mi, (long long)1), ans = 0;       ;       if (num1 < num2)         ans = 0;       else         ans = num1 - num2 + 1;       printf( %I64d n , n * ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int binarySearch(int arr[], int l, int r, int x) {     while (l <= r) {       int m = l + (r - l) / 2;       if (arr[m] == x) return m;       if (arr[m] < x)         l = m + 1;       else         r = m - 1;     }     return -1;   }   bool isprime(int n) {     if (n <= 1) return false;     for (int i = 2; i < n; i++)       if (n % i == 0) return false;     return true;   }   long long int factorial(int n) {     if (n == 0) return 1;     return n * factorial(n - 1);   }   int countDigit(long long n) {     int count = 0;     while (n != 0) {       n = n / 10;       ++count;     }     return count;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int v1, v2, t, d, sum = 0;     cin >> v1 >> v2 >> t >> d;     for (int i = 0; i < t; i++) sum += min(v2 + (t - 1 - i) * d, v1 + i * d);     cout << sum;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = (int)(1e5 + 1e1);   const double PI = acos(-1.0);   long long a, m, t;   int main() {     cin >> m >> a;     if (a == 0 && m > 1) {       cout <<  No solution ;       return 0;     }     cout << a;     for (int i = 1; i < m; i++) cout << 0;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     bool ok[999];     memset(ok, false, sizeof(ok));     ok[ A ] = true;     ok[ H ] = true;     ok[ I ] = true;     ok[ M ] = true;     ok[ O ] = true;     ok[ T ] = true;     ok[ U ] = true;     ok[ V ] = true;     ok[ W ] = true;     ok[ X ] = true;     ok[ Y ] = true;     static char s[199919];     scanf( %s , s + 1);     int n = strlen(s + 1);     bool flag = true;     for (int i = 1, j = n; i <= j; ++i, --j)       if (s[i] != s[j] || !ok[s[i]]) flag = false;     printf( %s n , flag ?  YES  :  NO );     return 0;   }
#include <bits/stdc++.h>   int dx[] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};   int dy[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1};   using namespace std;   void fast() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);   }   long long to_int(string s) {     long long ans = 0;     for (int i = 0; i < s.size(); i++) {       ans = ans * 10 + (s[i] - 48);     }     return ans;   }   int l[100001];   int r[100001];   int a[100001];   int main() {     fast();     int d1, d2, d3, ans = 0;     cin >> d1 >> d2 >> d3;     if (d2 < d1) swap(d2, d1);     ans += d1;     ans += min(d3, d1 + d2);     ans += min(d2, d3 + d1);     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long f[2][200500], g[2][200500], sf[2][200500], sg[2][200500], ans;   int a, b, k, t;   const long long MOD = 1000000007;   int main() {     scanf( %d%d%d%d , &a, &b, &k, &t);     f[0][a + 100210] = 1;     g[0][b + 100210] = 1;     for (int j = -100000; j <= 100100; j++) {       sf[0][j + 100210] = (sf[0][j + 100209] + f[0][j + 100210]) % MOD;       sg[0][j + 100210] = (sg[0][j + 100209] + g[0][j + 100210]) % MOD;     }     for (int i = 1; i <= t; i++) {       for (int j = -100000; j <= 100100; j++) {         f[i & 1][j + 100210] =             (sf[(i - 1) & 1][min(100210 + a + k * i, j + k + 100210)] -              sf[(i - 1) & 1][max(100209 + a - k * i, j - k + 100209)]) %             MOD;         if (f[i & 1][j + 100210] < 0) f[i & 1][j + 100210] += MOD;         sf[i & 1][j + 100210] =             (sf[i & 1][j + 100209] + f[i & 1][j + 100210]) % MOD;       }       for (int j = -100000; j <= 100100; j++) {         g[i & 1][j + 100210] =             (sg[(i - 1) & 1][min(100210 + b + k * i, j + k + 100210)] -              sg[(i - 1) & 1][max(100209 + b - k * i, j - k + 100209)]) %             MOD;         if (g[i & 1][j + 100210] < 0) g[i & 1][j + 100210] += MOD;         sg[i & 1][j + 100210] =             (sg[i & 1][j + 100209] + g[i & 1][j + 100210]) % MOD;       }     }     for (int j = -100000; j <= 100100; j++) {       ans = (ans + f[t & 1][j + 100210] * sg[t & 1][j + 100209]) % MOD;     }     printf( %lld n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   const double eps = 1e-7;   const long long MOD = 1000000007LL;   const int INF = 0x3f3f3f3f;   const int _NAN = -0x3f3f3f3f;   const double EULC = 0.5772156649015328;   const int NIL = -1;   template <typename T>   void read(T &x) {     x = 0;     char ch = getchar();     long long f = 1;     while (!isdigit(ch)) {       if (ch ==  - ) f *= -1;       ch = getchar();     }     while (isdigit(ch)) {       x = x * 10 + ch - 48;       ch = getchar();     }     x *= f;   }   const int maxn = 2e5 + 10;   int arr[maxn];   int main(void) {     ios::sync_with_stdio(false);     int n;     while (cin >> n) {       if (~n & 1) {         cout <<  NO n ;         continue;       }       for (int i = 1; i <= n; ++i) {         if (i & 1) {           arr[i] = 2 * i - 1;           arr[i + n] = 2 * i;         } else {           arr[i] = 2 * i;           arr[i + n] = 2 * i - 1;         }       }       cout <<  YES n ;       for (int i = 1; i <= 2 * n; ++i)         cout << arr[i] << (i == 2 * n ?   n  :    );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n;     cin >> n;     string s;     cin >> s;     long long o = 0;     long long z = 0;     for (long long i = 0; i < n; i++)       if (s[i] ==  n )         o++;       else if (s[i] ==  z )         z++;     while (o--) cout << 1 <<    ;     while (z--) cout << 0 <<    ;   }   int main() {     long long t;     t = 1;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 998244353;   int add(int a, int b) {     a += b;     if (a >= MOD) a -= MOD;     if (a < 0) a += MOD;     return a;   }   int mul(int a, int b) { return a * 1ll * b % MOD; }   int binpow(int a, int b) {     int res = 1;     while (b) {       if (b & 1) res = mul(res, a);       a = mul(a, a);       b >>= 1;     }     return res;   }   vector<int> pr;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int n;     cin >> n;     vector<int> c(n);     for (int i = 0; i < int(n); i++) cin >> c[i];     sort(c.begin(), c.end(), greater<int>());     pr.push_back(0);     for (int i = 0; i < int(n); i++) {       pr.push_back(add(pr.back(), c[i]));     }     int invn = binpow(n, MOD - 2);     for (int k = 1; k <= n; ++k) {       int ans = 0;       for (int i = 0, j = 0; i < n; i += k, ++j) {         ans = add(ans, mul(j, add(pr[min(n, i + k)], -pr[i])));       }       cout << mul(ans, invn) <<    ;     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, cnt = 0;   long long a[623456], b[623456], v[9999999];   int main() {     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       v[a[i]] = 1;     }     for (int i = 1; i <= n; i++) {       cin >> b[i];       v[b[i]] = 1;     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) {         long long x = a[i] ^ b[j];         if (v[x]) {           cnt++;         }       }     }     if (cnt % 2 == 0)       cout <<  Karen ;     else       cout <<  Koyomi ;   }