malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int getSum(vector<int> BITree[], int index, int n) {     int sum = 0;     index = index + 1;     while (index > 0) {       sum += BITree[n][index];       index -= index & (-index);     }     return sum;   }   void updateBIT(vector<int> BITree[], int n, int index, int val, int num) {     index = index + 1;     while (index <= n) {       BITree[num][index] += val;       index += index & (-index);     }   }   int main() {     string str;     cin >> str;     int n = str.size();     int q;     cin >> q;     int type;     int pos;     char ch, ch2;     int num, num2;     int l, r;     vector<int> bit[26];     for (int i = 0; i < 26; i++) {       for (int j = 0; j < n + 1; j++) bit[i].push_back(0);     }     for (int i = 0; i < n; i++) {       ch = str[i];       num = int(ch) - 97;       updateBIT(bit, n, i, 1, num);     }     while (q--) {       cin >> type;       if (type == 1) {         cin >> pos >> ch;         pos--;         num = int(ch) - 97;         ch2 = str[pos];         str[pos] = ch;         num2 = int(ch2) - 97;         updateBIT(bit, n, pos, 1, num);         updateBIT(bit, n, pos, -1, num2);       } else {         cin >> l >> r;         l--, r--;         int cnt = 0;         for (int i = 0; i < 26; i++)           if (getSum(bit, r, i) - getSum(bit, l - 1, i) > 0) cnt++;         cout << cnt <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 500010;   int main() {     int n;     cin >> n;     int a[111][111] = {0};     int ans1 = 0, ans2 = 0;     vector<int> mids;     for (int i = 1; i <= n; i++) {       cin >> a[i][0];       for (int j = 1; j <= a[i][0]; j++) {         cin >> a[i][j];         if (a[i][0] % 2 == 0) {           if (j <= a[i][0] / 2) {             ans1 += a[i][j];           } else             ans2 += a[i][j];         } else {           if (j < a[i][0] / 2 + 1) {             ans1 += a[i][j];           } else if (j == a[i][0] / 2 + 1 || a[i][0] == 1) {             mids.push_back(a[i][j]);           } else             ans2 += a[i][j];         }       }     }     sort(mids.begin(), mids.end());     reverse(mids.begin(), mids.end());     for (int i = 0; i < mids.size(); i++) {       if (i % 2 == 0) {         ans1 += mids[i];       } else         ans2 += mids[i];     }     cout << ans1 <<     << ans2;     return 0;   }
#include <bits/stdc++.h>   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 * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   using namespace std;   bool b[100000 + 5];   vector<int> v[100000 + 5];   int n, m;   int s[100000 + 5];   int ans[100000 + 5], cnt = 0;   bool yes = true;   void dfs(int x, int fa) {     if (fa != 0 && s[x] != x && s[x] != s[fa]) {       puts( -1 );       yes = false;     }     if (s[x] == x) ans[++cnt] = x;     for (int i = 0; i < v[x].size(); i++) {       int y = v[x][i];       if (y == fa) continue;       dfs(y, x);     }   }   int main() {     n = read();     m = read();     for (int i = 1; i <= m; i++) {       int x = read(), y = read();       v[x].push_back(y);       b[y] = 1;     }     for (int i = 1; i <= n; i++) s[i] = read();     for (int i = 1; i <= n; i++) {       if (!b[i]) dfs(i, 0);     }     if (yes == true) {       cout << cnt << endl;       for (int i = cnt; i >= 1; i--) {         cout << ans[i] << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long mod = 1000000007;   int main() {     long long n, k;     cin >> n >> k;     map<int, int, greater<int> > st;     long long n1 = n;     for (int i = 0; n1 > 0; ++i) {       if (n1 & 1) st[i] = 1;       n1 >>= 1;     }     k -= (int)(st.size());     if (k < 0) {       cout <<  No n ;       return 0;     }     while (k > 0) {       auto it = *st.begin();       if (k >= it.second) {         st.erase(it.first);         st[it.first - 1] += it.second * 2;         k -= it.second;       } else {         auto it = *st.rbegin();         st[it.first] -= 1;         st[it.first - 1] += 2;         k -= 1;         if (st[it.first] == 0) st.erase(it.first);       }     }     cout <<  Yes n ;     for (auto it : st) {       for (int i = 0; i < (it.second); ++i) cout << it.first <<    ;     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   long long x, y;   int maxdis(long long x, long long n, long long s) {     if (x > (s >> 1)) x = s - x;     if (x * n > s)       return maxdis(s % x, (x * n + s % x) / s, x);     else       return (x > (s - x * (n - 1)) ? x : (s - x * (n - 1)));   }   int a, n, p, h;   int main() {     int t;     using namespace std;     ios::sync_with_stdio(false);     cin >> t;     for (register int i = 0; i < t; i++) {       cin >> a >> n >> p >> h, a %= p;       int maxd = ((long long)a * n < p) ? a : maxdis(a % p, n + 1, p);       if (maxd <= h)         cout <<  YES n ;       else         cout <<  NO n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     while (cin >> s) {       int N = s.size();       int l = N - 1;       for (; l > 0; --l) {         for (int i = 0; i + l <= N; ++i) {           string sub = s.substr(i, l);           size_t head = s.find(sub);           if (head != string::npos) {             size_t tail = s.find(sub, head + 1);             if (tail != string::npos) {               goto END;             }           }         }       }     END:;       cout << l << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, so7, so4, kiemtra7;   bool check = true;   int main() {     cin >> n;     if (n % 7 == 0) {       so7 = n / 7;       for (int i = 1; i <= so7; i++) cout <<  7 ;     } else {       int r = n % 4;       if (r == 0) {         kiemtra7 = (n - 4) / 28;         if (kiemtra7 == 0) {           check = false;         } else {           so7 = (((n - 4) / 7) / 4 * 4);           n = n - so7 * 7;           so4 = n / 4;           for (int i = 1; i <= so4; i++) cout <<  4 ;           for (int i = 1; i <= so7; i++) cout <<  7 ;         }         if (check == false) {           so4 = n / 4;           for (int i = 1; i <= so4; i++) cout <<  4 ;         }       }       if (r == 1) {         kiemtra7 = (n - 4) / 7 - 3;         so7 = ((((n - 4) / 7 - 3) / 4) * 4 + 3);         n = n - so7 * 7;         if (kiemtra7 < 0)           cout <<  -1 ;         else {           so4 = n / 4;           for (int i = 1; i <= so4; i++) cout <<  4 ;           for (int i = 1; i <= so7; i++) cout <<  7 ;         }       }       if (r == 2) {         kiemtra7 = (n - 4) / 7 - 2;         so7 = ((((n - 4) / 7 - 2) / 4) * 4 + 2);         n = n - so7 * 7;         if (kiemtra7 < 0)           cout <<  -1 ;         else {           so4 = n / 4;           for (int i = 1; i <= so4; i++) cout <<  4 ;           for (int i = 1; i <= so7; i++) cout <<  7 ;         }       }       if (r == 3) {         kiemtra7 = (n - 4) / 7 - 1;         so7 = ((((n - 4) / 7 - 1) / 4) * 4 + 1);         n = n - so7 * 7;         if (kiemtra7 < 0)           cout <<  -1 ;         else {           so4 = n / 4;           for (int i = 1; i <= so4; i++) cout <<  4 ;           for (int i = 1; i <= so7; i++) cout <<  7 ;         }       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, b;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> b;       int a[b + 1];       for (int j = 0; j < b; j++) cin >> a[j];       sort(a, a + b);       int mn = 999999;       for (int j = 1; j < b; j++) {         mn = min(a[j] - a[j - 1], mn);       }       cout << mn << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   static const int INF = 500000000;   template <class T>   void debug(T a, T b) {     for (; a != b; ++a) cerr << *a <<    ;     cerr << endl;   }   long long int n;   pair<long long int, int> factor[100];   long long int tot[100];   int m = 0;   long long int ans;   bool f(long long int a) {     if (a <= 0 || a & 1) return true;     return false;   }   void check(long long int a, long long int b, long long int c) {     if (f(b + c - a) || f(c + a - b) || f(a + b - c))       ;     else       ++ans;   }   void dfs(int d, long long int a, long long int b, long long int c) {     if (d == m) {       check(a, b, c);       return;     }     long long int mul1 = 1;     for (int i = 0; i < factor[d].second + 1; ++i) {       long long int mul2 = 1;       for (int j = 0; j < factor[d].second + 1 - i; ++j) {         long long int mul3 = tot[d] / mul1 / mul2;         dfs(d + 1, a * mul1, b * mul2, c * mul3);         mul2 *= factor[d].first;       }       mul1 *= factor[d].first;     }   }   int main() {     cin >> n;     if (n % 3) {       puts( 0 );       return 0;     }     n /= 3;     long long int t = n;     for (long long int i = 2; i * i <= t; ++i)       if (t % i == 0) {         factor[m].first = i;         long long int tmp = 1;         while (t % i == 0) {           t /= i;           tmp *= i;           factor[m].second++;         }         tot[m] = tmp;         ++m;       }     if (t > 1) factor[m++] = make_pair(t, 1), tot[m - 1] = t;     ;     dfs(0, 1, 1, 1);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, k, x[5], a[30], d = 0;   long long mod = 1000000007ll, fc[30];   long long C[30][30];   bool vis[30];   long long first(long long s1, long long s2, long long s3, long long ind,                   long long q, long long t) {     if (t == 1) {       if (s1 == 0) return (fc[q] * first(0, s2, s3, 0, 0, 2)) % mod;       long long r = 0;       for (int i = ind + 1; i <= n && a[i] <= s1; i++) {         int N = 1;         for (int j = i + 1; j <= n && a[j] == a[i]; j++) N++;         for (int k = 1; k <= N && a[i] * k <= s1; k++) {           vis[i + k - 1] = 1;           r = (r + (C[N][k] * first(s1 - k * a[i], s2, s3, i + N - 1, q + k, 1)) %                        mod) %               mod;         }         for (int j = i; j < i + N; ++j) vis[j] = 0;         i += N - 1;       }       return r;     }     if (t == 2) {       if (s2 == 0) return (fc[q] * first(0, 0, s3, 0, 0, 3)) % mod;       long long r = 0;       for (int i = ind + 1; i <= n && a[i] <= s2; i++)         if (!vis[i]) {           vis[i] = 1;           r = (r + first(0, s2 - a[i], s3, i, q + 1, 2)) % mod;           vis[i] = 0;         }       return r;     }     q = 0;     for (int i = 1; i <= n; i++)       if (!vis[i]) q++;     return fc[q];   }   int main() {     memset(C, 0, sizeof(C));     memset(vis, 0, sizeof(vis));     for (int i = 0; i < 30; i++) C[i][0] = 1;     for (int i = 1; i < 30; i++)       for (int j = 1; j <= i; j++)         C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;     cin >> n;     fc[0] = 1;     for (int i = 1; i <= n; ++i) {       cin >> a[i];       d += a[i];       fc[i] = (fc[i - 1] * i) % mod;     }     sort(a + 1, a + n + 1);     cin >> k;     for (int i = 1; i <= k; i++) cin >> x[i];     if (k == 0) {       cout << fc[n];       return 0;     }     if (k == 1) {       fc[n] = (fc[n] - first(x[1], 0, d - x[1], 0, 0, 1) + mod) % mod;       cout << fc[n];       return 0;     }     if (x[1] > x[2]) swap(x[1], x[2]);     long long r1 = first(min(x[1], d - x[1]), 0, max(d - x[1], x[1]), 0, 0, 1);     memset(vis, 0, sizeof(vis));     long long r2 = first(min(x[2], d - x[2]), 0, max(d - x[2], x[2]), 0, 0, 1);     memset(vis, 0, sizeof(vis));     x[3] = d - x[2];     x[2] -= x[1];     sort(x + 1, x + 3);     long long r3 = first(x[1], x[2], x[3], 0, 0, 1);     long long res = (fc[n] - r1 - r2 + r3 + 2 * mod) % mod;     cout << res;     return 0;   }
/*---------------------------------------------------------------   　　　　　　　　　　　 ∧＿∧   　　　　　 ∧＿∧ 　（´<_｀ ）　    　　　　 （ ´_ゝ`）　/　 ⌒i        　　　　／　　　＼　 　  |　|   　　　 /　　 /￣￣￣￣/　　|   　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿   　 　　　＼/＿＿＿＿/　（u　⊃   --------------------------------------------------------------*/   #include<bits/stdc++.h>   #define IO  ios::sync_with_stdio(false);cin.tie(0)   #define rep(i,a,b) for(int i=a;i<=b;i++)   #define req(i,a,b) for(int i=a;i>=b;i--)   #define pb push_back     #define fi first   #define se second   #define PI pair<int,int>   #define PII pair<ll,PI>      using namespace std;      typedef long long ll;   const int N=1e5+7;   const ll mod=1e9+7;   int a[107],b[107],x[107];   PI p[107];   int main()   {    IO;     int t;    cin>>t;    while(t--){     int n;     cin >> n;     for (int i = 1; i <= n; ++i)     {      cin >> a[i];     }     for (int i = 1; i <= n; ++i)     {      cin >> b[i];     }     int ans = 0;     for (int i = 1; i <= n; ++i)     {      ans += a[i]-b[i];     }     if (ans != 0)     {      cout << -1 << endl;      continue;     }      int sum1 = 0, sum2 =0;     for (int i = 1; i <= n; ++i)     {      x[i] = a[i] - b[i];      if (x[i] > 0)      {       sum1 += x[i];      }      else if(x[i] < 0)      {       sum2 += x[i];      }     }     cout << sum1 << endl;     while(sum1){      for(int i = 1; i <= n; i++){       if(x[i] < 0){        for(int j = 1; j <= n; j++){         if(x[j] > 0){          cout << j <<     << i << endl;          x[i]++;          x[j]--;          sum1--;          break;         }             }           }         }     }   }    return 0;   }
#ifdef Prateek     #include  Prateek.h    #else     #include <bits/stdc++.h>     using namespace std;     #define debug(...) 42   #endif   #define int ll   #define all(c) begin(c),end(c)   using ll = long long;   const int MOD = 1e9+7, N = 1e5 + 10;       struct edge{      int u, v, w;   };      int32_t main(){      ios::sync_with_stdio(false);      cin.tie(NULL);      int L, R;      cin >> L >> R;      int B = L - 1;      int D = R - L + 1;      int k = 30;      while (!(D >> k & 1)) --k;      int mxN = k + 2;      vector<edge> Edge;         auto add = [&](int u, int v, int wt) {         Edge.push_back({u, v, wt});      };         for (int i = 2; i <= mxN; ++i) {         add(1, i, 1);         int pw = 1;         for (int j = 2; j < i; ++j) {            add(j, i, pw);            pw *= 2;         }      }         cout <<  YES n ;         if (D - (1 << k) == 0) {         if (B) {            mxN++;            Edge.push_back({mxN - 1, mxN, B});         }         cout << mxN <<     << Edge.size() <<   n ;         for (auto [u, v, w] : Edge) {            cout << u <<     << v <<     << w <<   n ;         }         return 0;      }         mxN++;      --D;      add(1, mxN, 1);      for (int i = 0; i <= k; ++i) {         if (D >> i & 1) {            D -= (1 << i);            add(i + 2, mxN, D + 1);         }      }            if (B) {         mxN++;         Edge.push_back({mxN - 1, mxN, B});      }      cout << mxN <<     << Edge.size() <<   n ;      for (auto [u, v, w] : Edge) {         cout << u <<     << v <<     << w <<   n ;      }      return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       long long a, b, c;       cin >> a >> b >> c;       if (a < c)         cout << 1 <<    ;       else         cout << -1 <<    ;       if (c < a * b)         cout << b << endl;       else         cout << -1 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   static int n;   static vector<int> ve;   int main() {     while (scanf( %d , &n) != EOF) {       ve.clear();       ve.resize(n);       for (int i = 0; i < n; i++) scanf( %d , &ve[i]);       if (n == 1 && ve[n - 1] != 15 && ve[n - 1] != 0) {         printf( -1 n );       } else {         if (ve[n - 1] == 15) {           printf( DOWN n );         } else if (ve[n - 1] == 0) {           printf( UP n );         } else if (ve[n - 1] == 1) {           if (ve[n - 2] == 2)             printf( DOWN n );           else if (ve[n - 2] == 0)             printf( UP n );         } else {           if (ve[n - 1] > ve[n - 2])             printf( UP n );           else             printf( DOWN n );         }       }     }     return 0;   }
#include <bits/stdc++.h>   const int N = 100005;   int K, n, maxb, t;   int c[N];   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 * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   void update(int x, int d) {     while (x <= maxb) {       if (d > c[x]) c[x] = d;       x += x & -x;     }   }   int get(int x) {     int ans = 0;     while (x > 0) {       ans = std::max(ans, c[x]);       x -= x & -x;     }     return ans;   }   int a[N], ans[N];   int cal() {     memset(c, 0, sizeof(c));     memset(ans, 0, sizeof(ans));     for (int i = 1; i <= t; i++)       for (int j = 1; j <= n; j++) {         int k = get(a[j] - 1) + 1;         if (k > ans[j]) {           ans[j] = k;           update(a[j], k);         }       }     return *std::max_element(ans + 1, ans + n + 1);   }   int main() {     K = read(), n = read(), maxb = read(), t = read();     t = std::min(maxb, t);     while (K--) {       for (int i = 1; i <= n; i++) a[i] = read();       printf( %d n , cal());     }   }
#include <bits/stdc++.h>   const int maxn(505);   char ans[maxn];   int main() {     int n;     scanf( %d , &n);     int nr(1), nc(1);     ans[(n - 1) * 2] =   0 ;     for (int i(0); i < n - 1; ++i) {       printf( ? %d %d %d %d n , nr, nc + 1, n, n);       fflush(stdout);       char tmp[5];       scanf( %s , tmp);       if (!strcmp(tmp,  BAD )) {         return 0;       } else if (!strcmp(tmp,  YES )) {         ++nc;         ans[i] =  R ;       } else if (!strcmp(tmp,  NO )) {         ++nr;         ans[i] =  D ;       } else {         printf( F**K n );         return 0;       }     }     nr = nc = n;     for (int i((n - 1) * 2 - 1); i >= n - 1; --i) {       printf( ? 1 1 %d %d n , nr - 1, nc);       fflush(stdout);       char tmp[5];       scanf( %s , tmp);       if (!strcmp(tmp,  BAD )) {         printf( F**K n );         return 0;       } else if (!strcmp(tmp,  YES )) {         --nr;         ans[i] =  D ;       } else if (!strcmp(tmp,  NO )) {         --nc;         ans[i] =  R ;       } else {         printf( F**K n );         return 0;       }     }     printf( ! %s n , ans);     fflush(stdout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename A, typename B>   inline void smin(A &a, const B &b) {     if (a > b) a = b;   }   struct point {     double x, y, z;     inline point(double x = 0, double y = 0, double z = 0) : x(x), y(y), z(z) {}     inline point operator-(point a) { return point(x - a.x, y - a.y, z - a.z); }     inline double al() { return atan2(y, x); }     inline double nor2() { return *this * *this; }     inline double nor() { return sqrt(*this * *this); }     inline double operator*(point a) { return x * a.x + y * a.y + z * a.z; }     inline void input() { scanf( %lf %lf %lf , &x, &y, &z); }     inline void print() { printf( %lf %lf %lf n , x, y, z); }   } A, B, A_, B_, F;   double r, h, R;   double all = 6.283185307179586476925286766559;   double _120 = 2.0943951023931954923084289221863;   double _150 = 2.2689280275926284500007979990352;   inline double dist(point a, point b) {     double al = fabs(a.al() - b.al());     smin(al, all - al);     double da = (a - F).nor2(), db = (b - F).nor2();     return sqrt(da + db - 2 * sqrt(da * db) * cos(r * al / R));   }   inline double calc_A() {     double ans = 1e100;     for (double st_ = 0; st_ < all; st_ += _120) {       double st = st_, ed = st + _120 + 0.1;       while (ed - st > 1e-6) {         double a = (st + st + ed) / 3;         B_ = {r * cos(a), r * sin(a)};         double val_a = (A_ - B_).nor() + dist(B, B_);         double b = (st + ed + ed) / 3;         B_ = {r * cos(b), r * sin(b)};         double val_b = (A_ - B_).nor() + dist(B, B_);         if (val_a < val_b)           ed = b;         else           st = a;       }       double al = (st + ed) / 2;       B_ = {r * cos(al), r * sin(al)};       smin(ans, (A_ - B_).nor() + dist(B, B_));     }     return ans;   }   int main() {     scanf( %lf %lf , &r, &h);     F = point(0, 0, h);     R = sqrt(r * r + h * h);     A.input(), B.input();     if (A.z > B.z) swap(A, B);     double ans;     if (B.z < 1e-6)       ans = (A - B).nor();     else if (A.z < 1e-6)       A_ = A, ans = calc_A();     else {       ans = dist(A, B);       for (double st_ = 0; st_ < all; st_ += _120) {         double st = st_, ed = st + _120 + 0.1;         while (ed - st > 1e-6) {           double a = (st + st + ed) / 3;           A_ = {r * cos(a), r * sin(a)};           double val_a = dist(A, A_) + calc_A();           double b = (st + ed + ed) / 3;           A_ = {r * cos(b), r * sin(b)};           double val_b = dist(A, A_) + calc_A();           if (val_a < val_b)             ed = b;           else             st = a;         }         double al = (st + ed) / 2;         A_ = {r * cos(al), r * sin(al)};         smin(ans, dist(A, A_) + calc_A());       }     }     printf( %.6lf , ans);   }
#include <bits/stdc++.h>   using namespace std;   const int N = 255;   const int md = 1e9 + 7;   char c[N][N];   int as, n, m, d, mk, f[2][(1 << 17) + 1][2];   void upd(int &x, int y) {     x += y;     x >= md ? x -= md : 0;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) scanf( %s , c[i] + 1);     if (n < m) {       for (int i = 1; i <= n; i++)         for (int j = i; j <= m; j++) swap(c[i][j], c[j][i]);       swap(n, m);     }     mk = (1 << (m + 1)), f[0][0][0] = 1;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         d ^= 1, memset(f[d], 0, sizeof(f[d]));         for (int s = 0, x, p, q, s0, s1, t; s < mk; s++) {           t = s;           x = j - 1, p = (s >> x) & 1, q = (s >> j) & 1, s0 = f[d ^ 1][s][0],           s1 = f[d ^ 1][s][1];           if (!s0 && !s1) continue;           if (p) t -= 1 << x;           if (q) t -= 1 << j;           if (c[i][j] ==  x ) {             upd(f[d][t][0], s0), upd(f[d][t][1], s1);             continue;           }           upd(f[d][s | 1 << x | 1 << j][0], s0);           upd(f[d][s | 1 << x | 1 << j][1], s1);           if (p || q)             upd(f[d][t | (q << x) | (p << j)][0], s0),                 upd(f[d][t | (q << x) | (p << j)][1], s1);           else             upd(f[d][t][1], s0);         }       }       d ^= 1, memset(f[d], 0, sizeof(f[d]));       for (int s = 0; s < mk; s++)         upd(f[d][(s << 1) & (mk - 1)][0], f[d ^ 1][s][0]),             upd(f[d][(s << 1) & (mk - 1)][1], f[d ^ 1][s][1]);     }     for (int s = 0; s < mk; s++) upd(as, f[d][s][0]), upd(as, f[d][s][1]);     printf( %d , as);   }
#include <bits/stdc++.h>   using namespace std;   const long long maxn = 100000000000;   long long Ceil(long long a, long long b) { return (a / b) + ((a % b) != 0); }   int main() {     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       long long cb = 0, rem = 0, total = 0;       while (n / 10 > 0) {         cb = n / 10;         rem = n % 10;         total += cb * 10;         n = cb + rem;       }       cout << total + (n % 10) << endl;     }   }
#include <bits/stdc++.h>   int main() {     int t;     scanf( %d , &t);     while (t--) {       unsigned int a, b, c, d;       scanf( %u %u %u %u , &a, &b, &c, &d);       if (a <= b)         printf( %u n , b);       else if (c <= d)         printf( -1 n );       else {         unsigned long long f =             (a - b) % (c - d) == 0 ? (a - b) / (c - d) : ((a - b) / (c - d) + 1);         unsigned long long g = b + c * f;         printf( %llu n , g);       }     }     return 0;   }