malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   template <typename T>   T gcd(T a, T b) {     while (b > 0) {       a %= b;       swap(a, b);     }     return a;   }   template <class _T>   inline _T sqr(const _T& first) {     return first * first;   }   template <class _T>   inline string tostr(const _T& a) {     ostringstream os(  );     os << a;     return os.str();   }   const long double PI = 3.1415926535897932384626433832795L;   const double EPS = 1e-9;   char TEMPORARY_CHAR;   const int INF = 1e9;   inline void input(int& a) {     a = 0;     while (((TEMPORARY_CHAR = getchar()) >  9  || TEMPORARY_CHAR <  0 ) &&            (TEMPORARY_CHAR !=  - )) {     }     char neg = 0;     if (TEMPORARY_CHAR ==  - ) {       neg = 1;       TEMPORARY_CHAR = getchar();     }     while (TEMPORARY_CHAR <=  9  && TEMPORARY_CHAR >=  0 ) {       a = 10 * a + TEMPORARY_CHAR -  0 ;       TEMPORARY_CHAR = getchar();     }     if (neg) a = -a;   }   inline void out(long long a) {     if (!a) putchar( 0 );     if (a < 0) {       putchar( - );       a = -a;     }     char s[20];     int i;     for (i = 0; a; ++i) {       s[i] =  0  + a % 10;       a /= 10;     }     for (int j = (i)-1; j >= 0; j--) putchar(s[j]);   }   inline int nxt() {     int(ret);     input((ret));     ;     return ret;   }   const int MAXN = 300000;   long long powers[MAXN + 1];   struct data {     int len;     long long data1;     long long data2;   };   data merge(const data& l, const data& r) {     data res;     res.len = l.len + r.len;     res.data1 = r.data1 + l.data1 * powers[r.len];     res.data2 = l.data2 + r.data2 * powers[l.len];     return res;   }   int main() {     int(n);     input((n));     ;     int first[n];     powers[0] = 1;     for (int i = 1; i <= n; ++i) {       powers[i] = powers[i - 1] * 3;     }     for (int i = 0; i < n; ++i) {       first[i] = nxt() - 1;     }     data t[n + n];     for (int i = 0; i < n; ++i) {       t[i + n].len = 1;       t[i + n].data1 = t[i + n].data2 = 0;     }     for (int i = n - 1; i > 0; --i) {       t[i] = merge(t[i + i], t[i + i + 1]);     }     for (int i = 0; i < n; ++i) {       t[first[i] + n].data1 = t[first[i] + n].data2 = 1;       int pos = first[i] + n;       for (pos >>= 1; pos; pos >>= 1) {         t[pos] = merge(t[pos + pos], t[pos + pos + 1]);       }       int r = min(first[i], n - first[i] - 1);       data L{0, 0, 0};       data R{0, 0, 0};       int a = first[i] - r, b = first[i] + r;       for (a += n, b += n; a <= b; a = (a + 1) >> 1, b = (b - 1) >> 1) {         if (a & 1) {           L = merge(L, t[a]);         }         if (!(b & 1)) {           R = merge(t[b], R);         }       }       data res = merge(L, R);       if (res.data1 != res.data2) {         puts( YES );         return 0;       }     }     puts( NO );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2007;   const int mod = 998244353;   template <class I>   inline void read(I &x) {     int f = 1;     char c;     for (c = getchar(); c <  0  || c >  9 ; c = getchar())       if (c ==  - ) f = -1;     for (x = 0; c >=  0  && c <=  9 ;          x = (x << 3) + (x << 1) + (c & 15), c = getchar())       ;     x *= f;   }   long long ksm(int x, int y) {     long long res = 1;     while (y) {       if (y & 1) res = res * x % mod;       y >>= 1;       x = 1ll * x * x % mod;     }     return res;   }   long long f[2 * N][2 * N][2], jc[N * 2];   int main() {     int n, l, k;     read(n), read(k), read(l);     f[0][0][0] = 1;     for (int i = 0; i <= 2 * n; i++)       for (int j = 0; j <= i; j++)         for (int o = 0; o <= 1; o++) {           f[i + 1][j + 1][o] = (f[i + 1][j + 1][o] + f[i][j][o]) % mod;           if (o == 0 && j >= k)             f[i + 1][j][1] = (f[i + 1][j][1] + f[i][j][o]) % mod;           if (j) f[i + 1][j - 1][o] = (f[i + 1][j - 1][o] + f[i][j][o] * j) % mod;         }     jc[0] = 1;     for (int i = 1; i <= 2 * n + 1; i++) jc[i] = jc[i - 1] * i % mod;     long long ans = f[2 * n + 1][0][1] * ksm(2, n) % mod * jc[n] % mod *                     ksm(jc[2 * n + 1], mod - 2) % mod * l % mod;     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   long long expow(long long a, long long b, long long p) {     long long v = 1;     for (; b; b >>= 1, a = a * a % p)       if (b & 1) v = v * a % p;     return v;   }   long long inv(long long a, long long p) { return expow(a, p - 2, p); }   using namespace std;   const int N = 1000 + 11;   const int M = 1000000007;   struct node {     int a, b, c, d, e;   } p[N];   node sub(node a, node b) {     return (node){a.a - b.a, a.b - b.b, a.c - b.c, a.d - b.d, a.e - b.e};   }   double mix(node a, node b) {     return 1.0 * a.a * b.a + a.b * b.b + a.c * b.c + a.d * b.d + a.e * b.e;   }   vector<int> ans;   int main() {     int k;     scanf( %d , &k);     for (int i = 0; i < k; i++) {       scanf( %d%d%d%d%d , &p[i].a, &p[i].b, &p[i].c, &p[i].d, &p[i].e);     }     for (int j = 0; j < k; j++) {       bool f = false;       for (int i = 0; i < k; i++)         if (i != j) {           for (int l = 0; l < k; l++)             if (l != i && l != j) {               node cha = sub(p[j], p[i]), cha2 = sub(p[j], p[l]);               double ding = mix(cha, cha2),                      di = sqrt(mix(cha, cha)) * sqrt(mix(cha2, cha2));               double xx = ding / di;               if (xx > 0 && xx <= 1) {                 f = true;                 break;               }             }           if (f) break;         }       if (!f) ans.push_back(j + 1);     }     int sz = ans.size();     printf( %d n , sz);     for (int j = 0; j < sz; j++) printf( %d n , ans[j]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   const int Inf = 0x3f3f3f3f;   struct Edge {     int id;     int u, v, w;     Edge(int x = 0, int y = 0, int z = 0) : v(x), w(y), id(z) {}   } e[N];   vector<Edge> edges;   vector<int> G[N];   int ans[N], fa[N][20], dep[N], st[N][20], used[N], f[N], to[N];   int n, m;   void addeage(int u, int v, int w, int id) {     edges.push_back(Edge(v, w, id));     int tot = edges.size();     G[u].push_back(tot - 1);   }   void dfs(int u, int fat) {     fa[u][0] = fat;     for (int i = 1; i <= 18; ++i)       fa[u][i] = fa[fa[u][i - 1]][i - 1],       st[u][i] = max(st[u][i - 1], st[fa[u][i - 1]][i - 1]);     for (int i = 0; i < G[u].size(); ++i) {       Edge e = edges[G[u][i]];       if (e.v == fat) continue;       to[e.v] = e.id;       st[e.v][0] = e.w;       dep[e.v] = dep[u] + 1;       dfs(e.v, u);     }   }   int LCA(int u, int v, int& d) {     d = 0;     if (dep[u] < dep[v]) swap(u, v);     int t = dep[u] - dep[v];     for (int i = 0; i <= 18; ++i)       if ((1 << i) & t) {         d = max(d, st[u][i]);         u = fa[u][i];       }     if (u == v) return u;     for (int i = 18; i >= 0; --i) {       if (fa[u][i] != fa[v][i]) {         d = max(d, max(st[u][i], st[v][i]));         u = fa[u][i];         v = fa[v][i];       }     }     d = max(d, max(st[u][0], st[v][0]));     return fa[u][0];   }   int getfa(int u) { return (u == f[u]) ? u : f[u] = getfa(f[u]); }   bool cmp(Edge x, Edge y) { return x.w < y.w; }   void KrusKal() {     int tot = 0;     sort(e + 1, e + 1 + m, cmp);     for (int i = 1; i <= m; ++i) {       int u = e[i].u, v = e[i].v;       int u1 = getfa(u), v1 = getfa(v);       if (u1 != v1) {         f[u1] = v1;         used[i] = 1;         addeage(u, v, e[i].w, e[i].id);         addeage(v, u, e[i].w, e[i].id);         tot++;       }       if (tot == n - 1) break;     }   }   void modify(int u, int v, int d) {     u = getfa(u);     while (dep[u] > dep[v]) {       ans[to[u]] = min(ans[to[u]], d);       int y = getfa(fa[u][0]);       f[u] = y;       u = getfa(u);     }   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; ++i) {       int u, v, w;       scanf( %d%d%d , &u, &v, &w);       e[i].u = u, e[i].v = v, e[i].w = w, e[i].id = i;     }     for (int i = 1; i <= n; ++i) f[i] = i;     KrusKal();     dfs(1, 1);     memset(ans, Inf, sizeof ans);     for (int i = 1; i <= n; ++i) f[i] = i;     for (int i = 1; i <= m; ++i) {       if (used[i]) continue;       int u = e[i].u, v = e[i].v;       int ffa = LCA(u, v, ans[e[i].id]);       ans[e[i].id]--;       modify(u, ffa, e[i].w - 1);       modify(v, ffa, e[i].w - 1);     }     for (int i = 1; i <= m; ++i)       if (ans[i] == Inf)         printf( -1  );       else         printf( %d  , ans[i]);     return 0;   }
#include <bits/stdc++.h>   const int N = 1e5 + 10, M = 26;   template <typename T = int>   inline T read() {     T x = 0, f = 0;     char ch = getchar();     while (!isdigit(ch)) f |= ch ==  - , ch = getchar();     while (isdigit(ch)) x = x * 10 + ch -  0 , ch = getchar();     return f ? -x : x;   }   char s[N];   int a[N], pre[N][26], suf[N][26], f[N][26], g[N], dp[27];   inline int mex(int a) {     int res = 0;     while (a >> res & 1) ++res;     return res;   }   inline int solve(int l, int r, int c) {     if (l > r) return 0;     if (dp[c] != -1) return dp[c];     int sta = 0;     for (int i = 0; i < 26; ++i) {       int L = suf[l][i], R = pre[r][i];       if (R < L) continue;       sta |= 1 << (f[L - 1][c] ^ g[R] ^ g[L] ^ solve(R + 1, r, i));     }     return dp[c] = mex(sta);   }   inline int Solve(int l, int r, int c) {     if (l > r) return 0;     if (dp[c] != -1) return dp[c];     int sta = 0;     for (int i = 0; i < 26; ++i) {       int L = suf[l][i], R = pre[r][i];       if (R < L) continue;       sta |= 1 << (Solve(l, L - 1, i) ^ g[R] ^ g[L] ^ f[r][i]);     }     return dp[c] = mex(sta);   }   int main() {     scanf( %s , s + 1);     int n = strlen(s + 1);     for (int i = 1; i <= n; ++i) a[i] = s[i] -  a ;     for (int i = 0; i < 26; ++i) suf[n + 1][i] = n + 1;     for (int i = 1; i <= n; ++i)       memcpy(pre[i], pre[i - 1], sizeof(pre[i])), pre[i][a[i]] = i;     for (int i = n; i >= 1; --i)       memcpy(suf[i], suf[i + 1], sizeof(suf[i])), suf[i][a[i]] = i;     for (int i = 1; i <= n; ++i) {       memset(dp, -1, sizeof(dp)), g[i] = g[pre[i - 1][a[i]]] ^ f[i - 1][a[i]];       for (int c = 0; c < 26; ++c) f[i][c] = solve(pre[i][c] + 1, i, c);     }     for (int q = read(); q; --q) {       int l = read(), r = read();       memset(dp, -1, sizeof(dp));       puts(Solve(l, r, 26) ?  Alice  :  Bob );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long power(long long x, long long n) {     long long ans = 1;     for (int i = 1; i <= n; i++) ans *= x;     return ans;   }   long long gcd(long long x, long long y) {     return (x % y == 0) ? y : gcd(y, x % y);   }   long long n, l, r;   int main() {     cin >> n >> l >> r;     if (n == 1)       cout << r - l + 1;     else if (n == 2) {       cout << (r - l + 1) * (r - l);     } else if (n > 30) {       cout << 0;     } else {       long long ans = 0;       for (int i = 2; i < r; i++) {         int p = i, R = r / power(p, n - 1);         if (R == 0) break;         for (int j = 1; j < p; j++) {           int q = j;           int L = (l - 1) / power(q, n - 1) + 1;           if (L > R) continue;           if (gcd(p, q) == 1) {             ans += (R - L + 1);           }         }       }       cout << ans * 2 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int M = 200000 + 10;   int a[M];   int main() {     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> a[i];     }     sort(a, a + n);     double R_L = 0;     double R_R = 0.5 * a[n - 1] - 0.5 * a[0];     int num = 0;     double C1, C2, C3;     C2 = a[0];     while (num < 200) {       double R_M = (R_L + R_R) / 2;       double D1 = a[0] + R_M * 2;       int ind1 = -1;       for (int i = 0; i < n; i++) {         if (a[i] > D1) {           ind1 = i;           break;         }       }       double D2 = R_M * 2;       int ind2 = -1;       for (int i = n - 1; i >= 0; i--) {         if (a[i] + D2 < a[n - 1]) {           ind2 = i;           break;         }       }       if (ind1 == -1 || ind2 == -1) {         R_R = R_M;       } else {         if (ind1 > ind2) {           R_R = R_M;         } else {           int Dis = a[ind2] - a[ind1];           C2 = 0.5 * (a[ind2] + a[ind1]);           if (Dis <= R_M * 2) {             R_R = R_M;           } else {             R_L = R_M;           }         }       }       num++;     }     C1 = a[0] + R_R;     C3 = a[n - 1] - R_R;     C2 = a[0];     for (int i = 0; i < n; i++) {       if (a[i] > a[0] + 2 * R_R) {         C2 = a[i] + R_R;         break;       }     }     printf( %.10f n , R_R);     printf( %.10f %.10f %.10f n , C1, C2, C3);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100000 + 10;   using ll = long long;   using pii = pair<int, int>;   int pa[maxn];   int sz[maxn];   int d[maxn];   int f[maxn];   vector<ll> pre[maxn];   vector<int> g[maxn], dis[maxn];   map<pii, ll> ans;   int find(int p) { return p == pa[p] ? pa[p] : pa[p] = find(pa[p]); }   void unionPQ(int p, int q) {     int pp = find(p);     int pq = find(q);     if (pp != pq) {       pa[pp] = pq;       sz[pq] += sz[pp];     }   }   int depth, id, root, flag;   void dfs(int node, int fa = -1, int h = 0) {     if (h > depth) {       depth = h;       id = node;     }     if (f[node] < h) f[node] = h;     if (flag) dis[root].push_back(f[node]);     for (auto v : g[node])       if (v != fa) dfs(v, node, h + 1);   }   int main() {     int n, m, q;     scanf( %d%d%d , &n, &m, &q);     for (int i = 0; i < n; ++i) {       pa[i] = i;       sz[i] = 1;     }     for (int i = 0; i < m; ++i) {       int a, b;       scanf( %d%d , &a, &b);       a--, b--;       g[a].push_back(b);       g[b].push_back(a);       unionPQ(a, b);     }     for (int i = 0; i < n; ++i)       if (i == pa[i]) {         flag = false;         root = i;         depth = 0;         id = i;         dfs(i);         depth = 0;         dfs(id);         d[i] = depth;         flag = true;         dfs(id);         sort(dis[i].begin(), dis[i].end());         pre[i].resize(1 + sz[i]);         pre[i][0] = 0;         for (int j = 0; j < sz[i]; ++j) pre[i][j + 1] = pre[i][j] + dis[i][j];       }     for (int i = 0; i < q; ++i) {       int u, v;       scanf( %d%d , &u, &v);       u--;       v--;       u = find(u);       v = find(v);       if (u == v) {         printf( -1 n );         continue;       }       if (sz[u] > sz[v] || (sz[u] == sz[v] && u > v)) swap(u, v);       if (ans.count({u, v})) {         printf( %.10f n , (double)ans[{u, v}] / sz[u] / sz[v]);         continue;       }       int maxd = max(d[u], d[v]);       ll t = 0;       int p = sz[v] - 1;       for (int x : dis[u]) {         while (p >= 0 && x + 1 + dis[v][p] > maxd) p--;         t += (ll)maxd * (p + 1) + (ll)(x + 1) * (sz[v] - p - 1) + pre[v].back() -              pre[v][p + 1];       }       ans[{u, v}] = t;       printf( %.10f n , (double)ans[{u, v}] / sz[u] / sz[v]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline void ad(int& x, long long y) { x = (x + y) % 1000000007; }   int n, f[40][40][2], t[40], c;   int main() {     scanf( %d , &n);     f[30][0][1] = 1;     for (int i = 30; i; --i)       for (int j = 0; j <= 30; ++j) {         ad(f[i - 1][j][0], f[i][j][0] * (1ll << j) % 1000000007);         ad(f[i - 1][j + 1][0], f[i][j][0]);         int x = j ? (1 << j - 1) : 1, y = j ? (1 << j - 1) : 0;         if ((n >> i - 1) & 1) {           ad(f[i - 1][j][0], (long long)x * f[i][j][1] % 1000000007);           ad(f[i - 1][j][1], (long long)y * f[i][j][1] % 1000000007);           ad(f[i - 1][j + 1][1], f[i][j][1]);         } else           ad(f[i - 1][j][1], (long long)x * f[i][j][1]);       }     int A = 0;     for (int i = 30; ~i; --i) ad(A, f[0][i][0] + f[0][i][1]);     printf( %d n , A);   }
#include<bits/stdc++.h>   using namespace std;   long long ans;   int d[100005];   int main(){    int t; cin>>t; while(t--){     int n; scanf( %d ,&n);     for(int i=1;i<=n;++i)scanf( %d ,&d[i]);     sort(d+1,d+1+n); ans=d[n];     for(int i=1;i<=n;++i)ans+=d[i]*(n+1ll-i-i);     printf( %lld n ,ans);    }   }
#include <bits/stdc++.h>   using namespace std;   int gcd(int a, int b) {     if (b == 0) return a;     return gcd(b, a % b);   }   void solve() {     int a, b, n;     cin >> a >> b >> n;     bool aturn = true;     while (n > 0) {       int x;       if (aturn) {         x = gcd(a, n);         aturn = false;       } else {         x = gcd(b, n);         aturn = true;       }       n -= x;     }     if (aturn == false)       cout <<  0             <<   n ;     else       cout <<  1             <<   n ;   }   int main(void) {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int read() {     int res = 0, f = 1;     char c = getchar();     while (!isdigit(c) && c !=  - ) c = getchar();     if (c ==  - ) f = -1, c = getchar();     while (isdigit(c)) res = (res << 3) + (res << 1) + (c ^ 48), c = getchar();     return res * f;   }   const int maxn = 2e5 + 10;   int n, k, val[26];   char s[maxn];   int main() {     int T = read();     while (T--) {       n = read();       k = read();       int ans = 0;       scanf( %s , s + 1);       for (int i = 1; i <= k / 2; i++) {         memset(val, 0, sizeof(val));         for (int j = 0; j < n / k; j++) {           val[s[i + j * k] -  a ]++;           val[s[k - i + 1 + j * k] -  a ]++;         }         int tmp = 0;         for (int j = 0; j < 26; j++) tmp = max(tmp, val[j]);         ans += n / k * 2 - tmp;       }       if (k & 1) {         memset(val, 0, sizeof(val));         for (int j = 0; j < n / k; j++) {           val[s[k / 2 + 1 + j * k] -  a ]++;         }         int tmp = 0;         for (int j = 0; j < 26; j++) tmp = max(tmp, val[j]);         ans += n / k - tmp;       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b;     while (cin >> a >> b) {       long long divi = a - b, cnt = 0;       if (a == b)         cout <<  infinity  << endl;       else {         for (long long i = 1; i * i <= divi; i++) {           if (divi % i == 0) {             long long other = divi / i;             if (i > b) cnt++;             if (other > b && other != i) cnt++;           }         }         cout << cnt << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   const long long MAX = 300000;   const double PI = 3.14159265358979323846;   long long T[MAX * 2];   long long ceil_log2(long long n) {     long long v = 1;     long long log = 0;     while (v < n) {       v <<= 1;       log++;     }     return log;   }   std::bitset<64> reverse(std::bitset<64> set, long long bit_count) {     for (long long i = 0; i < bit_count / 2; i++) {       bool tmp = set[i];       set[i] = set[bit_count - 1 - i];       set[bit_count - 1 - i] = tmp;     }     return set;   }   void fft(std::complex<double> *A, long long bit_count, bool inverse = false) {     static std::complex<double> W[MAX];     long long N = 1 << bit_count;     for (long long i = 0; i < N; i++) {       long long j = T[i];       if (i < j) std::swap(A[i], A[j]);     }     for (long long step = 1; step < N; step <<= 1) {       double angle = -PI / step;       if (inverse) angle = -angle;       std::complex<double> w(1, 0), wn(std::cos(angle), std::sin(angle));       for (long long i = 0; i < step; i++) {         W[i] = w;         w *= wn;       }       for (long long start_even = 0; start_even < N; start_even += step * 2) {         auto start_odd = start_even + step;         for (long long i = 0; i < step; i++) {           std::complex<double> U = A[start_even + i];           std::complex<double> V = W[i] * A[start_odd + i];           A[start_even + i] = U + V;           A[start_odd + i] = U - V;         }       }     }     if (inverse) {       for (long long i = 0; i < N; i++) A[i] /= N;     }   }   long long C[MAX];   long long zero_count = 0;   long long n, x;   long long C_len, bit_count, N;   void init() {     std::fill(C, C + n + 1, 0);     C[0] = 1;     C_len = n + 1;     bit_count = ceil_log2(C_len * 2);     N = 1 << bit_count;     for (long long i = 0; i < N; i++) {       T[i] = reverse(i, bit_count).to_ullong();     }   }   void input() {     std::cin >> n >> x;     init();     long long sum = 0;     for (long long i = 0; i < n; i++) {       long long v;       std::cin >> v;       sum += v < x;       C[sum]++;     }     for (long long i = 0; i <= sum; i++)       if (C[i] > 1) zero_count += C[i] * (C[i] - 1) / 2;   }   int main() {     input();     std::cout << zero_count <<    ;     static std::complex<double> A[MAX * 2], B[MAX * 2];     std::copy(C, C + C_len, A);     std::fill(A + C_len, A + N, 0);     std::fill(B, B + 2 * n - C_len, 0);     std::reverse_copy(C, C + C_len, B + 2 * n - C_len);     std::fill(B + 2 * n, B + N, 0);     fft(A, bit_count);     fft(B, bit_count);     for (long long i = 0; i < N; i++) A[i] *= B[i];     fft(A, bit_count, true);     for (long long k = 1; k <= n; k++)       std::cout << (long long)std::round(A[2 * n - k - 1].real()) <<    ;     std::cout << std::endl;     return 0;     for (long long i = 0; i < N; i++) std::cout << A[i] <<    ;     std::cout << std::endl;     for (long long i = 0; i < N; i++) std::cout << B[i] <<    ;     std::cout << std::endl;     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast,no-stack-protector )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx )   #pragma GCC target( avx,tune=native )   using namespace std;   const long long mod = 1e9 + 7;   long long w[11];   vector<vector<long long> > mul(vector<vector<long long> >& a,                                  vector<vector<long long> >& b) {     vector<vector<long long> > ret(a.size(), vector<long long>(a.size(), 0));     for (long long i = 0; i < a.size(); i++)       for (long long j = 0; j < a.size(); j++) ret[i][j] = 0;     for (long long i = 0; i < a.size(); i++) {       for (long long j = 0; j < a.size(); j++) {         for (long long k = 0; k < a.size(); k++) {           ret[i][j] += a[i][k] * b[k][j];           ret[i][j] %= mod;         }       }     }     return ret;   }   vector<vector<long long> > Pow(vector<vector<long long> > a, long long k) {     vector<vector<long long> > ret = a, m = a;     k--;     do {       if (k & 1) ret = mul(ret, m);       m = mul(m, m);     } while (k >>= 1);     return ret;   }   long long dp[1 << 7], tdp[1 << 7], pre;   void solve(long long x, long long times) {     vector<vector<long long> > mat((1 << x), vector<long long>((1 << x), 0));     for (long long st = 0; st < (1 << x); st++) {       for (long long ed = 0; ed < (1 << x); ed++) {         for (long long bt = 0; bt < (1 << (x - 1)); bt++) {           long long add = 1;           for (long long j = 0; j < x; j++) {             long long cnt = 0;             if (bt & (1 << j) || j == x - 1) cnt++;             if (j == 0 || (bt & (1 << (j - 1)))) cnt++;             if (st & (1 << j)) cnt++;             if (ed & (1 << j)) cnt++;             if (cnt == 4) add = 0;           }           if (add) mat[st][ed]++;           if (mat[st][ed] >= mod) mat[st][ed] -= mod;         }       }     }     mat = Pow(mat, times);     memset(tdp, 0, sizeof tdp);     long long or_mask = 0;     for (long long i = pre; i < x; i++) or_mask |= (1 << i);     for (long long i = 0; i < (1 << x); i++) {       for (long long j = 0; j < (1 << x); j++) {         tdp[j] += dp[i] * mat[i | or_mask][j];         tdp[j] %= mod;       }     }     memcpy(dp, tdp, sizeof tdp);     pre = x;   }   signed main() {     for (long long i = 1; i <= 7; i++) cin >> w[i];     for (long long i = 1; i <= 7; i++) {       if (w[i]) {         dp[(1 << i) - 1] = 1;         break;       }     }     for (long long i = 1; i <= 7; i++) {       if (w[i]) {         solve(i, w[i]);       }     }     for (long long i = 7; i >= 1; i--) {       if (w[i]) {         cout << dp[(1 << i) - 1] << endl;         return 0;       }     }     return 0;   }