malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   bool prime[10000007];   void SieveOfEratosthenes() {     memset(prime, true, sizeof(prime));     for (long long int p = 2; p * p <= 10000007; p++) {       if (prime[p] == true) {         for (long long int i = p * p; i <= 10000007; i += p) prime[i] = false;       }     }   }   const long long int N = 300500;   long long int fact[N];   long long int invFact[N];   long long int fast_pow(long long int a, long long int p, long long int m) {     long long int res = 1;     while (p) {       if (p % 2 == 0) {         a = (a * a) % m;         p /= 2;       } else {         res = (res * a) % m;         p--;       }     }     return res;   }   void Call_For_nCr() {     fact[0] = invFact[0] = 1;     for (long long int i = 1; i < N; i++) {       fact[i] = (fact[i - 1] * i) % 1000000007;       invFact[i] = fast_pow(fact[i], 1000000007 - 2, 1000000007);     }   }   long long int nCR(long long int n, long long int k, long long int m) {     if (k > n) {       return 0;     }     return fact[n] * invFact[k] % m * invFact[n - k] % m;   }   long long int sumOfDigit(long long int n, long long int b) {     long long int unitDigit, sum = 0;     while (n > 0) {       unitDigit = n % b;       sum += unitDigit;       n = n / b;     }     return sum;   }   long long int factorial(long long int n) {     return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);   }   bool compare(pair<long long int, long long int> a,                pair<long long int, long long int> b) {     if (a.first < b.first) return 1;     if (b.first < a.first) return 0;     if (a.second > b.second) return 1;     return 0;   }   void solve() {     string s;     cin >> s;     long long int ans = 0, one = 0, ok = 0, zero = 0;     for (long long int i = 0; i < s.length(); i++) {       if (s[i] ==  0 ) {         zero = 1;         ok = 1;         if (one && zero) ans = 1;       }       if (s[i] ==  1 ) {         if (zero) one = 1;       }     }     if (!ok) {       cout << 0 <<   n ;       return;     }     if (ans)       cout << 2 <<   n ;     else       cout << 1 <<   n ;   }   void init_code() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);   }   signed main() {     init_code();     long long int t = 1;     cin >> t;     long long int i = 1;     while (t--) {       solve();       i++;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline bool is_palindrome(const string& s) {     return std::equal(s.begin(), s.end(), s.rbegin());   }   const long long MOD = 1000000007;   const long long INF = 1e9 + 5;   const double eps = 1e-7;   const double PI = acos(-1.0);   inline void debug_vi(vector<int> a) {     for (long long i = (long long)(0); i < (long long)(a.size()); i++)       cout << a[i] <<    ;   }   inline void debug_vll(vector<long long> a) {     for (long long i = (long long)(0); i < (long long)(a.size()); i++)       cout << a[i] <<    ;   }   const int N = 1e5 + 5;   int arr[N];   pair<int, int> xpos, ypos;   int main() {     std::ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n, l, x, y, j;     cin >> n >> l >> x >> y;     xpos = {-1, -1};     ypos = xpos;     for (long long i = (long long)(0); i < (long long)(n); i++) {       cin >> arr[i];     }     j = 0;     for (long long i = (long long)(0); i < (long long)(n); i++) {       while (j < n && arr[j] - arr[i] < x) j++;       if (j < n && arr[j] - arr[i] == x) {         xpos = {i, j};         break;       }     }     j = 0;     for (long long i = (long long)(0); i < (long long)(n); i++) {       while (j < n && arr[j] - arr[i] < y) j++;       if (j < n && arr[j] - arr[i] == y) {         ypos = {i, j};         break;       }     }     if (xpos.first != -1 && ypos.first != -1) {       cout << 0;     } else if (xpos.first != -1 || ypos.first != -1) {       cout << 1 <<   n ;       if (xpos.first != -1) {         cout << y;       } else {         cout << x;       }     } else {       j = 0;       for (long long i = (long long)(0); i < (long long)(n); i++) {         while (j < n && arr[j] - arr[i] < x + y) j++;         if (j < n && arr[j] - arr[i] == x + y) {           cout << 1 <<   n ;           cout << arr[i] + x <<   n ;           return 0;         }       }       j = 0;       for (long long i = (long long)(0); i < (long long)(n); i++) {         while (j < n && arr[j] - arr[i] < y - x) j++;         if (j < n && arr[j] - arr[i] == y - x) {           if (arr[i] - x >= 0) {             cout << 1 <<   n ;             cout << arr[i] - x;             return 0;           } else if (arr[j] + x <= l) {             cout << 1 <<   n ;             cout << arr[j] + x;             return 0;           }         }       }       cout << 2 <<   n ;       cout << x <<     << y;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   void in(T &x) {     x = 0;     bool f = 0;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = 1;       c = getchar();     }     while ( 0  <= c && c <=  9 ) {       x = (x << 3) + (x << 1) + (c ^ 48);       c = getchar();     }     if (f) x = -x;   }   char tc[1000005];   int a[1000005], b[1000005];   int n, m;   int sum[1000005][3][3];   signed main() {     scanf( %s , tc + 1);     n = strlen(tc + 1);     for (register int i = 1; i <= n; ++i)       a[i] = (tc[i] ==  R  ? 0 : (tc[i] ==  G  ? 1 : 2));     scanf( %s , tc + 1);     m = strlen(tc + 1);     for (register int i = 1; i <= m; ++i)       b[i] = (tc[i] ==  R  ? 0 : (tc[i] ==  G  ? 1 : 2));     for (register int i = 2; i <= m; ++i) {       for (register int j = 0; j < 3; ++j)         for (register int k = 0; k < 3; ++k) sum[i][j][k] = sum[i - 1][j][k];       ++sum[i][b[i - 1]][b[i]];     }     int l = 1, r = 0;     long long ans = 0;     for (register int i = 1; i <= n; ++i) {       ++r;       while (r < m && b[r] != a[i]) ++r;       if (r > m) r = m;       if (i > 1 && b[l] == a[i - 1]) ++l;       if (l > m) break;       ans += r - l + 1;       if (i > 1 && a[i] != a[i - 1])         ans -= sum[r][a[i]][a[i - 1]] - sum[l - 1][a[i]][a[i - 1]];     }     printf( %lld , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MAX = 100001;   long long n, k, l[MAX], inf = 1000000000000;   multiset<long long> kek;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> k;     for (int i = 0; i < n; i++) {       cin >> l[i + 1];     }     long long a;     cin >> a;     long long ans = 0;     kek.insert(inf);     for (int i = 1; i <= n; i++) {       long long b;       cin >> b;       kek.insert(b);       while (k < l[i]) {         if (*(kek.begin()) == inf) {           cout << -1;           return 0;         }         long long take = *(kek.begin());         kek.erase(kek.find(take));         k += a;         ans += take;       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int a[n], b[1000000] = {0};     for (int i = 0; i < n; i++) {       cin >> a[i];     }     for (int i = 0; i < n / 2; i++) {       if (a[i] - i - 1 >= 0) b[a[i] - i - 1]++;       if (a[n - 1 - i] - i - 1 >= 0) b[a[n - 1 - i] - i - 1]++;     }     if (n % 2 && a[n / 2] - (n / 2 + 1) >= 0) {       b[a[n / 2] - (n / 2 + 1)]++;     }     int m = -1;     for (int i = 0; i < 1000000; i++) m = m > b[i] ? m : b[i];     cout << n - m;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, a, b;   int main() {     scanf( %lld %lld %lld %lld , &n, &m, &a, &b);     long long int mm = n % m;     unsigned long long ans = min((m - mm) * a, mm * b);     printf( %llu n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout << setprecision(20);     auto solve = [&]() -> string {       long long int n, k, a, b;       cin >> n >> k >> a >> b;       long long int remG = a;       long long int remB = b;       string ans;       vector<long long int> rem({remG, remB});       vector<long long int> lab({ G ,  B });       long long int cur = (remG > remB) ? 0 : 1;       while (true) {         if (rem[cur] == 0) {           return  NO ;         } else if (rem[cur] < rem[1 - cur]) {           ans += lab[cur];           rem[cur] -= 1;         } else {           long long int t = min(rem[cur], k);           for (long long int i = 0; i < t; i++) ans += lab[cur];           rem[cur] -= t;         }         if (rem[0] == 0 && rem[1] == 0) return ans;         cur = 1 - cur;       }     };     cout << solve() << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int bit[2][100011], head[100011], tail[100011], name[100011], dist[100011], n,       z, D;   vector<int> adj[100011];   int query(int x, int* bit) {     int r = 0;     while (x) {       r += bit[x];       x -= x & -x;     }     return r;   }   void update(int x, int v, int* bit) {     while (x < 100011) {       bit[x] += v;       x += x & -x;     }   }   void dfs(int p, int h, int d) {     if (name[p]) return;     D = max(D, d);     name[p] = z++;     head[p] = h;     dist[p] = d;     for (int i = 0; i < adj[p].size(); ++i) dfs(adj[p][i], h, d + 1);   }   int main() {     int q, t, v, x, d;     scanf( %d%d , &n, &q);     for (int i = 0; i < n - 1; ++i) {       int a, b;       scanf( %d%d , &a, &b);       adj[a].push_back(b);       adj[b].push_back(a);     }     z = 2;     name[1] = head[1] = 1;     for (int i = 0; i < adj[1].size(); ++i) {       int u = adj[1][i];       dfs(u, z, 1);       tail[name[u]] = z - 1;     }     ++D;     while (q--) {       scanf( %d , &t);       if (t == 0) {         scanf( %d%d%d , &v, &x, &d);         int g = d - dist[v];         if (g >= 0) update(max(1, D - g), x, bit[0]);         if (g >= 0) {           int cob = head[v] + g;           if (cob <= tail[head[v]]) {             update(cob, x, bit[1]);             update(min(tail[head[v]] + 1, name[v] + d + 1), -x, bit[1]);           }         } else {           update(name[v] - d, x, bit[1]);           update(min(tail[head[v]] + 1, name[v] + d + 1), -x, bit[1]);         }       } else {         scanf( %d , &v);         int resa = query(D - dist[v], bit[0]);         int resb = query(name[v], bit[1]);         printf( %d n , resa + resb);       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, i, j, k, p, t, a = 0, b = 0;     cin >> n;     vector<long long int> vec;     for (i = 0; i < n; i++) {       cin >> p;       if (p % 2 == 0)         a++;       else         b++;       vec.push_back(p);     }     if (a == 0 || b == 0) {       for (i = 0; i < n; i++) cout << vec[i] <<    ;     } else {       sort(vec.begin(), vec.end());       for (i = 0; i < n; i++) cout << vec[i] <<    ;     }   }
#include <bits/stdc++.h>   int main() {     int n, p, q, p1[150], q1[150], pq[300], i, j, k, l, m;     scanf( %d , &n);     scanf( %d , &p);     for (i = 0; i < p; i++) {       scanf( %d , &p1[i]);     }     scanf( %d , &q);     for (j = 0; j < q; j++) {       scanf( %d , &q1[j]);     }     if ((p == 0) && (q == 0)) {       printf( Oh, my keyboard! n );       return 0;     } else {       for (k = 0; k < (p + q); k++) {         if (k < p) {           pq[k] = p1[k];         } else {           pq[k] = q1[k - p];         }       }       for (l = 1; l <= n; l++) {         for (m = 0; m < p + q; m++) {           if (pq[m] == l) {             break;           } else if (m == (p + q - 1)) {             printf( Oh, my keyboard! n );             return 0;           }         }       }       printf( I become the guy. n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   long long a[1111], b[1111];   int main() {     cin >> n;     for (int i = 1; i <= n; ++i) cin >> a[i];     for (int i = 1; i <= n; ++i) cin >> b[i];     long long ans = 0;     for (int i = 1; i <= n; ++i) {       long long cur1 = 0, cur2 = 0;       for (int j = i; j <= n; ++j) {         cur1 = cur1 | a[j];         cur2 = cur2 | b[j];         ans = max(ans, cur1 + cur2);       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 3e5 + 10;   const long long M = 3e5 + 1;   const long long oo = 1e9;   long long n, minn, ans;   long long bit[N], deg[N];   pair<long long, long long> nex[N];   vector<long long> vi[N];   void upd(long long pos, long long val) {     for (long long i = pos; i < N; i += (i & -i)) bit[i] += val;   }   long long get(long long pos) {     long long res = 0;     for (long long i = pos; i >= 1; i -= (i & -i)) res += bit[i];     return res;   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> minn;     for (long long i = 1; i <= n; ++i) {       long long x, y;       cin >> x >> y;       nex[i] = pair<long long, long long>(x, y);       vi[x].push_back(i);       vi[y].push_back(i);       deg[x]++;       deg[y]++;     }     for (long long i = 1; i <= n; ++i) upd(M - vi[i].size(), 1);     for (long long i = 1; i <= n; ++i) {       long long cur = vi[i].size();       for (long long v : vi[i]) {         long long die = (nex[v].first == i) ? nex[v].second : nex[v].first;         upd(M - deg[die], -1);         deg[die]--;         upd(M - deg[die], 1);       }       upd(M - deg[i], -1);       long long rem = max(0ll, minn - cur);       ans += get(M - rem);       upd(M - deg[i], 1);       for (long long v : vi[i]) {         long long die = (nex[v].first == i) ? nex[v].second : nex[v].first;         upd(M - deg[die], -1);         deg[die]++;         upd(M - deg[die], 1);       }     }     cout << ans / 2;   }
#include <bits/stdc++.h>   using namespace std;   long long n, k, c[3000001], s;   set<pair<long long, long long> > d, t;   set<pair<long long, long long> >::iterator p;   int main() {     cin >> n >> k;     for (int i = 1; i <= n; i++) cin >> c[i];     for (int i = 1; i <= k; i++) d.insert({c[i], i});     for (int i = k + 1; i <= k + n; i++) {       if (i <= n) d.insert({c[i], i});       p = d.end();       p--;       long long r = (*p).first;       long long l = (*p).second;       s += ((i - l) * r);       d.erase(p);       t.insert({l, i});     }     cout << s << endl;     for (auto e : t) cout << e.second <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long sqr(long long x) { return x * x; }   int n, m, x, y;   int main() {     cin >> x >> y >> n;     long double ans = 1e9, p = 0;     for (int i = 0; i < n; ++i) {       int x1, y1, v;       cin >> x1 >> y1 >> v;       p = sqrt(sqr(x1 - x) + sqr(y1 - y)) / v;       ans = min(ans, p);     }     cout << fixed << setprecision(10) << ans;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 20;   long long n, m, x, y, ans, low, dp[maxn][1 << maxn];   bool f[maxn][maxn];   long long lowbit(long long x) {     long long ret = 0;     while (x) {       if (x & 1)         return ret;       else         ret++;       x /= 2;     }   }   int main() {     scanf( %lld%lld , &n, &m);     for (long long i = 1; i <= m; i++)       scanf( %d%d , &x, &y), x--, y--, f[x][y] = f[y][x] = true;     for (long long i = 0; i < n; i++) dp[i][1 << i] = 1;     for (long long i = 1; i < (1 << n); i++) {       long long minn = lowbit(i);       for (long long j = 0; j < n; j++)         if ((i & (1 << j)) && dp[j][i])           for (long long k = minn; k < n; k++)             if (f[j][k]) {               if ((!(i & (1 << k))))                 dp[k][i | (1 << k)] += dp[j][i];               else if (k == minn)                 ans += dp[j][i];             }     }     printf( %lld n , (ans - m) / 2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int q[2005], a[2005], cum[2005];   int cnt = 1, n;   set<int> use;   set<pair<int, int> > s;   set<pair<int, int> >::iterator it;   map<int, vector<int> > mp;   long long diff(int dif) { return (dif * 1LL * (dif + 1)) / 2; }   int main() {     scanf( %d , &n);     int cur = 0;     for (int i = 0; i < n; i++) {       int ti;       scanf( %d , &ti);       int ok = 1, ni = ti;       while (ni > 0) {         if (!(ni % 10 == 4 || ni % 10 == 7)) {           ok = 0;           break;         }         ni /= 10;       }       if (ok == 1) {         if (cur > 0) {           q[cnt] = cur;           a[cnt] = 0;           cnt++;           cur = 0;         }         mp[ti].push_back(cnt);         q[cnt] = 1;         a[cnt] = ti;         cnt++;       } else         cur++;     }     if (cur > 0) {       q[cnt] = cur;       a[cnt] = 0;       cnt++;     }     cum[0] = 0;     for (int i = 1; i < cnt; i++) {       cum[i] = cum[i - 1] + q[i];     }     long long ret = 0;     for (int i = 1; i < cnt; i++) {       if (q[i] >= 2) {         for (int j = 1; j < q[i]; j++) {           ret += j * 1LL * (j + 1) / 2 * (q[i] - j);         }         for (int j = 1; j < q[i]; j++) {           ret += j * 1LL * (cum[cnt - 1] - cum[i]) * 1LL * (q[i] - j);           ret += (q[i] - j) * 1LL * (cum[i - 1]) * 1LL * j;         }       }       s.clear();       use.clear();       long long sum = diff(cum[i - 1]);       if (i > 1) s.insert(make_pair(1, i - 1));       for (int j = i; j < cnt; j++) {         if (a[j] == 0) {           if (i != j) {             ret += sum * 1LL * q[j] * 1LL * q[i];           } else {             ret += sum * 1LL * q[i] * 1LL * (q[i] + 1) / 2;           }         } else {           if (use.find(a[j]) == use.end()) {             int len = mp[a[j]].size();             for (int k = 0; k < len; k++) {               int pos = mp[a[j]][k];               if (pos >= i) break;               it = s.lower_bound(make_pair(pos + 1, 0));               if (it != s.begin()) {                 it--;                 if ((*it).second >= pos) {                   int pa = (*it).second, pb = (*it).first;                   sum -= diff(cum[pa] - cum[pb - 1]);                   s.erase(*it);                   if (pa > pos) {                     s.insert(make_pair(pos + 1, pa));                     sum += diff(cum[pa] - cum[pos]);                   }                   if (pb < pos) {                     s.insert(make_pair(pb, pos - 1));                     sum += diff(cum[pos - 1] - cum[pb - 1]);                   }                 }               }             }             use.insert(a[j]);           }           ret += sum * 1LL * q[i];         }         if (i != j) {           if (!s.empty()) {             it = s.end();             it--;             if ((*it).second == i - 1) {               int pos = cum[i - 1] - cum[(*it).first - 1];               ret += q[j] * 1LL * pos * 1LL * q[i] * 1LL * (q[i] - 1) / 2;             }           }         }       }     }     printf( %I64d n , ret);   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 101000 * 8;   const int G = 3;   const int Mod = 998244353;   int n;   long long m;   int Fc[maxN], Ifc[maxN];   int In[maxN], A[maxN], B[maxN], C[maxN], R[maxN];   int QPow(int x, int cnt);   void NTT(int *P, int N, int opt);   int main() {     Fc[0] = Ifc[0] = 1;     for (int i = 1; i < maxN; i++) Fc[i] = 1ll * Fc[i - 1] * i % Mod;     Ifc[maxN - 1] = QPow(Fc[maxN - 1], Mod - 2);     for (int i = maxN - 2; i >= 1; i--) Ifc[i] = 1ll * Ifc[i + 1] * (i + 1) % Mod;     scanf( %d%lld , &n, &m);     int N = 1;     while (N <= n + n) N <<= 1;     m = m % (Mod - 1);     for (int i = 0; i <= n; i++)       scanf( %d , &In[i]), B[i] = 1ll * Fc[i] * In[i] % Mod;     for (int i = 0; i <= n; i++) C[i] = Ifc[n - i];     NTT(B, N, 1);     NTT(C, N, 1);     for (int i = 0; i < N; i++) B[i] = 1ll * B[i] * C[i] % Mod;     NTT(B, N, -1);     for (int i = 0; i <= n; i++) A[i] = 1ll * B[i + n] * Ifc[i] % Mod;     for (int i = 0; i <= n; i++)       A[i] = 1ll * A[i] * QPow(QPow(i + 1, Mod - 2), m) % Mod * Fc[i] % Mod;     memset(C, 0, sizeof(C));     for (int i = 0; i <= n; i++) C[i] = (i & 1) ? Mod - Ifc[i] : Ifc[i];     reverse(&C[0], &C[n + 1]);     NTT(A, N, 1);     NTT(C, N, 1);     for (int i = 0; i < N; i++) A[i] = 1ll * A[i] * C[i] % Mod;     NTT(A, N, -1);     for (int i = 0; i <= n; i++) printf( %I64d  , 1ll * A[i + n] * Ifc[i] % Mod);     printf(  n );     return 0;   }   int QPow(int x, int cnt) {     int ret = 1;     while (cnt) {       if (cnt & 1) ret = 1ll * ret * x % Mod;       cnt >>= 1;       x = 1ll * x * x % Mod;     }     return ret;   }   void NTT(int *P, int N, int opt) {     int l = -1, _n = N;     while (_n) ++l, _n >>= 1;     for (int i = 0; i < N; i++) R[i] = (R[i >> 1] >> 1) | ((i & 1) << (l - 1));     for (int i = 0; i < N; i++)       if (i < R[i]) swap(P[i], P[R[i]]);     for (int i = 1; i < N; i <<= 1) {       int dw = QPow(G, (Mod - 1) / (i << 1));       if (opt == -1) dw = QPow(dw, Mod - 2);       for (int j = 0; j < N; j += (i << 1))         for (int k = 0, w = 1; k < i; k++, w = 1ll * w * dw % Mod) {           int X = P[j + k], Y = 1ll * P[j + k + i] * w % Mod;           P[j + k] = (X + Y) % Mod;           P[j + k + i] = (X - Y + Mod) % Mod;         }     }     if (opt == -1) {       int inv = QPow(N, Mod - 2);       for (int i = 0; i < N; i++) P[i] = 1ll * P[i] * inv % Mod;     }     return;   }
#include <bits/stdc++.h>   using namespace std;   long long mi = 2e9;   long long ma = -2 * 1e9;   const int N = 1e5 + 5;   int main() {     std::ios_base::sync_with_stdio(0);     cin.tie(NULL);     cout.tie(NULL);     long long na, nb, ka, kb;     cin >> na >> nb >> ka >> kb;     long long a[na], b[nb];     for (int i = 0; i < na; ++i) cin >> a[i];     for (int i = 0; i < nb; ++i) cin >> b[i];     sort(a, a + na);     sort(b, b + nb);     long long x = nb - kb;     if (a[ka - 1] < b[nb - 1] && b[x] > a[ka - 1])       cout <<  YES ;     else       cout <<  NO ;   }
#include <bits/stdc++.h>   const long long Inf = 1ll << 50;   const long long N = 200010;   using namespace std;   long long cl[2 * N], b, c, d, i, j, k, l, n, ans, a[N], y, kk;   int main() {     scanf( %I64d%I64d , &n, &k);     for (i = n + 1; i > 0; i--) scanf( %I64d , &a[i]);     memset(cl, 0, sizeof(cl));     cl[0] = a[0] = 0;     for (i = 1; i <= n + 1; i++) {       cl[i] = (cl[i - 1] + a[i - 1]) << 1ll;       if ((cl[i] > Inf) || (cl[i] < -Inf)) break;     }     y = 0;     ans = 0;     i--;     for (j = n + 1; j > i; j--) {       if ((y & 1) == 0)         y >>= 1ll;       else         break;       y += a[j];     }     if (i == j) {       for (kk = i; kk > 0; kk--) {         if ((y % 2) == 0)           y /= 2ll;         else           break;         if (cl[kk] + y - y == cl[kk] && abs(cl[kk] + y) <= k &&             (!(kk == 1 && (cl[kk] + y == 0))))           ans++;         y += a[kk];       }     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long arr[300000];   long long temp[300000];   int main() {     int q;     cin >> q;     while (q--) {       int n;       cin >> n;       for (int i = 0; i < n; i++) {         cin >> arr[i];         temp[i] = arr[i];       }       int st = 0;       int endIdx1 = -1;       for (int i = 0; i < n; i++) {         if (arr[i] >= st) {           st++;           endIdx1 = i;         } else {           break;         }       }       if (endIdx1 == n - 1) {         cout <<  Yes  << endl;         continue;       }       st = 0;       int endIdx = n;       for (int i = n - 1; i >= 0; i--) {         if (arr[i] >= st) {           st++;           endIdx = i;         } else {           break;         }       }       if (endIdx == 0) {         cout <<  Yes  << endl;         continue;       }       if (endIdx1 >= endIdx) {         cout <<  Yes  << endl;       } else {         cout <<  No  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t;     cin >> t;     long long k = 0, m = 1;     while (t > 0) {       if (t % 10 == 4) {         k = k + m;       } else {         k = k + 2 * m;       }       m = m * 2;       t = t / 10;     }     cout << k;   }