malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   string s;   int n;   long long ans;   vector<int> ls, rr;   long long cal(int l, int r) {     long long val = 0;     long long tmp = s[l] -  0 ;     for (int i = l + 1; i < r; i += 2) {       if (s[i] ==  * )         tmp *= s[i + 1] -  0 ;       else {         val += tmp;         tmp = s[i + 1] -  0 ;       }     }     val += tmp;     long long res = 0;     tmp = s[0] -  0 ;     if (l == 0) tmp = val;     for (int i = (l == 0) ? r : 1; i < n; i += 2) {       if (i + 1 == l) {         tmp *= val;         i = r - 2;         continue;       }       if (s[i] ==  * )         tmp *= (long long)(s[i + 1] -  0 );       else {         res += tmp;         tmp = (long long)(s[i + 1] -  0 );       }     }     res += tmp;     return res;   }   int main() {     cin >> s;     n = s.length();     ls.push_back(0);     rr.push_back(n);     for (int i = 1; i < n; i += 2) {       if (s[i] ==  * ) {         ls.push_back(i + 1);         rr.push_back(i);       }     }     for (int l = 0; l < ls.size(); l++)       for (int r = 0; r < rr.size(); r++) {         if (ls[l] >= rr[r]) continue;         ans = max(ans, cal(ls[l], rr[r]));       }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   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;   }   int n, l[200100], r[200100], L[200100], R[200100];   int main() {     n = read();     for (int i = 1; i <= n; i++) {       l[i] = read();       r[i] = read();       r[i] += l[i];     }     L[0] = R[n + 1] = 1e9 + 10;     for (int i = 1; i <= n; i++) L[i] = min(r[i], L[i - 1] + 1);     for (int i = n; i >= 1; i--) R[i] = min(r[i], R[i + 1] + 1);     long long ans = 0, f = 0;     for (int i = 1; i <= n; i++) {       if (min(L[i], R[i]) < l[i]) f = 1;       ans += min(L[i], R[i]) - l[i];     }     if (f) {       puts( -1 );       return 0;     }     printf( %I64d n , ans);     for (int i = 1; i <= n; i++) printf( %d  , min(L[i], R[i]));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[100005], c[100005];   vector<pair<long long, long long>> p[100005];   long long check(long long x, long long i) {     long long v = 0;     for (auto j : p[i]) {       long long v1 = j.first, v2 = j.second;       if (v1 != -1) v += abs(v1 - x);       if (v2 != -1) v += abs(v2 - x);     }     return v;   }   int main() {     long long n, m, sum = 0;     cin >> n >> m;     for (long long i = 1; i <= m; i++) {       scanf( %lld , &a[i]);     }     if (m == 1) {       cout << 0 << endl;       return 0;     }     a[0] = a[1], a[m + 1] = a[m];     for (long long i = 1; i <= m; i++) {       long long x = a[i - 1], y = a[i + 1];       if (x == a[i]) x = -1;       if (y == a[i]) y = -1;       p[a[i]].push_back({min(x, y), max(x, y)});     }     for (long long i = 2; i <= m; i++) {       sum += abs(a[i] - a[i - 1]);     }     for (long long i = 1; i <= n; i++) {       c[i] = check(i, i);     }     long long res = 2e18;     for (long long i = 1; i <= n; i++) {       if (p[i].size() == 0) continue;       long long l = 1, r = n, ans = 2e18;       while (r >= l) {         long long midl = l + (r - l) / 3, numl = check(midl, i);         long long midr = r - (r - l) / 3, numr = check(midr, i);         if (numl <= numr)           r = midr - 1, ans = min(ans, numl);         else           l = midl + 1, ans = min(ans, numr);       }       res = min(res, sum - c[i] + ans);     }     cout << res << endl;   }
#include <bits/stdc++.h>   using namespace std;   const long long mxn = 1e5 + 7;   int main() {     long long n, mx = 0, a[mxn];     cin >> n;     for (int i = 1; i <= n; i++) {       int x;       cin >> x;       a[x]++;     }     for (int i = 1; i <= 101; i++) {       mx = max(mx, a[i]);     }     cout << mx;   }
#include <bits/stdc++.h>   using namespace std;   int na, ma, nb, mb;   char s[55][55];   char t[55][55];   int main() {     while (~scanf( %d%d , &na, &ma)) {       for (int i = 0; i < na; i++) scanf( %s , s[i]);       scanf( %d%d , &nb, &mb);       for (int i = 0; i < nb; i++) scanf( %s , t[i]);       int ans = 0, xx = 0, yy = 0;       int n = max(na, nb), m = max(ma, mb);       for (int x = -n; x <= n; x++)         for (int y = -m; y <= m; y++) {           int tmp = 0;           for (int i = 0; i < na; i++)             for (int j = 0; j < ma; j++)               if (i + x < nb && j + y < mb && i + x >= 0 && j + y >= 0)                 tmp += (s[i][j] ==  1 ) & (t[i + x][j + y] ==  1 );           if (ans < tmp) ans = tmp, xx = x, yy = y;         }       printf( %d %d n , xx, yy);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) putchar( 1 );     puts(  );     for (int i = 1; i < n; ++i) putchar( 8 );     puts( 9 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int l[10100];   int r[10100];   int per[100100];   int pr(int x) {     if (x == per[x]) return x;     return per[x] = pr(per[x]);   }   int main() {     ios::sync_with_stdio(0);     int n;     cin >> n;     int t = 0;     for (int i = 1; i <= n; i++) {       per[i] = i;       cin >> l[i];       cin >> r[i];       t += l[i] == 0;     }     for (int i = 1; i <= n; i++) {       if (l[i]) {         r[l[i]] = i;         per[pr(i)] = pr(l[i]);       }       if (r[i]) {         l[r[i]] = i;         per[pr(i)] = pr(r[i]);       }     }     for (int i = 1; i <= n; i++) {       if (l[i] == 0) {         if (t == 1) continue;         for (int j = 1; j <= n; j++) {           if (i == j) continue;           if (pr(i) == pr(j)) continue;           if (r[j] == 0) {             r[j] = i;             l[i] = j;             per[pr(i)] = pr(j);             break;           }         }         t--;       }     }     for (int i = 1; i <= n; i++) {       cout << l[i] <<     << r[i] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   const int maxn = 100001;   int n, a[maxn];   struct Segment {     int val, tag;   } seg[maxn << 1 | 1];   inline int seg_idx(int L, int R) { return (L + R) | (L < R); }   void seg_down(int rt, int lch, int rch) {     if (!seg[rt].tag) return;     seg[lch].val += seg[rt].tag;     seg[lch].tag += seg[rt].tag;     seg[rch].val += seg[rt].tag;     seg[rch].tag += seg[rt].tag;     seg[rt].tag = 0;   }   void seg_up(int rt, int lch, int rch) {     seg[rt].val = std::max(seg[lch].val, seg[rch].val);   }   void seg_upd(int L, int R, int x, int v) {     int rt = seg_idx(L, R);     if (R <= x) {       seg[rt].val += v;       seg[rt].tag += v;       return;     }     int M = (L + R) >> 1, lch = seg_idx(L, M), rch = seg_idx(M + 1, R);     seg_down(rt, lch, rch);     seg_upd(L, M, x, v);     if (x > M) seg_upd(M + 1, R, x, v);     seg_up(rt, lch, rch);   }   int seg_que(int L, int R) {     int rt = seg_idx(L, R);     if (L == R) return L;     int M = (L + R) >> 1, lch = seg_idx(L, M), rch = seg_idx(M + 1, R), ret;     seg_down(rt, lch, rch);     ret = seg[rch].val <= 0 ? seg_que(L, M) : seg_que(M + 1, R);     seg_up(rt, lch, rch);     return ret;   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) {       int pos, typ;       scanf( %d%d , &pos, &typ);       if (typ == 1) {         scanf( %d , a + pos);         seg_upd(1, n, pos, 1);       } else         seg_upd(1, n, pos, -1);       if (seg[seg_idx(1, n)].val <= 0)         puts( -1 );       else         printf( %d n , a[seg_que(1, n)]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   bool judge(string& s, string& t) {     auto f = [](string& x, vector<int>& cnt) {       ll res = 0;       for (char c : x) {         int v = c -  a ;         for (int i = v + 1; i < 26; i++) res += cnt[i];         cnt[v]++;       }       return res;     };     vector<int> vecS(26);     vector<int> vecT(26);     int nums = f(s, vecS), numt = f(t, vecT);     return (nums % 2 == numt % 2 ||             *max_element(vecS.begin(), vecS.end()) >= 2) &&            vecS == vecT;   }   int main() {     int q;     cin >> q;     while (q--) {       int n;       cin >> n;       string s, t;       cin >> s >> t;       cout << (judge(s, t) ?  YES  :  NO ) << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int i, j, n, m, k;   int main() {     scanf( %d , &n);     if (n <= 2) {       printf( %d n , -1);     } else {       printf( %d n , 35);       printf( %d n , 77);       for (i = 1; i <= n - 2; i++) printf( %d n , i * 55);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-9;   long long read() {     long long x = 0;     long long f = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -f;       c = getchar();     }     while (c >=  0  && c <=  9 ) {       x = x * 10 + c -  0 ;       c = getchar();     }     x *= f;     return x;   }   long long n, m;   struct matrix {     long long s[315][315];     void inti() {       for (int i = 1; i <= n; i++)         for (int j = 1; j <= n; j++) s[i][j] = -0x3f3f3f3f;       return;     }     matrix operator*(matrix b) const {       matrix f;       f.inti();       for (int k = 1; k <= n; k++)         for (int i = 1; i <= n; i++)           for (int j = 1; j <= n; j++)             f.s[i][j] = max(f.s[i][j], s[i][k] + b.s[k][j]);       return f;     }   } t[10], now, p;   int main() {     n = read(), m = read();     t[0].inti();     for (int i = 1; i <= n; i++) t[0].s[i][i] = 0;     for (int i = 1; i <= m; i++) {       long long u = read(), v = read();       t[0].s[u][v] = read();       t[0].s[v][u] = read();     }     for (int i = 1; i < 10; i++) t[i] = t[i - 1] * t[i - 1];     now.inti(), p.inti();     for (int i = 1; i <= n; i++) now.s[i][i] = 0;     long long ans = 0;     for (int i = 10 - 1; ~i; i--) {       p = now * t[i];       bool flag = 0;       for (int j = 1; j <= n; j++)         if (p.s[j][j] > 0) {           flag = 1;           break;         }       if (flag) continue;       ans += (1 << i), now = p;     }     if (ans > n)       puts( 0 );     else       printf( %lld , ans + 1);   }
#include <bits/stdc++.h>   int S, T, n, m, l, vol[200020];   int dis[400040], pos[400040], q[400040 * 2];   int E, u[200020], v[200020], go[400040], to[400040];   void AE(int s, int t) {     to[++E] = t;     v[s] = u[s] ? go[v[s]] = E : u[s] = E;   }   int spfa(int maxq) {     register int i, j, k, top, tail;     memset(dis, 0x7f, sizeof(dis));     memset(pos, 0, sizeof(pos));     q[1] = S;     dis[S] = top = 0;     pos[S] = tail = 1;     while (++top <= tail) {       i = q[top];       if (dis[i] < maxq)         for (j = u[i]; j; j = go[j]) {           int tmp = vol[to[j]] ? 0 : dis[i] + 1;           if (dis[to[j]] > tmp) {             dis[to[j]] = tmp;             if (!pos[to[j]]) {               q[++tail] = to[j];               pos[to[j]] = 1;             }           }         }       pos[i] = 0;     }     return dis[T] < 0x7f7f7f7f;   }   int main() {     register int i, j, k;     scanf( %d%d%d , &n, &m, &l);     for (i = 1; i <= l; i++) {       scanf( %d , &k);       vol[k] = 1;     }     for (i = 1; i <= m; i++) {       scanf( %d%d , &j, &k);       AE(j, k);       AE(k, j);     }     scanf( %d%d , &S, &T);     int l = 1, r = n, m, ans = -1;     while (l <= r) {       m = l + r + 1 >> 1;       if (spfa(m)) {         ans = m;         r = m - 1;       } else         l = m + 1;     }     printf( %d n , ans < 0 ? -1 : ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int counts = 0, counts2 = 0;     for (int i = 0; i < n; ++i) {       int a, b;       cin >> a >> b;       if (a < 0)         counts++;       else         counts2++;     }     if (counts <= 1 || counts2 <= 1)       cout <<  Yes ;     else       cout <<  No ;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 205, inf = 1 << 27;   int g[maxn][maxn], g1[maxn][maxn];   int qq[maxn], h, t, n, dis[maxn];   char col[maxn];   int aa[maxn], dd[maxn], x[maxn], bb[maxn], l;   int find_min() {     int i, ind, ind1, ans;     ind = 1;     for (i = 2; i <= n; i++) {       if (aa[i] > aa[ind] || aa[i] == aa[ind] && x[i] > x[ind]) {         ind = i;       }     }     ans = aa[ind];     while (x[ind] < l) {       ind1 = -1;       for (i = 1; i <= n; i++) {         if (x[i] + dd[i] > x[ind] + dd[ind] &&             (ind1 == -1 || aa[i] > aa[ind1] ||              aa[i] == aa[ind1] && dd[i] > dd[ind1])) {           ind1 = i;         }       }       if (ind1 == -1) break;       ans = min(ans, (x[ind] + dd[ind] + aa[ind1]) / 2);       ind = ind1;     }     return ans;   }   int main() {     int m, i, j, k, a, b, w;     int cur, ans;     scanf( %d %d , &n, &m);     for (i = 0; i < m; i++) {       scanf( %d %d %d , &a, &b, &w);       g[a][b] = g[b][a] = 2 * w;     }     for (i = 1; i <= n; i++) {       for (j = i + 1; j <= n; j++) {         g1[i][j] = g1[j][i] = (g[i][j] ? g[i][j] : inf);       }     }     for (k = 1; k <= n; k++) {       for (i = 1; i <= n; i++) {         for (j = 1; j <= n; j++) {           g1[i][j] = min(g1[i][j], g1[i][k] + g1[k][j]);         }       }     }     ans = inf;     for (i = 1; i <= n; i++) {       cur = 0;       for (j = 1; j <= n; j++) {         cur = max(cur, g1[i][j]);       }       ans = min(ans, cur);     }     for (i = 1; i <= n; i++) {       for (j = i + 1; j <= n; j++) {         if (!g[i][j]) continue;         cur = 0;         l = g[i][j];         for (k = 1; k <= n; k++) {           aa[k] = g1[i][k];           bb[k] = g1[j][k];           x[k] = (bb[k] + l - aa[k]) / 2;           dd[k] = aa[k] + x[k];         }         cur = find_min();         ans = min(ans, cur);       }     }     printf( %d.%d , ans / 2, 5 * (ans % 2));   }
#include <bits/stdc++.h>   using namespace std;   const int MAX_H = 100;   const int MAX_W = 100;   char s[MAX_W + 4];   int main() {     int h, w;     scanf( %d%d , &h, &w);     for (int y = 0; y < h; y++) scanf( %s , s);     int c = 0;     for (int i = 0; i < w;) {       while (i < w && s[i] ==  . ) i++;       if (i >= w) break;       while (i < w && s[i] ==  B ) i++;       c++;     }     printf( %d n , c);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 10000;   int n;   set<pair<int, int> > a;   set<pair<int, int> >::iterator it;   pair<int, int> b[MAX];   void dive(int s, int e) {     if (e - s == 1) return;     int mid = s + e;     mid /= 2;     dive(s, mid);     dive(mid, e);     for (int i = s; i < e; i++) a.insert(make_pair(b[mid].first, b[i].second));   }   int main() {     cin >> n;     int x, y;     for (int i = 0; i < n; i++) {       cin >> b[i].first >> b[i].second;       a.insert(b[i]);     }     sort(b, b + n);     dive(0, n);     cout << a.size() << endl;     for (it = a.begin(); it != a.end(); it++)       cout << it->first <<     << it->second << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       long long a[n + 1];       for (int i = 1; i <= n; i++) {         cin >> a[i];       }       for (int i = 1; i <= n; i += 2) {         cout << a[n - i + 1] * -1 <<     << a[n - i] <<    ;       }       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long k, a, b;     cin >> k >> a >> b;     if (k == 1) {       cout << a + b << endl;       return 0;     }     long long ret = (a / k) + (b / k);     long long la = a % k, lb = b % k;     if ((la / (k - 1) + (la % (k - 1) > 0)) <= b / k &&         (lb / (k - 1) + (lb % (k - 1) > 0)) <= a / k)       cout << ret << endl;     else       cout << -1 << endl;   }
#include <bits/stdc++.h>   using namespace std;   int N;   vector<string> a;   vector<int> big;   vector<int> mark;   string s;   string t;   int main() {     cin >> N;     string s1;     for (int i = 0; i < N; i++) {       cin >> s1;       a.push_back(s1);     }     cin >> s;     cin >> t;     for (int i = 0; i < s.size(); i++) {       string s1 = s.substr(i, 1);       if (s1[0] <=  Z ) {         big.push_back(1);       } else {         big.push_back(0);       }     }     for (int i = 0; i < s.length(); i++) mark.push_back(0);     transform(s.begin(), s.end(), s.begin(), ::tolower);     for (int i = 0; i < N; i++)       transform(a[i].begin(), a[i].end(), a[i].begin(), ::tolower);     for (int i = 0; i < N; i++) {       int start = 0;       while (s.substr(start).find(a[i]) != -1) {         start += s.substr(start).find(a[i]) + 1;         for (int j = start - 1; j <= start + a[i].length() - 2; j++) mark[j] = 1;       }     }     string answ;     for (int i = 0; i < s.length(); i++) {       if (mark[i] == 0)         answ.append(s.substr(i, 1));       else {         if (s.substr(i, 1) == t) {           if (t ==  a )             answ.append( b );           else             answ.append( a );         } else {           answ.append(t);         }       }     }     for (int i = 0; i < answ.length(); i++) {       if (big[i]) {         string s1 = answ.substr(i, 1);         transform(s1.begin(), s1.end(), s1.begin(), ::toupper);         string s2 = answ.substr(0, i);         s2.append(s1);         if (i + 1 < answ.length()) s2.append(answ.substr(i + 1));         answ = s2;       }     }     cout << answ << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct w {     int c, mi;   } tr[1010 * 1010 * 8];   struct ww {     int h, b, l, r, x, y;   } c[1010 * 1010];   int i, j, k, n, m, s, vx, vy, t, ans;   int a[1010][1010], b[1010][1010];   double d[1010 * 1010];   long long an;   inline bool cc1(const ww &a, const ww &b) { return a.b > b.b; }   inline void update(int x) { tr[x].mi = min(tr[x * 2].mi, tr[x * 2 + 1].mi); }   inline void Cover(int x, int y) {     tr[x].c = max(tr[x].c, y);     tr[x].mi = max(tr[x].mi, y);   }   inline void renew(int x) {     if (tr[x].c) Cover(x * 2, tr[x].c), Cover(x * 2 + 1, tr[x].c);     tr[x].c = 0;   }   void cover(int q, int x, int y, int l, int r, int h) {     if (l <= x && y <= r) {       Cover(q, h);       return;     }     renew(q);     int mid = (x + y) / 2;     if (l <= mid) cover(q * 2, x, mid, l, r, h);     if (mid < r) cover(q * 2 + 1, mid + 1, y, l, r, h);     update(q);   }   void cal(int q, int x, int y, int l, int r) {     if (l <= x && y <= r) {       ans = min(ans, tr[q].mi);       return;     }     renew(q);     int mid = (x + y) / 2;     if (l <= mid) cal(q * 2, x, mid, l, r);     if (mid < r) cal(q * 2 + 1, mid + 1, y, l, r);   }   int main() {     scanf( %d%d%d , &n, &vx, &vy);     for (i = 1; i <= n; i++)       for (j = 1; j <= n; j++) scanf( %d , &a[i][j]);     vx = -vx, vy = -vy;     if (vx < 0) {       vx = -vx;       for (j = 1; j <= n; j++)         for (i = 1; i <= n / 2; i++) swap(a[i][j], a[n - i + 1][j]);     }     if (vy < 0) {       vy = -vy;       for (i = 1; i <= n; i++)         for (j = 1; j <= n / 2; j++) swap(a[i][j], a[i][n - j + 1]);     }     if (!vx) {       swap(vx, vy);       for (i = 1; i <= n; i++)         for (j = 1; j <= n; j++) b[i][j] = a[i][j];       for (i = 1; i <= n; i++)         for (j = 1; j <= n; j++) a[j][n - i + 1] = b[i][j];     }     sort(d + 1, d + t + 1);     for (i = 1; i <= t; i++)       if (!m || d[m] < d[i]) d[++m] = d[i];     double ay = 1. * vy / vx;     for (i = 0; i <= n; i++)       for (j = 0; j <= n; j++) d[++m] = j - i * ay;     sort(d + 1, d + m + 1);     for (i = 1; i <= m; i++)       if (!t || d[t] + (1e-9) < d[i]) d[++t] = d[i];     for (i = 1; i <= n; i++)       for (j = 0; j <= n - 1; j++) {         int l = lower_bound(d + 1, d + t + 1, j - i * ay - (1e-9)) - d;         int r = lower_bound(d + 1, d + t + 1, j + 1 - (i - 1) * ay - (1e-9)) - d;         c[++s] = (ww){a[i][j + 1], i + j, l * 2, r * 2};       }     m = t * 2;     sort(c + 1, c + s + 1, cc1);     for (i = 1; i <= s; i++) {       ans = 2000000000;       cal(1, 1, m, c[i].l, c[i].r);       if (ans < c[i].h) an += c[i].h - ans;       cover(1, 1, m, c[i].l, c[i].r, c[i].h);     }     printf( %I64d n , an);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long arr[1000007];   long long cs[1000007];   long long ps[1000007];   int main() {     int t;     cin >> t;     while (t--) {       int n;       cin >> n;       for (int i = 1; i <= n; i++) cin >> arr[i];       for (int i = 1; i <= n; i++) {         if (i % 2) {           if (arr[i] > 0)             cout << -1 * arr[i] <<    ;           else             cout << arr[i] <<    ;         } else {           if (arr[i] < 0)             cout << -1 * arr[i] <<    ;           else             cout << arr[i] <<    ;         }       }       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   double const PI = 4 * atan(1.0);   using namespace std;   int main() {     long long a, b, x1, y1, x2, y2;     scanf( %I64d %I64d %I64d %I64d %I64d %I64d , &a, &b, &x1, &y1, &x2, &y2);     a = 2 * a;     b = 2 * b;     long long t1 = (x1 + y1);     long long t2 = (x2 + y2);     long long g1 = (x1 - y1);     long long g2 = (x2 - y2);     if (t1 < 0)       t1 = t1 / a - 1;     else       t1 = t1 / a;     if (t2 < 0)       t2 = t2 / a - 1;     else       t2 = t2 / a;     if (g1 < 0)       g1 = g1 / b - 1;     else       g1 = g1 / b;     if (g2 < 0)       g2 = g2 / b - 1;     else       g2 = g2 / b;     printf( %I64d , max(abs(t1 - t2), abs(g1 - g2)));   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long int n, c;     cin >> n >> c;     long int ar[n], i, sum = 0;     for (i = 0; i < n; ++i) {       cin >> ar[i];       if (i != 0) {         if ((ar[i] - ar[i - 1]) > c)           sum = 0;         else           sum++;       }     }     cout << sum + 1;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5;   const long long mol = 1e9 + 7;   int fa[maxn + 11], siz[maxn + 11], x[maxn + 11], y[maxn + 11];   bool cir[maxn + 11];   vector<int> row, cul;   int get(int x) { return x == fa[x] ? x : fa[x] = get(fa[x]); }   void merge(int x, int y) {     int fax = get(x);     int fay = get(y);     if (fax == fay) {       cir[fax] = true;       return;     }     fa[fay] = fax;     cir[fax] |= cir[fay];     siz[fax] += siz[fay];   }   long long qpow(long long a, long long b) {     long long ans = 1;     while (b) {       if (b & 1) ans = ans * a % mol;       a = a * a % mol;       b >>= 1;     }     return ans;   }   long long sub(long long a, long long b) {     a -= b;     if (a < 0) a += mol;     return a;   }   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) {       scanf( %d %d , &x[i], &y[i]);       row.emplace_back(x[i]);       cul.emplace_back(y[i]);     }     sort((row).begin(), (row).end());     row.erase(unique((row).begin(), (row).end()), row.end());     sort((cul).begin(), (cul).end());     cul.erase(unique((cul).begin(), (cul).end()), cul.end());     int m = row.size() + cul.size();     for (int i = 1; i <= m; i++) fa[i] = i, siz[i] = 1, cir[i] = false;     for (int i = 1; i <= n; i++) {       x[i] = lower_bound((row).begin(), (row).end(), x[i]) - row.begin() + 1;       y[i] = lower_bound((cul).begin(), (cul).end(), y[i]) - cul.begin() +              row.size() + 1;       merge(x[i], y[i]);     }     long long ans = 1;     for (int i = 1; i <= m; i++)       if (get(i) == i) {         int p = siz[i];         long long t = qpow(2, p);         if (!cir[i]) t = sub(t, 1);         ans = ans * t % mol;       }     printf( %lld n , ans);   }