malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   using ll = int64_t;   using ii = pair<ll, ll>;   int main() {     cin.tie(nullptr);     cout.tie(nullptr);     ios::sync_with_stdio(false);     ll n, m;     cin >> n >> m;     ll nn = n - 2;     ll n1 = nn / 2;     ll n2 = nn - n1;     ll sm = (n1 + 1) * n1 / 2 + (n2 + 1) * n2 / 2;     if (m == 0) {       ll fff = ll(1e9) - 5050 * 5050;       for (int i = (0); i < (n); i++) {         cout << fff + i * 5050 <<    ;       }       cout << endl;       return 0;     }     if (sm >= m) {       if (m == 1) {         cout << 1 <<     << 2 <<     << 3 <<    ;         n -= 3;         ll fff = ll(1e9) - 5050 * 5050;         for (int i = (0); i < (n); i++) {           cout << fff + i * 5050 <<    ;         }         cout << endl;         return 0;       }       ll f1 = 1, f2 = 1;       sm = 0;       for (int i = (0); i < (n - 2); i++) {         if (sm + f1 >= m) {           f2 = i - 1;           break;         }         sm += f1;         if (i % 2 == 1) f1++;       }       ll last;       ll ff1 = f1 - (m - sm);       if (f2 % 2 == 0) {         last = 2 * ff1 + 1;       } else {         last = 2 * ff1;         if (ff1 == 0) last = 1;       }       cout << 1 <<     << 2 <<    ;       for (int i = (0); i < (f2 + 1); i++) {         cout << i + 3 <<    ;         if (i == f2) {           cout << i + 3 + last <<    ;         }       }       ll kk = f2 + 4;       kk = n - kk;       ll fff = ll(1e9) - 5050 * 5050;       for (int i = (0); i < (kk); i++) {         cout << fff + i * 5050 <<    ;       }       cout << endl;     } else {       cout << -1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int n, i, j, g, k, a[3];     while (~scanf( %d , &n)) {       for (i = 0, k = 0; i < n; i++) {         for (j = 0, g = 0; j < 3; j++) {           scanf( %d , &a[j]);           if (a[j] == 1) {             g++;           }         }         if (g >= 2) {           k++;         }       }       printf( %d n , k);     }     return 0;   }
#include <bits/stdc++.h>   const int MAX_N = 500000;   const int MAX_M = 500000;   const int MOD = 998244353;   int l[MAX_M], r[MAX_M], val[MAX_M];   int smen[1 + MAX_N + 1], left[1 + MAX_N], dp[1 + MAX_N], _sp[1 + 1 + MAX_N],       *sp = _sp + 1;   int solve(int n, int m, int bit) {     int last = 0, p = 0;     for (int i = 1; i <= n; ++i) {       smen[i] = 0;       left[i] = 0;     }     smen[n + 1] = left[n + 1] = 0;     for (int i = 0; i < m; ++i)       if ((1 << bit) & val[i]) {         smen[l[i]]++;         smen[r[i] + 1]--;       } else         left[r[i] + 1] = std::max(left[r[i] + 1], l[i]);     sp[0] = 1;     dp[0] = 1;     for (int i = 1; i <= n + 1; ++i) {       p += smen[i];       last = std::max(last, left[i]);       if (p == 0) {         dp[i] = (sp[i - 1] + MOD - sp[last - 1]) % MOD;       } else         dp[i] = 0;       sp[i] = (sp[i - 1] + dp[i]) % MOD;     }     return dp[n + 1];   }   int main() {     int n, k, m;     scanf( %d%d%d , &n, &k, &m);     for (int i = 0; i < m; ++i) scanf( %d%d%d , &l[i], &r[i], &val[i]);     int res = 1;     for (int i = 0; i < k; ++i) res = (long long)res * solve(n, m, i) % MOD;     printf( %d , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int d[3 * 1000001], v1[3 * 1000001], v2[3 * 1000001], a[1000001], i, n, tt, tt2,       kq;   void BFS1(int s, int k) {     queue<int> q;     if (v1[s] == 0) {       q.push(s);       v1[s] = k;     }     while (q.size() > 0) {       int u = q.front();       q.pop();       for (int i = 0; i <= 21; i++)         if ((u >> i) & 1) {           int v = u - (1 << i);           if (v1[v] == 0) {             q.push(v);             v1[v] = k;           }         }     }   }   void BFS2(int s, int k) {     queue<int> q;     if (v2[s] > 0) return;     if (d[s] == 0 || d[s] > k) {       q.push(s);       if (d[s] == 0)         d[s] = k;       else         v2[s] = k;     }     while (q.size() > 0) {       int u = q.front();       q.pop();       for (int i = 0; i <= 21; i++)         if ((u >> i) & 1) {           int v = u - (1 << i);           if (v2[v] > 0) continue;           if (d[v] == 0 || d[v] > k) {             q.push(v);             if (d[v] == 0)               d[v] = k;             else               v2[v] = k;           }         }     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     for (i = 1; i <= n; i++) cin >> a[i];     for (i = 1; i <= n; i++) BFS1(a[i], i);     for (i = n; i >= 1; i--) BFS2(a[i], i);     for (tt = 0; tt <= 2000000; tt++) {       tt2 = 0;       if (v2[tt] == 0) continue;       for (i = 21; i >= 0; i--) {         if ((tt >> i) & 1) continue;         if (v1[tt2 | (1 << i)] < v2[tt] && v1[tt2 | (1 << i)] > 0)           tt2 |= (1 << i);       }       kq = max(kq, tt | tt2);     }     cout << kq;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> ans;     int x[n], y[n];     for (int i = 0; i < n; i++) {       cin >> x[i] >> y[i];       x[i] += 1e8;       y[i] += 1e8;     }     while (1) {       for (int i = 0; i < n; i++) {         if ((x[i] + y[i]) & 1) ans.push_back(i + 1);       }       if (ans.size() == 0 || ans.size() == n) {         ans.clear();         for (int j = 0; j < n; j++) {           int op = (x[j] + y[j]) / 2;           x[j] = (x[j] - y[j] + (int)1e9) / 2 - 5e8;           y[j] = op;         }       } else         break;     }     cout << ans.size() << endl;     for (auto x : ans) {       cout << x <<    ;     }   }
#include <bits/stdc++.h>   int n;   int mat[3][6];   int solv[6];   int pt[6];   int main() {     memset(solv, 0, sizeof solv);     memset(mat, -1, sizeof mat);     scanf( %d , &n);     int i, j;     for (i = 0; i < 2; i++)       for (j = 0; j < 5; j++) {         scanf( %d , &mat[i][j]);         if (mat[i][j] != -1) solv[j]++;       }     for (i = 2; i < n; i++)       for (j = 0; j < 5; j++) {         int a;         scanf( %d , &a);         if (a != -1) solv[j]++;       }     for (i = 0; i <= 31 * n; i++) {       for (j = 0; j < 5; j++) {         int cur = solv[j];         if (mat[0][j] != -1 && mat[1][j] != -1 && mat[1][j] < mat[0][j]) cur += i;         pt[j] = 500;         while (pt[j] < 3000 && cur * 2 <= n + i) pt[j] += 500, cur *= 2;       }       int sc1 = 0, sc2 = 0;       for (j = 0; j < 5; j++) {         if (mat[0][j] != -1) sc1 += pt[j] / 250 * (250 - mat[0][j]);         if (mat[1][j] != -1) sc2 += pt[j] / 250 * (250 - mat[1][j]);       }       if (sc1 > sc2) {         printf( %d n , i);         return 0;       }     }     printf( -1 n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = 2.0 * acos(0.0);   const double eps = 1e-9;   template <class T>   T Abs(T x) {     return x > 0 ? x : -x;   }   template <class T>   string toString(T n) {     ostringstream ost;     ost << n;     ost.flush();     return ost.str();   }   template <class T>   inline T gcd(T a, T b) {     if (a < 0) return gcd(-a, b);     if (b < 0) return gcd(a, -b);     return (b == 0) ? a : gcd(b, a % b);   }   template <class T>   inline T lcm(T a, T b) {     if (a < 0) return lcm(-a, b);     if (b < 0) return lcm(a, -b);     return a * (b / gcd(a, b));   }   long long bit_set(long long k, int p) { return k = (k | (1 << p)); }   long long re_set(long long k, int p) { return k = (k & ~(1 << p)); }   template <class T>   inline T sqr(T n) {     return n * n;   }   template <class T>   T power(T n, int p) {     if (!p)       return 1;     else {       T sum = sqr(power(n, p >> 1));       if (p & 1) sum = n;       return sum;     }   }   int main() {     long long num;     cin >> num;     num = (num + 1) / 3LL;     cout << (num / 12LL) <<     << num % 12LL << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s[105];   int main() {     int n, m, cnt = 0, t, tt, temp, dis = 0, ans = 0, len;     int row = 0, rowup = 2e9, rowdn = -1, col = 0, collft = 2e9, colrt = -1;     int rowupcol, rowdncol, collftrow, colrtrow;     scanf( %d %d , &n, &m);     for (int i = 0; i < n; i++) cin >> s[i];     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (s[i][j] ==  B ) {           cnt++;           if (i < rowup) {             rowup = i;             rowupcol = j;           }           if (rowdn < i) {             rowdn = i;             rowdncol = j;           }           if (j < collft) {             collft = j;             collftrow = i;           }           if (colrt < j) {             colrt = j;             colrtrow = i;           }         }       }     }     if (!cnt)       printf( 1 n );     else if (cnt == 1)       printf( 0 n );     else {       len = max(rowdn - rowup + 1, colrt - collft + 1);       if (len > n || len > m)         printf( -1 n );       else         printf( %d n , (len * len) - cnt);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0), cout.tie(0);     int n;     cin >> n;     vector<int> a(n + 1), b(n + 1), p(n + 1);     for (int i = 1; i <= n; ++i) {       cin >> a[i];       p[a[i]] = 0;     }     for (int i = 1; i <= n; ++i) {       cin >> b[i];       p[b[i]] = i;     }     if (p[1]) {       int k = 1, i;       for (i = 2; p[i] == p[1] + i - 1; ++i) {         k++;       }       if (p[i - 1] == n) {         set<int> s;         for (auto x : a) {           if (x) {             s.insert(x);           }         }         int f = 1;         int ind = 1;         for (; i <= n; ++i) {           auto it = s.find(i);           if (it == s.end()) {             f = 0;             break;           }           s.erase(it);           s.insert(b[ind]);           ind++;         }         if (f == 1) {           cout << n - k;           return 0;         }       }     }     int ans = 0;     for (int i = 1; i <= n; ++i) {       ans = max(ans, p[i] - i + 1 + n);     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n, t;     cin >> n >> t;     if (n == 1 && t == 10) {       cout <<  -1 ;       return 0;     }     if (t != 10)       cout << t;     else       cout <<  1 ;     for (int i = 1; i < n; i++) cout <<  0 ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long h[1000010], dp[1000010][2];   int n;   int main() {     int i, j;     while (scanf( %d , &n) != EOF) {       for (i = 1; i <= n; i++) scanf( %lld , &h[i]), h[i]--;       for (i = 1; i <= n; i++) {         dp[i][0] = (dp[i - 1][0] + dp[i - 1][1] * min(h[i], h[i - 1]) + h[i]) %                    1000000007;         dp[i][1] = (min(h[i + 1], h[i]) +                     min(min(h[i], h[i - 1]), h[i + 1]) * dp[i - 1][1]) %                    1000000007;       }       printf( %d n , dp[n][0]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char board[8][8];   int main() {     for (int i = 0; i < 8; i++) {       for (int j = 0; j < 8; j++) scanf(  %c , &board[i][j]);     }     int minA = 100, minB = 100;     for (int i = 0; i < 8; i++) {       for (int j = 0; j < 8; j++) {         if (board[i][j] ==  W ) {           int k;           for (k = i; k >= 0; k--) {             if (k == i) continue;             if (board[k][j] !=  . ) break;           }           if (k < 0 and i < minA) minA = i;         }         if (board[i][j] ==  B ) {           int k;           for (k = i; k < 8; k++) {             if (k == i) continue;             if (board[k][j] !=  . ) break;           }           if (k >= 8 and 7 - i < minB) minB = 7 - i;         }       }     }     if (minA <= minB)       cout <<  A  << endl;     else       cout <<  B  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long x, y;     cin >> x >> y;     long long d = x * x + y * y;     if (x == 0 || y == 0) {       cout <<  black  << endl;       return 0;     }     for (long long i = 1; i <= 10000; i++) {       if (d < i * i) {         bool white = (i % 2 == 0 && x * y > 0) || (i % 2 == 1 && x * y < 0);         cout << (white ?  white  :  black ) << endl;         return 0;       }       if (d == i * i) {         cout <<  black  << endl;         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int f, int s) {     if (s == 0)       return f;     else       return gcd(s, f % s);   }   int const N = 1002006;   long long const M = 998244353;   long double const ep = .000000000000000001;   vector<int> G[N];   long long pw[N];   int od = 0, ev = 0;   int vis[N];   bool wtf = 1;   void dfs(int node, int col) {     if (col % 2 == 0)       ev++;     else       od++;     vis[node] = col;     for (int i = 0; i < G[node].size(); i++) {       int el = G[node][i];       if (vis[el] == -1)         dfs(el, col ^ 1);       else if (col == vis[el])         wtf = 0;     }   }   int main() {     pw[0] = 1;     for (int i = 1; i < N; i++) pw[i] = (pw[i - 1] * 2) % M;     int t;     cin >> t;     while (t--) {       int n, e;       scanf( %d%d , &n, &e);       for (int i = 1; i <= n; i++) {         G[i].clear();         vis[i] = -1;       }       for (int i = 0; i < e; i++) {         int temp, temp1;         scanf( %d%d , &temp, &temp1);         G[temp].push_back(temp1);         G[temp1].push_back(temp);       }       wtf = 1;       long long ans = 1;       for (int i = 1; i <= n; i++) {         if (vis[i] == -1) {           od = 0, ev = 0;           dfs(i, 0);           long long tot = pw[od] + pw[ev];           tot %= M;           ans = (ans * tot) % M;         }       }       ans *= wtf;       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200005;   int a[maxn], cnt[maxn], n, q;   long long ans = 0;   map<pair<long long, long long>, int> mp;   int main() {     ios::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];       ans += a[i];     }     cin >> q;     long long s, t, u;     while (q--) {       cin >> s >> t >> u;       if (mp.find(pair<long long, long long>(s, t)) != mp.end()) {         int c = mp[pair<long long, long long>(s, t)];         if (cnt[c] <= a[c]) ans++;         cnt[c]--;         mp.erase(pair<long long, long long>(s, t));       }       if (u != 0) {         mp[pair<long long, long long>(s, t)] = u;         if (cnt[u] < a[u]) ans--;         cnt[u]++;       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   long long n, i, j, pw = 1, ans1, ans2, diff = 1;   char a[100000], b[100000];   int main() {     ios_base::sync_with_stdio(0);     cin.tie();     cin >> n;     for (i = 0; i < n; i++) cin >> a[i];     for (i = 0; i < n; i++) cin >> b[i];     ans1 = ans2 = 1;     for (i = 0; i < n; i++) {       if (a[i] ==  ? ) pw = (pw * 10) % mod;       if (b[i] ==  ? ) pw = (pw * 10) % mod;       if (a[i] ==  ?  && b[i] ==  ? )         ans1 = (ans1 * 55) % mod, ans2 = (ans2 * 55) % mod, diff *= 10;       else {         if (a[i] ==  ?  || b[i] ==  ? ) {           if (a[i] ==  ? )             ans1 = (ans1 * ( 9  - b[i] + 1)) % mod,             ans2 = (ans2 * (b[i] -  0  + 1)) % mod;           else             ans2 = (ans2 * ( 9  - a[i] + 1)) % mod,             ans1 = (ans1 * (a[i] -  0  + 1)) % mod;         } else {           if (a[i] < b[i]) ans1 = 0, diff = 0;           if (a[i] > b[i]) ans2 = 0, diff = 0;         }       }     }     cout << (pw - ans1 - ans2 + 3 * mod + diff) % mod;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000 + 10;   int n, m;   int a[maxn];   int res0, res1;   void output(int l, int r) {     printf( ?  );     for (int i = 1; i < l; i++) printf( 0 );     for (int i = l; i <= r; i++) printf( 1 );     for (int i = r + 1; i <= n; i++) printf( 0 );     printf(  n );     fflush(stdout);   }   void dfs(int l, int r) {     if (res0 && res1) return;     if (l == r) {       output(l, l);       scanf( %d , &a[++m]);       if (a[m] - a[1] == 1)         res0 = l;       else         res1 = l;       return;     }     if (r - l == 1) {       output(l, l);       scanf( %d , &a[++m]);       if (a[m] - a[1] == 1) res0 = l;       if (a[1] - a[m] == 1) res1 = l;       if (res0 && res1) return;       dfs(r, r);       return;     }     int mid = (l + r) >> 1;     output(l, mid);     scanf( %d , &a[++m]);     if (a[m] - a[1] == mid - l + 1) {       res0 = l;       if (res0 && res1) return;       dfs(mid + 1, r);     } else if (a[1] - a[m] == mid - l + 1) {       res1 = l;       if (res0 && res1) return;       dfs(mid + 1, r);     } else {       if (res0 && res1) return;       dfs(l, mid);       if (res0 && res1) return;       dfs(mid + 1, r);     }   }   int main() {     scanf( %d , &n);     output(1, 0);     scanf( %d , &a[++m]);     dfs(1, n);     printf( ! %d %d n , res0, res1);     fflush(stdout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mmax = 1e6 + 10;   const int eps = 1e-9;   struct node {     string name;   } s[105];   long long cmp(node a, node b) {     if (a.name == b.name) return a.name < b.name;     return a.name < b.name;   }   int main() {     long long n;     while (cin >> n) {       for (int i = 0; i < n; i++) {         cin >> s[i].name;       }       sort(s, s + n, cmp);       long long ans = 0, sum = 0;       for (int i = 0; i < n; i++) {         if (s[i].name[0] == s[i + 1].name[0])           ans++;         else {           long long num0 = (ans + 1) / 2;           long long num1 = ans + 1 - num0;           long long sum0 = 0, sum1 = 0;           for (int i = 1; i < num0; i++) sum0 += i;           for (int i = 1; i < num1; i++) sum1 += i;           sum += (sum0 + sum1);           ans = 0;         }       }       cout << sum << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k, kk;   vector<int> g[10], e[10];   int cnt = 0;   bool used[10] = {}, vis[10] = {};   int usedCnt, visCnt;   long long cur;   int st;   int pc[1024];   void go(int v) {     vis[v] = true, ++visCnt;     vector<int> &f = e[v];     int sz = 0;     for (int x : g[v])       if (!used[x]) {         f[sz++] = x;       }     for (int mask = 0; mask < (int)(1 << sz); ++mask) {       int pcm = pc[mask];       for (int i = 0; i < (int)(sz); ++i)         if (mask & (1 << i)) {           used[f[i]] = true;         }       usedCnt += pcm;       int pos = 0;       while (pos < n && (!used[pos] || vis[pos])) ++pos;       if (pos != n) {         go(pos);       } else {         if (usedCnt == n) ++cur;       }       for (int i = 0; i < (int)(sz); ++i)         if (mask & (1 << i)) {           used[f[i]] = false;         }       usedCnt -= pcm;     }     vis[v] = false, --visCnt;   }   long long ans[15], c[15][15];   int main() {     for (int i = 0; i < (int)(1024); ++i) pc[i] = __builtin_popcount(i);     scanf( %d%d%d , &n, &m, &kk);     for (int i = 0; i < (int)(m); ++i) {       int from, to;       scanf( %d%d , &from, &to), --from, --to;       g[from].push_back(to);       g[to].push_back(from);     }     for (int i = 0; i < (int)(n); ++i) e[i].resize(g[i].size());     for (int i = 0; i < (int)(15); ++i) c[0][i] = 0;     c[0][0] = 1;     for (int i = 1; i < 15; ++i) {       c[i][0] = 1;       for (int j = 1; j < 15; ++j) {         c[i][j] = c[i - 1][j] + c[i - 1][j - 1];       }     }     for (int k = n - 1; k >= kk; --k) {       for (int mask = 0; mask < (int)(1 << n); ++mask)         if (pc[mask] == k) {           for (int i = 0; i < (int)(n); ++i)             vis[i] = used[i] = (mask & (1 << i)) > 0;           st = 0;           while (used[st]) ++st;           if (st == n) break;           usedCnt = k + 1;           visCnt = k;           used[st] = true;           cur = 0;           go(st);           for (int i = 0; i < (int)(n); ++i)             if (mask & (1 << i)) {               int mul = 0;               for (int to : g[i])                 if (!(mask & (1 << to))) {                   ++mul;                 }               cur *= mul;             }           ans[k] += cur;         }       for (int x = n - 1; x > k; --x) {         ans[k] -= ans[x] * c[x][k];       }     }     printf( %d n , (int)ans[kk]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long s;   int main() {     int n, a, b, c, d;     cin >> n >> a >> b >> c >> d;     for (int x = 1; x <= n; x++) {       int y = x + b - c;       int z = x + a - d;       int w = y + a - d;       if (y <= n && z <= n && w <= n && y > 0 && z > 0 && w > 0) s++;     }     s *= n;     cout << s;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n = 0, m = 0;     string s;     cin >> s;     for (int i = 0; i < s.length(); i++)       if (s[i] ==  x )         n++;       else         m++;     if (n > m)       for (int i = 1; i <= n - m; i++) cout <<  x ;     else if (n < m)       for (int i = 1; i <= m - n; i++) cout <<  y ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> vc[200007];   int main() {     int n;     scanf( %d , &n);     int res = 0;     for (auto i = (1); i <= (n); ++i) {       int m;       scanf( %d , &m);       vc[i].resize(m);       for (auto j = (0); j <= (m - 1); ++j) scanf( %d , &vc[i][j]);       sort(vc[i].rbegin(), vc[i].rend());       res = max(res, vc[i][0]);     }     long long ans = 0LL;     for (auto i = (1); i <= (n); ++i)       ans += (long long)(res - vc[i][0]) * (int)vc[i].size();     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int a, i, j, ct = 0;   int main() {     cin >> a;     for (i = 0; i < a; i++) {       ct++;       if (ct == 1 || ct == 2) {         cout <<  a ;       }       if (ct == 3 || ct == 4) {         cout <<  b ;         if (ct == 4) {           ct = 0;         }       }     }     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:1024000000,1024000000 )   using namespace std;   int n, k;   char str[100005];   long long jie[100005];   long long ni[100005];   long long sum[100005];   long long extend_gcd(long long a, long long b, long long &x, long long &y) {     if (b == 0) {       x = 1, y = 0;       return a;     }     long long gcd = extend_gcd(b, a % b, x, y);     long long t = x;     x = y;     y = t - a / b * x;     return gcd;   }   long long Get_Inverse(long long num) {     long long x, y;     extend_gcd(num, 1000000007, x, y);     return (x % 1000000007 + 1000000007) % 1000000007;   }   void init() {     jie[0] = jie[1] = 1;     ni[0] = ni[1] = 1;     for (int i = 2; i <= 100000; i++) {       jie[i] = (jie[i - 1] * i) % 1000000007;       ni[i] = Get_Inverse(jie[i]);     }   }   long long cal(int n, int m) {     if (n < m) return 0;     return jie[n] * ni[n - m] % 1000000007 * ni[m] % 1000000007;   }   int main(void) {     init();     scanf( %d%d , &n, &k);     scanf( %s , str + 1);     long long ans = 0;     long long ten = 1;     for (int i = 1; i <= n; i++) {       sum[i] =           (sum[i - 1] + ten * cal(n - i - 1, k - 1) % 1000000007) % 1000000007;       ten = ten * 10 % 1000000007;     }     ten = 1;     for (int i = n; i >= 1; i--) {       int c = str[i] -  0 ;       ans += c * ten % 1000000007 * cal(i - 1, k) % 1000000007;       ans += c * sum[n - i] % 1000000007;       ans %= 1000000007;       ten = ten * 10 % 1000000007;     }     printf( %I64d n , ans);     return 0;   }