malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 1000000 + 10;   int n, m, k;   int a[N], b[N];   char s[N], t[N];   int p[22];   int mn[1 << 20], mx[1 << 20];   int getint(char *str) {     char news[22];     for (int i = 1; i <= k; i++) {       news[p[i]] = str[i];     }     int ans = 0;     for (int i = 1; i <= k; i++) {       ans = ans << 1 | (news[i] ==  1 );     }     return ans;   }   void updmx(int &x, int y) { x = max(x, y); }   void updmn(int &x, int y) { x = min(x, y); }   int bitcount(int x) {     int ans = 0;     for (int i = 0; i < k; i++)       if (x >> i & 1) ans++;     return ans;   }   int main() {     scanf( %d%d%d , &n, &m, &k);     scanf( %s%s , s + 1, t + 1);     for (int i = 1; i <= n; i++) {       scanf( %d%d , &a[i], &b[i]);     }     for (int i = 0; i < 1 << k; i++) mn[i] = 1e9, mx[i] = -1e9;     int all = (1 << k) - 1;     for (int i = 1; i <= k; i++) p[i] = i;     updmx(mx[getint(t) ^ all], 0);     for (int i = 1; i <= n; i++) {       swap(p[a[i]], p[b[i]]);       updmx(mx[getint(t) ^ all], i);     }     for (int i = 1; i <= k; i++) p[i] = i;     updmn(mn[getint(s) ^ all], 0);     for (int i = 1; i <= n; i++) {       swap(p[a[i]], p[b[i]]);       updmn(mn[getint(s) ^ all], i);     }     for (int bit = 0; bit < k; bit++) {       for (int i = 1; i < (1 << k); i++) {         if (((i >> bit) & 1) == 1) {           mx[i] = max(mx[i], mx[i ^ (1 << bit)]);           mn[i] = min(mn[i], mn[i ^ (1 << bit)]);         }       }     }     int bstval = -1, bstL, bstR;     for (int i = 0; i < 1 << k; i++) {       if (mx[all ^ i] - mn[all ^ i] >= m) {         if (bitcount(i) >= bstval) {           bstval = bitcount(i);           bstR = mx[all ^ i];           bstL = mn[all ^ i] + 1;         }       }     }     int s1 = 0, t1 = 0;     for (int i = 1; s[i]; i++) s1 += (s[i] ==  1  ? 1 : 0);     for (int i = 1; t[i]; i++) t1 += (t[i] ==  1  ? 1 : 0);     printf( %d n , k + 2 * bstval - s1 - t1);     printf( %d %d n , bstL, bstR);   }
#include <bits/stdc++.h>   using namespace std;   inline int read() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = (x << 3) + (x << 1) + (ch ^ 48);       ch = getchar();     }     return x * f;   }   int n, f[5010][5010][2], out[5010], siz[5010], size, rt = 1;   struct node {     int u, v, nxt;   } e[5010 << 1];   int head[5010], js;   void add(int u, int v) {     e[++js] = (node){u, v, head[u]};     head[u] = js;   }   void dfs1(int u, int pre) {     for (int i = head[u]; i; i = e[i].nxt) {       int v = e[i].v;       out[u]++;       if (v == pre) continue;       dfs1(v, u);     }     size += out[u] == 1;   }   void dfs2(int u, int pre) {     if (out[u] == 1) {       siz[u] = 1;       f[u][0][0] = f[u][1][1] = 0;       return;     } else       f[u][0][0] = f[u][0][1] = 0;     for (int i = head[u]; i; i = e[i].nxt) {       int v = e[i].v;       if (v == pre) continue;       dfs2(v, u);       siz[u] += siz[v];       for (int j = siz[u]; j >= 0; j--) {         int tmp0 = 0x7fffffff, tmp1 = 0x7fffffff;         for (int k = 0; k <= siz[v]; k++)           if (k <= j) {             tmp0 = min(tmp0, f[u][j - k][0] + min(f[v][k][0], f[v][k][1] + 1));             tmp1 = min(tmp1, f[u][j - k][1] + min(f[v][k][1], f[v][k][0] + 1));           }         f[u][j][0] = tmp0;         f[u][j][1] = tmp1;       }     }   }   int main() {     n = read();     memset(f, 63, sizeof f);     for (int i = 1; i < n; i++) {       int x = read(), y = read();       add(x, y), add(y, x);     }     dfs1(1, 0);     while (out[rt] == 1) rt++;     dfs2(rt, 0);     printf( %d , min(f[rt][size >> 1][0], f[rt][size >> 1][1]));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t, n, a[110];   int main() {     scanf( %d , &t);     while (t--) {       scanf( %d , &n);       for (int i = 0; i < n; i++) scanf( %d , &a[i]);       for (int i = 0; i < n; i++) a[i] %= 2;       int sum = 0;       for (int i = 0; i < n; i++) sum += a[i];       if (sum == 0 || sum == n)         printf( YES n );       else         printf( NO n );     }   }
#include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-8, pi = acos(-1);   const int SZ = 100050, INF = 0x7FFFFFFF;   vector<int> mp[SZ];   int res, pos;   int in[SZ];   void dfs(int u, int par) {     int cur = 0;     for (int i = 0; i < mp[u].size(); ++i) {       int to = mp[u][i];       if (to != par) {         ++cur;         dfs(to, u);       }     }     if (par == -1 && cur == 2) --cur;     if (cur > 1) {       pos = u;       ++res;     }   }   int main() {     std::ios::sync_with_stdio(0);     int casenum;     {       int n;       cin >> n;       for (int i = 0; i < n - 1; ++i) {         int u, v;         cin >> u >> v;         mp[u].push_back(v);         mp[v].push_back(u);         ++in[u];         ++in[v];       }       dfs(1, -1);       if (res > 1)         cout <<  No  << endl;       else if (res == 0) {         cout <<  Yes n1  << endl;         vector<int> tmp;         for (int i = 1; i <= n; ++i) {           if (in[i] == 1) {             tmp.push_back(i);           }         }         cout << tmp[0] <<     << tmp[1] << endl;       } else {         cout <<  Yes  << endl;         int num = count(in + 1, in + 1 + n, 1);         cout << num << endl;         for (int i = 1; i <= n; ++i) {           if (in[i] == 1) cout << i <<     << pos << endl;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int len, rt, n, m;   vector<int> g[210];   int a[210], b[210];   void dfs(int cur, int pre, int dep) {     int i;     if (dep > len) {       len = dep;       rt = cur;     }     for (i = 0; i < g[cur].size(); i++) {       int u = g[cur][i];       if (u == pre) continue;       dfs(u, cur, dep + 1);     }   }   int solve(int root) {     rt = root;     len = 0;     dfs(root, root, 0);     len = 0;     dfs(rt, rt, 0);     return len;   }   void Init() {     for (int i = 1; i <= n; ++i) g[i].clear();   }   int main() {     int i, j;     scanf( %d , &n);     for (i = 1; i < n; i++) scanf( %d%d , &a[i], &b[i]);     int ans = 0;     for (i = 1; i < n; i++) {       Init();       int x = a[i], y = b[i];       for (j = 1; j < n; j++)         if (i != j) {           g[a[j]].push_back(b[j]);           g[b[j]].push_back(a[j]);         }       ans = max(ans, solve(x) * solve(y));     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   int n;   int fa[1000005], huan[1000005], zihuan[1000005], siz[1000005];   int find(int now) { return fa[now] == now ? now : fa[now] = find(fa[now]); }   int main() {     scanf( %d , &n);     for (int i = 1; i <= 2 * n; i++) {       fa[i] = i;       siz[i] = 1;     }     for (int i = 1; i <= n; i++) {       int x, y;       scanf( %d%d , &x, &y);       int x1 = find(x), y1 = find(y);       if (x == y) zihuan[x1] = 1;       if (x1 == y1) huan[y1] = 1;       fa[x1] = y1;     }     for (int i = 1; i <= 2 * n; i++) {       int x = find(i);       if (x != i) {         siz[x] += siz[i];         huan[x] |= huan[i];         zihuan[x] |= zihuan[i];       }     }     long long ans = 1;     for (int i = 1; i <= 2 * n; i++) {       if (find(i) == i) {         if (zihuan[i])           continue;         else if (huan[i])           ans = (ans * 2) % mod;         else           ans = (ans * siz[i]) % mod;       }     }     printf( %I64d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void amin(T &x, const T &y) {     if (y < x) x = y;   }   template <class T>   inline void amax(T &x, const T &y) {     if (x < y) x = y;   }   template <class Iter>   void rprintf(const char *fmt, Iter begin, Iter end) {     for (bool sp = 0; begin != end; ++begin) {       if (sp)         putchar(   );       else         sp = true;       printf(fmt, *begin);     }     putchar(  n );   }   int N;   int A[200011];   int B[200011];   using Tuple = tuple<int, int, int>;   Tuple X[100011];   void MAIN() {     scanf( %d , &N);     for (int i = 0, i_len = (N); i < i_len; ++i) scanf( %d , A + i);     int Q;     scanf( %d , &Q);     vector<Tuple> sortedX;     sortedX.reserve(Q);     for (int i = 0, i_len = (Q); i < i_len; ++i) {       int s, t, u;       scanf( %d%d%d , &s, &t, &u);       s--;       u--;       X[i] = Tuple(s, t, u);       sortedX.emplace_back(s, t, -1);     }     sort(sortedX.begin(), sortedX.end());     sortedX.erase(unique(sortedX.begin(), sortedX.end()), sortedX.end());     long long sum = 0;     for (int i = 0, i_len = (N); i < i_len; ++i) sum += A[i];     for (int i = 0, i_len = (Q); i < i_len; ++i) {       int s, t, u;       tie(s, t, u) = X[i];       auto it = lower_bound(sortedX.begin(), sortedX.end(), Tuple(s, t, -1));       int s0, t0, u0;       tie(s0, t0, u0) = *it;       if (0 <= u0) {         sum -= max(0, A[u0] - B[u0]);         B[u0]--;         sum += max(0, A[u0] - B[u0]);       }       if (0 <= u) {         sum -= max(0, A[u] - B[u]);         B[u]++;         sum += max(0, A[u] - B[u]);       }       *it = Tuple(s, t, u);       printf( %lld n , sum);     }   }   int main() {     int TC = 1;     for (int tc = 0, tc_len = (TC); tc < tc_len; ++tc) MAIN();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     for (int q = 0; q < t; ++q) {       int n, k;       cin >> n >> k;       vector<int> x(n);       for (int i = 0; i < n; ++i) {         cin >> x[i];       }       vector<int> p(n, 0);       for (int i = 1; i < n - 1; ++i) {         if (x[i] > x[i + 1] && x[i] > x[i - 1]) {           p[i] = p[i - 1] + 1;         } else {           p[i] = p[i - 1];         }       }       p[n - 1] = p[n - 2];       int ans = 0, left = 0;       for (int l = 0; l + k - 1 < n; ++l) {         if (p[l + k - 2] - p[l] > ans) {           ans = p[l + k - 2] - p[l];           left = l;         }       }       cout << ans + 1 <<     << left + 1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool isPowerOfTwo(long long x) { return x && (!(x & (x - 1))); }   void solve() {     long long n, m;     cin >> n >> m;     if (n == 1 || m == 1) {       cout <<  YES  <<   n ;       return;     }     if (n != m) {       cout <<  NO  <<   n ;       return;     }     if (n == 2) {       cout <<  YES  <<   n ;       return;     }     cout <<  NO  <<   n ;   }   signed main() {     cin.tie(NULL), ios_base::sync_with_stdio(false), cout.tie(NULL);     long long t = 1;     cin >> t;     while (t--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     string s;     cin >> s;     vector<string> a, b;     string t =   ;     bool if_num = true, if_first = true;     for (int i = 0; i < (int)s.size(); i++) {       if (s[i] ==  ,  or s[i] ==  ; ) {         if (if_num and t !=   ) {           a.push_back(t);         } else {           b.push_back(t);         }         t =   ;         if_num = true;         if_first = true;         continue;       }       if (s[i] <  0  or s[i] >  9  or           (s[i] ==  0  and if_first and            (i != (int)s.size() - 1 and s[i + 1] !=  ;  and s[i + 1] !=  , ))) {         if_num = false;       }       if_first = false;       t += s[i];     }     if (if_num and t !=   ) {       a.push_back(t);     } else {       b.push_back(t);     }     if (a.empty()) {       cout <<  -  << endl;     } else {       cout <<    ;       for (int i = 0; i < (int)a.size(); i++) {         cout << a[i];         if (i != (int)a.size() - 1) {           cout <<  , ;         }       }       cout <<     << endl;     }     if (b.empty()) {       cout <<  -  << endl;     } else {       cout <<    ;       for (int i = 0; i < (int)b.size(); i++) {         cout << b[i];         if (i != (int)b.size() - 1) {           cout <<  , ;         }       }       cout <<     << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int a, b;     int count = 0;     for (int a = 0; a <= n + m; a++)       for (int b = 0; b <= n + m; b++) {         if (a * a + b == n && b * b + a == m) count++;       }     cout << count;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000000007;   const int MAX = 505;   int n, grid[MAX][MAX];   char s[5];   bool valid(int x, int y) {     if (x < 1) return false;     if (y < 1) return false;     if (x > n) return false;     if (y > n) return false;     return true;   }   bool dist(int x1, int y1, int x2, int y2) {     return ((abs(x1 - x2) + abs(y1 - y2)) >= n - 1);   }   bool cmd(int x1, int y1, int x2, int y2) {     printf( ? %d %d %d %d n , x1, y1, x2, y2);     fflush(stdout);     scanf( %s , s);     return (s[0] ==  Y );   }   int main() {     scanf( %d , &n);     grid[1][1] = 1;     grid[n][n] = 1;     int x = 1, y = 1;     while (true) {       int ok = 0;       if (valid(x, y + 1)) {         if (dist(x, y + 1, n, n)) {           if (cmd(x, y + 1, n, n)) {             grid[x][y + 1] = 1;             ok = 1;             y++;           }         }       }       if (ok) continue;       if (valid(x + 1, y)) {         if (dist(x + 1, y, n, n)) {           if (cmd(x + 1, y, n, n)) {             grid[x + 1][y] = 1;             ok = 1;             x++;           }         }       }       if (ok) continue;       break;     }     x = n, y = n;     while (true) {       int ok = 0;       if (valid(x - 1, y)) {         if (dist(x - 1, y, 1, 1)) {           if (cmd(1, 1, x - 1, y)) {             grid[x - 1][y] = 1;             ok = 1;             x--;           }         }       }       if (ok) continue;       if (valid(x, y - 1)) {         if (dist(x, y - 1, 1, 1)) {           if (cmd(1, 1, x, y - 1)) {             grid[x][y - 1] = 1;             ok = 1;             y--;           }         }       }       if (ok) continue;       break;     }     string ans =   ;     x = 1, y = 1;     while (true) {       if (x == n and y == n) break;       if (grid[x][y + 1])         ans +=  R , y++;       else         ans +=  D , x++;     }     printf( !  );     for (int i = 0; i < ans.size(); i++) printf( %c , ans[i]);     printf(  n );     fflush(stdout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 7;   int Log[N], bin[21], ls[N], rs[N], root, a[N], n, i, j;   set<int> s[N];   pair<int, int> mx[N][20];   long long ans;   void merge(int x, int y) {     if (s[x].size() < s[y].size()) swap(s[x], s[y]);     for (auto& z : s[y]) s[x].insert(z);     s[y].clear();   }   void dfs(int x) {     if (!x) return;     dfs(ls[x]);     dfs(rs[x]);     if (s[ls[x]].size() > s[rs[x]].size()) swap(ls[x], rs[x]);     for (auto& z : s[ls[x]])       if (s[rs[x]].count(a[x] - z)) ans++;     s[x].insert(a[x]);     merge(x, ls[x]);     merge(x, rs[x]);   }   int query(int l, int r) {     int t = Log[r - l + 1];     return max(mx[l][t], mx[r - bin[t] + 1][t]).second;   }   int build(int l, int r) {     if (l > r) return 0;     int x = query(l, r);     ls[x] = build(l, x - 1);     rs[x] = build(x + 1, r);     return x;   }   int main() {     for (scanf( %d , &n), i = 1; i <= n; ++i) scanf( %d , a + i);     for (Log[0] = -1, i = 1; i <= n; ++i) Log[i] = Log[i >> 1] + 1;     for (bin[0] = 1, i = 1; i < 20; ++i) bin[i] = bin[i - 1] << 1;     for (i = 1; i <= n; ++i) mx[i][0] = pair<int, int>(a[i], i);     for (j = 1; j <= Log[n]; ++j)       for (i = 1; i + bin[j - 1] <= n; ++i)         mx[i][j] = max(mx[i][j - 1], mx[i + bin[j - 1]][j - 1]);     root = build(1, n);     dfs(root);     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 510;   long long sum[maxn];   int main() {     long long n, k;     int t;     cin >> t;     while (t--) {       cin >> n >> k;       if (n >= 32) {         cout <<  YES               <<     << n - 1 << endl;       } else {         memset(sum, 0, sizeof(sum));         int ans = -1;         long long total = (pow(4, n) - 1) / 3;         if (k > total) {           cout <<  NO  << endl;           continue;         }         long long temp = pow(2, n - 1) * 2 - 1, cnt = 0;         while (temp) {           sum[++cnt] = 2 * (temp / 2) + 1;           temp /= 2;         }         for (int i = cnt; i >= 1; i--) sum[i] += sum[i + 1];         for (int i = 1; i <= cnt; i++)           if (sum[i] <= k && total - sum[1] >= k - sum[i]) {             ans = i;             break;           }         if (ans == -1)           cout <<  NO  << endl;         else           cout <<  YES                 <<     << ans - 1 << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   void solve();   int main() { solve(); }   void solve() {     int t;     cin >> t;     while (t--) {       string s;       cin >> s;       priority_queue<int> q;       int k = s.length();       int cur = (s[0] ==  1 ) ? 1 : 0;       for (int i = 1; i < k; i++) {         if (s[i] ==  1  && s[i - 1] ==  0 ) {           cur = 1;         }         if (s[i] ==  1  && s[i - 1] ==  1 ) {           cur++;         }         if (s[i] ==  0 ) {           if (cur != 0) {             q.push(cur);             cur = 0;           }         }       }       if (s[k - 1] ==  1 ) {         if (cur != 0) {           q.push(cur);           cur = 0;         }       }       int ans = 0;       int qs = q.size();       for (int i = 0; i < qs; i++) {         if ((i & 0x1) == 0) {           ans += q.top();         } else {         }         q.pop();       }       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     float a1, b1, c1, a2, b2, c2;     cin >> a1 >> b1 >> c1 >> a2 >> b2 >> c2;     if (!b1 && !b2) {       if (!a1 && !a2 && c1 && c2) {         cout << 0 << endl;         return 0;       }       if ((!a1 && c1) || (!a1 && c2)) {         cout << 0 << endl;         return 0;       }       if ((!c1 && !c2) || (!a1 && !a2) || c1 / a1 == c2 / a2) {         cout << -1 << endl;         return 0;       } else {         cout << 0 << endl;         return 0;       }     } else if ((!b1 && !a1 && !c1) || (!b2 && !a2 && !c2)) {       cout << -1 << endl;       return 0;     } else if ((!b1 && !a1) || (!b2 && !a2)) {       cout << 0 << endl;       return 0;     } else if (!b1 || !b2) {       cout << 1 << endl;       return 0;     }     if (a1 / b1 == a2 / b2 && c1 / b1 == c2 / b2)       cout << -1 << endl;     else if (a1 / b1 == a2 / b2)       cout << 0 << endl;     else       cout << 1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     string s, curr[1000];     long long int size = 0, j;     cin >> j;     while (j--) {       cin >> s;       if (s.compare( pwd ) == 0) {         for (long long int i = 0; i < size; ++i) {           cout <<  /  << curr[i];         }         cout <<  /               <<   n ;       } else if (s.compare( cd ) == 0) {         string temp;         cin >> s;         if (s[0] ==  / ) {           size = 0;         }         for (long long int i = 0; i < s.size(); ++i) {           temp =   ;           for (; i < s.size(); ++i) {             if (s[i] ==  / ) break;             temp += s[i];           }           if (temp.compare( .. ) == 0)             --size;           else if (temp.size()) {             curr[size] = temp;             ++size;           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e5 + 10;   const int M = N * 30;   int tree[M][2];   vector<int> val[M];   int main() {     int n;     scanf( %d , &n);     vector<int> a(n + 1);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     int idx = 0;     auto insert = [&](int n, int id) {       int tmp = 0;       bitset<30> st(n);       for (int i = 29; i >= 0; i--) {         if (!tree[tmp][st[i]]) tree[tmp][st[i]] = ++idx;         tmp = tree[tmp][st[i]];         val[tmp].emplace_back(id);       }     };     for (int i = 1; i <= n; i++) insert(a[i], i);     auto get_cal = [&](vector<int> &a, vector<int> &b) -> long long {       long long ans = 0;       int i = 0, j = 0;       while (i < a.size() && j < b.size()) {         if (a[i] < b[j])           i++;         else           ans += (int)a.size() - i, j++;       }       return ans;     };     vector<vector<long long>> ans(30, vector<long long>(2, 0));     function<void(int, int)> query = [&](int root, int deep) {       if (!tree[root][0] && !tree[root][1]) return;       long long cnt = get_cal(val[tree[root][0]], val[tree[root][1]]);       ans[deep][0] += cnt;       ans[deep][1] +=           1LL * val[tree[root][0]].size() * val[tree[root][1]].size() - cnt;       if (tree[root][0]) query(tree[root][0], deep - 1);       if (tree[root][1]) query(tree[root][1], deep - 1);     };     query(0, 29);     int res = 0;     long long cnt = 0;     for (int i = 29; i >= 0; i--) {       if (ans[i][0] > ans[i][1])         res += 1 << i, cnt += ans[i][1];       else         cnt += ans[i][0];     }     printf( %lld %d n , cnt, res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   long long qpow(long long a, long long b) {     long long res = 1;     while (b) {       if (b & 1) res = res * a;       b >>= 1;       a = a * a;     }     return res;   }   int a[500005];   int main() {     int n, k;     cin >> n >> k;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     sort(a + 1, a + n + 1);     k = 8 * k / n;     if (k >= ceil(log(n) / log(2))) {       cout << 0;       return 0;     }     long long q = pow(2, k);     int min1 = n;     int sum = 0;     for (int l = 1, r = 1; r <= n && l <= n;) {       while (r < n && a[r] == a[r + 1]) r++;       sum++;       if (sum == q) {         min1 = min(min1, n - (r - l + 1)), sum--;         while (l < n && a[l] == a[l + 1]) l++;         l++;       }       r++;     }     if (min1 == n)       cout << 0;     else       cout << min1;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast ,  unroll-loops )   using namespace std;   const int inf = numeric_limits<int>::max() / 2;   const long double eps = 1e-9;   const long double pi = acos(-1);   const int MAXN = (3e8 + 10) / 3;   int n;   unsigned int a, b, c, d;   bitset<MAXN> primes;   unsigned int f(unsigned int x) { return d + x * (c + x * (b + x * a)); }   int fict(int i) { return i - i / 2 - i / 3 + i / 6 - 1; }   void sieve() {     primes.set();     for (int i = 5; i * i <= n; i++) {       if (i % 2 == 0 || i % 3 == 0) {         continue;       }       if (primes[fict(i)]) {         for (int j = i * i; j <= n; j += i) {           if (j % 2 == 0 || j % 3 == 0) {             continue;           }           primes[fict(j)] = 0;         }       }     }   }   inline void solve() {     sieve();     unsigned int ans = 0;     for (int p = 2; p <= n; p++) {       if (p != 2 && p % 2 == 0 || p != 3 && p % 3 == 0) {         continue;       }       if (p != 2 && p != 3 && !primes[fict(p)]) {         continue;       }       unsigned int s = 0;       unsigned int q = n / p;       while (q >= 1) {         s += q;         q /= p;       }       ans += f(p) * s;     }     cout << ans <<   n ;   }   inline void read() { cin >> n >> a >> b >> c >> d; }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     read();     solve();     return 0;   }