malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, jump[100005];     bool visited[100005];     string s;     cin >> n;     cin >> s;     for (int i = 0; i < n; i++) cin >> jump[i];     int pos = 0;     fill(visited, visited + n, false);     while (!visited[pos]) {       visited[pos] = true;       if (s[pos] ==  > )         pos += jump[pos];       else if (s[pos] ==  < )         pos -= jump[pos];       if (pos < 0 || pos >= n) {         cout <<  FINITE  << endl;         return 0;       }     }     cout <<  INFINITE  << endl;   }
#include <bits/stdc++.h>   using namespace std;   int a[105][105], b, c, d, e, f, g, h, i, j, k, l, m, n;   inline bool pd(int x, int y, int s) {     return a[x - 1][y] == s || a[x + 1][y] == s || a[x][y - 1] == s ||            a[x][y + 1] == s;   }   int main() {     scanf( %d%d , &n, &m);     for (i = 1; i <= n; i++)       for (j = 1; j <= m; j++)         if (!a[i][j]) {           if (i == 3 && j == 21) {             k = 1;           }           for (k = 1; k <= 26; k++)             if (!pd(i, j, k)) {               for (l = 1; l <= n; l++) {                 if (i + l > n || j + l > m) break;                 d = 0;                 for (g = j; g <= j + l; g++)                   if (a[i + l][g] || pd(i + l, g, k)) {                     d = 1;                     break;                   }                 if (d) break;                 for (g = i; g <= i + l; g++)                   if (a[g][j + l] || pd(g, j + l, k)) {                     d = 1;                     break;                   }                 if (d) break;                 for (g = 1; g < k; g++)                   if (!pd(i, j + l, g)) d = 1;                 if (d) break;               }               l--;               for (d = i; d <= i + l; d++)                 for (e = j; e <= j + l; e++) a[d][e] = k;               break;             }         }     for (i = 1; i <= n; i++) {       for (j = 1; j <= m; j++) putchar(a[i][j] +  A  - 1);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int h, q, v, e;   string s;   map<int, int> xx;   inline double dfs(int x, int mx) {     if (xx[x] <= mx) return mx;     return 0.5 * (dfs(x << 1, max(mx, xx[x] - xx[x << 1])) +                   dfs(x << 1 | 1, max(mx, xx[x] - xx[x << 1 | 1])));   }   int main() {     scanf( %d%d , &h, &q);     while (q--) {       cin >> s;       if (s[0] ==  a ) {         scanf( %d%d , &v, &e);         while (v) xx[v] += e, v >>= 1;       } else         printf( %.8lf n , dfs(1, 0));     }   }
#include <bits/stdc++.h>   using namespace std;   int a[200000];   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       int odd = 0, even = 0;       for (int i = 0; i < n; i++) {         cin >> a[i];         if (a[i] & 1)           odd++;         else           even++;       }       if (odd == 0 or (even == 0 and n % 2 == 0)) {         cout <<  NO  << endl;       } else {         cout <<  YES  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long i, j, n, m, a, b, s = 0, e1, e2, o1, o2;     long long t;     cin >> t;     while (t--) {       e1 = e2 = o1 = o2 = 0;       cin >> n;       for (int i = 0; i < n; i++) {         cin >> a;         if (a & 1)           o1++;         else           e1++;       }       cin >> m;       for (int i = 0; i < m; i++) {         cin >> b;         if (b & 1)           o2++;         else           e2++;       }       cout << o1 * o2 + e1 * e2 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 400050;   int n, x;   long long w;   vector<long long> val[4];   int Abs(int a) { return a < 0 ? -a : a; }   int main() {     scanf( %d , &n);     long long sum = 0;     for (int i = 0; i < n; i++) {       scanf( %d%I64d , &x, &w);       if (x == 11)         val[0].push_back(w), sum += w;       else if (x == 1)         val[1].push_back(w), sum += w;       else if (x == 10)         val[2].push_back(w), sum += w;       else         val[3].push_back(w);     }     int len = val[3].size();     int cnt = n - len;     int num = min(val[1].size(), val[2].size());     num += val[0].size();     for (int i = 0; i < 4; i++) sort(val[i].begin(), val[i].end());     long long ans = sum;     int now1 = 0, now2 = 0;     if (num * 2 < cnt) {       ans = 0;       int no = Abs(val[1].size() - val[2].size());       if (val[2].size() < val[1].size()) {         for (int i = 0; i < no; i++) {           if (num * 2 >= cnt) break;           sum -= val[1][i];           cnt--;           now1++;           if (num * 2 >= cnt) ans = max(ans, sum);         }       } else {         for (int i = 0; i < no; i++) {           if (num * 2 >= cnt) break;           sum -= val[2][i];           cnt--;           now2++;           if (num * 2 >= cnt) ans = max(ans, sum);         }       }       if (num * 2 >= cnt) ans = max(ans, sum);     }     if (num * 2 > cnt) {       ans = sum;       int pos = 1;       while (num * 2 >= cnt) {         if (pos > len) break;         if (num * 2 >= (cnt + 1)) {           sum += val[3][len - pos];           ans = max(ans, sum);           cnt++;         } else           break;         pos++;       }       if (num * 2 >= cnt) ans = max(ans, sum);       int no = Abs(val[2].size() - val[1].size());       if (val[2].size() > val[1].size()) {         for (int i = now2; i < no; i++) {           if (pos + i - now2 > len) break;           sum -= val[2][i];           sum += val[3][len - i + now2 - pos];           if (num * 2 >= cnt) ans = max(ans, sum);         }       } else {         for (int i = now1; i < no; i++) {           if (pos + i - now1 > len) break;           sum -= val[1][i];           sum += val[3][len - i + now1 - pos];           if (num * 2 >= cnt) ans = max(ans, sum);         }       }     } else if (num * 2 == cnt) {       int no = Abs(val[2].size() - val[1].size());       if (val[2].size() > val[1].size()) {         for (int i = now2; i < no; i++) {           if (i - now2 >= len) break;           sum -= val[2][i];           sum += val[3][len - i + now2 - 1];           if (num * 2 >= cnt) ans = max(ans, sum);         }       } else {         for (int i = now1; i < no; i++) {           if (i - now1 >= len) break;           sum -= val[1][i];           sum += val[3][len - i + now1 - 1];           if (num * 2 >= cnt) ans = max(ans, sum);         }       }     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int r, c;     cin >> r;     cin >> c;     vector<vector<bool> > a(r);     for (int i = 0; i < r; i++) a[i].resize(c);     char t_c;     for (int i = 0; i < r; i++) {       for (int j = 0; j < c; j++) {         cin >> t_c;         if (t_c ==  . )           a[i][j] = true;         else           a[i][j] = false;       }     }     vector<vector<bool> > b(r);     vector<vector<bool> > d(r);     b = a;     d = a;     b[0][0] = true;     d[r - 1][c - 1] = true;     for (int i = 1; i <= r + c - 2; i++) {       for (int j = max(0, i - c + 1); j <= min(r - 1, i); j++) {         b[j][i - j] = false;         if (a[j][i - j] == true) {           if (j != 0)             if (b[j - 1][i - j] == true) b[j][i - j] = true;           if (i - j != 0)             if (b[j][i - j - 1] == true) b[j][i - j] = true;         }       }     }     for (int i = r + c - 3; i >= 0; i--) {       for (int j = max(0, i - c + 1); j <= min(r - 1, i); j++) {         d[j][i - j] = false;         if (a[j][i - j] == true) {           if (j != r - 1)             if (d[j + 1][i - j] == true) d[j][i - j] = true;           if (i - j != c - 1)             if (d[j][i - j + 1] == true) d[j][i - j] = true;         }       }     }     bool weak = false;     for (int i = 1; i <= r + c - 3; i++) {       int cnt1 = 0;       for (int j = max(0, i - c + 1); j <= min(r - 1, i); j++) {         if (b[j][i - j] && d[j][i - j]) cnt1++;       }       if (cnt1 < 2) weak = true;     }     if (!d[0][0])       cout <<  0 ;     else if (weak)       cout <<  1 ;     else       cout <<  2 ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100 + 5;   const long long MOD = 1000000007;   long long pow2[MAXN];   char x[MAXN];   int main() {     scanf( %s , x);     int n = strlen(x);     pow2[0] = 1;     for (int i = 1; i < n; i++) pow2[i] = (pow2[i - 1] * 2) % MOD;     long long d = pow2[n - 1], ans = 0;     for (int i = 0; i < n; i++)       if (x[i] ==  1 ) ans = (ans + pow2[n - i - 1] * d) % MOD;     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = 1000000 + 20;   int pos[MAX_N], mark[MAX_N];   int inter[MAX_N];   set<int> D;   long long ans;   int n, k;   void add(int x) {     for (; x <= n; x += x & (-x)) ++inter[x];   }   int get(int x) {     if (x < 1) return 0;     int res = 0;     for (; x > 0; x -= x & (-x)) res += inter[x];     return res;   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> k;     for (int i = 0; i < n; i++) {       int x;       cin >> x;       pos[x] = i + 1;     }     for (int i = 0; i < k; ++i) {       int x;       cin >> x;       mark[x] = 1;     }     D.insert(0);     D.insert(n + 1);     for (int i = 1; i <= n; ++i) {       if (mark[i])         D.insert(pos[i]);       else {         int l, r;         set<int>::iterator it = D.lower_bound(pos[i]);         r = *it - 1;         --it;         l = *it + 1;         ans += r - l + 1 - get(r) + get(l - 1);         add(pos[i]);       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   const long long inf = 1e18 + 9;   const long long MAX_SIZE = 1e7 + 1;   long long _t = 1, _T, csn;   long long max(long long a, long long b) {     if (a < b) return b;     return a;   }   long long min(long long a, long long b) {     if (a > b) return b;     return a;   }   long long mmi(long long a, long long m) {     long long m0 = m;     long long y = 0, x = 1;     if (m == 1) return 0;     while (a > 1) {       long long q = a / m;       long long t = m;       m = a % m, a = t;       t = y;       y = x - q * y;       x = t;     }     if (x < 0) x += m0;     return x;   }   long long nxor(long long n) {     if (n % 4 == 0) return n;     if (n % 4 == 1) return 1;     if (n % 4 == 2) return n + 1;     return 0;   }   long long sum(long long n) { return ((n * (n + 1)) / 2); }   long long modsum(long long n, long long m) {     long long ans = n % m;     ans *= (n + 1) % m;     ans %= m;     ans *= mmi(2, m);     return ans % m;   }   long long leap(long long y) {     if (y % 400 == 0)       return 1;     else if (y % 100 == 0)       return 0;     else if (y % 4 == 0)       return 1;     else       return 0;   }   void solve();   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(0);     bool multicases = 0;     if (multicases) cin >> _t;     _T = _t;     while (_t--) solve();     return 0;   }   void solve() {     csn = _T - _t;     long long n;     cin >> n;     ;     map<string, long long> m;     string s, ts;     vector<vector<pair<long long, string>>> ans;     for (long long i = 0; i < n; i += 1) {       cin >> s;       vector<pair<long long, string>> tv;       for (long long j = 0; j < 9; j += 1) {         for (long long k = 1; k < 9 - j + 1; k += 1) {           ts = s.substr(j, k);           m[ts]++;           tv.emplace_back(make_pair(k, ts));         }       }       sort(tv.begin(), tv.end());       for (long long j = 1; j < tv.size(); j += 1)         if (tv[j].second == tv[j - 1].second) m[tv[j].second]--;       ans.emplace_back(tv);     }     for (long long i = 0; i < n; i += 1) {       for (long long j = 0; j < ans[i].size(); j += 1)         if (m[ans[i][j].second] == 1) {           cout << ans[i][j].second <<   n ;           ;           break;         }     }     return;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5005;   int n, a, b, k;   int d[3][N];   int sum[N];   int ans = 0;   int cur = 1;   int main() {     scanf( %d%d%d%d , &n, &a, &b, &k);     d[0][a] = 1;     for (int cnt = 1; cnt <= k; ++cnt) {       for (int i = 1; i <= n; ++i)         sum[i] = (sum[i - 1] + d[cur ^ 1][i]) % 1000000007;       for (int i = 1; i <= n; ++i) {         if (i == b) continue;         if (i < b) {           int r = i + (b - i) / 2;           if ((b - i) % 2 == 0) --r;           d[cur][i] = (sum[r] - d[cur ^ 1][i] + 1000000007) % 1000000007;         } else {           int l = i - (i - b) / 2;           if ((i - b) % 2 == 0) ++l;           d[cur][i] = (((sum[n] - sum[l - 1] - d[cur ^ 1][i]) % 1000000007) +                        1000000007) %                       1000000007;         }       }       cur ^= 1;     }     for (int i = 1; i <= n; ++i) ans = (ans + d[cur ^ 1][i]) % 1000000007;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 9;   const int L = 20;   int par[N][L];   int up[N][L];   int h[N];   int to[N];   int s[N], t[N];   pair<int, int> edge[N];   vector<pair<int, int> > al[N];   int find(int v) {     if (to[v] == v) return v;     return to[v] = find(to[v]);   }   int unite(int u, int v) {     u = find(u), v = find(v);     to[u] = v;     return (u != v);   }   void dfs(int v, int p = -1) {     h[v] = (p + 1 ? h[p] + 1 : 0);     par[v][0] = p;     for (int i = 1; i < L; i++) {       if (par[v][i - 1] + 1) {         par[v][i] = par[par[v][i - 1]][i - 1];         up[v][i] = max(up[v][i - 1], up[par[v][i - 1]][i - 1]);       }     }     for (int i = 0; i < al[v].size(); i++) {       int u = al[v][i].first;       if (u == p) continue;       up[u][0] = al[v][i].second;       dfs(u, v);     }     return;   }   pair<int, int> go_up(int v, int x) {     int mx = 0;     for (int b = 0; b < L; b++)       if (x >> b & 1) mx = max(mx, up[v][b]), v = par[v][b];     return {v, mx};   }   int lca(int u, int v) {     if (h[u] < h[v]) swap(u, v);     u = go_up(u, h[u] - h[v]).first;     if (u == v) return v;     for (int b = L - 1; ~b; --b)       if (par[v][b] != par[u][b]) v = par[v][b], u = par[u][b];     return par[v][0];   }   int main() {     ios_base::sync_with_stdio(0);     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) to[i] = i;     for (int i = 0; i < m; i++) {       int u, v, w;       cin >> u >> v >> w;       --u, --v;       s[i] = u, t[i] = v;       edge[i] = {w, i};     }     sort(edge, edge + m);     long long ans = 0;     int p = 0;     for (int i = 0; i < m; i++) {       long long w = edge[i].first, id = edge[i].second;       int u = s[id], v = t[id];       if (unite(u, v)) {         ans += w, p++;         al[u].push_back({v, w});         al[v].push_back({u, w});       }     }     dfs(0);     int q;     cin >> q;     while (q--) {       int u, v;       cin >> u >> v;       --u, --v;       int pu = find(u), pv = find(v);       if ((p == n - 2 && pu == pv) || p < n - 2) {         cout << -1 <<   n ;         continue;       }       if (p == n - 2) {         cout << ans <<   n ;         continue;       }       int lc = lca(u, v);       cout << ans - max(go_up(u, h[u] - h[lc]).second,                         go_up(v, h[v] - h[lc]).second)            <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = 1999999999;   const double pi = acos(-1.0);   const double eps = 1e-10;   char gc() {     char c;     while (isspace(c = getchar()))       ;     return c;   }   int gs(char* s) {     gets(s);     int l = strlen(s);     while (l && isspace(s[l - 1])) s[--l] = 0;     return l;   }   int n;   double p[101];   double isok(double a) {     double tmn = 1e20, tmx = -1e20;     for (int i = 0; i <= n; i++) {       if (i * 2 > n) tmx = max(tmx, (p[i] - a) / (i - n / 2.));       if (i * 2 < n) tmn = min(tmn, (a - p[i]) / (n / 2. - i));     }     return tmn < tmx;   }   int main() {     scanf( %d , &n);     for (int i = 0; i <= n; i++) scanf( %lf , &p[i]);     double low = -0.001, mid, high = 1.001;     if ((n % 2) == 0) low = p[n / 2];     for (int i = 0; i < 60; i++) {       mid = (low + high) / 2;       if (isok(mid))         low = mid;       else         high = mid;     }     printf( %.10f n , (low + high) / 2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     vector<vector<string> > tab(9);     int emp[3][3];     memset(emp, 0, sizeof emp);     for (int i = 0; i < 9; i++) {       tab[i].resize(3);       for (int j = 0; j < 3; j++) {         string a;         cin >> a;         for (int k = 0; k < a.size(); k++) {           if (a[k] ==  . ) emp[i / 3][j]++;         }         tab[i][j] = a;       }     }     int n, m;     cin >> n >> m;     n--;     m--;     char ne;     int ln = n, lm = (m + 1) % 3;     if (tab[ln][lm][m % 3] ==  x )       ne =  o ;     else       ne =  x ;     n = n % 3;     m = m % 3;     if (emp[n][m] == 0) {       for (int i = 0; i < 9; i++) {         for (int j = 0; j < 3; j++) {           string a = tab[i][j];           for (int k = 0; k < 3; k++) {             if (a[k] ==  . ) tab[i][j][k] =  ! ;           }         }       }     } else {       for (int i = n * 3; i < (n + 1) * 3; i++) {         string a = tab[i][m];         for (int j = 0; j < 3; j++) {           if (a[j] ==  . ) tab[i][m][j] =  ! ;         }       }     }     for (int i = 0; i < 9; i++) {       if (i != 0 && i % 3 == 0) cout << endl;       for (int j = 0; j < 3; j++) {         cout << tab[i][j] <<    ;       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAXN = 1e6 + 10;   const long long INF = 8e18;   const long long MOD = 1e9 + 7;   inline long long poww(long long a, long long b) {     a %= MOD;     long long ans = 1;     while (b > 0) {       if (b & 1) ans = ans * a % MOD;       b >>= 1;       a = a * a % MOD;     }     return ans;   }   long long fact[MAXN], inv[MAXN], n, k, ans, F[MAXN];   inline long long C(int k, int n) {     return fact[n] * inv[k] % MOD * inv[n - k] % MOD;   }   inline void mkey(long long& a) {     if (a >= MOD) a -= MOD;     if (a < 0) a += MOD;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> k;     fact[0] = inv[0] = 1;     for (int i = 1; i < MAXN; i++)       fact[i] = fact[i - 1] * i % MOD, inv[i] = poww(fact[i], MOD - 2);     F[0] = 1;     for (int i = 1; i <= n; i++) {       F[i] = i * F[i - 1] % MOD;       if (i > k) mkey(F[i] -= C(k, i - 1) * fact[k] % MOD * F[i - k - 1] % MOD);     }     for (int i = 1; i <= n; i++)       mkey(ans += C(i - 1, n - 1) * F[i - 1] % MOD * fact[n - i] % MOD);     cout << (fact[n] - ans + MOD) % MOD <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[105], c[105];   int findz(int n) { return a[n] == n ? a[n] : a[n] = findz(a[n]); }   void un(int x, int y) { a[findz(x)] = findz(y); }   int main() {     int n, l, f;     cin >> n >> l;     int count = 0;     int wei = 0;     memset(c, 0, sizeof(c));     for (int i = 1; i <= l; i++) a[i] = i;     for (int i = 0; i < n; i++) {       int z;       cin >> z;       if (z >= 1) {         cin >> f;         c[f]++;       } else         count++;       for (int j = 1; j < z; j++) {         int b;         cin >> b;         c[b]++;         un(f, b);       }     }     set<int> s;     for (int i = 1; i <= l; i++) {       s.insert(findz(i));       if (c[i] == 0) wei++;     }     if (s.size() - wei == 0) {       cout << count;     } else {       cout << count + s.size() - wei - 1;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline long long mod(long long n) { return (n % 1000000007); }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, m;     cin >> n;     vector<long long> v(n);     map<long long, long long> has, cnt;     for (long long i = 0; i < n; i++) {       cin >> v[i];     }     cin >> m;     for (long long i = 0; i < m; i++) {       long long x;       cin >> x;       has[v[x - 1]]++;     }     long long sz = has.size();     while (v.size() < n + 5 * m) {       for (long long i = n - 2; i >= 0; i--) v.push_back(v[i]);       for (long long i = 1; i < n; i++) v.push_back(v[i]);     }     set<long long> possible;     long long cur = 0;     long long match = 0;     for (long long i = 0; i < m; i++) {       if (cnt[v[i]] == has[v[i]] && cnt[v[i]] > 0) match--;       cnt[v[i]]++;       if (cnt[v[i]] == has[v[i]] && cnt[v[i]] > 0) match++;       cur += abs(v[i] - (i - 1 >= 0 ? v[i - 1] : 0));       if (i == 0) cur -= v[i];       if (match == sz) possible.insert(cur);     }     for (long long i = m; i < n + 5 * m; i++) {       if (cnt[v[i - m]] == has[v[i - m]] && cnt[v[i - m]] > 0) match--;       cnt[v[i - m]]--;       if (cnt[v[i - m]] == has[v[i - m]] && cnt[v[i - m]] > 0) match++;       if (cnt[v[i]] == has[v[i]] && cnt[v[i]] > 0) match--;       cnt[v[i]]++;       if (cnt[v[i]] == has[v[i]] && cnt[v[i]] > 0) match++;       cur += abs(v[i] - (i - 1 >= 0 ? v[i - 1] : 0));       cur -= abs(v[i - m + 1] - (i - m >= 0 ? v[i - m] : 0));       if (match == sz) possible.insert(cur);     }     if (possible.size() > 1)       cout << -1 <<   n ;     else if (possible.size() == 0)       cout << -1 <<   n ;     else       cout << *possible.begin() <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int invertir(int n) {     int r = 0;     while (n > 0) {       r = r * 10 + (n % 10);       n = n / 10;     }     return r;   }   int main() {     int a, b;     cin >> a >> b;     cout << (a + invertir(b));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n;   int m;   const long long mod = 1e9 + 7;   struct Mat {     long long mat[111][111];   } st, ed;   long long stt[111][111];   void init() {     memset(stt, 0, sizeof(stt));     stt[0][0] = stt[0][m - 1] = 1;     for (int i = 1; i < m; ++i) stt[i][i - 1] = 1;     for (int i = 0; i < m; ++i)       for (int j = 0; j < m; ++j) st.mat[i][j] = stt[i][j];   }   Mat mul(Mat a, Mat b) {     Mat ret;     for (int i = 0; i < m; ++i)       for (int j = 0; j < m; ++j) {         ret.mat[i][j] = 0;         for (int k = 0; k < m; ++k)           (ret.mat[i][j] += a.mat[i][k] * b.mat[k][j] % mod) %= mod;       }     return ret;   }   Mat pow(Mat a, long long b) {     Mat ret;     memset(ret.mat, 0, sizeof(ret.mat));     for (int i = 0; i < m; ++i) ret.mat[i][i] = 1;     while (b) {       if (b & 1) ret = mul(ret, a);       a = mul(a, a);       b >>= 1;     }     return ret;   }   int main() {     cin >> n >> m;     if (n < m) return 0 * puts( 1 );     init();     ed = pow(st, n - m + 1);     long long ans = 0;     for (int i = 0; i < m; ++i) (ans += ed.mat[0][i]) %= mod;     cout << ans << (  n );   }