malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int INF = (1u << 31) - 1;   const int MAXN = 100086;   int mice[MAXN], arr[MAXN], chese[MAXN];   int main() {     for (int n, m; ~scanf( %d%d%*d%*d , &n, &m);) {       for (int i = 0; i < n; i++) {         scanf( %d , &mice[i]);       }       for (int i = 0; i < m; i++) {         scanf( %d , &chese[i]);       }       fill(arr, arr + m, INF);       int ans = 0;       for (int i = 0; i < n; i++) {         int left, right = lower_bound(chese, chese + m, mice[i]) - chese;         if (right == m) {           left = --right;         } else if (right == 0 || mice[i] == chese[right]) {           left = right;         } else {           left = right - 1;           if (abs(mice[i] - chese[left]) < abs(mice[i] - chese[right])) {             right = left;           } else if (abs(mice[i] - chese[left]) > abs(mice[i] - chese[right])) {             left = right;           }         }         int dist = abs(mice[i] - chese[left]);         if (arr[left] == INF) {           ans++;           arr[left] = dist;         } else if (arr[left] == dist) {           ans++;         } else if (arr[left] > dist && left == right) {           arr[left] = dist;         } else if (left != right) {           dist = abs(mice[i] - chese[right]);           arr[right] = dist;           ans++;         }       }       printf( %d n , n - ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int a[101][101], f[101], ans[101];   int main() {     int n, m;     cin >> n >> m;     memset(a, 0, sizeof(a));     memset(f, 0, sizeof(f));     memset(ans, 0, sizeof(ans));     for (int i = 1; i <= m; i++) {       for (int j = 1; j <= n; j++) {         cin >> a[i][j];       }     }     for (int i = 1; i <= m; i++) {       int t, t1, mv = -1;       for (int j = 1; j <= n; j++) {         if (a[i][j] > mv) {           mv = a[i][j];           t = i;           t1 = j;         }       }       f[t] = t1;     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         if (i == f[j]) ans[i]++;       }     }     int max(0), out(1);     ;     for (int i = 1; i <= n; i++) {       if (ans[i] > max) {         max = ans[i];         out = i;       }     }     cout << out;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 7 + (int)1e9;   long long process(string s) {     for (int i = 0; i < s.size(); i++) s[i] = (s[i] -  0 ) % 2 +  0 ;     return stoll(s);   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n;     char c;     map<long long, int> m;     cin >> n;     while (n--) {       string a;       cin >> c >> a;       if (c ==  + ) {         m[process(a)]++;       } else if (c ==  - ) {         m[process(a)]--;       } else if (c ==  ? ) {         cout << m[stoll(a)] << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > v;   int n, a, b;   int max(int a, int b) {     if (a > b) return a;     return b;   }   bool checkNorm(pair<int, int> f, pair<int, int> s) {     int x1, y1;     x1 = max(f.first, s.first), y1 = f.second + s.second;     if (x1 <= a && y1 <= b) return 1;     y1 = max(f.second, s.second), x1 = f.first + s.first;     if (x1 <= a && y1 <= b) return 1;     return 0;   }   pair<int, int> rotate(pair<int, int> p) {     swap(p.first, p.second);     return p;   }   int main() {     ios_base ::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);     cin >> n >> a >> b;     for (int i = 0; i < n; i++) {       int x, y;       cin >> x >> y;       v.push_back(make_pair(x, y));     }     int mx = 0;     for (int i = 1; i < n; i++) {       for (int j = 0; j < i; j++) {         if (checkNorm(v[i], v[j])) {           mx = max(mx, v[i].first * v[i].second + v[j].first * v[j].second);         }         if (checkNorm(v[i], rotate(v[j]))) {           mx = max(mx, v[i].first * v[i].second + v[j].first * v[j].second);         }         if (checkNorm(rotate(v[i]), (v[j]))) {           mx = max(mx, v[i].first * v[i].second + v[j].first * v[j].second);         }         if (checkNorm(rotate(v[i]), rotate(v[j]))) {           mx = max(mx, v[i].first * v[i].second + v[j].first * v[j].second);         }       }     }     cout << mx;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int cnt[100005];     int cmax[10];     memset(cnt, 0, sizeof(cnt));     memset(cmax, 0, sizeof(cmax));     for (int i = 1; i <= n; i++) {       int a;       cin >> a;       cnt[a]++;       if (cnt[a] < 10) cmax[cnt[a]]++;     }     int t;     cin >> t;     while (t--) {       char ch;       int x;       cin >> ch >> x;       if (ch ==  + ) {         cnt[x]++;         if (cnt[x] < 10) cmax[cnt[x]]++;       } else {         if (cnt[x] < 10) cmax[cnt[x]]--;         cnt[x]--;       }       if (cmax[8])         cout <<  YES  << endl;       else if (cmax[4] >= 2)         cout <<  YES  << endl;       else if (cmax[4]) {         if (cmax[2] >= 3)           cout <<  YES  << endl;         else if (cmax[2] >= 2 && cmax[6])           cout <<  YES  << endl;         else           cout <<  NO  << endl;       } else         cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   list<char> lanc;   using It = list<char>::iterator;   bool torolni_kell(It mit) {     if (*mit ==  - ) return false;     char akt = *mit, el = *prev(mit), kov = *next(mit);     return (el !=  -  && el != akt) || (kov !=  -  && kov != akt);   }   int main() {     ios_base::sync_with_stdio(false);     string be;     cin >> be;     be =  -  + be +  - ;     lanc.insert(begin(lanc), begin(be), end(be));     int valasz = 0;     vector<It> to_check;     for (It it = next(lanc.begin()); *it !=  - ; ++it) to_check.push_back(it);     while (1) {       vector<It> torlendok;       for (It akt : to_check)         if (torolni_kell(akt)) torlendok.push_back(akt);       to_check = {};       for (int i = 0; i < torlendok.size(); i++) {         if ((i == 0 || prev(torlendok[i]) != torlendok[i - 1]) &&             (to_check.empty() || to_check.back() != prev(torlendok[i])))           to_check.push_back(prev(torlendok[i]));         if ((i + 1 == torlendok.size() ||              next(torlendok[i]) != torlendok[i + 1]) &&             (to_check.empty() || to_check.back() != next(torlendok[i])))           to_check.push_back(next(torlendok[i]));       }       if (torlendok.empty()) break;       for (auto akt : torlendok) lanc.erase(akt);       valasz++;     }     cout << valasz;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int t;     cin >> t;     while (t--) {       bool f = false;       set<int> v1;       int n, ans = -1;       cin >> n;       int a[n];       for (long long i = 0; i < n; i++) {         cin >> a[i];         v1.insert(a[i]);       }       for (int i = 1; i <= 1024; i++) {         long long count = 0;         for (int j = 0; j < n; j++) {           int m = a[j] ^ i;           v1.insert(a[j] ^ i);           if (v1.size() > n) {             count++;             v1.erase(v1.find(m));             break;           }         }         if (count == 0) {           ans = i;           break;         }       }       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 10;   int cnt[32][N + 10];   int main() {     for (int i = 1; i <= N; i++) {       int n = i, t = 0;       while (n > 0) {         cnt[t][i] = cnt[t][i - 1] + n % 2;         t++;         n /= 2;       }     }     int t;     cin >> t;     while (t--) {       int l, r;       cin >> l >> r;       int k[32] = {};       for (int i = 0; i < 32; i++) {         k[i] = cnt[i][r] - cnt[i][l - 1];       }       int res = 0;       for (int i = 0; i < 32; i++) {         res = max(res, k[i]);       }       cout << (r - l + 1) - res <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, q;   int sz, nxt[(1 << 20)][2], son[(1 << 20)], val[(1 << 20)];   bool vis[(1 << 20)];   void insert(int v, int add) {     int x = 0;     for (int i = 18; i >= 0; i--) {       int c = (v >> i) & 1;       if (!nxt[x][c]) nxt[x][c] = sz++;       x = nxt[x][c];       son[x] += add;     }     val[x] = v;   }   int query(int v) {     int x = 0;     for (int i = 18; i >= 0; i--) {       int c = (v >> i) & 1;       if (son[nxt[x][c]] == (1 << i))         x = nxt[x][c ^ 1];       else         x = nxt[x][c];     }     return val[x];   }   int main() {     scanf( %d %d , &n, &q);     sz++;     for (int i = 0; i < (1 << 19); i++) insert(i, 0);     for (int i = 1; i <= n; i++) {       int x;       scanf( %d , &x);       if (vis[x]) continue;       insert(x, 1);       vis[x] = 1;     }     int cur = 0, x;     while (q--) {       scanf( %d , &x);       cur ^= x;       printf( %d n , query(cur) ^ cur);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long MOD = 1000000007;   const int MAX = 100005;   bool check(int x, int y) {     int cnt1[11] = {0};     int cnt2[11] = {0};     while (x > 0) {       cnt1[x % 10]++;       x /= 10;     }     while (y > 0) {       cnt2[y % 10]++;       y /= 10;     }     for (int i = 0; i < 10; i++) {       if (cnt1[i] > 0 and cnt2[i] > 0) return true;     }     return false;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int x;     cin >> x;     vector<int> v;     for (int i = 1; i * i <= x; i++) {       if (x % i == 0) {         if (i * i == x)           v.push_back(i);         else           v.push_back(i), v.push_back(x / i);       }     }     int ans = 0, sz = v.size();     for (int i = 0; i < sz; i++) {       if (check(x, v[i])) ans++;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 3e6 + 7;   long long int a[N], b[N], c[N], tree[N], lazy[N], cnt, sum, s2, mx;   vector<long long int> v, u;   vector<pair<long long int, long long int>> vp;   map<long long int, long long int> mp;   bool vis[111111];   pair<long long int, long long int> p;   set<pair<long long int, long long int>> ss;   queue<long long int> q;   int main() {     ios_base ::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long int n, m = 0, d, i = 0, s1 = 0, s2 = 0, q = 5, x = 0, y, k, j;     string s;     cin >> n;     if (n % 2 == 0)       m = n / 2 - 1;     else       m = n / 2;     double mx = 0.0;     for (i = m; i > 0; i--) {       map<long long int, long long int> mm;       cnt = 0;       for (j = 2; j <= i; j++) {         if (i % j == 0) mm[j]++;       }       for (j = 2; j <= (n - i); j++) {         if ((n - i) % j == 0 && mm[j] != 0) {           cnt = 1;           break;         }       }       if (cnt == 0) return cout << i <<     << n - i, 0;     }   }
#include <bits/stdc++.h>   using namespace std;   int n;   int A[1000];   int main() {     cin >> n;     for (int i = 0; i < n; i++) cin >> A[i];     int G = 0, C = 0;     for (int i = 0; i < n; i++) {       if (A[i] == 0) {         G = min(C, G) + 1;         C = G;       } else if (A[i] == 1) {         int temp = G;         G = min(G, C) + 1;         C = min(temp, C + 1);       } else if (A[i] == 2) {         int temp = C;         C = min(G, C) + 1;         G = min(temp, G + 1);       } else {         int temp = G;         G = min(C, G + 1);         C = min(temp, C + 1);       }     }     cout << min(G, C) << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<int> angles(n);     for (int i = 0; i < n; i++) {       int angle;       cin >> angle;       angles[i] = angle;     }     int difference = 360;     for (int i = 0; i < n; i++) {       int current_angle = angles[i];       for (int j = 1; j < n; j++) {         int curr_diff = max(current_angle, 360 - current_angle) -                         min(current_angle, 360 - current_angle);         difference = min(difference, curr_diff);         current_angle += angles[(i + j) % n];       }       int curr_diff = max(current_angle, 360 - current_angle) -                       min(current_angle, 360 - current_angle);       difference = min(difference, curr_diff);     }     cout << difference << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       vector<pair<long long, long long> > v(n);       for (long long i = 0; i < n; i++) {         cin >> v[i].first >> v[i].second;       }       sort(v.begin(), v.end());       long long a, b;       a = v[n - 1].first;       for (long long i = 0; i < n; i++) swap(v[i].first, v[i].second);       sort(v.begin(), v.end());       b = v[0].first;       if (a - b <= 0)         cout << 0 << endl;       else         cout << a - b << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 100100;   int P, n, m, s[maxn];   long long K;   struct que {     long long x;     int prey, y;     bool operator<(const que &a) const { return x < a.x; }   } q[maxn];   struct Matrix {     int a[2][2];     Matrix() { memset(a, 0, sizeof a); }     Matrix(int a_, int b_) {       a[0][0] = a_, a[0][1] = 1;       a[1][0] = b_, a[1][1] = 0;     }     void init(int x) {       memset(a, 0, sizeof a);       a[0][0] = a[1][1] = x;     }     Matrix operator*(const Matrix &b) {       Matrix c;       c.init(0);       for (int i = 0; i < 2; i++)         for (int j = 0; j < 2; j++)           for (int k = 0; k < 2; k++)             c.a[i][j] = (c.a[i][j] + 1ll * a[i][k] * b.a[k][j] % P) % P;       return c;     }   } tr[maxn * 4];   int le, ri;   void build(int rt, int l, int r) {     if (l == r) {       tr[rt] = Matrix(s[l], s[l - 1]);       return;     }     int mid = (l + r) / 2;     build(rt * 2, l, mid);     build(rt * 2 + 1, mid + 1, r);     tr[rt] = tr[rt * 2] * tr[rt * 2 + 1];   }   Matrix query(int rt, int l, int r) {     if (le <= l && ri >= r) return tr[rt];     int mid = (l + r) / 2;     if (ri <= mid) return query(rt * 2, l, mid);     if (le > mid) return query(rt * 2 + 1, mid + 1, r);     return query(rt * 2, l, mid) * query(rt * 2 + 1, mid + 1, r);   }   Matrix qk_pow(Matrix a, long long b) {     Matrix p;     p.init(1);     for (; b; b /= 2, a = a * a)       if (b & 1) p = p * a;     return p;   }   int get(int x) { return x ? x : n; }   Matrix query(long long l, long long r) {     long long rr = l + n - get((l - 1) % n);     if (rr > r) {       le = get((l - 1) % n), ri = get((r - 1) % n);       return query(1, 1, n);     } else {       Matrix c;       c.init(0);       le = get((l - 1) % n), ri = n;       c = query(1, 1, n);       c = c * qk_pow(tr[1], (r - rr) / n);       if ((r - rr) % n) le = 1, ri = (r - rr) % n, c = c * query(1, 1, n);       return c;     }   }   int main() {     scanf( %lld%d%d , &K, &P, &n);     if (K == 0 || K == 1) {       printf( %lld , K % P);       return 0;     }     for (int i = 0; i < n; i++) scanf( %d , &s[i]);     s[n] = s[0];     build(1, 1, n);     scanf( %d , &m);     for (int i = 1; i <= m; i++) scanf( %lld%d , &q[i].x, &q[i].y);     sort(q + 1, q + m + 1);     while (q[m].x > K) m--;     if (q[m].x != K) q[++m].x = K, q[m].y = s[m % n];     Matrix ans;     ans.a[0][0] = 1;     for (int i = 1; i <= m; i++)       q[i].prey = q[i - 1].x + 1 == q[i].x ? q[i - 1].y : s[(q[i].x - 1) % n];     q[0].x = 1, q[0].y = s[1], q[0].prey = s[0];     for (int i = 1; i <= m; i++) {       ans = ans * Matrix(q[i - 1].y, q[i - 1].prey);       if (q[i].x == q[i - 1].x + 1) continue;       ans = ans * Matrix(s[(q[i - 1].x + 1) % n], q[i - 1].y);       if (q[i].x == q[i - 1].x + 2) continue;       ans = ans * query(q[i - 1].x + 3, q[i].x);     }     printf( %d n , ans.a[0][0]);     fclose(stdin);     fclose(stdout);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, MOD, f[(long long)4e6 + 5], sum[(long long)4e6 + 5],       d[(long long)4e6 + 5];   signed main() {     cin >> n >> MOD;     long long Sum = 0;     for (long long i = 1; i <= n; i++) {       if (i == 1)         f[1] = 1;       else         f[i] = (Sum + d[i] + sum[i - 1]) % MOD;       sum[i] = (sum[i - 1] + f[i]) % MOD;       for (long long j = 1; j * i <= n; j++) {         d[j * i] = (d[j * i] + f[i]) % MOD;         if (j * i + j <= n) d[j * i + j] = (d[j * i + j] - f[i] + MOD) % MOD;       }       Sum = (Sum + d[i]) % MOD;     }     cout << f[n] % MOD;     return 0;   }
#include <bits/stdc++.h>   using ll = long long int;   using namespace std;   int main() {     int n;     cin >> n;     string s;     cin >> s;     int cnt = 0;     int negative = -1;     int ans = 0;     for (int i = 0; i < n; ++i) {       if (s[i] ==  ) )         --cnt;       else if (s[i] ==  ( )         ++cnt;       if (cnt < 0 && negative == -1) negative = i;       if (cnt == 0 && negative != -1) {         ans += i - negative + 1;         negative = -1;       }     }     if (cnt != 0) {       cout << -1 << endl;     } else {       cout << ans << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 5056, M = 1e9 + 7;   long long n, a[N], pr[N], ans[N * 2], h[N * 2];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> n;     pr[0] = 1;     for (int i = 1; i <= n - 1; ++i) {       cin >> a[i];       pr[i] = a[i] * pr[i - 1] % M;       for (int j = 1; j <= i; ++j) ans[j] += pr[i];     }     for (int i = n - 1; i >= 1; --i) {       for (int j = n + n - 2; j >= 2; --j)         h[j] = (a[i + 1] * a[i + 1] % M) * h[j - 2] % M;       long long p = 1;       for (int j = 2; i + j - 1 <= n; ++j) {         (h[j] += p * (j > 2 ? 2 : 1)) %= M;         p = (p * a[i + j - 1]) % M;       }       for (int j = 2; j <= 2 * n - 2; ++j)         ans[j] += a[i] * (a[i] - 1) / 2 % M * pr[i - 1] % M * h[j] % M;     }     for (int k = 1; k <= n + n - 2; ++k)       cout << ans[k] % M <<    n [k == n + n - 2];   }
#include <bits/stdc++.h>   using namespace std;   int transition;   int dp[10][2][1 << 9];   int solve(int idx, int tight, int mask, string &s) {     if (idx == s.size()) {       return __builtin_popcount(mask) == s.size();     }     if (dp[idx][tight][mask] != -1) return dp[idx][tight][mask];     int &ans = dp[idx][tight][mask];     ans = 0;     if (idx == transition) {       for (int i = 0; i <= s[idx] -  0 ; i++) {         ans += solve(idx + 1, s[idx] -  0  == i, mask | (1 << i), s);       }     } else {       if (tight) {         for (int i = 0; i <= s[idx] -  0 ; i++) {           ans += solve(idx + 1, s[idx] -  0  == i, mask | (1 << i), s);         }       } else {         for (int i = 0; i < 7; i++) {           ans += solve(idx + 1, 0, mask | (1 << i), s);         }       }     }     return ans;   }   string base7(int n) {     string ans;     if (n == 0) {       ans.push_back( 0 );       return ans;     }     while (n) {       ans.push_back( 0  + n % 7);       n /= 7;     }     reverse(ans.begin(), ans.end());     return ans;   }   int main() {     int n, m;     cin >> n >> m;     m--;     n--;     memset(dp, -1, sizeof(dp));     string hours = base7(n);     string minutes = base7(m);     string s = hours + minutes;     transition = hours.size();     if (s.size() > 7)       cout << 0 <<   n ;     else {       cout << solve(0, 1, 0, s) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int fx[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};   const int fxx[8][2] = {{0, 1}, {0, -1}, {1, 0},  {-1, 0},                          {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};   int gcD(int a, int b) {     while (a && b) a > b ? a %= b : b %= a;     return a + b;   }   const int MAXN = 2e5 + 10;   int a[MAXN];   int N;   int main() {     scanf( %d , &N);     int g = 0;     for (int i = 0; i < N; i++) {       scanf( %d , &a[i]);       g = gcD(a[i], g);     }     for (int i = 0; i < N; i++) {       a[i] /= g;       while ((a[i] & 1) == 0) a[i] = a[i] >> 1;       while (a[i] % 3 == 0) a[i] /= 3;       if (a[i] != 1) {         printf( No n );         return 0;       }     }     printf( Yes n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 310000;   int n, m, cs[N], cd[N], nr, rez[N], aint[4 * N], full[4 * N];   vector<int> v[N];   vector<pair<int, int> > x[N];   bool ver[N];   void df(int nod) {     ver[nod] = 1;     cs[nod] = ++nr;     for (vector<int>::iterator it = v[nod].begin(); it != v[nod].end(); ++it)       if (!ver[*it]) df(*it);     cd[nod] = nr;   }   void update(int nod, int pozx, int pozy, int poz1, int poz2, int val) {     if (pozx >= poz1 && poz2 >= pozy) {       full[nod] += val;       if (full[nod])         aint[nod] = pozy - pozx + 1;       else         aint[nod] = aint[2 * nod] + aint[2 * nod + 1];       return;     }     int mid = (pozx + pozy) / 2;     if (mid >= poz1) update(2 * nod, pozx, mid, poz1, poz2, val);     if (mid < poz2) update(2 * nod + 1, mid + 1, pozy, poz1, poz2, val);     if (full[nod])       aint[nod] = pozy - pozx + 1;     else       aint[nod] = aint[2 * nod + 1] + aint[2 * nod];   }   void df2(int nod) {     vector<pair<int, int> >::iterator i;     vector<int>::iterator it;     ver[nod] = 1;     for (i = x[nod].begin(); i != x[nod].end(); ++i) {       update(1, 1, n, i->first, i->second, 1);     }     rez[nod] = max(0, aint[1] - 1);     for (it = v[nod].begin(); it != v[nod].end(); ++it)       if (!ver[*it]) df2(*it);     for (i = x[nod].begin(); i != x[nod].end(); ++i)       update(1, 1, n, i->first, i->second, -1);   }   int main() {     int i, a, b;     cin >> n >> m;     for (i = 1; i != n; ++i) {       cin >> a >> b;       v[a].push_back(b);       v[b].push_back(a);     }     df(1);     for (i = 1; i <= m; ++i) {       cin >> a >> b;       x[a].push_back(pair<int, int>(cs[a], cd[a]));       x[b].push_back(pair<int, int>(cs[b], cd[b]));       x[a].push_back(pair<int, int>(cs[b], cd[b]));       x[b].push_back(pair<int, int>(cs[a], cd[a]));     }     for (i = 1; i <= n; ++i) ver[i] = 0;     df2(1);     for (i = 1; i <= n; ++i) cout << rez[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int func1(long long int i) {     return i * (i + 1) * (2 * i + 1) / 6 - (i + i + 2) * i * (i + 1) / 2 +            (i + i + 1 + i * i) * i;   }   long long int func2(long long int i) { return i + i * i - i * (i + 1) / 2; }   int main() {     long long int inp;     cin >> inp;     set<pair<long long int, long long int> > s;     for (long long int i = 1; func1(i) <= inp; i++)       if ((inp - func1(i)) % func2(i) == 0) {         s.insert(make_pair(i, i + (inp - func1(i)) / func2(i)));         s.insert(make_pair(i + (inp - func1(i)) / func2(i), i));       }     cout << s.size() <<   n ;     for (auto i = s.begin(); i != s.end(); i++)       cout << (*i).first <<     << (*i).second <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double dp[200];   int next1[200];   int cnt(int i, int j) {     if ((11 - i) % 2 == 1) {       return (10 - i) * 10 + j;     } else {       return (10 - i) * 10 + (11 - j);     }   }   int main() {     for (int i = (1); i < (11); i++) {       for (int j = (1); j < (11); j++) {         int x;         cin >> x;         int now = cnt(i, j);         int net = cnt(i - x, j);         next1[now] = net;       }     }     for (int i = (0); i < (6); i++) dp[99 - i] = 6;     for (int i = 93; i >= 1; i--) {       dp[i] = 1;       for (int j = (1); j < (7); j++) {         dp[i] += min(dp[i + j], dp[next1[i + j]]) / 6;       }     }     printf( %.10lf , dp[1]);     return 0;   }