malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int iinf = 1e9 + 7;   const long long linf = 1ll << 60;   const double dinf = 1e10;   template <typename T>   inline void scf(T &x) {     bool f = 0;     x = 0;     char c = getchar();     while ((c <  0  || c >  9 ) && c !=  - ) c = getchar();     if (c ==  - ) {       f = 1;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = x * 10 + c -  0 ;       c = getchar();     }     if (f) x = -x;     return;   }   template <typename T1, typename T2>   void scf(T1 &x, T2 &y) {     scf(x);     return scf(y);   }   template <typename T1, typename T2, typename T3>   void scf(T1 &x, T2 &y, T3 &z) {     scf(x);     scf(y);     return scf(z);   }   const int N = 233;   int n, l, k;   int p[N], a[N];   double dp[N][N][N * 2];   int main() {     scf(n, l, k);     for (int i = (1); i <= (n); i++) scf(p[i]);     for (int i = (1); i <= (n); i++) scf(a[i]);     dp[0][0][k + 200] = 1.0;     for (int i = 0; i < (n); i++)       for (int j = (0); j <= (i); j++)         for (int k = (0); k <= (400); k++)           if (dp[i][j][k] > 1e-20) {             dp[i + 1][j][k] += dp[i][j][k] * (1.0 * (100 - p[i + 1]) / 100.0);             int nxtk = k;             if (a[i + 1] < 0)               nxtk--;             else               nxtk += a[i + 1];             if (nxtk > 400) nxtk = 400;             if (k >= 0)               dp[i + 1][j + 1][nxtk] += dp[i][j][k] * (1.0 * p[i + 1] / 100.0);           }     double ans = 0.0;     for (int j = (l); j <= (n); j++)       for (int k = (200); k <= (400); k++) ans += dp[n][j][k];     printf( %.12f n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long int t;     cin >> t;     while (t--) {       int n, m;       cin >> n >> m;       vector<int> v1(n), v2(m);       vector<int> v;       for (auto &x : v1) cin >> x;       for (auto &x : v2) cin >> x;       for (int i = 0; i < n; i++)         for (int j = 0; j < m; j++) {           if (v1[i] == v2[j]) v.push_back(v1[i]);         }       if (v.size()) {         cout <<  Yes  <<   n ;         cout << 1 <<     << v[0] <<   n ;       } else         cout <<  No  <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   static int LOCAL = 0;   const long long int mod = 1000000007ll;   const long long int MOD = 1000000009ll;   const long long int INF = LLONG_MAX / 10;   const int inf = INT_MAX / 10;   long long int powermod(long long int _a, long long int _b,                          long long int _m = mod) {     long long int _r = 1;     while (_b) {       if (_b % 2 == 1) _r = (_r * _a) % _m;       _b /= 2;       _a = (_a * _a) % _m;     }     return _r;   }   long long int power(long long int _a, long long int _b) {     long long int _r = 1;     while (_b) {       if (_b % 2 == 1) _r = (_r * _a);       _b /= 2;       _a = (_a * _a);     }     return _r;   }   long long int add(long long int a, long long int b, long long int m = mod) {     long long int x = a + b;     while (x >= m) x -= m;     return x;   }   long long int sub(long long int a, long long int b, long long int m = mod) {     long long int x = a - b;     while (x < 0) x += m;     return x;   }   long long int mul(long long int a, long long int b, long long int m = mod) {     return ((a % m) * (b % m)) % m;   }   long long int gcd(long long int a, long long int b) {     while (a && b) a > b ? a %= b : b %= a;     return a + b;   }   long long int lcm(long long int a, long long int b) {     return (max(a, b) / gcd(a, b)) * min(a, b);   }   struct pair_hash {     std::size_t operator()(const std::pair<int, int> &p) const {       auto h1 = std::hash<long long int>{}(p.first);       auto h2 = std::hash<long long int>{}(p.second);       return (int)add(h1, mul(h2, h1, MOD));     }   };   struct cmp {     bool operator()(pair<int, pair<long long int, long long int> > const &l,                     pair<int, pair<long long int, long long int> > const &r) {       return l.second.first < r.second.first;     }   } myobject;   multiset<int> second;   int main() {     int n, x;     cin >> n;     double sum = 0;     for (int i = 1; i <= n; i++) scanf( %d , &x), second.insert(x), sum += x;     double avg = sum / n;     int cnt = 0;     while (!(avg >= 4.50)) {       x = *second.begin();       second.erase(second.begin());       sum -= x;       sum += 5;       avg = sum / n;       cnt++;     }     cout << cnt;     return 0;   }
/* Author: EndlessK    * Time: 2021-05-06 20:40:25   **/   #include<bits/stdc++.h>   #define maxn 100010   #define pb push_back   #define ll long long   #define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)   using namespace std;   int main()   {       fast;       int t;       cin>>t;       map<int,int> mp;       while(t--)       {           int n;           int ans=0;           cin>>n;           for(int i=1;i<=min(9,n);i++)           {               ans++;           }           for(int i=11;i<=min(99,n);i+=11)           {               ans++;           }           for(int i=111;i<=min(999,n);i+=111)           {               ans++;           }           for(int i=1111;i<=min(9999,n);i+=1111)           {               ans++;           }           for(int i=11111;i<=min(99999,n);i+=11111)           {               ans++;           }           for(int i=111111;i<=min(999999,n);i+=111111)           {               ans++;           }           for(int i=1111111;i<=min(9999999,n);i+=1111111)           {               ans++;           }           for(int i=11111111;i<=min(99999999,n);i+=11111111)           {               ans++;           }           for(int i=111111111;i<=min(999999999,n);i+=111111111)           {               ans++;           }           cout<<ans<<  n ;       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool way[5003][5003];   int dis[5003], counter;   vector<pair<int, int> > edge[5003], child[5003];   priority_queue<pair<int, int> > pq[5003];   void cari(int pos) {     int j, sz;     sz = edge[pos].size();     for (j = 0; j < sz; ++j) {       if (way[pos][edge[pos][j].first]) {         way[pos][edge[pos][j].first] = false;         way[edge[pos][j].first][pos] = false;         child[pos].push_back(edge[pos][j]);         cari(edge[pos][j].first);       }     }   }   void cek(int posisi, int time) {     int i, j, x, size, sz;     sz = child[posisi].size();     for (i = 0; i < sz; ++i) {       x = child[posisi][i].first;       size = child[posisi][i].second;       for (j = 0; j < size; ++j) {         if (pq[x].empty()) break;         pq[posisi].push(pq[x].top());         if (posisi == 1) {           dis[pq[x].top().second] = time;           ++counter;         }         pq[x].pop();       }       cek(x, time);     }   }   int main() {     int i, a, b, c, n, sz, arrive, dummy, division[5003];     scanf( %d , &n);     for (i = 1; i <= n; ++i) scanf( %d , &division[i]);     memset(way, true, sizeof(way));     for (i = 1; i < n; ++i) {       scanf( %d %d %d , &a, &b, &c);       edge[a].push_back(make_pair(b, c));       edge[b].push_back(make_pair(a, c));     }     cari(1);     for (i = 2; i <= n; ++i) pq[i].push(make_pair(-division[i], i));     sz = child[1].size();     dis[1] = 0;     int temp = 1;     counter = 1;     while (counter < n) {       cek(1, temp);       ++temp;     }     for (i = 1; i <= n; ++i) {       if (i != n)         printf( %d  , dis[i]);       else         printf( %d n , dis[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long GCD(long long a, long long b) {     if (b == 0) return a;     return (a % b == 0 ? b : GCD(b, a % b));   }   long long POW(long long base, long long exp) {     long long val;     val = 1;     while (exp > 0) {       if (exp % 2 == 1) {         val = (val * base) % 1000000007;       }       base = (base * base) % 1000000007;       exp = exp / 2;     }     return val;   }   int a[100005];   int pos[100005];   int main() {     int n, i, c, mx;     scanf( %d , &n);     for (i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     for (i = 1; i <= n; i++) {       pos[a[i]] = i;     }     mx = 0;     for (i = 1; i <= n; i++) {       c = 1;       while (i < n && pos[i + 1] > pos[i]) {         i++;         c++;       }       mx = max(mx, c);     }     printf( %d n , n - mx);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize(2)   using namespace std;   const int maxn = 2e5 + 10, mod = 1e9 + 7, inf = 0x3f3f3f3f;   int n, a[maxn];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     int _t;     cin >> _t;     while (_t--) {       cin >> n;       for (int i = 1; i <= n; i++) cin >> a[i];       bool isok = true;       sort(a + 1, a + 1 + n);       for (int i = 2; i <= n; i++)         if (a[i] - a[i - 1] > 1) isok = false;       (isok ? cout <<  YES n  : cout <<  NO n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000ll * 1000 * 1000 + 7;   int main() {     vector<string> name;     string str;     int n, m;     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> str;       name.push_back(str);     }     long long ans = 1ll;     for (int i = 0; i < m; i++) {       set<char> s;       for (int j = 0; j < n; j++) s.insert(name[j][i]);       ans = (ans * s.size()) % mod;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[26];   int A[26];   string s, t;   int x1, x2;   char c;   int main() {     cin >> s >> t;     for (int i = 0; i < t.size(); i++) {       c = t[i];       if (c > 96)         a[c - 97]++;       else         A[c - 65]++;     }     for (int i = 0; i < s.size(); i++) {       c = s[i];       if (c > 96) {         if (a[c - 97]) {           a[c - 97]--;           x1++;           s[i] =  0 ;         }       } else if (A[c - 65]) {         A[c - 65]--;         x1++;         s[i] =  0 ;       }     }     for (int i = 0; i < s.size(); i++) {       c = s[i];       if (c ==  0 ) continue;       if (c >= 97) {         c = c - 32;         if (A[c - 65]) {           x2++;           A[c - 65]--;         }       } else {         c = c + 32;         if (a[c - 97]) {           x2++;           a[c - 97]--;         }       }     }     cout << x1 <<     << x2 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200000 + 10;   int T, n, m, sum, du[maxn], K;   vector<pair<int, int> > p[maxn];   struct node {     int x, y;     long long val;     bool operator<(const node i) const { return val < i.val; }   } a[maxn];   queue<int> q2;   int b[maxn], cnt;   long long dis[1000][1000];   long long ans[maxn], sum1, INF;   int main() {     cin >> n >> m >> K;     for (int i = 1; i <= m; i++) {       scanf( %d %d %lld , &a[i].x, &a[i].y, &a[i].val);     }     sort(a + 1, a + m + 1);     int Mx = min(m, K);     memset(dis, 0x3f, sizeof(dis));     INF = dis[0][0];     for (int i = 1; i <= Mx; i++) {       if (!b[a[i].x]) {         cnt++;         b[a[i].x] = cnt;       }       if (!b[a[i].y]) {         cnt++;         b[a[i].y] = cnt;       }       dis[b[a[i].x]][b[a[i].y]] = dis[b[a[i].y]][b[a[i].x]] = a[i].val;     }     for (int i = 1; i <= cnt; i++) dis[i][i] = 0;     for (int k = 1; k <= cnt; k++) {       for (int i = 1; i <= cnt; i++) {         for (int j = 1; j <= cnt; j++) {           dis[i][j] = min(dis[i][k] + dis[k][j], dis[i][j]);         }       }     }     for (int i = 1; i <= cnt; i++) {       for (int j = i + 1; j <= cnt; j++) {         if (i != j && dis[i][j] != INF) {           ans[++sum1] = dis[i][j];         }       }     }     sort(ans + 1, ans + sum1 + 1);     cout << ans[K] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct online_hull {     map<int, int> points;     long long area;     inline online_hull() {       points.clear();       area = 0;     }     inline map<int, int>::iterator prev(map<int, int>::iterator it) {       return it == points.begin() ? it : --it;     }     inline map<int, int>::iterator next(map<int, int>::iterator it) {       return it == points.end() ? it : ++it;     }     inline long long traparea(long long x1, long long y1, long long x2,                               long long y2) {       return (x2 - x1) * (y1 + y2);     }     inline long long triarea(long long x1, long long y1, long long x2,                              long long y2, long long x3, long long y3) {       return traparea(x1, y1, x2, y2) + traparea(x2, y2, x3, y3) +              traparea(x3, y3, x1, y1);     }     inline long long traparea(map<int, int>::iterator a,                               map<int, int>::iterator b) {       return traparea(a->first, a->second, b->first, b->second);     }     inline long long triarea(map<int, int>::iterator it) {       long long sum = 0;       if (it != points.begin()) sum += traparea(prev(it), it);       if (next(it) != points.end()) sum += traparea(it, next(it));       if (it != points.begin() && next(it) != points.end())         sum += traparea(next(it), prev(it));       return sum;     }     inline bool bad(map<int, int>::iterator it) {       if (points.size() < 3 || it == points.begin() || next(it) == points.end())         return false;       return triarea(it) <= 0;     }     inline bool insert(int x, int y) {       if (points.find(x) != points.end()) {         if (y <= points[x]) return false;         area -= triarea(points.find(x));         points.erase(x);       }       map<int, int>::iterator it = points.insert(make_pair(x, y)).first;       if (bad(it)) {         points.erase(it);         return false;       }       area += triarea(it);       while (bad(prev(it))) {         area -= triarea(prev(it));         points.erase(prev(it));       }       while (bad(next(it))) {         area -= triarea(next(it));         points.erase(next(it));       }       return true;     }     inline bool contains(int x, int y) {       if (points.empty()) return false;       map<int, int>::iterator first = points.begin(), last = prev(points.end());       if (x < first->first || x > last->first) return false;       if (x == first->first) return y <= first->second;       if (x == last->first) return y <= last->second;       map<int, int>::iterator it = points.lower_bound(x), p = prev(it);       return triarea(p->first, p->second, x, y, it->first, it->second) <= 0;     }   };   int Q;   online_hull upper, lower;   int main() {     scanf( %d , &Q);     while (Q-- > 0) {       int type, x, y;       scanf( %d %d %d , &type, &x, &y);       if (type == 1) {         upper.insert(x, y);         lower.insert(x, -y);       } else if (type == 2)         puts((upper.contains(x, y) && lower.contains(x, -y)) ?  YES  :  NO );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<string, int> id;   inline int getID(string s) {     if (id.find(s) == id.end()) {       int sz = id.size();       id[s] = sz;     }     return id[s];   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, a, b, k, f;     cin >> n >> a >> b >> k >> f;     map<pair<int, int>, int> rcost;     int last = -1, sum = 0;     for (int i = 0; i < n; ++i) {       string u, v;       cin >> u >> v;       int su = getID(u);       int sv = getID(v);       if (last == su) {         rcost[pair<int, int>(min(su, sv), max(su, sv))] += b;         sum += b;       } else {         rcost[pair<int, int>(min(su, sv), max(su, sv))] += a;         sum += a;       }       last = sv;     }     vector<int> diff;     for (auto it = rcost.begin(); it != rcost.end(); it++) {       int cost = it->second;       if (cost > f) {         diff.push_back(cost - f);       }     }     sort(diff.rbegin(), diff.rend());     for (int i = 0; i < min((int)diff.size(), k); ++i) {       sum -= diff[i];     }     cout << sum;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int two(int n) { return 1 << n; }   inline void set_bit(int& n, int b) { n |= two(b); }   inline void unset_bit(int& n, int b) { n &= ~two(b); }   inline int last_bit(int n) { return n & (-n); }   template <class T>   T gcd(T a, T b) {     return (b != 0 ? gcd<T>(b, a % b) : a);   }   template <class T>   T lcm(T a, T b) {     return (a / gcd<T>(a, b) * b);   }   int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};   const double pi = 2 * acos(0.0);   const int mod = 1000000;   int main() {     std::ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     ;     long long m, n;     cin >> m >> n;     double res = m;     for (int i = 1; i < m; i++) {       res -= pow(i / double(m), n);     }     cout << fixed << setprecision(10) << res;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2005;   const long long inf = 0x3f3f3f3f3f3f3f3f;   const int mod = 998244353;   vector<int> ga[N], gb[N];   int n, a, b;   int ca[N], cb[N];   int dp[N][N][2];   int ha[N], hb[N];   int lfta[N], rgta[N], lftb[N], rgtb[N];   int cnta, cntb;   int faa[N][11], fab[N][11];   void dfsa(int u, int last) {     lfta[u] = ++cnta;     ha[u] = ha[last] + 1;     for (int i = 1; i < 11; i++) faa[u][i] = faa[faa[u][i - 1]][i - 1];     for (auto v : ga[u]) {       if (v == last) continue;       faa[v][0] = u;       dfsa(v, u);     }     rgta[u] = cnta;   }   void dfsb(int u, int last) {     lftb[u] = ++cntb;     hb[u] = hb[last] + 1;     for (int i = 1; i < 11; i++) fab[u][i] = fab[fab[u][i - 1]][i - 1];     for (auto v : gb[u]) {       if (v == last) continue;       fab[v][0] = u;       dfsb(v, u);     }     rgtb[u] = cntb;   }   int costa(int u, int v) {     int x = u;     if (!v) return ha[u] - 1;     for (int i = 10; i >= 0; i--) {       if (!faa[x][i]) continue;       if (lfta[faa[x][i]] <= lfta[v] && rgta[faa[x][i]] >= rgta[v]) continue;       x = faa[x][i];     }     return ha[u] - ha[x] + 1;   }   int costb(int u, int v) {     int x = u;     if (!v) return hb[u] - 1;     for (int i = 10; i >= 0; i--) {       if (!fab[x][i]) continue;       if (lftb[fab[x][i]] <= lftb[v] && rgtb[fab[x][i]] >= rgtb[v]) continue;       x = fab[x][i];     }     return hb[u] - hb[x] + 1;   }   int main() {     int i, j;     cin >> n;     cin >> a;     for (i = 2; i <= a; i++) {       int fa;       cin >> fa;       ga[i].push_back(fa);       ga[fa].push_back(i);     }     for (i = 1; i <= n; i++) cin >> ca[i];     cin >> b;     for (i = 2; i <= b; i++) {       int fa;       cin >> fa;       gb[i].push_back(fa);       gb[fa].push_back(i);     }     for (i = 1; i <= n; i++) cin >> cb[i];     dfsa(1, 0);     dfsb(1, 0);     memset(dp, 0x3f, sizeof(dp));     dp[0][0][0] = dp[0][0][1] = 0;     for (i = 1; i <= n; i++) {       for (j = 0; j < i; j++) {         dp[i][j][0] = min(dp[i][j][0], dp[i - 1][j][0] + costa(ca[i], ca[i - 1]));         dp[i][j][1] = min(dp[i][j][1], dp[i - 1][j][1] + costb(cb[i], cb[i - 1]));         dp[i][i - 1][0] =             min(dp[i][i - 1][0], dp[i - 1][j][1] + costa(ca[i], ca[j]));         dp[i][i - 1][1] =             min(dp[i][i - 1][1], dp[i - 1][j][0] + costb(cb[i], cb[j]));       }     }     int ans = 0x3f3f3f3f;     for (i = 0; i < n; i++) {       ans = min(ans, dp[n][i][0]);       ans = min(ans, dp[n][i][1]);     }     cout << (a - 1) + (b - 1) - ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct th {     int id, num;     th() { id = 0, num = 0; }     th(int a, int b) { id = a, num = b; }     bool operator<(const th &a) const {       if (num != a.num) return num < a.num;       return id < a.id;     }   };   set<th> x;   vector<int> ns[1000005];   int n, m;   int hp[1000005];   long long dv = 0;   int a[1000005];   long long sm = 0;   void work(int bg, int n) {     if (!n)       return;     else {       if (bg == m) a[bg] = n;       while (1) {         set<th>::iterator t = x.end();         t--;         if ((*t).num < n) break;         th n1 = (*t);         x.erase(n1);         int nd = n1.num / n;         for (int j = bg; j <= m; j++)           for (int tm = 0; tm < nd; tm++) ns[j].push_back(n1.id);         sm -= nd * n;         n1.num %= n;         x.insert(n1);       }       if (bg == m) return;       set<th>::iterator q = x.begin();       int nt = sm / n;       a[bg] = (*q).num;       ns[bg].push_back((*q).id);       x.erase(q);       sm -= nt * a[bg];       if (a[bg]) {         set<th>::iterator t = x.begin();         for (int j = 1; j < nt; j++) {           th q1 = *t;           t++;           x.erase(q1);           ns[bg].push_back(q1.id);           q1.num -= a[bg];           x.insert(q1);         }       }       work(bg + 1, n - a[bg]);     }   }   int main() {     scanf( %d%d , &n, &m);     long long sum = 0;     for (int i = 1; i <= m; i++) {       scanf( %d , &hp[i]);       sum += hp[i];     }     dv = sum / n;     if (sum % n) dv++;     sum = dv * n;     sm = sum;     for (int i = 1; i < m; i++) sum -= hp[i];     hp[m] = sum;     for (int i = 1; i <= m; i++) x.insert(th(i, hp[i]));     work(1, n);     cout << dv << endl;     for (int i = 1; i <= m; i++) printf( %d  , a[i]);     printf(  n );     for (int j = 1; j <= m; j++)       while (ns[j].size() < dv) ns[j].push_back(1);     for (int i = 1; i <= dv; i++) {       for (int j = 1; j <= m; j++) printf( %d  , ns[j][i - 1]);       printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, m;   int arr[50];   int sub[50];   int result = 0;   int task_tot_time = 0;   void take(int score, int t) {     if (0 >= t) return;     int tt = t;     int ss = score;     for (decltype(0) i = 0; i < k; i++) {       int su = sub[i];       while (su > 0) {         if (arr[i] > tt) break;         ss++;         tt -= arr[i];         su--;       }     }     result = max(result, ss);     if (t >= task_tot_time) {       int task_left = sub[0];       for (decltype(1) i = 1; i < k; i++) task_left = min(task_left, sub[i]);       if (task_left == 0) return;       for (decltype(0) i = 0; i < k; i++) sub[i]--;       result = max(result, score + k + 1);       take(score + k + 1, t - task_tot_time);     }   }   int main() {     scanf( %d , &n) == 0, scanf( %d , &k) == 0, scanf( %d , &m) == 0;     for (decltype(0) i = 0; i < k; i++) {       scanf( %d , &arr[i]) == 0;       task_tot_time += arr[i];     }     for (decltype(0) i = 0; i < k; i++) sub[i] = n;     sort(arr, arr + k);     take(0, m);     printf( %d , result);   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 110;   const int MOD = 1e9 + 7;   long long n, k, dp[MAXN][MAXN][MAXN], local[MAXN][MAXN];   vector<int> adj[MAXN];   void add(long long& v, long long u) { v = (v + u) % MOD; }   void dfs(int v, int par = -1) {     dp[v][1][0] = dp[v][0][1] = 1;     for (auto i : adj[v]) {       if (i == par) continue;       dfs(i, v);       for (int w = 0; w < 23; w++)         for (int j = 0; j < 50; j++) {           local[w][j] = dp[v][w][j];           dp[v][w][j] = 0;         }       for (int a = 0; a <= (k + 1); a++)         for (int b = 0; b <= (2 * k + 1); b++)           for (int c = 0; c <= (k + 1); c++)             for (int d = 0; d <= (2 * k + 1); d++) {               int locala = 0;               if (!d) locala = b;               if (!b && d) locala = d + 1;               if (b && d) locala = min(b, d + 1);               int localb = a;               if (localb && locala) {                 if ((localb - 1 + locala - 1) <= k) localb = 0;               }               int localc = c;               if (localc) localc++;               if (localc && locala) {                 if ((locala - 1 + localc - 1) <= k) localc = 0;               }               int locald = 0;               if (!localc) locald = localb;               if (!localb && localc) locald = localc;               if (localb && localc) locald = max(localc, localb);               if (locald <= (k + 1) && locala <= (2 * k + 3))                 add(dp[v][locald][locala], local[a][b] * dp[i][c][d] % MOD);             }     }   }   int main() {     ios::sync_with_stdio(0);     cin >> n >> k;     for (int i = 1; i < n; i++) {       int u, v;       cin >> u >> v;       adj[u].push_back(v);       adj[v].push_back(u);     }     dfs(1);     long long answer = 0;     for (int i = 0; i <= (2 * k + 3); i++) answer = (answer + dp[1][0][i]) % MOD;     cout << answer << endl;     return 0;   }