malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int a[100005];   int l[100005];   int r[100005];   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     for (int i = 1; i <= n; i++) {       l[i] = min(l[i - 1] + 1, a[i]);     }     for (int i = n; i >= 1; i--) {       r[i] = min(r[i + 1] + 1, a[i]);     }     int ma = 0;     for (int i = 1; i <= n; i++) {       ma = max(ma, min(l[i], r[i]));     }     cout << ma << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n;     cin >> n;     long long a, b;     for (a = 0; a <= n / 1234567; a++) {       for (b = 0; b * 123456 <= n - a * 1234567; b++)         if ((n - (a * 1234567 + b * 123456)) % 1234 == 0) {           cout <<  YES ;           return 0;         }     }     cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   long long rdtsc() {     long long tmp;     asm( rdtsc  :  =A (tmp));     return tmp;   }   inline int myrand() { return abs((rand() << 15) ^ rand()); }   inline int rnd(int x) { return myrand() % x; }   void precalc() {}   const int maxn = 1e4 + 10;   int n;   char s[maxn];   bool read() {     if (scanf( %s , s) < 1) {       return false;     }     n = strlen(s);     return true;   }   set<string> ans;   int dp[maxn][2];   void solve() {     ans.clear();     memset(dp, 0, sizeof(dp));     if (n >= 7) {       dp[n - 2][0] = 1;     }     if (n >= 8) {       dp[n - 3][1] = 1;     }     for (int i = n - 2; i >= 5; --i) {       for (int it = 0; it < 2; ++it) {         int len = it + 2;         if (!dp[i][it]) {           continue;         }         string cur = string(s + i, len);         ans.insert(cur);         for (int nit = 0; nit < 2; ++nit) {           int nlen = nit + 2;           if (i - nlen < 5) {             break;           }           string t = string(s + (i - nlen), nlen);           if (t != cur) {             dp[i - nlen][nit] = 1;           }         }       }     }     printf( %d n , ((int)(ans).size()));     for (auto t : ans) {       printf( %s n , t.c_str());     }   }   int main() {     srand(rdtsc());     precalc();     while (true) {       if (!read()) {         break;       }       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int L(int i) { return i << 1; }   inline int R(int i) { return (i << 1) | 1; }   inline long long max(long long a, long long b) { return a < b ? b : a; }   inline long long min(long long a, long long b) { return a < b ? a : b; }   inline int abs(int x) { return x < 0 ? -x : x; }   struct data {     long long l, r;   } A[2][10100], tmp;   int top[2];   long long B[33];   void init() {     int i;     B[0] = 1;     for (i = 1; i < 33; i++) B[i] = B[i - 1] << 1;   }   void dfs(long long l, long long r, int id, int n) {     l = max(1, l);     r = min(B[n] - 1, r);     if (l <= r) {       tmp.l = l, tmp.r = r;       A[id][top[id]++] = tmp;       if (!((l <= 1) && (r >= B[n - 1] - 1))) {         dfs(l, r, id, n - 1);         dfs(l - B[n - 1], r - B[n - 1], id, n - 1);       }     }   }   int main() {     long long l1, r1, l2, r2, ret;     int i, j;     init();     while (cin >> l1 >> r1 >> l2 >> r2) {       top[0] = top[1] = 0;       dfs(l1, r1, 0, 30);       dfs(l2, r2, 1, 30);       ret = 0;       for (i = 0; i < top[0]; i++)         for (j = 0; j < top[1]; j++)           ret =               max(min(A[0][i].r, A[1][j].r) - max(A[0][i].l, A[1][j].l) + 1, ret);       cout << ret << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a, b, n, i, j;   int f[5001];   int dp[5001][5001];   char s[5003];   int main() {     while (~scanf( %d%d%d , &n, &a, &b)) {       scanf( %s , &s[1]);       for (i = 1; i <= n; i++) f[i] = f[i - 1] + a;       for (i = 1; i <= n; i++) {         f[i] = min(f[i], f[i - 1] + a);         for (j = 1; j < i; j++) {           if (s[i] == s[j]) {             dp[i][j] = dp[i - 1][j - 1] + 1;           } else             dp[i][j] = 0;           if (j <= i - dp[i][j]) {             f[i] = min(f[i], f[i - dp[i][j]] + b);           } else {             f[i] = min(f[i], f[j] + b);           }         }       }       printf( %d n , f[n]);     }   }
#include <bits/stdc++.h>   using namespace std;   int n;   int t[60], v[60];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &t[i]);     for (int i = 1; i <= n; i++) scanf( %d , &v[i]);     int nrOfStonesTakenAway = 0;     for (int i = 1; i <= n; i++) {       if (t[i] > v[i]) nrOfStonesTakenAway += (t[i] - v[i]);     }     for (int i = 1; i <= n; i++)       if (t[i] < v[i]) {         nrOfStonesTakenAway -= (v[i] - t[i]);       }     if (nrOfStonesTakenAway < 0)       puts( No );     else       puts( Yes );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, a, i, j, k, l;     cin >> n >> a;     long long arr[n + 2];     for (i = 1; i <= n; i++) {       cin >> arr[i];     }     long long pos;     arr[n + 1] = a;     sort(arr + 1, arr + n + 2);     for (i = 1; i <= n + 1; i++) {       if (arr[i] == a) {         pos = i;         break;       }     }     long long dist, d1, d2, d3, d4;     if (pos == 1 || pos == n + 1) {       if (pos == 1) {         cout << arr[n] - arr[pos] << endl;         return 0;       }       if (pos == n + 1) {         cout << arr[pos] - arr[2] << endl;         return 0;       }     } else {       d1 = 2 * (arr[pos] - arr[1]) + arr[n] - arr[pos];       d2 = arr[pos] - arr[1] + 2 * (arr[n] - arr[pos]);       d3 = 2 * (arr[pos] - arr[2]) + arr[n + 1] - arr[pos];       d4 = arr[pos] - arr[2] + 2 * (arr[n + 1] - arr[pos]);     }     dist = min(min(d1, d2), min(d3, d4));     cout << dist << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:64000000 )   using namespace std;   const double eps = 1e-9;   const double pi = acos(-1.0);   int main() {     int n, s;     cin >> n >> s;     int res = -1;     for (int i = 0; i < n; i++) {       int x, y;       cin >> x >> y;       if (y == 0) {         if (s >= x) {           res = max(res, 0);         }       } else {         if (s > x) {           res = max(res, 100 - y);         }       }     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1003;   int n, k;   bitset<N * 3> A, dp, dpt;   int main() {     scanf( %d%d , &n, &k);     for (int a; k; k--) scanf( %d , &a), A[a] = 1;     dp[1500] = 1;     for (int __ = 1; __ <= 1009; __++) {       dpt = 0;       for (int i = 0; i < 3000; i++)         if (dp[i] == 1) dpt |= A << (i - n);       dp = dpt;       if (dp[1500] == 1) return !printf( %d n , __);     }     return !printf( -1 n );   }
#include <bits/stdc++.h>   using namespace std;   long long n, fir;   int main() {     scanf( %lld , &n);     fir = n;     for (int i = 2; 1ll * i * i <= n; i++)       if (n % i == 0) {         fir = i;         break;       }     for (; n != 1 && n % fir == 0; n /= fir)       ;     printf( %lld n , n == 1 ? fir : 1);   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   int a[110];   int b[110];   int dp[121000];   int main(int argc, char *argv[]) {     cin >> n >> k;     for (int i = 0; i < n; i += 1) {       cin >> a[i];     }     for (int i = 0; i < n; i += 1) {       cin >> b[i];     }     for (int i = 0; i < 121000; i += 1) {       dp[i] = -1;     }     dp[100000] = 0;     for (int i = 0; i < n; i += 1) {       int x = a[i] - k * b[i];       if (x > 0) {         for (int j = 121000 - 1; j >= x; j -= 1) {           if (dp[j - x] != -1) {             if (dp[j] == -1 || dp[j - x] + a[i] > dp[j]) {               dp[j] = dp[j - x] + a[i];             }           }         }       } else {         for (int j = 0; j - x < 121000; j += 1) {           if (dp[j - x] != -1) {             if (dp[j] == -1 || dp[j - x] + a[i] > dp[j]) {               dp[j] = dp[j - x] + a[i];             }           }         }       }     }     if (dp[100000] == 0) {       dp[100000] = -1;     }     cout << dp[100000] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   map<long long, long long> m;   long long f(string s) {     long long ff[27] = {0}, ans = 0, i, j;     for (i = 0; i < s.size(); i++) {       ff[s[i] -  a ]++;     }     for (i = 0; i < 26; i++) {       if (ff[i] % 2) {         ans |= (1LL << i);       }     }     return ans;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     long long n, i, j;     cin >> n;     string s[n + 1];     vector<long long> v;     for (i = 0; i < n; i++) {       cin >> s[i];       v.push_back(f(s[i]));     }     for (i = 0; i < v.size(); i++) m[v[i]]++;     long long ans = 0;     for (auto i : m) {       ans += (i.second * (i.second - 1)) / 2;     }     for (i = 0; i < 26; i++) {       map<long long, long long> mm;       for (j = 0; j < n; j++)         if (v[j] & (1 << i)) mm[v[j] ^ (1LL << i)]++;       for (auto j : mm) {         ans += m[j.first] * j.second;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     int n, m, k;     cin >> n >> m >> k;     int result = n - m;     if (k >= abs(result) && k != 0) {       cout <<  ?  <<   n ;     } else {       if (result > 0)         cout <<  + n ;       else if (result < 0)         cout <<  - n ;       else if (result == 0)         cout <<  0 n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   stack<char> st;   char s[100005];   int main() {     scanf( %s , s);     int len = strlen(s);     for (int i = 0; i < len; ++i) {       if (st.empty() || st.top() != s[i])         st.push(s[i]);       else         st.pop();     }     if (st.empty())       puts( Yes );     else       puts( No );   }
#include <bits/stdc++.h>   using namespace std;   #define ll long long   int n,m;   char a[6][6];   bool used[6][6];   int ans;   void dfs(int x,int y)   {       if(a[x][y]== * )       {           ans++;       }       if(x==n&&y==m)       {           cout << ans;           exit(0);       }       if(x+1<=n&&a[x+1][y]== * )       {           dfs(x+1,y);       }       if(y+1<=m&&a[x][y+1]== * )       {           dfs(x,y+1);       }       if(y+1<=m)       {           dfs(x,y+1);       }       if(x+1<=n)       {           dfs(x+1,y);       }   }   int main()   {       cin >> n >> m;       for(int i = 1;i<=n;i++)       {           for(int j = 1;j<=m;j++)           {               cin >> a[i][j];           }       }       dfs(1,1);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     iostream::sync_with_stdio(0);     int a, b, c, d;     cin >> a >> b >> c >> d;     for (int i = a; i <= 200; i++) {       for (int j = b; j <= 200; j++) {         for (int k = 1; k <= 200; k++) {           if (a * 2 >= i && b * 2 >= j && c <= k && c * 2 >= k && i > d * 2 &&               j > d * 2 && d <= k && d * 2 >= k && i > j && j > k) {             cout << i << endl << j << endl << k << endl;             return 0;           }         }       }     }     cout << -1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int visit[100005];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     while (t--) {       int n, m;       cin >> n >> m;       char a[n][m];       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           if (i == 0 && j == 0) {             a[i][j] =  W ;           } else {             a[i][j] =  B ;           }         }       }       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           cout << a[i][j];         }         cout <<   n ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   struct Edge {     int from, to;     Edge(int f, int t) : from(f), to(t) {}   };   vector<Edge> edges;   vector<int> G[100005];   int h[100005];   void add_edge(int from, int to) {     edges.push_back(Edge(from, to));     int m = edges.size();     G[from].push_back(m - 1);     return;   }   void bfs(int x) {     queue<int> Q;     Q.push(x);     int cnt = 1, first = 1;     h[x] = cnt;     while (!Q.empty()) {       int u = Q.front();       Q.pop();       if (h[u] == cnt && first) {         cnt++;         first = 0;       }       for (int i = 0; i < G[u].size(); i++) {         Edge &e = edges[G[u][i]];         if (!h[e.to]) {           h[e.to] = cnt;           Q.push(e.to);         }       }       first = 1;     }   }   int main() {     int n;     while (scanf( %d , &n) != EOF) {       for (int i = 0; i < n - 1; i++) {         int u, v;         scanf( %d %d , &u, &v);         add_edge(u, v);         add_edge(v, u);       }       memset(h, 0, sizeof(h));       bfs(1);       double sum = 0.0;       for (int i = 1; i <= n; i++) {         if (h[i] != 0) sum += (double)1 / h[i];       }       printf( %lf n , sum);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int pot(int x, int y) {     if (y == 0) {       return 1;     } else {       return x * pot(x, y - 1);     }   }   int bin(int x, int y) {     if ((x == 0 && y != 0) || (y == 0 && x != 0)) {       return 1;     } else {       return bin(x, y - 1) + bin(x - 1, y);     }   }   void strlwr(string& s) {     for (int i = 0; (unsigned)i < s.size(); i++) {       if (s[i] >=  A  && s[i] <=  Z ) {         s[i] += 32;       }     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int a[26] = {};     int n;     string s;     cin >> s;     n = s.size();     for (int i = 0; i < n; i++) {       a[s[i] -  a ]++;     }     int k = 25;     for (int i = 0; i < n; i++) {       while (a[k] == 0 && k > 0) {         k--;       }       if (s[i] -  a  < k) {         a[s[i] -  a ]--;       }       if (s[i] -  a  == k) {         a[s[i] -  a ]--;         cout << s[i];       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int i;   long n, m;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n;     map<string, int> mp;     string s;     while (n--) {       cin >> s;       mp[s]++;       if (mp[s] > 1) {         cout <<  YES  << endl;       } else         cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int ans[52];     memset(ans, 0, sizeof(ans));     int flag = 0;     for (int i = 0; i < n; ++i) {       int arr[52];       memset(arr, 0, sizeof(arr));       for (int j = 0; j < n; ++j) {         int k;         cin >> k;         arr[k]++;       }       for (int j = 0; j < n; ++j) {         if (arr[j] == n - j) {           ans[i] = j;           if (j == n - 1) {             ans[i] += flag;             flag++;           }           break;         }       }     }     for (int i = 0; i < n; ++i) {       if (ans[i] == 0) ans[i] = n;       cout << ans[i] <<    ;     }   }
#include <bits/stdc++.h>   int const MOD = 998244353;   int main() {     std::ios::sync_with_stdio(0);     std::cin.tie(0);     int n, nopt;     std::cin >> n >> nopt;     std::vector<int> h;     h.reserve(n + 1);     h.resize(n);     for (int& hi : h) std::cin >> hi;     h.push_back(h[0]);     std::vector<int> f{1};     f.reserve(n * 2 + 1);     std::vector<int> g;     g.reserve(n * 2 + 1);     for (int i = 0; i < n; ++i) {       if (h[i] == h[i + 1]) {         for (auto& fi : f) fi = int(fi * (int64_t)nopt % MOD);         f.insert(begin(f), 0);         f.push_back(0);       } else {         g.assign(begin(f), end(f));         g.push_back(0);         g.push_back(0);         assert(nopt - 2 >= 0);         std::transform(begin(f), end(f), ++begin(g), ++begin(g),                        [nopt](int fi, int gi) {                          return int((gi + fi * int64_t(nopt - 2)) % MOD);                        });         std::transform(begin(f), end(f), ++ ++begin(g), ++ ++begin(g),                        [](int fi, int gi) {                          return gi + fi >= MOD ? gi + fi - MOD : gi + fi;                        });         std::swap(f, g);       }     }     std::cout << std::accumulate(begin(f) + n + 1, end(f), 0LL) % MOD <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 100;   int arr[maxn];   int main() {     int T;     cin >> T;     while (T--) {       int n;       cin >> n;       for (int i = 0; i < n; ++i) cin >> arr[i];       for (int i = 0; i < n; ++i) {         if (i % 2) {           if (arr[i] > 0) arr[i] = -arr[i];         } else {           if (arr[i] < 0) arr[i] = -arr[i];         }       }       for (int i = 0; i < n; ++i) cout << arr[i] <<    ;       cout << endl;     }     return 0;   }
/* https://codeforces.com/blog/entry/87523 */   #include <stdio.h>   #include <stdlib.h>   #include <string.h>      #define N 100000      int *ej[N], eo[N];      void append(int i, int j) {    int o = eo[i]++;       if (o >= 2 && (o & o - 1) == 0)     ej[i] = (int *) realloc(ej[i], o * 2 * sizeof *ej[i]);    ej[i][o] = j;   }      int main() {    static int dd[N], ll[N + 1], qu[N], *qq[N], kk[N], dp[N + 1], dq[N + 1];    static char ans[N + 1];    int n, x, y, h, i, d, d_, k, s, cnt;       scanf( %d%d , &n, &x);    for (i = 0; i < n; i++)     ej[i] = (int *) malloc(2 * sizeof *ej[i]);    for (i = 1; i < n; i++) {     int p;        scanf( %d , &p), p--;     append(p, i);    }    for (i = 1; i < n; i++)     dd[i] = n;    cnt = 0, qu[cnt++] = 0;    for (d = 0; d < n && cnt; d++) {     qq[d] = (int *) malloc(cnt * sizeof *qq[d]), memcpy(qq[d], qu, (kk[d] = cnt) * sizeof *qu);     cnt = 0;     for (h = 0; h < kk[d]; h++) {      int o;         i = qq[d][h];      for (o = eo[i]; o--; ) {       int j = ej[i][o];          qu[cnt++] = j;      }     }    }    d_ = d;    for (d = 0; d < d_; d++)     ll[kk[d]]++;    dp[0] = -1;    for (k = 1; k <= n; k++) {     if (ll[k] == 0)      continue;     for (s = 0; s <= n; s++)      dq[s] = dp[s] ? 0 : (s >= k && dq[s - k] < ll[k] ? dq[s - k] : ll[k]) + 1;     for (s = 0; s <= n; s++)      if (!dp[s] && dq[s] <= ll[k])       dp[s] = k;    }    if (dp[x]) {     printf( %d n , d_);     memset(ll, 0, (n + 1) * sizeof *ll);     for (k = n, s = x; k >= 1; k--)      while (dp[s] == k)       s -= k, ll[k]++;     for (d = 0; d < d_; d++)      if (ll[kk[d]]) {       ll[kk[d]]--;       for (h = 0; h < kk[d]; h++)        ans[qq[d][h]] =  a ;      } else       for (h = 0; h < kk[d]; h++)        ans[qq[d][h]] =  b ;    } else {     printf( %d n , d_ + 1);     y = n - x;     for (d = 0; d < d_; d++)      if (x >= kk[d])       for (h = 0; h < kk[d]; h++)        ans[qq[d][h]] =  a , x--;      else if (y >= kk[d])       for (h = 0; h < kk[d]; h++)        ans[qq[d][h]] =  b , y--;      else {       for (h = 0; h < kk[d]; h++) {        i = qq[d][h];        if (eo[i])         ans[i] =  a , x--;       }       for (h = 0; h < kk[d]; h++) {        i = qq[d][h];        if (!eo[i]) {         if (x > 0)          ans[i] =  a , x--;         else          ans[i] =  b , y--;        }       }      }    }    printf( %s n , ans);    return 0;   }
#include <bits/stdc++.h>   #ifdef ALGO   #include  el_psy_congroo.hpp    #else   #define DUMP(...) 1145141919810   #define CHECK(...) (__VA_ARGS__)   #endif      struct Dsu {     std::vector<int> dsu;        explicit Dsu(int size) : dsu(size) {       std::iota(dsu.begin(), dsu.end(), 0);     }        int find(int x) {       return dsu[x] == x ? x : dsu[x] = find(dsu[x]);     }   };      using LL = long long;      LL binom2(int x) {     if (x < 2) return 0;     return x * 1LL * (x - 1) / 2;   }      struct Solver {     int n;     std::vector<std::vector<int>> edges;     std::vector<int> sz;     std::vector<int> parent;        Solver(int n, std::vector<std::vector<int>> edges) : n(n), edges(edges), sz(n), parent(n, -1) {}        void dfs(int u, int fa) {       parent[u] = fa;       sz[u] = 1;       for (int v : edges[u]) if (v != fa) {         dfs(v, u);         sz[u] += sz[v];       }     }        void solve() {       dfs(0, -1);       std::vector<LL> result(n + 1);       for (int v : edges[0]) result[0] += binom2(sz[v]);       std::set<int> eds;       Dsu dsu(n);       std::vector<bool> mark(n);       mark[0] = true;       std::set<int> r1;       for (int u = 1; u < n; ++u) {         if (!mark[u]) {           eds.emplace(u);           for (int v = u; ; v = dsu.find(v)) {             mark[v] = true;             int w = parent[v];             if (w == 0) break;             if (eds.count(w)) {               eds.erase(w);             }             dsu.dsu[v] = w;           }         }         r1.emplace(dsu.find(u));         if (r1.size() != eds.size()) {           break;         }         if (eds.size() == 2) {           LL val = 1;           for (int v : eds)             val *= sz[v];           result[u + 1] += val;         } else if (eds.size() == 1) {           LL val = sz[*eds.begin()];           val *= n - sz[dsu.find(u)];           result[u + 1] += val;         }         if (u > 1) result[u] -= result[u + 1];       }       result[1] = binom2(n) - std::accumulate(result.begin(), result.end(), 0LL);       for (int i = 0; i <= n; ++i)         printf( %lld%c , result[i],    n [i == n]);     }   };      int main() {     std::ios::sync_with_stdio(false);     std::cin.tie(nullptr);     std::istream& reader = std::cin;        int cas;     reader >> cas;     while (cas--) {       int n;       reader >> n;       std::vector<std::vector<int>> edges(n);       for (int i = 0; i < n - 1; ++i) {         int x, y;         reader >> x >> y;         edges[x].emplace_back(y);         edges[y].emplace_back(x);       }       Solver(n, edges).solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const long long maxm = 1e+18;   vector<long long> prime;   long long power(long long x, long long y) {     long long res = 1;     x = x % 1000000007;     while (y > 0) {       if (y & 1) res = (res * x) % 1000000007;       y = y >> 1;       x = (x * x) % 1000000007;     }     return res;   }   void primeFactors(long long n) {     prime.clear();     while (n % 2 == 0) {       prime.push_back(2);       n = n / 2;     }     for (int i = 3; i <= sqrt(n); i = i + 2) {       while (n % i == 0) {         prime.push_back(i);         n = n / i;       }     }     if (n > 2) prime.push_back(n);   }   long long getRes(long long n, long long p) {     long long res = 1;     long long x[101];     long long i = 1;     long long j = 0;     long long z = p;     while (true) {       if (z > n) break;       x[j++] = n / z;       if (maxm / z < p) break;       z *= p;       i++;     }     for (int i = 0; i < j - 1; i++) {       x[i] -= x[i + 1];     }     long long mul = 1;     for (int i = 0; i < j; i++) {       long long val = power(power(p, mul), x[i]);       res = (res * (val) % 1000000007) % 1000000007;       mul += 1;     }     return res;   }   int main() {     long long x, n;     cin >> x >> n;     primeFactors(x);     vector<long long>::iterator ip;     ip = std::unique(prime.begin(), prime.end());     prime.resize(std::distance(prime.begin(), ip));     long long ans = 1;     for (int i = 0; i < prime.size(); i++) {       long long res = getRes(n, prime[i]);       ans = (ans * res) % 1000000007;     }     cout << ans <<   n ;   }