malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<int> v;   long long int arr[100001], operation[100001][3], kitnibaar1[100002],       kitnibaar[100002], update1[100002], update[100002];   int main() {     int n, m, k;     cin >> n >> m >> k;     for (int i = 1; i <= n; i++) {       cin >> arr[i];     }     for (int i = 1; i <= m; i++) {       cin >> operation[i][0];       cin >> operation[i][1];       cin >> operation[i][2];     }     for (int i = 1; i <= k; i++) {       int start, end;       cin >> start >> end;       kitnibaar1[start]++;       kitnibaar1[end + 1]--;     }     long long int up = 0;     for (int i = 1; i <= m; i++) {       up += kitnibaar1[i];       kitnibaar[i] += up;     }     up = 0;     for (int i = 1; i <= m; i++) {       operation[i][2] *= kitnibaar[i];       update[operation[i][0]] += operation[i][2];       update[operation[i][1] + 1] -= operation[i][2];     }     up = 0;     for (int i = 1; i <= n; i++) {       up += update[i];       arr[i] += up;       cout << arr[i] <<    ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 400010;   int n, ans[N], where[N];   long long sz[N];   vector<int> v[N];   bool visit[N];   void init() {     scanf( %d , &n);     int a, b;     for (int i = 0; i < n - 1; ++i) {       scanf( %d %d , &a, &b);       v[a].push_back(b);       v[b].push_back(a);     }   }   void dfs(int now) {     visit[now] = true;     for (int i = 0; i < v[now].size(); ++i)       if (!visit[v[now][i]]) {         dfs(v[now][i]);         sz[now] += sz[v[now][i]];       }     if (sz[now] == 0)       sz[now] = 1;     else       sz[now] += 1;   }   int find_centroid(int now) {     visit[now] = true;     for (int i = 0; i < v[now].size(); ++i) {       if (visit[v[now][i]]) continue;       if (sz[v[now][i]] > n / 2) return find_centroid(v[now][i]);     }     return now;   }   void sv(int now, int value) {     if (visit[now]) return;     visit[now] = true;     where[now] = value;     for (int i = 0; i < v[now].size(); ++i) sv(v[now][i], value);   }   void dfs2(int now) {     visit[now] = true;     for (int i = 0; i < v[now].size(); ++i) sv(v[now][i], i);   }   void solve() {     dfs(1);     for (int i = 1; i <= n; ++i) visit[i] = false;     int centroid = find_centroid(1);     for (int i = 1; i <= n; ++i) visit[i] = false;     dfs2(centroid);     for (int i = 1; i <= n; ++i) {       visit[i] = false;       sz[i] = 0;     }     dfs(centroid);     vector<int> tmp;     for (int i = 0; i < v[centroid].size(); ++i)       tmp.push_back(sz[v[centroid][i]]);     int max1 = -1000000006, idx1, max2 = -1000000006, idx2;     for (int i = 0; i < tmp.size(); ++i)       if (tmp[i] > max1) {         max1 = tmp[i];         idx1 = i;       }     if ((n % 2 == 0) && max1 == n / 2)       max2 = n / 2;     else {       for (int i = 0; i < tmp.size(); ++i)         if (tmp[i] > max2 && i != idx1) {           max2 = tmp[i];           idx2 = i;         }     }     for (int i = 1; i <= n; ++i) {       if (i == centroid)         ans[i] = 1;       else if (where[i] == idx1) {         int tmp = n - sz[i] - max2;         if (tmp <= n / 2)           ans[i] = 1;         else           ans[i] = 0;       } else {         int tmp = n - sz[i] - max1;         if (tmp <= n / 2)           ans[i] = 1;         else           ans[i] = 0;       }     }     for (int i = 1; i <= n; ++i) printf( %d  , ans[i]);     printf(  n );   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     ;     int __ = 1;     while (__--) {       init();       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int oo = 0x3f3f3f3f;   const long long ooo = 9223372036854775807ll;   const int _cnt = 1000 * 1000 + 7;   const int _p = 1000 * 1000 * 1000 + 7;   const int N = 1001005;   const double PI = acos(-1.0);   const double eps = 1e-9;   int o(int x) { return x % _p; }   int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }   int lcm(int a, int b) { return a / gcd(a, b) * b; }   void file_put() {     freopen( filename.in ,  r , stdin);     freopen( filename.out ,  w , stdout);   }   long long a, b, p, x, r[N], tt = 1, q[N], x0, ans = 0, T = 1, T_rev;   bool v[N];   long long Pow(long long x, long long k) {     long long ans = 1;     for (; k; k >>= 1, (x *= x) %= p)       if (k & 1) (ans *= x) %= p;     return ans;   }   int main() {     scanf( %I64d%I64d%I64d%I64d , &a, &b, &p, &x);     if (a == 1)       if (x < b)         return 0 * printf( 0 n );       else         return 0 * printf( %I64d n , (x - b) / p + 1);     v[1] = 1;     while (1) {       (tt *= a) %= p;       if (v[tt]) break;       v[tt] = 1;       T++;     }     r[1] = tt = 1;     for (int i = (1); i <= (T - 1); ++i) q[(tt *= a) %= p] = i;     q[1] = 0;     T_rev = Pow(T, p - 2);     for (int i = (2); i <= (p - 1); ++i) r[i] = (p - p / i) * r[p % i] % p;     for (int i = (1); i <= (p - 1); ++i) {       if (i > 1 && !q[i]) continue;       long long t = i;       x0 = (r[t] * b % p * T * T_rev + q[t] * p) % (p * T);       if (x < x0) continue;       ans += (x - x0) / (p * T) + 1;     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     char str[200];     int num, i, j, k;     int pre = 0;     char temp[10];     cin.getline(str, 200,   n );     for (i = 0; str[i] != 0; i++) {       num = str[i];       j = 0;       while (num != 0) {         k = num % 2;         temp[j++] = k +  0 ;         num = (num - k) / 2;       }       while (j < 8) temp[j++] =  0 ;       temp[j] =   0 ;       for (j = 0; j < 8; j++) num += (temp[j] -  0 ) << (7 - j);       k = (pre - num) % 256;       if (k < 0) k += 256;       cout << k << endl;       pre = num;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct triple {     int first;     int second;     int third;     void set(int a, int b, int c) {       first = a;       second = b;       third = c;     }   };   triple t[53][53][8] = {0};   int table[53][53] = {0};   void f(int a, int b, int c) {     if (table[a][b] == 0 || b > 50 || a > 50 || a < 1 || b < 1) return;     int x = a;     int y = b;     if (c == 0) {       while (table[x - 1][y] == table[a][b]) x--;       while (table[x][y + 1] == table[a][b]) y++;       if (table[x][y + 1] != 0)         t[a][b][c].set(x, y + 1, c);       else         t[a][b][c].set(a, b, 1);     } else if (c == 1) {       while (table[x + 1][y] == table[a][b]) x++;       while (table[x][y + 1] == table[a][b]) y++;       if (table[x][y + 1] != 0)         t[a][b][c].set(x, y + 1, c);       else         t[a][b][c].set(a, b, 2);     } else if (c == 2) {       while (table[x + 1][y] == table[a][b]) x++;       while (table[x][y + 1] == table[a][b]) y++;       if (table[x + 1][y] != 0)         t[a][b][c].set(x + 1, y, c);       else         t[a][b][c].set(a, b, 3);     } else if (c == 3) {       while (table[x + 1][y] == table[a][b]) x++;       while (table[x][y - 1] == table[a][b]) y--;       if (table[x + 1][y] != 0)         t[a][b][c].set(x + 1, y, c);       else         t[a][b][c].set(a, b, 4);     } else if (c == 4) {       while (table[x + 1][y] == table[a][b]) x++;       while (table[x][y - 1] == table[a][b]) y--;       if (table[x][y - 1] != 0)         t[a][b][c].set(x, y - 1, c);       else         t[a][b][c].set(a, b, 5);     } else if (c == 5) {       while (table[x - 1][y] == table[a][b]) x--;       while (table[x][y - 1] == table[a][b]) y--;       if (table[x][y - 1] != 0)         t[a][b][c].set(x, y - 1, c);       else         t[a][b][c].set(a, b, 6);     } else if (c == 6) {       while (table[x - 1][y] == table[a][b]) x--;       while (table[x][y - 1] == table[a][b]) y--;       if (table[x - 1][y] != 0)         t[a][b][c].set(x - 1, y, c);       else         t[a][b][c].set(a, b, 7);     } else if (c == 7) {       while (table[x - 1][y] == table[a][b]) x--;       while (table[x][y + 1] == table[a][b]) y++;       if (table[x - 1][y] != 0)         t[a][b][c].set(x - 1, y, c);       else         t[a][b][c].set(a, b, 0);     }   }   int main() {     int n, m;     cin >> n >> m;     string s;     int h = 0;     cin.ignore();     for (int i = 0; i < n; i++) {       getline(cin, s);       for (int j = 0; j < s.size(); j++) {         table[i + 1][j + 1] = s[j] -  0 ;       }     }     h = s.size();     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= h; j++) {         for (int k = 0; k < 8; k++) {           f(i, j, k);         }       }     }     int q1 = 1, q2 = 1, q3 = 0;     int w1, w2, w3;     for (int i = 0; i < m; i++) {       w1 = t[q1][q2][q3].first;       w2 = t[q1][q2][q3].second;       w3 = t[q1][q2][q3].third;       q1 = w1;       q2 = w2;       q3 = w3;     }     cout << table[q1][q2] << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int V = 25;   int n, k, sx, sy;   bool adj[V][V];   double p[V];   double mat[V * V][V * V];   int id[V][V], deg[V];   double calc_p(int i, int j) {     return (i == j) ? p[i] : (adj[i][j]) ? (1 - p[i]) / deg[i] : 0.0;   }   void gauss(double a[][V * V], int m, int n) {     for (int i = 0; i < m; i++) {       int u = i;       for (int r = i + 1; r < m; r++)         if (fabs(a[r][i]) > fabs(a[u][i])) u = r;       if (u != i)         for (int j = i; j < m + n; j++) swap(a[i][j], a[u][j]);       double t = a[i][i];       for (int j = i; j < m + n; j++) a[i][j] /= t;       for (int c = 0; c < m; c++)         if (c != i) {           t = a[c][i];           for (int j = i; j < m + n; j++) a[c][j] -= t * a[i][j];         }     }   }   int main() {     int a, b;     scanf( %d%d%d%d , &n, &k, &sx, &sy);     sx--;     sy--;     memset(deg, 0, sizeof(deg));     memset(adj, 0, sizeof(adj));     for (int i = 0; i < k; i++) {       scanf( %d%d , &a, &b);       a--;       b--;       adj[a][b] = adj[b][a] = true;       deg[a]++;       deg[b]++;     }     int m = 0;     for (int i = 0; i < n; i++)       for (int j = i; j < n; j++) id[i][j] = id[j][i] = m++;     for (int i = 0; i < n; i++) scanf( %lf , &p[i]);     memset(mat, 0, sizeof(mat));     for (int i = 0; i < n; i++)       for (int j = i + 1; j < n; j++) {         for (int x = 0; x < n; x++)           for (int y = 0; y < n; y++) {             mat[id[i][j]][id[x][y]] += calc_p(i, x) * calc_p(j, y);           }       }     for (int i = 0; i < m; i++) mat[i][i] -= 1;     for (int i = 0; i < n; i++) mat[id[i][i]][id[i][i]] = 1;     for (int i = 0; i < n; i++) mat[id[i][i]][m + i] = 1;     gauss(mat, m, n);     for (int i = 0; i < n; i++) {       if (i) printf(   );       printf( %.9f , mat[id[sx][sy]][m + i]);     }     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   int dp[1 << 25];   int tick[25][25], value[25][25], cost[25][25];   int n, m;   string s[25];   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> s[i];     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) cin >> value[i][j];     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         int maxi = 0;         for (int x = 0; x < n; x++)           if (s[i][j] == s[x][j]) {             tick[i][j] |= (1 << x);             maxi = max(maxi, value[x][j]);             cost[i][j] += value[x][j];           }         cost[i][j] -= maxi;       }     memset(dp, 1000000005, sizeof(dp));     dp[0] = 0;     for (int mask = 1; mask < (1 << n); mask++) {       int t;       for (int pos = 0; pos < n; pos++)         if ((mask >> pos) & 1) {           t = pos;           break;         }       for (int pos = 0; pos < m; pos++) {         dp[mask] = min(dp[mask], dp[mask & (mask ^ tick[t][pos])] + cost[t][pos]);         dp[mask] = min(dp[mask], dp[mask - (1 << t)] + value[t][pos]);       }     }     cout << dp[(1 << n) - 1];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937_64 rnd(time(NULL));   const int N = 25;   const int inf = 1e9;   const double MAX_T = 1000;   const double MIN_T = 1e-5;   const int max_mutations = 10;   int n, m;   vector<int> A, B;   vector<vector<int> > best_ans, cur_ans;   int best_cost = 0;   inline void mutation(vector<vector<int> > &a) {     int cnt = rnd() % max_mutations + 1;     for (; cnt; cnt--) {       int x = rnd() % n, y = rnd() % m;       a[x][y] = rnd() % 2;     }   }   inline int calc(vector<vector<int> > &a) {     int x = 0, res = 0;     for (int i = 0; i < n; i++) {       x = 0;       for (int j = 0; j < m; j++) {         if (a[i][j] == 1 && (j == 0 || a[i][j - 1] == 0)) x++;       }       res += (x - A[i]) * (x - A[i]);     }     for (int i = 0; i < m; i++) {       x = 0;       for (int j = 0; j < n; j++) {         if (a[j][i] == 1 && (j == 0 || a[j - 1][i] == 0)) x++;       }       res += (x - B[i]) * (x - B[i]);     }     return res;   }   inline double ok(double E, double t) { return exp(-E / t); }   inline bool valid(double E, double t) {     if (E < 0) return true;     double x = ok(E, t);     x *= inf;     return (rnd() % inf <= x);   }   int main() {     ios_base ::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     A.resize(n, 0);     B.resize(m, 0);     for (int i = 0; i < n; i++) cin >> A[i];     for (int j = 0; j < m; j++) cin >> B[j];     cur_ans.assign(n, vector<int>(m));     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) cur_ans[i][j] = rnd() % 2;     best_ans = cur_ans;     best_cost = calc(cur_ans);     double T = MAX_T;     int i = 1;     while (T > MIN_T && best_cost != 0) {       mutation(cur_ans);       int cur_cost = calc(cur_ans);       if (valid(cur_cost - best_cost, T)) {         best_cost = min(best_cost, cur_cost);         if (best_cost == cur_cost) best_ans = cur_ans;       } else         cur_ans = best_ans;       T = MAX_T * 0.1 / i;       i++;     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (best_ans[i][j])           cout <<  * ;         else           cout <<  . ;       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using lint = long long;   using ld = long double;   using pint = pair<int, int>;   using plint = pair<lint, lint>;   lint _pow(lint a, lint n) {     if (n == 0)       return 1;     else {       lint res = 1;       lint buf = a;       while (n > 0) {         if (n % 2 == 1) {           res *= buf;           res %= 998244353LL;         }         buf *= buf;         buf %= 998244353LL;         n /= 2;       }       return res;     }   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     vector<int> c(n + 10, 0);     for (lint i = 0; i < (int)n; i++) {       int a;       cin >> a;       c[a]++;     }     lint ans = 0;     vector<lint> dp(n + 10, 0);     dp[0] = 1;     vector<lint> rev(n + 10);     for (lint i = 0; i < (int)n + 10; i++) rev[i] = _pow(i, 998244353LL - 2);     for (lint i = 0; i < (int)n + 10; i++) {       if (c[i] == 0) continue;       if (c[i] >= 2) {         for (lint j = 0; j < (int)n + 10; j++) {           lint p = dp[j];           p *= c[i];           p %= 998244353LL;           p *= c[i] - 1;           p %= 998244353LL;           p *= rev[n - j];           p %= 998244353LL;           p *= rev[n - j - 1];           p %= 998244353LL;           ans += p;           ans %= 998244353LL;         }       }       vector<lint> ndp(n + 10, 0);       for (lint j = 0; j < (int)n + 10; j++) ndp[j] += dp[j];       for (lint j = 1; j < (int)n + 10; j++) {         lint p = dp[j - 1];         p *= c[i];         p %= 998244353LL;         p *= rev[n - j + 1];         p %= 998244353LL;         ndp[j] += p;         ndp[j] %= 998244353LL;       }       dp = ndp;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:104857600 )   using namespace std;   const int c = 1000100;   int n, m;   int a[c];   int ans;   int d;   void go(int i, int b) {     if (a[i]) return;     a[i] = 1;     int k = (m - 1) << 1;     int nb = b;     int p = i;     while (k) {       if (b > 0)         d = min(k, n - p);       else         d = min(k, p - 1);       p += d * b;       if (d < k) b = -b;       k -= d;     }     go(p, b);     k = (m - 1) << 1;     p = i;     b = -nb;     while (k) {       if (b > 0)         d = min(k, n - p);       else         d = min(k, p - 1);       p += d * b;       if (d < k) b = -b;       k -= d;     }     go(p, b);   }   int main() {     scanf( %d%d , &n, &m);     ans = 0;     int i;     for (i = 1; i <= n; ++i)       if (!a[i]) {         ++ans;         go(i, 1);       }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long MOD = 1000000007;   long long small(long long a, long long b) {     if (a < b) return a;     return b;   }   long long large(long long a, long long b) {     if (a > b) return a;     return b;   }   long long root(long long x, vector<long long>& a) {     if (a[x] == x) return x;     a[x] = root(a[x], a);     return (a[x]);   }   int main() {     long long t;     t = 1;     while (t--) {       long long n, i, c, m, x, y, a1, h, k = 0;       cin >> n >> m;       vector<long long> v(n + 1, 0), a(n + 1, 0);       for (i = 1; i <= n; i++) {         cin >> v[i];         a[i] = i;       }       while (m--) {         cin >> x >> y;         x = root(x, a);         y = root(y, a);         if (v[x] < v[y])           a[y] = x;         else           a[x] = y;       }       for (i = 1; i <= n; i++) {         if (a[i] == i) k = k + v[i];       }       cout << k << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int const maxn = 60, maxl = 10010;   int f[maxn * maxl];   int n, d, c, sum;   int main() {     cin >> n >> d;     f[0] = 1;     for (int i = 0; i < n; i++) {       cin >> c;       for (int j = sum; j >= 0; j--)         if (f[j]) f[j + c] = 1;       sum += c;     }     int last = 0, t = 0;     while (true) {       int cur = last;       for (int i = d; i > 0; i--) {         if (f[last + i]) {           cur = last + i;           break;         }       }       if (cur == last) {         cout << last <<     << t << endl;         break;       }       last = cur;       t++;     }   }
#include <bits/stdc++.h>   using namespace std;   int a, b;   int noOfDivisors(int n) {     int till = sqrt(n);     int c = 0;     for (int i = 1; i < till + 1; i++) {       if ((n % i) == 0) {         if (i > b) c++;         if ((n / i) > b && (n != i * i)) c++;       }     }     return c;   }   int main() {     scanf( %d%d , &a, &b);     int ans = 0;     if (a == b) {       printf( infinity );       return 0;     } else {       printf( %d , noOfDivisors(a - b));     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 200;   const int maxm = maxn * maxn;   const int INF = 0x3f3f3f3f;   int n, k, s, ans, res;   int a[maxn];   int dp[maxn][maxm];   inline int read() {     int x = 0;     char ch = getchar();     while (ch <  0  || ch >  9 ) ch = getchar();     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x;   }   int main() {     if (fopen( D.in ,  r ) != NULL) {       freopen( D.in ,  r , stdin);       freopen( D.out ,  w , stdout);     }     n = read(), k = read(), s = read();     s = min(s, n * (n - 1) / 2);     for (int i = 1; i <= n; i++) a[i] = read();     for (int i = 1; i <= k; i++) ans += a[i];     memset(dp, INF, sizeof(dp));     dp[0][0] = 0;     for (int p = 1; p <= k; p++)       for (int i = p - 1; i >= 0; i--)         for (int j = s - (k + 1 - p); j >= 0; j--)           dp[i + 1][j + k + 1 - p] =               min(dp[i + 1][j + k + 1 - p], dp[i][j] - a[p]);     for (int p = k + 1; p <= n; p++)       for (int i = 1; i <= k; i++)         for (int j = s - (p - (k + 1)); j >= 0; j--)           dp[i - 1][j + p - (k + 1)] =               min(dp[i - 1][j + p - (k + 1)], dp[i][j] + a[p]);     for (int i = 0; i <= s; i++) res = min(res, dp[0][i]);     printf( %d n , ans + res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = (int)2e9;   const long long INFL = (long long)9e18;   const int MAXINT = ((~0) ^ (1 << 31));   const long long MAXLL = ((~0) ^ ((long long)1 << 63));   template <class T>   inline T pow2(T a) {     return a * a;   }   template <class T>   inline bool mineq(T& a, T b) {     return (a > b) ? (a = b, true) : false;   }   template <class T>   inline bool maxeq(T& a, T b) {     return (a < b) ? (a = b, true) : false;   }   const int maxn = 2e5 + 100;   long long n, m, d, lt, a, b, t;   long long dp[2 * maxn];   long long rmq[2 * maxn];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m >> d;     for (int i = 0; i < (int)(m); i++) {       cin >> a >> b >> t;       t = t - lt;       lt = lt + t;       long long gap = min(n, t * d);       deque<int> stk;       for (int i = 0; i < (int)(2 * n); i++) {         while (!stk.empty() && dp[stk.back()] <= dp[i]) stk.pop_back();         if (!stk.empty() && stk.front() == i - 2 * gap - 1) stk.pop_front();         stk.push_back(i);         rmq[i] = dp[stk.front()];       }       for (int i = 0; i < (int)(n); i++) {         dp[i] = rmq[i + gap] + b - abs(a - i - 1);       }       for (int i = n; i < (int)(2 * n); i++) dp[i] = -INF / 2;     }     cout << *max_element(dp, dp + n) << endl;   }
#include <bits/stdc++.h>   using namespace std;   void sdvig(char *c, int n) {     int i;     char s = c[0];     for (i = 0; i < n - 1; i++) {       c[i] = c[i + 1];     }     c[n - 1] = s;   }   int main() {     int n;     scanf( %d n , &n);     char c[1010], cc[1010];     cin >> cc;     int i, g, f, l = n - 1;     int mmin = 1000000000, kol;     bool fl;     for (f = 0; f < n; f++) {       kol = 0;       for (i = 0; i < n; i++) {         c[i] = cc[i];       }       while (true) {         i = 0;         g = l;         while (c[i] ==  H ) i++;         while (c[g] ==  T ) g--;         if (i < g) {           swap(c[i], c[g]);           kol++;         } else {           break;         }       }       if (kol < mmin) mmin = kol;       sdvig(cc, n);     }     cout << mmin;     return 0;   }
#include <iostream>         using namespace std;         int main()   {    int n, q;       cin >> n >> q;       char s[n+1];    int x[n+1];       for (int i = 1; i < n+1; i++)    {     cin >> s[i];     x[i] = x[i-1] + s[i] -  ` ;       }        int l, r;       for (int i = 0; i < q; i++)    {     cin >> l >> r;     cout << (x[r]-x[l-1]) << endl;       }                      return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long f[61 + 1], g[61 + 1], x, k;   int Q, op, pos;   int main() {     scanf( %d , &Q);     f[0] = 1;     for (int i = 1; i < 61; i++) f[i] = f[i - 1] * 2;     while (Q--) {       scanf( %d , &op);       if (op == 1) {         scanf( %I64d%I64d , &x, &k);         for (int i = 0; i < 61; i++)           if (f[i] >= x) {             pos = i;             break;           } else             x -= f[i];         g[pos] = (g[pos] + k) % f[pos];       }       if (op == 2) {         scanf( %I64d%I64d , &x, &k);         for (int i = 0; i < 61; i++)           if (f[i] >= x) {             pos = i;             break;           } else             x -= f[i];         k %= f[pos];         for (int i = pos; i < 61; i++) {           g[i] = (g[i] + k) % f[i];           k *= 2;         }       }       if (op == 3) {         scanf( %I64d , &x);         printf( %I64d , x);         long long tmp = x;         for (int i = 0; i < 61; i++)           if (f[i] >= x) {             pos = i;             break;           } else             x -= f[i];         x = tmp;         while (x != 1) {           long long xx = x, fa;           xx += g[pos];           if (xx < f[pos]) xx += f[pos];           if (xx >= f[pos + 1]) xx -= f[pos];           fa = xx / 2;           pos--;           fa -= g[pos];           if (fa < f[pos]) fa += f[pos];           if (fa >= f[pos + 1]) fa -= f[pos];           x = fa;           printf(  %I64d , fa);         }         printf(  n );       }     }   }