malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <iostream>   #include <cstdio>   #include <cstring>   using namespace std;   char s[5010];   int n;      bool ok(int x,int y,int fx,int fy){    if(x==fx && y==fy)return 0;    return 1;   }      bool check(int fx,int fy){    int x=0,y=0;    for(int i=1;i<=n;i++){     if(s[i]== D ){      if(ok(x,y-1,fx,fy))y--;     }     if(s[i]== U ){      if(ok(x,y+1,fx,fy))y++;     }     if(s[i]== L ){      if(ok(x-1,y,fx,fy))x--;     }     if(s[i]== R ){      if(ok(x+1,y,fx,fy))x++;     }    }    if(x==0 && y==0)return 1;    else return 0;   }      void work(){    int x=0,y=0;    for(int i=1;i<=n;i++){     if(s[i]== D ){      if(check(x,y-1)){       printf( %d %d n ,x,y-1);       return;      }      else y--;     }     else if(s[i]== U ){      if(check(x,y+1)){       printf( %d %d n ,x,y+1);       return;      }      else y++;     }     else if(s[i]== L ){      if(check(x-1,y)){       printf( %d %d n ,x-1,y);       return;      }      else x--;     }     else if(s[i]== R ){      if(check(x+1,y)){       printf( %d %d n ,x+1,y);       return;      }      else x++;     }    }    puts( 0 0 );    return;   }      int main(){    int T;    scanf( %d ,&T);    while(T--){     scanf( %s ,s+1);     n=strlen(s+1);     if(check(5001,5001)){      printf( 5001 5001 n );      continue;     }     work();    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int X = 0, w = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) w = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) X = X * 10 + c -  0 , c = getchar();     return X * w;   }   const int N = 125000 + 10;   int n, m;   char s[N], t[N];   int bl[N], ans[N];   int nxt[N];   void getnext() {     for (int i = 2, j = 0; i <= m; ++i) {       while (j && bl[t[j + 1]] != bl[t[i]]) j = nxt[j];       if (bl[t[j + 1]] == bl[t[i]]) ++j;       nxt[i] = j;     }   }   void calc(int w) {     getnext();     for (int i = 1, j = 0; i <= n; ++i) {       while (j && bl[t[j + 1]] != bl[s[i]]) j = nxt[j];       if (bl[t[j + 1]] == bl[s[i]]) ++j;       if (j == m) ans[i - m + 1] = min(ans[i - m + 1], w);     }   }   void dfs(char c, int tot) {     if (c >  f ) {       calc(6 - tot);       return;     }     for (int i = 1; i <= tot; ++i) bl[c] = i, dfs(c + 1, tot);     bl[c] = tot + 1, dfs(c + 1, tot + 1);   }   int main() {     scanf( %s%s , s + 1, t + 1), n = strlen(s + 1), m = strlen(t + 1);     memset(ans, 0x3f, sizeof(ans));     dfs( a , 0);     for (int i = 1; i <= n - m + 1; ++i) printf( %d  , ans[i]);     puts(  );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   int main() {     ios_base::sync_with_stdio(false);     int N;     cin >> N;     ll ans = 0;     priority_queue<int, vector<int>, greater<int>> q;     for (int i = 0; i < N; ++i) {       int v;       cin >> v;       q.emplace(v);       q.emplace(v);       ans += v - q.top();       q.pop();     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 10;   int ar[maxn], num[maxn];   int main() {     int t;     cin >> t;     while (t--) {       int n, m;       memset(num, 0, sizeof(num));       memset(ar, 0, sizeof(ar));       cin >> n >> m;       string s;       cin >> s;       for (int i = 1; i <= m; i++) {         int x;         cin >> x;         x--;         ar[x]++;       }       int len = s.length();       for (int i = 0; i < len; i++) {         num[s[i] - 97]++;       }       for (int i = len - 1; i >= 0; i--) {         ar[i] += ar[i + 1];         num[s[i] - 97] += ar[i];       }       for (int i = 0; i < 26; i++) {         if (i < 25)           cout << num[i] <<    ;         else           cout << num[i] << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int getDaysOfMonth(int m) {     if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12)       return 31;     if (m == 2) return 28;     return 30;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     int n;     cin >> n;     char a[n];     for (int i = 0; i < int(n); i++) cin >> a[i];     for (int i = 1; i <= n; i++) {       if (n % i == 0) {         reverse(a, a + i);       }     }     for (int i = 0; i < int(n); i++) cout << a[i];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long MOD = 1000000007;   string yes =  YES n ;   string no =  NO n ;   long long gcd(long long a, long long b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, k;     cin >> n >> k;     long long dp[k + 1][n + 1];     memset(dp, 0, sizeof(dp));     for (long long i = 1; i <= n; i++) dp[1][i] = 1;     for (long long i = 2; i <= k; i++) {       for (long long j = 1; j <= n; j++) {         for (long long t = j; t <= n; t += j)           dp[i][t] = (dp[i][t] + dp[i - 1][j]) % MOD;       }     }     long long ans = 0;     for (long long i = 1; i <= n; i++) {       ans += dp[k][i];       ans %= MOD;     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   using uint = unsigned int;   using ull = unsigned long long;   template <typename T>   using pair2 = pair<T, T>;   using pii = pair<int, int>;   using pli = pair<ll, int>;   using pll = pair<ll, ll>;   mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());   ll myRand(ll B) { return (ull)rng() % B; }   clock_t startTime;   double getCurrentTime() {     return (double)(clock() - startTime) / CLOCKS_PER_SEC;   }   const ll MOD = 998244353;   ll add(ll x, ll y) {     x += y;     if (x >= MOD) return x - MOD;     return x;   }   ll sub(ll x, ll y) {     x -= y;     if (x < 0) return x + MOD;     return x;   }   ll mult(ll x, ll y) { return (x * y) % MOD; }   ll bin_pow(ll x, ll p) {     if (p == 0) return 1;     if (p & 1) return mult(x, bin_pow(x, p - 1));     return bin_pow(mult(x, x), p / 2);   }   ll rev(ll x) { return bin_pow(x, MOD - 2); }   const int N = 1505;   const int M = 2 * N;   const int K = N * N / 2;   vector<int> g[M];   vector<int> a[M];   vector<int> b[M];   int par[M];   int sz[M];   int cntEd[M];   int dp[M][N];   int ed[K][2];   int n, m;   void unite(int v, int u) {     v = par[v];     u = par[u];     if (v == u) {       cntEd[v]++;       if (cntEd[v] == sz[v] * (sz[v] - 1) / 2) {         for (int w : b[v]) {           g[v].push_back(w);         }         b[v].clear();         b[v].push_back(v);       }       return;     }     sz[m] = sz[v] + sz[u];     cntEd[m] = cntEd[v] + cntEd[u] + 1;     for (int x : a[v]) {       a[m].push_back(x);       par[x] = m;     }     for (int x : a[u]) {       a[m].push_back(x);       par[x] = m;     }     for (int x : b[v]) b[m].push_back(x);     for (int x : b[u]) b[m].push_back(x);     v = m;     m++;     if (cntEd[v] == sz[v] * (sz[v] - 1) / 2) {       for (int w : b[v]) {         g[v].push_back(w);       }       b[v].clear();       b[v].push_back(v);     }   }   void dfs(int v) {     if (g[v].empty()) {       dp[v][1] = 1;       return;     }     dp[v][0] = 1;     int cur = 0;     for (int u : g[v]) {       dfs(u);       int inner[N];       for (int i = 0; i <= cur + sz[u]; i++) inner[i] = 0;       for (int i = 0; i <= cur; i++)         for (int j = 1; j <= sz[u]; j++)           inner[i + j] = add(inner[i + j], mult(dp[v][i], dp[u][j]));       cur += sz[u];       for (int i = 0; i <= cur; i++) dp[v][i] = inner[i];     }     assert(cur == sz[v]);     dp[v][1] = add(dp[v][1], 1);   }   int main() {     startTime = clock();     scanf( %d , &n);     m = n;     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         int x;         scanf( %d , &x);         if (i < j) {           ed[x][0] = i;           ed[x][1] = j;         }       }     }     for (int i = 0; i < n; i++) {       par[i] = i;       a[i].push_back(i);       b[i].push_back(i);       sz[i] = 1;       cntEd[i] = 0;     }     for (int x = 1; x <= n * (n - 1) / 2; x++) {       int v = ed[x][0], u = ed[x][1];       assert(u > 0);       unite(v, u);     }     dfs(m - 1);     for (int i = 1; i <= n; i++) printf( %d  , dp[m - 1][i]);     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void doicho(int &t1, int &t2) {     if (t1 > t2) swap(t1, t2);   }   void sapxep(pair<double, int> result[], int n) {     for (int i = 0; i < n - 1; i++) {       for (int j = i + 1; j < n; j++) {         if (result[i].first < result[j].first) {           swap(result[i].first, result[j].first);           swap(result[i].second, result[j].second);         } else if (result[i].first == result[j].first &&                    result[i].second > result[j].second) {           swap(result[i].first, result[j].first);           swap(result[i].second, result[j].second);         }       }     }   }   int main() {     int n, t1, t2, k;     cin >> n >> t1 >> t2 >> k;     int a[n], b[n];     for (int i = 0; i < n; i++) cin >> a[i] >> b[i];     pair<double, int> result[n];     for (int i = 0; i < n; i++) {       double x, y, z, t;       x = (a[i] * t1 - t1 * a[i] * ((double)k / 100) + b[i] * t2);       t = (a[i] * t2 - t1 * b[i] * ((double)k / 100) + b[i] * t1);       double max2 = x > t ? x : t;       result[i].first = max2;       result[i].second = i + 1;     }     sapxep(result, n);     for (int i = 0; i < n; i++)       printf( %d %.2f n , result[i].second, result[i].first);   }
#include <bits/stdc++.h>   int main() {     char s[22];     scanf( %s , s);     int len = strlen(s);     int d1 = s[0] -  0 , d2 = 9 - (s[0] -  0 );     if (d1 > d2 && d2 > 0) s[0] = d2 +  0 ;     for (int i = 1; i < len; i++) {       d1 = s[i] -  0 ;       d2 = 9 - (s[i] -  0 );       if (d1 > d2) s[i] = d2 +  0 ;     }     puts(s);   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1LL << 61;   int n, r;   long long a[30], b[30], k[30], p[30];   long long dfs(int u, bool op1) {     long long res = -INF;     if (u % 2 == 0) res = max(res, inner_product(a, a + n, k, 0LL));     if (u == 0) return res;     if (!op1) {       for (int i = 0; i < (n); i++) a[i] ^= b[i];       res = max(res, dfs(u - 1, true));       for (int i = 0; i < (n); i++) a[i] ^= b[i];     }     long long tmp[30];     memcpy(tmp, a, sizeof a);     for (int i = 0; i < (n); i++) a[i] = tmp[p[i]] + r;     res = max(res, dfs(u - 1, false));     memcpy(a, tmp, sizeof a);     return res;   }   int main() {     int u;     scanf( %d%d%d , &n, &u, &r);     for (int i = 0; i < (n); i++) scanf( %I64d , a + i);     for (int i = 0; i < (n); i++) scanf( %I64d , b + i);     for (int i = 0; i < (n); i++) scanf( %I64d , k + i);     for (int i = 0; i < (n); i++) scanf( %I64d , p + i), p[i]--;     printf( %I64d n , dfs(u, false));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, u, col[300005], dp[300005][2];   vector<long long> graph[300005];   void dfs(long long u) {     dp[u][col[u]] = 1;     for (long long i = 0; i < graph[u].size(); i++) {       long long v = graph[u][i];       dfs(v);       dp[u][1] = (((dp[u][1] * dp[v][0]) % 1000000007 +                    (dp[u][0] * dp[v][1]) % 1000000007) %                       1000000007 +                   (dp[u][1] * dp[v][1]) % 1000000007) %                  1000000007;       dp[u][0] = (dp[u][0] * ((dp[v][0] + dp[v][1]) % 1000000007)) % 1000000007;     }   }   int main() {     scanf( %lld , &n);     for (long long i = 1; i < n; i++) {       scanf( %lld , &u);       graph[u].push_back(i);     }     for (long long i = 0; i < n; i++) scanf( %lld , &col[i]);     dfs(0);     printf( %lld n , dp[0][1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool flag = true;   const long long int N = 2e5 + 5;   const long long int inf = 998244353;   void solve() {     long long int i = 0, j = 0, ans = 0, x = 0, y = 0, z = 0;     long long int n, k = 0, m = 0, mn = LLONG_MAX, mx = LLONG_MIN;     cin >> n >> k;     vector<long long int> a(n), v;     for (auto &it : a) {       cin >> it;       mx = max(mx, it);       mn = min(mn, it);     }     if (mx == mn) {       cout <<  0 ;       return;     }     sort(a.begin(), a.end());     for (i = mx; i >= mn; i--) {       j = upper_bound(a.begin(), a.end(), i) - a.begin();       v.push_back(n - j);     }     x = 0;     ans = 1;     for (i = 0; i < (long long int)v.size(); i++) {       if (x + v[i] <= k)         x += v[i];       else {         ans++;         x = v[i];       }     }     cout << ans << endl;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     ;     long long int T = 1, te = 1;     while (T--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<char> v;   int n;   string s;   bool potR() {     int freq[1000];     freq[ G ] = 0;     freq[ B ] = 0;     freq[ R ] = 0;     for (int i = 0; i < s.size(); ++i) {       ++freq[s[i]];     }     int cnt1 = freq[ B ];     int cnt2 = freq[ G ];     if (cnt1 >= 1 && cnt2 >= 1) {       return true;     }     if (cnt1 == 0 && cnt2 == 0) {       return true;     }     if (cnt1 == 0 && cnt2 >= 2) {       if (freq[ R ] >= 1) {         return true;       } else {         return false;       }     }     if (cnt1 >= 2 && cnt2 == 0) {       if (freq[ R ] >= 1) {         return true;       } else {         return false;       }     }     return false;   }   bool potG() {     int freq[1000];     freq[ G ] = 0;     freq[ B ] = 0;     freq[ R ] = 0;     for (int i = 0; i < s.size(); ++i) {       ++freq[s[i]];     }     int cnt1 = freq[ R ];     int cnt2 = freq[ B ];     if (cnt1 >= 1 && cnt2 >= 1) {       return true;     }     if (cnt1 == 0 && cnt2 == 0) {       return true;     }     if (cnt1 == 0 && cnt2 >= 2) {       if (freq[ G ] >= 1) {         return true;       } else {         return false;       }     }     if (cnt1 >= 2 && cnt2 == 0) {       if (freq[ G ] >= 1) {         return true;       } else {         return false;       }     }     return false;   }   bool potB() {     int freq[1000];     freq[ G ] = 0;     freq[ B ] = 0;     freq[ R ] = 0;     for (int i = 0; i < s.size(); ++i) {       ++freq[s[i]];     }     int cnt1 = freq[ G ];     int cnt2 = freq[ R ];     if (cnt1 >= 1 && cnt2 >= 1) {       return true;     }     if (cnt1 == 0 && cnt2 == 0) {       return true;     }     if (cnt1 == 0 && cnt2 >= 2) {       if (freq[ B ] >= 1) {         return true;       } else {         return false;       }     }     if (cnt1 >= 2 && cnt2 == 0) {       if (freq[ B ] >= 1) {         return true;       } else {         return false;       }     }     return false;   }   int main() {     ios::sync_with_stdio(false);     cin >> n;     cin.get();     cin >> s;     v.push_back( R );     v.push_back( G );     v.push_back( B );     set<char> mySet;     if (potR()) {       mySet.insert( R );     }     if (potB()) {       mySet.insert( B );     }     if (potG()) {       mySet.insert( G );     }     for (auto i : mySet) {       cout << i;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long binpow(long long a, long long b, long long mod) {     long long res = 1;     while (b != 0) {       if (1 & b) res = (res * a) % mod;       b >>= 1;       a = (a * a) % mod;     }     return res;   }   long long mminvprime(long long a, long long b) { return binpow(a, b - 2, b); }   long long mod_add(long long a, long long b, long long m) {     a = a % m;     b = b % m;     return (((a + b) % m) + m) % m;   }   long long mod_mul(long long a, long long b, long long m) {     a = a % m;     b = b % m;     return (((a * b) % m) + m) % m;   }   long long mod_sub(long long a, long long b, long long m) {     a = a % m;     b = b % m;     return (((a - b) % m) + m) % m;   }   long long mod_div(long long a, long long b, long long m) {     a = a % m;     b = b % m;     return (mod_mul(a, mminvprime(b, m), m) + m) % m;   }   long long combination(long long n, long long r, long long m, long long *fact) {     long long val1 = fact[n];     long long val2 = mod_mul(fact[n - r], fact[r], m);     return mod_mul(val1, binpow(val2, m - 2, m), m);   }   void solve() {     long long n;     cin >> n;     for (long long i = 0; i < n; i++) {       for (long long j = 0; j < n - i; j++) {         cout <<  ( ;       }       for (long long j = 0; j < n - i; j++) {         cout <<  ) ;       }       for (long long j = 0; j < i; j++) {         cout <<  () ;       }       cout <<   n ;     }   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long tt = 1;     cin >> tt;     while (tt--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     string s;     cin >> s;     long long n = s.size();     long long sum = 0;     for (long long i = 0; i < n; i++) {       sum += s[i] -  0 ;     }     string a = s;     for (long long i = n - 2; i >= 0; i--) {       if (s[i] !=  0 ) {         string p = s;         p[i] = p[i] - 1;         for (long long j = i + 1; j < n; j++) {           p[j] =  9 ;         }         long long su = 0;         for (long long i = 0; i < n; i++) {           su += p[i] -  0 ;         }         if (su > sum) {           sum = su;           a = p;         }       }     }     long long f = 0;     for (long long i = 0; i < a.size(); i++) {       if (a[i] !=  0 ) {         f = 1;         cout << a[i];       }       if (a[i] ==  0  && f == 1) {         cout << a[i];       }     }   }
#include <bits/stdc++.h>   using namespace std;   long long n, q, pre[1000000], a[1000000], f[100], vis[100], ans, rec[100],       temp[100];   int main() {     cin >> n >> q;     for (long long i = n; i >= 1; i--) pre[i] = pre[i + 1] + n - i + 1;     f[0] = 1;     for (long long i = 1; i <= 20; i++) f[i] = f[i - 1] * i;     long long num = 0;     for (long long o = 1; o <= q; o++) {       long long tag;       cin >> tag;       if (tag == 1) {         long long l, r;         cin >> l >> r;         if (n - r + 1 > 20) {           cout << pre[n - r + 1] - pre[n - l + 2] << endl;           continue;         }         long long t = num;         for (long long i = min(n, (long long)20); i >= 1; i--)           if (t >= f[i - 1]) {             rec[i] = t / f[i - 1] + 1;             t = t % f[i - 1];           } else             rec[i] = 1;         memset(vis, 0, sizeof vis);         long long base = n - 20;         if (n <= 20) base = 0;         for (long long i = min(n, (long long)20); i >= 1; i--) {           long long xx, cnt = 0, now = 1;           while (cnt < rec[i]) {             if (!vis[now]) cnt++;             now++;           }           now--;           temp[i] = now + base;           vis[now] = 1;         }         for (int i = min(n, (long long)20); i >= 1; i--)           pre[i] = pre[i + 1] + temp[i];         cout << pre[n - r + 1] - pre[n - l + 2] << endl;       } else {         long long x;         cin >> x;         num += x;       }     }   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const long long INF = 1e18;   const long long N = 1e5 + 100;   long long n;   long long a[N], dp_right[N], dp_left[N], full_right[N], full_left[N];   signed main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n;     for (long long i = 1; i <= n; ++i) {       cin >> a[i];     }     for (long long i = 1; i <= n; i++) {       if (a[i] != 1)         full_left[i] = full_left[i - 1] + (a[i] % 2 == 0 ? a[i] : a[i] - 1);       dp_left[i] = dp_left[i - 1] + (a[i] % 2 == 0 ? a[i] - 1 : a[i]);       dp_left[i] = max(dp_left[i], full_left[i]);     }     for (long long i = n; i >= 1; i--) {       if (a[i] != 1)         full_right[i] = full_right[i + 1] + (a[i] % 2 == 0 ? a[i] : a[i] - 1);       dp_right[i] = dp_right[i + 1] + (a[i] % 2 == 0 ? a[i] - 1 : a[i]);       dp_right[i] = max(dp_right[i], full_right[i]);     }     long long ans = 0;     for (long long i = 1; i <= n; i++) {       long long x = max({dp_right[i], dp_left[i], dp_left[i] + full_right[i + 1],                          full_left[i] + dp_right[i + 1]});       ans = max(ans, x);     }     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const double Pi = acos(-1.0);   const double Eps = 1e-6;   const int Mod = (int)1e9 + 7;   long long Bigmod(long long b, long long p, long long m) {     if (p == 0) return 1LL;     if (p % 2 == 0) {       long long c = Bigmod(b, p / 2, m);       return ((c % m) * (c % m)) % m;     } else       return ((b % m) * (Bigmod(b, p - 1, m))) % m;   }   long long ModInverse(long long a, long long M) { return Bigmod(a, M - 2, M); }   template <class T>   inline T GCD(T x, T y) {     if (y == 0) return x;     return GCD(y, x % y);   }   template <class T>   inline T LCM(T x, T y) {     return ((x / GCD(x, y)) * y);   }   bool Reverse(long long a, long long b) { return a > b; }   bool Compare(pair<long long, long long> a, pair<long long, long long> b) {     if (a.first == b.first) return a.second > b.second;     return a.first < b.first;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int T;     cin >> T;     while (T--) {       string A, B;       cin >> A >> B;       if (A < B)         cout << A << endl;       else {         int Pos[27];         for (int i = 0; i < 27; i++) Pos[i] = -1;         for (int i = 0; i < A.size(); i++) {           int Position = A[i] -  A  + 1;           Pos[Position] = max(Pos[Position], i);         }         bool PreBreak = false, SolutionFound = false;         for (int i = 1; i <= 26; i++) {           if (Pos[i] == -1) continue;           for (int j = 0; j < Pos[i]; j++) {             if (A[j] > A[Pos[i]]) {               string Temp = A;               swap(Temp[j], Temp[Pos[i]]);               if (Temp < B) {                 cout << Temp << endl;                 SolutionFound = true;                 PreBreak = true;                 break;               }             }           }           if (PreBreak) break;         }         if (SolutionFound == false) cout <<  ---  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[1010101];   int b[1010101];   int c[1010101], d[1010101];   long long dp[1010101][2];   long long l;   long long n, k;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> l >> k;     for (int i = 0; i < n; i++) {       cin >> a[i];       if (i < l % n) c[i] = a[i];     }     sort(a, a + n);     long long len = l % n;     sort(c, c + len);     int cntr = len - 1;     for (int i = n - 1; i >= 0; i--) {       if (i == n - 1 || a[i] != a[i + 1])         b[i] = i;       else         b[i] = b[i + 1];       if (cntr >= 0 && c[cntr] == a[i]) {         d[cntr] = b[i];         cntr--;       }     }     for (int i = 0; i < n; i++) dp[i][0] = i + 1;     long long res = l % 1000000007;     for (long long i = 1; i < k; i++) {       if ((i + 1) * n <= l) {         for (int j = 0; j < n; j++) {           dp[j][i % 2] = dp[b[j]][(i + 1) % 2];           if (j > 0) dp[j][i % 2] += dp[j - 1][i % 2];           dp[j][i % 2] %= 1000000007;         }         res += (((l / n - i) % 1000000007) * dp[n - 1][i % 2]) % 1000000007;         res %= 1000000007;       }       if (len && i * n < l) {         long long sum = 0;         for (int j = 0; j < len; j++) {           sum += dp[d[j]][(i + 1) % 2];           sum %= 1000000007;         }         res += sum;         res %= 1000000007;       }     }     cout << res <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   bool check(string s);   void multiple(string s, string d);   constexpr long long MAXN = 1e5 + 15;   int n;   string a[MAXN];   string ans =  1 , s;   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) {       if (a[i] ==  0 ) {         return cout <<  0 n , false;       } else if (check(a[i])) {         ans += a[i].substr(1, a[i].size() - 1);       } else {         s = a[i];       }     }     if (s ==   ) return cout << ans <<   n , false;     s = s + ans.substr(1, ans.size() - 1);     cout << s <<   n ;   }   bool check(string s) {     int cnt = 0;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  1 ) cnt++;       if (s[i] !=  1  && s[i] !=  0 ) return false;     }     return (cnt < 2 ? true : false);   }