malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, ans = 0, pot;     long long a, b, c, e;     cin >> n;     if (n <= 2) {       cout << n;       return 0;     }     for (long long i = n - 1e3; i <= n; i++) {       a = i;       b = i - 1;       e = a * b;       for (long long j = max(1LL, i - 50); j <= i - 2; j++) {         c = j;         pot = (e * c) / gcd(e, c);         ans = max(ans, pot);       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long fast_expo(long long base, long long exp, long long module) {     long long ans = 1;     while (exp) {       if (exp & 1) ans = (ans * base) % module;       base = (base * base) % module;       exp >>= 1;     }     return ans;   }   bool primes[100001];   void seive() {     memset(primes, true, sizeof(primes));     primes[0] = false;     primes[1] = false;     for (int i = 2; i * i <= 100000; i++) {       if (primes[i]) {         for (int j = i * i; j <= 100000; j += i) primes[j] = false;       }     }   }   bool isprime(int n) {     if (n == 1) return false;     if (n == 2) return true;     if (n % 2 == 0) return false;     for (int i = 3; i * i <= n; i += 2)       if (n % i == 0) return false;     return true;   }   long long gcd(long long a, long long b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   long long f[100001];   long long fib(long long n) {     if (n == 0) return 0;     if (n == 1 || n == 2) return (f[n] = 1);     if (f[n]) return f[n];     long long k = (n & 1) ? (n + 1) / 2 : n / 2;     f[n] = (n & 1) ? (fib(k) * fib(k) + fib(k - 1) * fib(k - 1))                    : (2 * fib(k - 1) + fib(k)) * fib(k);     return f[n];   }   int main() {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     int t1 = n % 10;     int t2 = t1;     int cnt1 = 0, cnt2 = 0;     if (t1 == 0) {       cout << n << endl;       return 0;     }     while (t1 <= 10) {       cnt1++;       t1++;     }     while (t2 > 0) {       t2--;       cnt2++;     }     if (cnt1 <= cnt2)       cout << (n + cnt1 - 1) << endl;     else       cout << (n - cnt2) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int MOD = 1000000007;   long long int gcd(long long int a, long long int b) {     if (b == 0)       return a;     else       return gcd(b, a % b);   }   long long int lcm(long long int a, long long int b) {     return a / gcd(a, b) * b;   }   long long int power(long long int a, long long int n) {     if (n == 0) return 1;     long long int p = power(a, n / 2);     p = (p * p) % MOD;     if (n % 2)       return (p * a) % MOD;     else       return p % MOD;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     long long int test = 1;     while (test--) {       long long int n, m, q;       cin >> n >> m >> q;       long long int c = gcd(n, m);       long long int q1 = n / c;       long long int q2 = m / c;       while (q--) {         long long int x1, y1, x2, y2;         cin >> x1 >> y1 >> x2 >> y2;         y1--;         y2--;         long long int secno1, secno2;         if (x1 == 1) {           secno1 = y1 / q1;         } else {           secno1 = y1 / q2;         }         if (x2 == 1) {           secno2 = y2 / q1;         } else {           secno2 = y2 / q2;         }         if (secno1 != secno2) {           cout <<  NO ;         } else {           cout <<  YES ;         }         cout <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     scanf( %d%d , &m, &n);     vector<int> a(n, 0);     for (int i = 0; m > 0; i = (i + 1) % n) {       a[i]++;       m--;     }     for (int i = 0; i < n; i++) printf( %d  , a[i]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a, b;   bool used[1000005];   int main() {     cin >> a >> b;     long long max_num = 0, s = 0, max_id;     for (;; max_num++) {       if (s + max_num + 1 > a + b) break;       s += max_num + 1;       max_id = max_num;     }     s = 0;     int cnt = 0;     for (long long i = max_num + 1; i > 1; i--) {       if (s + i - 1 > a) {         used[a - s] = 1;         if (a - s) cnt++;         break;       }       used[i - 1] = 1;       cnt++;       s += i - 1;     }     cout << cnt <<   n ;     for (int i = 1; i <= max_num; i++) {       if (used[i]) {         cout << i <<    ;       }     }     cout <<   n  << max_num - cnt <<   n ;     for (int i = 1; i <= max_num; i++) {       if (!used[i]) {         cout << i <<    ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   char BUF[500010];   int n, m;   int up[500010], down[500010], L[500010], R[500010];   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; ++i) {       scanf( %s , &BUF);       for (int j = 0; j < m; ++j) switch (BUF[j]) {           case  1 :             if (j & 1)               R[i] = 1;             else               L[i] = 1;             if (i & 1)               down[j] = 1;             else               up[j] = 1;             break;           case  2 :             if (j & 1)               R[i] = 1;             else               L[i] = 1;             if (i & 1)               up[j] = 1;             else               down[j] = 1;             break;           case  3 :             if (j & 1)               L[i] = 1;             else               R[i] = 1;             if (i & 1)               up[j] = 1;             else               down[j] = 1;             break;           case  4 :             if (j & 1)               L[i] = 1;             else               R[i] = 1;             if (i & 1)               down[j] = 1;             else               up[j] = 1;             break;         }     }     int ans = 1;     for (int i = 0; i < n; ++i) ans = (ans * (2 - L[i] - R[i])) % 1000003;     for (int i = 0; i < m; ++i) ans = (ans * (2 - up[i] - down[i])) % 1000003;     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 11, mod = 1e9 + 7;   const double EPS = 1e-7;   const int INF = 2e9;   const int base = 500;   const int dx[] = {1, -1, 0, 0};   const int dy[] = {0, 0, 1, -1};   int m, t, r, w[333], ans;   bool ct[333 + base + 11];   int main() {     if (fopen( string                 .in ,                r ))       freopen(            string             .in ,            r , stdin),           freopen(                string                 .out ,                w , stdout);     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> m >> t >> r;     for (int i = 1; i <= m; ++i) {       cin >> w[i];     }     for (int i = 1; i <= m; ++i) {       int candles = 0;       for (int j = w[i] - 1; j >= w[i] - t; --j) {         candles += ct[j + base];       }       if (candles < r) {         for (int j = w[i] - 1; j >= w[i] - t; --j) {           if (!ct[j + base] && candles < r) {             ct[j + base] = 1;             ++ans;             ++candles;           }         }         if (candles < r) {           return cout << -1, 0;         }       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MOD = 1e9 + 7;   const int MX = 2e5 + 5;   const long long INF = 1e18;   const long double PI = 4 * atan((long double)1);   template <class T>   bool ckmin(T& a, const T& b) {     return a > b ? a = b, 1 : 0;   }   template <class T>   bool ckmax(T& a, const T& b) {     return a < b ? a = b, 1 : 0;   }   set<int> v[26];   string ans;   int visited[26] = {0};   void dfs(int s) {     visited[s] = true;     ans += s +  a ;     for (auto& i : v[s]) {       if (visited[i] == false) dfs(i);     }   }   int main() {     int test;     cin >> test;     while (test--) {       string str;       cin >> str;       for (int i = 0; i < 26; i++) {         visited[i] = 0;         v[i].clear();       }       ans.clear();       int num1 = str.size();       for (int i = 1; i < num1; i++) {         v[str[i] -  a ].insert(str[i - 1] -  a );         v[str[i - 1] -  a ].insert(str[i] -  a );       }       int ok = 0;       for (int i = 0; i < 26; i++) {         if (v[i].size() > 2) {           ok = 1;           break;         }       }       if (ok == 1) {         cout <<  NO  << endl;       } else {         for (int i = 0; i < 26; i++) {           if (visited[i] == 0 && v[i].size() < 2) {             dfs(i);           }         }         bool ok = true;         for (int i = 0; i < 26; i++) {           if (visited[i] == 0) {             ok = false;           }         }         if (ok == false) {           cout <<  NO  << endl;         } else {           cout <<  YES  << endl;           cout << ans << endl;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   bool win(long long a, long long b) {     if (a < b) swap(a, b);     if (!b) return (false);     if (!win(b, a % b)) return (true);     long long p = a / b;     return (p % (b + 1) % 2 == 0);   }   int main() {     int T;     scanf( %d , &T);     while (T--) {       long long a, b;       scanf( %I64d%I64d , &a, &b);       printf( %s n , win(a, b) ?  First  :  Second );     }     return (0);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long n, m;     cin >> n >> m;     long long on[n + 2];     long long is[n + 1];     int inst[n + 2];     is[0] = 1;     int pval = m;     inst[0] = 0;     for (int i(1); i <= n; i++) {       cin >> inst[i];       if (is[i - 1] == 0) {         is[i] = 1;       } else         is[i] = 0;     }     inst[n + 1] = m;     if (is[n] == 1) {       on[n] = m - inst[n];       pval = inst[n];     } else {       on[n] = 0;       pval = inst[n];     }     for (int i(n - 1); i >= 1; --i) {       if (is[i] == 1) {         on[i] = on[i + 1] + (pval - inst[i]);         pval = inst[i];       } else {         on[i] = on[i + 1];         pval = inst[i];       }     }     on[0] = on[1] + inst[1] - 0;     pval = 0;     on[n + 1] = 0;     long long ans = on[0];     for (int i(0); i <= n; i++) {       if (inst[i + 1] - inst[i] < 2) {         continue;       } else {         long long l, m1, r;         l = on[0] - on[i];         m1 = inst[i + 1] - inst[i] - 1;         r = m - inst[i + 1] - on[i + 1];         ans = max(ans, l + m1 + r);       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   long long read() {     long long a = 0, b = getchar(), c = 1;     while (!isdigit(b)) c = b ==  -  ? -1 : 1, b = getchar();     while (isdigit(b)) a = a * 10 + b -  0 , b = getchar();     return a * c;   }   long long n, ans, p[200005];   pair<long long, long long> a[200005];   int main() {     n = read();     for (int i = 1; i <= n; i++) {       a[i].second = read();       p[i] = a[i].second;     }     for (int i = 1; i <= n; i++) a[i].first = read();     sort(a + 1, a + n + 1);     sort(p + 1, p + n + 1);     for (int i = 1; i <= n; i++)       ans += (lower_bound(p + 1, p + n + 1, a[i].second) - p - n + i - 1) *              a[i].second;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T abs(T t) {     return t < 0 ? -t : t;   }   const long long modn = 1000000007;   inline long long mod(long long x) { return x % modn; }   const int MAXN = 212345;   int n, m, k;   pair<long long, long long> s[MAXN];   long long d, v, V;   set<pair<long long, long long> > q;   void fail() {     puts( -1 );     exit(0);   }   int main() {     long long res = 0;     scanf( %lld %lld %d , &d, &v, &n);     V = v;     for (int a = 0; a < n; a++) scanf( %lld %lld , &s[a].first, &s[a].second);     sort(s, s + n);     s[n].first = d;     s[n].second = INT_MAX;     int i = 0, j = 0;     long long up = v;     while (i <= n && s[i].first <= v) {       q.insert(pair<long long, long long>(s[i].second, s[i].first));       i++;       ;     }     long long ult = 0;     while (j <= n) {       ;       v -= s[j].first - ult;       if (v < 0) {         ;         fail();       }       if (j == n) break;       pair<long long, long long> top = *q.begin();       swap(top.first, top.second);       while (i <= n && v < V && top == s[j]) {         ;         if (i <= n && v + s[i].first - up <= V) {           res += s[j].second * (s[i].first - up);           v += s[i].first - up;           up = s[i].first;           q.insert(pair<long long, long long>(s[i].second, s[i].first));           i++;         } else if (i <= n) {           res += s[j].second * (V - v);           up += V - v;           v = V;         }         top = *q.begin();         swap(top.first, top.second);       }       ult = s[j].first;       q.erase(pair<long long, long long>(s[j].second, s[j].first));       j++;     }     printf( %lld n , res);   }
#include <bits/stdc++.h>   using namespace std;   long long int GC(long long int a, long long int b) {     if (b == 0)       return a;     else       return GC(b, a % b);   }   long long int inv_gc(long long int a, long long int b) {     return a / GC(a, b) * b;   }   long long int Ceil(long long int a, long long int b) {     return a / b + (a % b != 0);   }   long long int fastModExp(long long int a, long long int b) {     long long int res = 1;     while (b > 0) {       if (b & 1) res = (res * a) % 1000000007;       a = (a * a) % 1000000007;       b = b >> 1;     }     return res;   }   map<int, int> par, rk;   void make_set() {     for (char i =  a ; i <=  z ; i++) {       par[i] = i;       rk[i] = 1;     }   }   int find(char x) {     if (x == par[x]) return x;     char p = find(par[x]);     par[x] = p;     return p;   }   int uni(char x, char y) {     char p1 = find(x);     char p2 = find(y);     if (p1 == p2) return 0;     if (rk[p1] > rk[p2]) {       par[p2] = p1;       rk[p1] += rk[p2];     } else {       par[p1] = p2;       rk[p2] += rk[p1];     }     return 1;   }   map<char, int> mpx;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     make_set();     int n;     vector<string> v;     cin >> n;     string s;     for (int i = 0; i < n; i++) {       cin >> s;       v.push_back(s);       if (s.length() > 1) {         for (int i = 0; i < s.length() - 1; i++) int r = uni(s[i], s[i + 1]);       }     }     for (int i = 0; i < v.size(); i++) {       mpx[find(v[i][0])] = 1;     }     long long int count = 0;     for (auto it = mpx.begin(); it != mpx.end(); it++)       if (it->second == 1) {         count++;       }     cout << count << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   const int P = 998244353;   int T, n;   int ans[N];   vector<int> e[N];   int f[N];   bool dfs(int x, int fa, int y) {     for (auto v : e[x])       if (v != fa && !dfs(v, x, y)) return 0;     if (f[x] % y == 0) {       f[fa]--;       return 1;     }     f[x]--;     if (f[x] % y == 0) return 1;     return 0;   }   int main() {     std::ios::sync_with_stdio(false);     std::cin.tie(nullptr);     cin >> T;     while (T--) {       cin >> n;       for (int i = 1; i <= n; i++) e[i].clear();       for (int i = 1; i < n; i++) {         int u, v;         cin >> u >> v;         e[u].push_back(v);         e[v].push_back(u);       }       if (n == 2) {         cout << 2 <<     << 0 <<   n ;       } else {         int rt = 0;         for (int i = 1; i <= n; i++)           if (((int)e[i].size()) > 1) rt = i;         for (int i = 1; i <= n; i++) ans[i] = 0;         for (int i = 1; i * i <= (n - 1); i++) {           if ((n - 1) % i) continue;           for (int j = 1; j <= n; j++) f[j] = ((int)e[j].size());           if (dfs(rt, 0, i)) ans[i] = 1;           for (int j = 1; j <= n; j++) f[j] = ((int)e[j].size());           if (dfs(rt, 0, (n - 1) / i)) ans[(n - 1) / i] = 1;         }         for (int i = 2; i <= n; i++)           for (int j = i + i; j <= n; j += i)             if (ans[j]) ans[i] = 0;         for (int i = 1; i < n; i++) ans[1] = 2 * ans[1] % P;         for (int i = 2; i <= n; i++) ans[1] = (ans[1] - ans[i] + P) % P;         for (int i = 1; i <= n; i++) cout << ans[i] <<    n [i == n];       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long con[2][2005][2005] = {0};   long long add[2][2005][2005] = {0};   long long can[2][2005][2005] = {0};   long long MOD = 1e9 + 7;   char all[2005][2005];   long long how[2][2005][2005];   int main() {     long long N, M, i, j, k, t = 0, l, r;     scanf( %lld %lld , &N, &M);     for (i = 0; i < N; i++) scanf( %s , all[i]);     t = 0;     for (i = 0; i < M; i++)       if (all[0][i] ==  R ) t++;     for (i = 1; i < M - t; i++) add[0][0][i] = con[0][0][i] = 1;     t = 0;     for (i = 0; i < N; i++)       if (all[i][0] ==  R ) t++;     for (i = 1; i < N - t; i++) add[1][i][0] = con[1][i][0] = 1;     for (i = 0; i < N; i++) {       how[0][i][M] = 0;       for (j = M - 1; j >= 0; j--)         how[0][i][j] = how[0][i][j + 1] + (all[i][j] ==  R );     }     for (i = 0; i < M; i++) {       how[1][N][i] = 0;       for (j = N - 1; j >= 0; j--)         how[1][j][i] = how[1][j + 1][i] + (all[j][i] ==  R );     }     for (i = 1; i < N; i++) {       for (j = 1; j < M; j++) {         t = 0;         l = 0;         r = N + 1;         while ((r - l) > 1) {           if (how[1][(r + l) / 2][j] >= N - i)             l = (r + l) / 2;           else             r = (r + l) / 2;         }         if (l >= i)           con[1][i][j] = 0;         else           con[1][i][j] += (add[0][i - 1][j] - add[0][l][j] + con[0][l][j] + MOD);         con[1][i][j] %= MOD;         add[1][i][j] = (add[1][i][j - 1] + con[1][i][j]) % MOD;         t = 0;         l = 0;         r = M + 1;         while ((r - l) > 1) {           if (how[0][i][(r + l) / 2] >= M - j)             l = (r + l) / 2;           else             r = (r + l) / 2;         }         if (l >= j)           con[0][i][j] = 0;         else           con[0][i][j] += (add[1][i][j - 1] - add[1][i][l] + con[1][i][l] + MOD);         con[0][i][j] %= MOD;         add[0][i][j] = (add[0][i - 1][j] + con[0][i][j]) % MOD;       }     }     if (N == 1 && M == 1)       printf( 1 n );     else       printf( %lld n , (con[0][N - 1][M - 1] + con[1][N - 1][M - 1]) % MOD);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int __gcd(long long int a, long long int b) {     return (a % b) ? __gcd(b, a % b) : b;   }   bool prime(long long int k) {     for (long long int i = 2; i * i <= k; i++)       if (k % i == 0) {         return false;       }     return true;   }   void pdash(int n = 1) {     for (int i = 0; i < n; i++) {       for (int j = 0; j < 30; j++) {         cout <<  - ;       }       cout <<   n ;     }   }   long long int cube_root(long long int a) {     long long int r = 1000000, l = 1;     long long int mid;     while (r - l > 1) {       mid = (r + l) >> 1;       if (mid * mid * mid == a) {         return mid;       } else if (mid * mid * mid > a) {         r = mid;       } else         l = mid;     }     if (l * l * l == a) return l;     if (r * r * r == a) return r;     return -1;   }   void solve() {     int n;     cin >> n;     long long int a, b;     while (n--) {       cin >> a >> b;       long long int c = cube_root(a * b);       if (c != -1 && a % c == 0 && b % c == 0) {         cout <<  Yes n ;       } else         cout <<  No n ;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t = 1;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200200;   int n, s[N] = {}, d[N] = {}, top = 0;   long long sum = 0;   int main() {     scanf( %d , &n);     s[++top] = 0;     for (int i = 1, t, x, y; i <= n; ++i) {       scanf( %d , &t);       if (t == 1)         scanf( %d%d , &x, &y), sum += x * y, d[x] += y;       else if (t == 2)         scanf( %d , &x), s[++top] = x, sum += x;       else         d[top - 1] += d[top], sum -= s[top] + d[top], d[top] = 0, --top;       printf( %.12f n , sum * 1.0 / top);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       vector<int> visited(n);       vector<int> a(n);       vector<int> ans(n);       for (int i = 0; i < n; i++) {         cin >> a[i];         a[i]--;       }       for (int i = 0; i < n; i++) {         if (visited[i] == 0) {           vector<int> v;           while (!visited[i]) {             v.push_back(i);             visited[i] = 1;             i = a[i];           }           for (auto x : v) ans[x] = v.size();         }       }       for (int i = 0; i < n; i++) cout << ans[i] <<    ;       cout << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const double pi = acos(-1.0);   const double eps = 1e-8;   const int T = 23;   inline double sqr(double x) { return x * x; }   inline int dcmp(double x) { return fabs(x) <= eps ? 0 : (x > 0 ? 1 : -1); }   int n;   double r, v, s, t;   bool check(double x) {     double len = x;     int tmp = (int)(x / (2.0 * pi * r));     x -= 2.0 * pi * r * tmp;     double delta = x / r;     len -= (t - s);     len /= r;     double y = sqrt(sqr(1 - cos(delta)) + sqr(sin(delta)));     len /= y;     double a = acos(len) - acos((1 - cos(delta)) / y);     if (a - 2.0 * pi >= 0) a -= 2 * pi;     if (a < 0) a += 2.0 * pi;     return dcmp(pi - a) >= 0;   }   int main() {     scanf( %d %lf %lf , &n, &r, &v);     for (int i = 1; i <= n; i++) {       scanf( %lf %lf , &s, &t);       double l = 0.0, r = t - s - eps;       for (int j = 1; j <= T; j++) {         double mid = (l + r) / 2.0;         if (check(mid))           r = mid;         else           l = mid;       }       printf( %.9f n , l / v);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename U>   inline void smin(T &a, const U &b) {     if (a > b) a = b;   }   template <typename T, typename U>   inline void smax(T &a, const U &b) {     if (a < b) a = b;   }   template <class T>   inline void gn(T &first) {     char c, sg = 0;     while (c = getchar(), (c >  9  || c <  0 ) && c !=  - )       ;     for ((c ==  -  ? sg = 1, c = getchar() : 0), first = 0; c >=  0  && c <=  9 ;          c = getchar())       first = (first << 1) + (first << 3) + c -  0 ;     if (sg) first = -first;   }   template <class T1, class T2>   inline void gn(T1 &x1, T2 &x2) {     gn(x1), gn(x2);   }   int power(int a, int b, int m, int ans = 1) {     for (; b; b >>= 1, a = 1LL * a * a % m)       if (b & 1) ans = 1LL * ans * a % m;     return ans;   }   const int mod = 1000000007;   vector<int> adj[111];   int dp[111][50], k;   int tmp[50];   inline void add(int &a, long long b) { a = (a + b) % mod; }   void dfs(int u, int f = 0) {     dp[u][25 + k] = 1;     dp[u][25 - 1] = 1;     for (int v : adj[u]) {       if (v == f) continue;       dfs(v, u);       for (int i = -k; i <= k; i++)         tmp[25 + i] = dp[u][25 + i], dp[u][25 + i] = 0;       for (int i = -k; i <= k; i++)         for (int j = -k; j <= k; j++) {           if (i + j >= 0)             add(dp[u][25 + max(i, j - 1)],                 (long long)tmp[25 + i] * dp[v][25 + j]);           else             add(dp[u][25 + min(i, j - 1)],                 (long long)tmp[25 + i] * dp[v][25 + j]);         }     }   }   int main() {     int n;     cin >> n >> k;     for (int i = 1; i < n; i++) {       int u, v;       gn(u, v);       adj[u].push_back(v);       adj[v].push_back(u);     }     dfs(1);     int ans = 0;     for (int i = 0; i <= k; i++) add(ans, dp[1][25 + i]);     cout << ans << endl;     return 0;   }