malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   char a[10][10];   int main(void) {     for (int i = 0; i < 8; i++) {       cin >> a[i];     }     int b = 10, w = 10;     for (int i = 0; i < 8; i++) {       for (int j = 0; j < 8; j++) {         if (a[i][j] ==  B ) {           int f = 0;           for (int k = i + 1; k < 8; k++) {             if (a[k][j] !=  . ) f = 1;           }           if (!f) b = min(8 - i - 1, b);         }         if (a[i][j] ==  W ) {           int f = 0;           for (int k = i - 1; k >= 0; k--) {             if (a[k][j] !=  . ) f = 1;           }           if (!f) w = min(i, w);         }       }     }     if (b < w)       cout <<  B ;     else       cout <<  A ;   }
#include <bits/stdc++.h>   using namespace std;   int e, s, n, m, st, q[4][200000 + 10];   pair<int, int> a[200000 * 2 + 10], f[200000 * 2 + 10], ans[200000 + 10];   int main() {     int i, front[4], rear[4], j;     memset(f, 0xff, sizeof f);     memset(ans, 0xff, sizeof ans);     scanf( %d%d%d%d , &e, &s, &n, &m);     for (i = 1; i <= n; i++) scanf( %d%d , &a[i].second, &a[i].first);     for (i = 1; i <= m; i++) {       scanf( %d , &a[i + n].first);       a[i + n].second = 3 + i;     }     sort(a + 1, a + n + m + 1);     for (i = 1; i <= n + m; i++)       if (a[i].first > e) break;     if (a[i].first == e) i--;     a[i].first = e, a[i].second = 3;     e = i;     f[e] = make_pair(0, 0);     q[3][0] = e;     front[3] = rear[3] = 0;     front[2] = front[1] = 0;     rear[2] = rear[1] = -1;     for (i = e - 1; i; i--) {       int t = 0x7fffffff;       while (front[3] <= rear[3] && a[q[3][front[3]]].first - a[i].first > s)         front[3]++;       while (front[2] <= rear[2] && a[q[2][front[2]]].first - a[i].first > s)         front[2]++;       while (front[1] <= rear[1] && a[q[1][front[1]]].first - a[i].first > s)         front[1]++;       if (a[i].second > 3) {         for (j = 3; j > 0; j--)           if (front[j] <= rear[j]) {             if (j == 1)               ans[a[i].second - 3] =                   make_pair(f[q[j][front[j]]].first - s +                                 a[q[j][front[j]]].first - a[i].first,                             f[q[j][front[j]]].second);             else if (j == 2)               ans[a[i].second - 3] =                   make_pair(f[q[j][front[j]]].first,                             f[q[j][front[j]]].second - s +                                 a[q[j][front[j]]].first - a[i].first);             else               ans[a[i].second - 3] =                   make_pair(f[q[j][front[j]]].first, f[q[j][front[j]]].second);             break;           }         if (!i) ans[a[i].second] = make_pair(-1, -1);         continue;       }       for (j = 3; j >= a[i].second; j--)         if (front[j] <= rear[j]) t = min(t, q[j][rear[j]]);       if (t == 0x7fffffff)         for (; j; j--)           if (front[j] <= rear[j]) {             t = q[j][front[j]];             break;           }       if (t == 0x7fffffff) break;       f[i] = f[t];       if (a[t].second >= a[i].second) {         if (a[i].second == 1)           f[i].first += a[t].first - a[i].first;         else if (a[i].second == 2)           f[i].second += a[t].first - a[i].first;       } else {         if (a[i].second == 2) {           f[i].second += s;           f[i].first -= s - a[t].first + a[i].first;         } else if (a[i].second == 3) {           if (a[t].second == 2)             f[i].second -= s - a[t].first + a[i].first;           else             f[i].first -= s - a[t].first + a[i].first;         }       }       q[a[i].second][++rear[a[i].second]] = i;     }     for (i = 1; i <= m; i++) printf( %d %d n , ans[i].first, ans[i].second);   }
#include <bits/stdc++.h>   using namespace std;   #define mp make_pair   #define pb push_back   #define x first   #define y second   typedef pair<int,int> pii;   typedef long long ll;   typedef unsigned long long ull;   template <typename T> void chkmax(T &x,T y){x<y?x=y:T();}   template <typename T> void chkmin(T &x,T y){y<x?x=y:T();}   template <typename T> void readint(T &x)   {    x=0;int f=1;char c;    for(c=getchar();!isdigit(c);c=getchar())if(c== - )f=-1;    for(;isdigit(c);c=getchar())x=x*10+(c- 0 );    x*=f;   }   const int MOD1=1010101039,MOD2=1000020001;   const int MAXN=300005,MAXK=19,MAXV=MAXN*21;      int n,a[MAXN];   vector<int> G[MAXN];   int anc[MAXN][MAXK],dep[MAXN];   int stot,vs[MAXN];   pii h[MAXV],pw[MAXN];   int lch[MAXV],rch[MAXV];   pii operator *(pii a,pii b){return mp(1ll*a.x*b.x%MOD1,1ll*a.y*b.y%MOD2);}   pii operator +(pii a,pii b){return mp((a.x+b.x)%MOD1,(a.y+b.y)%MOD2);}   int modify(int id,int l,int r,int x)   {    int rt=++stot;    if(l==r)    {     h[rt]=mp(1-h[id].x,1-h[id].y);     return rt;    }    int mid=(l+r)>>1;    if(x<=mid)lch[rt]=modify(lch[id],l,mid,x),rch[rt]=rch[id];    else rch[rt]=modify(rch[id],mid+1,r,x),lch[rt]=lch[id];    h[rt]=h[lch[rt]]*pw[r-mid]+h[rch[rt]];    return rt;   }   int query(int u,int v,int l,int r,int ql,int qr)   {    if(h[u]==h[v])return -1;    if(l==r)return l;    int mid=(l+r)>>1;    if(qr<=mid)return query(lch[u],lch[v],l,mid,ql,qr);    if(ql>mid)return query(rch[u],rch[v],mid+1,r,ql,qr);    int s=query(lch[u],lch[v],l,mid,ql,mid);    if(s>0)return s;    return query(rch[u],rch[v],mid+1,r,mid+1,qr);   }   void dfs(int u,int pa)   {    for(int j=1;j<MAXK;++j)anc[u][j]=anc[anc[u][j-1]][j-1];    for(auto v:G[u])     if(v!=pa)     {      anc[v][0]=u;      dep[v]=dep[u]+1;      vs[v]=modify(vs[u],1,n,a[v]);      dfs(v,u);     }   }   int lca(int u,int v)   {    if(dep[u]>dep[v])swap(u,v);    for(int i=MAXK-1;i>=0;--i)if(dep[anc[v][i]]>=dep[u])v=anc[v][i];    if(u==v)return u;    for(int i=MAXK-1;i>=0;--i)if(anc[u][i]!=anc[v][i])u=anc[u][i],v=anc[v][i];    return anc[u][0];   }      int main()   {    #ifdef LOCAL    freopen( code.in , r ,stdin);   // freopen( code.out , w ,stdout);    #endif    int Q,u,v,l,r;    readint(n),readint(Q);    for(int i=1;i<=n;++i)readint(a[i]);    for(int i=1;i<n;++i)readint(u),readint(v),G[u].pb(v),G[v].pb(u);    pw[0]=mp(1,1);pw[1]=mp(29,101);    for(int i=2;i<=n;++i)pw[i]=pw[i-1]*pw[1];     vs[1]=modify(0,1,n,a[1]);    dep[1]=1;    dfs(1,-1);    while(Q--)    {     readint(u),readint(v),readint(l),readint(r);     int d=lca(u,v);     if(a[d]<l || a[d]>r)     {      int t=query(vs[u],vs[v],1,n,l,r);      printf( %d n ,t);     }     else     {      int t=(a[d]==l?-1:query(vs[u],vs[v],1,n,l,a[d]-1));      if(t<0)      {       t=(a[d]==r?-1:query(vs[u],vs[v],1,n,a[d]+1,r));       if(t<0)       {        t=query(vs[u],vs[v],1,n,a[d],a[d]);        if(t==-1)t=a[d];        else t=-1;       }      }      printf( %d n ,t);     }    }    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int price[100005];   int sum[100005];   vector<int> tempo;   int main() {     int n, t;     scanf( %d , &n);     tempo.push_back(0);     for (int i = 1; i <= n; i++) {       scanf( %d , &t);       if (i == 1) {         price[i] = 20;         sum[i] = 20;         tempo.push_back(t);         continue;       }       int fim = i - 1;       int ini = (int)(lower_bound(tempo.begin(), tempo.end(), t - 1440 + 1) -                       tempo.begin());       ini = max(ini - 1, 0);       int p = (sum[fim] - sum[ini] >= 120 ? 0 : 120 - (sum[fim] - sum[ini]));       ini = (int)(lower_bound(tempo.begin(), tempo.end(), t - 90 + 1) -                   tempo.begin());       ini = max(ini - 1, 0);       int aux = (sum[fim] - sum[ini] >= 50 ? 0 : 50 - (sum[fim] - sum[ini]));       price[i] = min(p, min(aux, 20));       sum[i] = sum[i - 1] + price[i];       tempo.push_back(t);     }     for (int i = 1; i <= n; i++) {       printf( %d n , price[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main(int argc, char* argv[]) {     long long ax, ay, bx, by, cx, cy, ab, bc;     double slopeAB, slopeBC;     cin >> ax >> ay >> bx >> by >> cx >> cy;     if (ax == cx && ay == cy) {       cout <<  Yes n ;     } else {       ab = (ax - bx) * (ax - bx) + (ay - by) * (ay - by);       bc = (cx - bx) * (cx - bx) + (cy - by) * (cy - by);       slopeAB = (double)(ay - by) / (double)(ax - bx);       slopeBC = (double)(by - cy) / (double)(bx - cx);       if (ab == bc && slopeAB != slopeBC) {         cout <<  Yes n ;       } else {         cout <<  No n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long bigmod(long long b, long long p, long long m) {     if (p == 0) return 1;     if (p % 2 == 0) {       long long temp = bigmod(b, p / 2, m);       return (temp * temp) % m;     }     return (bigmod(b, p - 1, m) * (b % m)) % m;   }   int main() {     string s;     cin >> s;     int n = s.length();     long long cnt = 0;     long long ans = 0;     long long mod = 1e9 + 7;     for (int i = 0; i < n; i++) {       if (s[i] ==  a ) {         cnt++;       } else {         if (cnt > 0) ans += (bigmod(2, cnt, mod) - 1);         ans %= mod;       }     }     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   vector<bool> was;   vector<vector<int> > es;   vector<int> cst;   vector<int> cols;   vector<vector<int> > cycs;   void dfs(int v, int par = -1) {     was[v] = true;     cst.push_back(v);     for (int i = 0; i < ((int)(es[v]).size()); i++) {       int b = es[v][i];       if (b == par) continue;       if (was[b]) {         if (cols[v] >= 0) {           assert(cols[v] == cols[b]);         } else {           int cid = ((int)(cycs).size());           cycs.push_back(vector<int>());           for (int i2 = ((int)(cst).size()) - 1; i2 >= 0; i2--) {             cycs[cid].push_back(cst[i2]);             assert(cols[cst[i2]] < 0);             cols[cst[i2]] = cid;             if (cst[i2] == b) break;           }         }       } else         dfs(b, v);     }     cst.pop_back();   }   int dfs2(int v, int par = -1) {     int cid = cols[v];     int res = ((int)(cycs[cid]).size()) > 1;     int sumcnt = 0;     int nzcnt = 0;     for (int i = 0; i < ((int)(cycs[cid]).size()); i++) {       int a = cycs[cid][i];       int subcnt = 0;       for (int i2 = 0; i2 < ((int)(es[a]).size()); i2++) {         int b = es[a][i2];         if (cols[b] == cid) continue;         int cres = -1;         if (b != par) {           cres = dfs2(b, a);         } else {           cres = 1;         }         res += cres;         subcnt++;       }       res -= subcnt / 2;       sumcnt += subcnt;       if (subcnt) nzcnt++;     }     if (((int)(cycs[cid]).size()) > 1) {       if (nzcnt >= 2) {         res -= 1;       }     }     return res;   }   int main() {     int n, m;     while (scanf( %d%d , &n, &m) >= 1) {       es = vector<vector<int> >(n);       for (int i = 0; i < m; i++) {         int a, b;         scanf( %d%d , &a, &b), a--, b--;         es[a].push_back(b);         es[b].push_back(a);       }       was = vector<bool>(n, false);       cst.clear();       cols = vector<int>(n, -1);       cycs = vector<vector<int> >();       dfs(0);       for (int i = 0; i < n; i++)         if (cols[i] < 0) {           int cid = ((int)(cycs).size());           cycs.push_back(vector<int>(1, i));           cols[i] = cid;         }       int ans = dfs2(0);       printf( %d %d n , ans, m);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int T = 7;   int prosti[] = {114689, 163841, 147457, 188417, 151553, 270337, 286721};   int proots[] = {3, 3, 10, 3, 3, 10, 11};   int pows[7][300000];   void fft_trivial(vector<int>& a, int id) {     int n = a.size();     int mod = prosti[id];     int step = (mod - 1) / n;     vector<int> b(n);     for (int i = 0; i < n; i++) {       for (int k = 0, w = 0; k < n; k++, w = (w + i * step) % (mod - 1)) {         b[i] += a[k] * 1ll * pows[id][w] % mod;         if (b[i] >= mod) b[i] -= mod;       }     }     swap(a, b);   }   void fft(vector<int>& a, int id) {     int n = a.size();     if (n & 1) {       fft_trivial(a, id);       return;     }     int mod = prosti[id];     int step = (mod - 1) / n;     int h = n >> 1;     vector<int> b(h), c(h);     for (int i = 0; i < h; i++) {       b[i] = a[2 * i];       c[i] = a[2 * i + 1];     }     fft(b, id);     fft(c, id);     for (int i = 0, w = 0; i < h; i++, w += step) {       int bb = b[i];       int cc = c[i] * 1ll * pows[id][w] % mod;       int u = bb + cc;       int v = bb - cc;       if (u >= mod) u -= mod;       if (v < 0) v += mod;       a[i] = u;       a[i + h] = v;     }   }   void init() {     for (int i = 0; i < T; i++) {       int p = 1, q = proots[i];       for (int j = 0; j < 300000; j++) {         pows[i][j] = p;         p = p * 1ll * q % prosti[i];       }     }   }   int hsh(string s, int mod, int b) {     int z = 0;     for (int i = 0, p = 1; i < (int)s.size(); i++, p = p * 1ll * b % mod)       z = (z + s[i] * 1ll * p) % mod;     return z;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     cerr.tie(nullptr);     init();     int n, m;     string a, b;     cin >> n >> m >> a >> b;     for (int i = 0; i < T; i++) {       int mod = prosti[i];       vector<int> va(mod - 1, 0), vb(mod - 1, 0);       for (int j = 0; j < n; j++) {         va[j] = a[j];         vb[j] = b[j];       }       fft(va, i);       fft(vb, i);       for (int r = 0; r < mod - 1; r++) {         int y = pows[i][r];         if (va[r] == vb[r] && y > 1 && y < mod - 1) {           cout << mod <<     << y <<   n ;           return 0;         }       }     }     cout <<  Failed n ;     return 1;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:536870912 )   #pragma warning(disable : 4996)   using namespace std;   const int N = 5e5 + 100;   int q[N], a[N], b[N], w[N], used[N], in[N];   bool ok[N];   vector<int> tr[N], d[N];   vector<pair<int, vector<int>>> gr[N];   vector<pair<int, int>> ed;   int col = 0, cg = 0;   int find(int v) { return q[v] < 0 ? v : q[v] = find(q[v]); }   bool un(int a, int b) {     a = find(a), b = find(b);     if (a != b) {       if (q[a] > q[b]) swap(a, b);       q[a] += q[b];       q[b] = a;       return true;     }     return false;   }   bool dfs(int node, int p) {     used[node] = col;     for (int to : tr[node]) {       if (to == p) continue;       if (used[to] == col)         return true;       else if (dfs(to, node))         return true;     }     return false;   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     memset(q, -1, sizeof(q));     ;     for (int i = 0; i < m; i++) {       scanf( %d%d%d , &a[i], &b[i], &w[i]);       a[i]--, b[i]--;       ed.push_back({w[i], i});     }     sort(ed.begin(), ed.end());     int t;     scanf( %d , &t);     for (int i = 0; i < t; i++) {       int k;       scanf( %d , &k);       for (int j = 0; j < k; j++) {         scanf( %d , &in[j]);         in[j]--;         if (gr[w[in[j]]].empty() || !gr[w[in[j]]].back().second.empty()) {           gr[w[in[j]]].push_back({cg, vector<int>()});           d[i].push_back(cg);           cg++;         }       }       for (int j = 0; j < k; j++) {         gr[w[in[j]]].back().second.push_back(in[j]);       }     }     for (int i = 0; i < ed.size(); i++) {       if (i == 0 || ed[i].first != ed[i - 1].first) {         for (auto &p : gr[ed[i].first]) {           for (int j : p.second) {             int x = find(a[j]), y = find(b[j]);             tr[x].push_back(y);             tr[y].push_back(x);           }           col++;           ok[p.first] = 1;           for (int j : p.second) {             int x = find(a[j]);             if (used[x] != col && dfs(x, -1)) {               ok[p.first] = 0;               break;             }           }           for (int j : p.second) {             int x = find(a[j]), y = find(b[j]);             tr[x].clear();             tr[y].clear();           }         }       }       un(a[ed[i].second], b[ed[i].second]);     }     for (int i = 0; i < t; i++) {       bool f = true;       for (int j : d[i]) {         if (!ok[j]) {           f = false;           break;         }       }       printf( %s n , f ?  YES  :  NO );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     string str;     for (int i = 1; i <= t; i++) {       cin >> str;       string str1;       str1.append(str, 0, 1);       int j = 1, l = str.length();       while (j < l) {         str1.append(str, j, 1);         j += 2;       }       cout << str1 <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   #pragma warning(disable : 4996)   int a[100010], cnt[100010];   int queries[100010][2];   bool res[100010];   bool xpeHb[100010];   int main() {     int t;     scanf( %d , &t);     for (int y = 0; y < t; y++) {       int m, k;       scanf( %d %d , &m, &k);       for (int i = 1; i <= k; i++) {         scanf( %d , &a[i]);       }       int t, r;       int count = 0;       bool flag = false;       for (int i = 0; i < m - 1; i++) {         scanf( %d %d , &queries[i][0], &queries[i][1]);         if (queries[i][1] == 1) flag = true;         if (flag) {           if (queries[i][0]) xpeHb[queries[i][0]] = true;         }       }       flag = true;       for (int i = 0; i < m - 1; i++) {         t = queries[i][0];         r = queries[i][1];         if (r == 1 && flag) {           flag = false;           int max = 0;           for (int j = 1; j <= k; j++) {             if (cnt[j] + count >= a[j] && !xpeHb[j]) {               res[j] = true;               if (max < cnt[j] + count - a[j]) max = cnt[j] + count - a[j];             }           }           count = max;         }         if (t == 0)           count++;         else {           cnt[t]++;         }       }       for (int j = 1; j <= k; j++) {         if (cnt[j] + count >= a[j]) {           res[j] = true;         }         if (res[j])           printf( Y );         else           printf( N );       }       printf(  n );       memset(cnt, 0, (k + 1) * 4);       memset(res, 0, (k + 1) * 1);       memset(a, 0, (k + 1) * 4);       memset(xpeHb, 0, (k + 1) * 1);       memset(queries[0], 0, (m + 1) * 4);       memset(queries[1], 0, (m + 1) * 4);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   namespace fast {   inline char nc() {     static char buf[100000], *L = buf, *R = buf;     return L == R && (R = (L = buf) + fread(buf, 1, 100000, stdin), L == R)                ? EOF                : *L++;   }   template <class orz>   inline void qread(orz &x) {     x = 0;     char ch = nc();     bool f = 0;     while (ch <  0  || ch >  9 ) (ch ==  - ) && (f = 1), ch = nc();     while (ch >=  0  && ch <=  9 ) x = (x << 3) + (x << 1) + (ch ^ 48), ch = nc();     f && (x = -x);   }   }  // namespace fast   using namespace fast;   template <class orz>   inline void read(orz &x) {     x = 0;     bool f = 0;     char ch = getchar();     while (ch <  0  || ch >  9 ) (ch ==  - ) && (f = 1), ch = getchar();     while (ch >=  0  && ch <=  9 )       x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();     f && (x = -x);   }   template <class orz>   inline void out(orz x) {     (x < 0) && (putchar( - ), x = -x);     if (x > 9) out(x / 10);     putchar(x % 10 +  0 );   }   const double PI = acos(-1);   const double eps = 1e-8;   const int INF = 0x3f3f3f3f;   const long long mod = 1e9 + 7;   const int maxn = 1e3 + 5;   int a[maxn][maxn];   int n, m;   int r[maxn], c[maxn];   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) read(r[i]);     for (int i = 0; i < m; i++) read(c[i]);     for (int i = 0; i < n; i++) {       if (r[i] == 0) {         a[i][0] = -1;       } else {         for (int j = 0; j < r[i]; j++) {           a[i][j] = 1;         }         a[i][r[i]] = -1;       }     }     int flag = 0;     long long sum = 1;     for (int i = 0; i < m; i++) {       if (c[i] == 0) {         if (a[0][i] == 0 || a[0][i] == -1)           a[0][i] = -1;         else {           flag = 1;           break;         }       } else {         for (int j = 0; j < c[i]; j++) {           if (a[j][i] == 0 || a[j][i] == 1)             a[j][i] = 1;           else {             flag = 1;             break;           }         }         if (a[c[i]][i] == 0 || a[c[i]][i] == -1)           a[c[i]][i] = -1;         else {           flag = 1;           break;         }       }     }     if (!flag) {       for (int i = 0; i < n; i++) {         for (int j = 0; j < m; j++) {           if (a[i][j] == 0) sum = sum * 2 % mod;         }       }       cout << sum << endl;     } else       cout <<  0  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     cin >> n;     int sum = 0;     int i = 0;     while (i < n) {       int x;       cin >> x;       sum += x;       ++i;     }     cout << fixed << setprecision(12);     cout << (long double)sum / n;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int q;     cin >> q;     unsigned long long c;     for (int i = 0; i < q; i++) {       cin >> c;       if ((c < 4) | (c % 2 != 0 & c < 13 & c != 9))         cout << -1 << endl;       else {         if (c % 2 != 0)           cout << (c - 9) / 4 + 1 << endl;         else           cout << c / 4 << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     int tc;     cin >> tc;     while (tc--) {       int arr[103][103];       long long cnt = 0;       int n, m;       cin >> n >> m;       for (int i = 1; i <= n; i++)         for (int j = 1; j <= m; j++) cin >> arr[i][j];       for (int i = 1; i <= n / 2; i++) {         vector<int> a;         for (int j = 1; j <= m / 2; j++) {           a.push_back(arr[i][j]);           a.push_back(arr[n + 1 - i][j]);           a.push_back(arr[i][m + 1 - j]);           a.push_back(arr[n + 1 - i][m + 1 - j]);           sort(a.begin(), a.end());           for (int tmp : a) cnt += abs(tmp - a[1]);           a.clear();         }         if (m % 2) cnt += abs(arr[i][m / 2 + 1] - arr[n + 1 - i][m / 2 + 1]);       }       if (n % 2) {         for (int j = 1; j <= m / 2; j++)           cnt += abs(arr[n / 2 + 1][j] - arr[n / 2 + 1][m + 1 - j]);       }       cout << cnt <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, m, hours_digit = 1, minutes_digit = 1;     cin >> n >> m;     long long int temp = 0;     for (long long int a = 7; a < n; a *= 7) hours_digit += 1;     for (long long int b = 7; b < m; b *= 7) minutes_digit += 1;     if (hours_digit + minutes_digit > 7) {       cout << 0 << endl;       return 0;     }     long long int final_ans = 0;     for (int i = 0; i < n; i++) {       vector<int> arr(7, 0);       temp = i;       int temp2 = 0;       while (temp > 0) {         arr[temp % 7]++;         temp = temp / 7;         temp2++;       }       arr[0] += hours_digit - temp2;       for (int j = 0; j < m; j++) {         vector<int> arr2(7, 0);         temp = j;         temp2 = 0;         while (temp > 0) {           arr2[temp % 7]++;           temp = temp / 7;           temp2++;         }         arr2[0] += minutes_digit - temp2;         int flag = 0;         for (int k = 0; k < 7; k++) {           if (arr2[k] + arr[k] > 1) {             flag = 1;             break;           }         }         if (flag == 0) {           final_ans++;         }       }     }     cout << final_ans << endl;   }