malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   long long a, b, c, n, m, k = 0, T, maxx = -0x3f3f3f3f;   int main() {     scanf( %lld , &T);     while (T--) {       scanf( %lld%lld , &n, &k);       long long t = 0, tmp = 0;       if (n == 2 && k == 3) {         cout <<  No  << endl;         continue;       }       while (t < k) {         t = t * 4 + 1;         if (t > k) break;         tmp++;       }       if (tmp > n || (tmp == n && k != t))         cout <<  NO n ;       else {         if (t > k) t = (t - 1) / 4;         cout <<  YES  ;         long long s = ((1ll) << tmp);         tmp = n - tmp;         t = k - t;         if (t >= 2 * s - 1)           cout << tmp - 1 << endl;         else           cout << tmp << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   map<vector<long long>, long long> mp;   int main() {     long long n;     cin >> n;     long long a[] = {2, 3, 5, 7};     vector<long long> t;     for (long long mask = 1; mask < (1 << 4); mask++) {       t.clear();       for (long long j = 0; j < 4; j++) {         if (mask & (1 << j)) t.push_back(a[j]);       }       sort(t.begin(), t.end());       long long y = 1;       for (auto v : t) y *= v;       mp[t] += n / y;     }     for (auto x : mp) {       if (x.first.size() % 2) {         n -= x.second;         continue;       }       n += x.second;     }     cout << n << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 2005;   const int dx[10] = {0, 0, 0, 1, -1, 1, 1, -1, -1};   const int dy[10] = {0, 1, -1, 0, 0, -1, 1, -1, 1};   int n, area, sx, sy;   bool p[maxN][maxN], vis[maxN][maxN];   void init() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= n; ++j) scanf( %d , &p[i][j]);   }   void fixNoise() {     int cnt;     for (int tme = 1; tme <= 5; ++tme)       for (int i = 1; i <= n; ++i)         for (int j = 1; j <= n; ++j) {           cnt = 0;           for (int k = 0; k <= 8; ++k) cnt += p[i + dx[k]][j + dy[k]];           if (cnt < 5)             p[i][j] = 0;           else             p[i][j] = 1;         }   }   void dfs(int x, int y) {     int xx, yy;     vis[x][y] = 1;     ++area;     sx += x;     sy += y;     for (int i = 1; i <= 4; ++i) {       xx = x + dx[i];       yy = y + dy[i];       if (xx < 1 || yy < 1 || xx > n || yy > n || !p[xx][yy] || vis[xx][yy])         continue;       dfs(xx, yy);     }   }   void work() {     double ox, oy, r;     int circle = 0, rectangle = 0;     fixNoise();     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= n; ++j)         if (p[i][j] && !vis[i][j]) {           area = 0;           sx = 0;           sy = 0;           dfs(i, j);           if (area >= 158) {             ox = double(sx) / area;             oy = double(sy) / area;             r = ((i - ox) * (i - ox)) + ((j - oy) * (j - oy));             if (area / r > 2.9)               ++circle;             else               ++rectangle;           }         }     printf( %d %d n , circle, rectangle);   }   int main() {     init();     work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, m;     cin >> n >> m;     int floor[n][2 * m];     for (int i = 0; i < n; i++) {       for (int j = 0; j < 2 * m; j++) {         cin >> floor[i][j];       }     }     int count = 0;     for (int i = 0; i < n; i++) {       for (int j = 0; j < 2 * m - 1; j += 2) {         if (floor[i][j] == 1 || floor[i][j + 1] == 1) {           count++;         }       }     }     cout << count <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   void solve() {     int n;     cin >> n;     map<int, int> mx, my;     map<pair<int, int>, int> mp;     for (int i = 0; i < n; i++) {       int first, second;       cin >> first >> second;       mx[first]++;       my[second]++;       mp[{first, second}]++;     };     long long ans = 0;     for (auto it : mx) {       ans += (long long)it.second * (it.second - 1) / 2;     }     for (auto it : my) {       ans += (long long)it.second * (it.second - 1) / 2;     }     for (auto it : mp) {       ans -= (long long)it.second * (it.second - 1) / 2;     }     cout << ans <<   n ;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int up[200005];   int down[200005];   vector<int> answer;   bool done = true;   ;   int main() {     int n;     cin >> n;     for (int i = 1; i < n; i++) {       cin >> up[i];     }     for (int i = 1; i < n; i++) {       cin >> down[i];     }     answer.push_back(0);     int previous = 0;     for (int i = 1; i < n; i++) {       if (!done) {         break;       }       done = false;       for (int j = 0; j < 4; j++) {         int x = previous & j;         int z = previous | j;         if ((x == down[i]) && (z == up[i])) {           previous = j;           done = true;           answer.push_back(previous);           break;         }       }     }     if (done) {       cout <<  YES  << endl;       for (int i = 0; i < answer.size(); i++) {         cout << answer[i] <<    ;       }     } else {       answer.clear();       previous = 1;       answer.push_back(1);       done = true;       for (int i = 1; i < n; i++) {         if (!done) {           break;         }         done = false;         for (int j = 0; j < 4; j++) {           int x = previous & j;           int z = previous | j;           if ((x == down[i]) && (z == up[i])) {             previous = j;             done = true;             answer.push_back(previous);             break;           }         }       }       if (done) {         cout <<  YES  << endl;         for (int i = 0; i < answer.size(); i++) {           cout << answer[i] <<    ;         }       } else {         answer.clear();         previous = 2;         answer.push_back(2);         done = true;         for (int i = 1; i < n; i++) {           if (!done) {             break;           }           done = false;           for (int j = 0; j < 4; j++) {             int x = previous & j;             int z = previous | j;             if ((x == down[i]) && (z == up[i])) {               previous = j;               done = true;               answer.push_back(previous);               break;             }           }         }         if (done) {           cout <<  YES  << endl;           for (int i = 0; i < answer.size(); i++) {             cout << answer[i] <<    ;           }         } else {           answer.clear();           previous = 3;           answer.push_back(3);           done = true;           for (int i = 1; i < n; i++) {             if (!done) {               break;             }             done = false;             for (int j = 0; j < 4; j++) {               int x = previous & j;               int z = previous | j;               if ((x == down[i]) && (z == up[i])) {                 previous = j;                 done = true;                 answer.push_back(previous);                 break;               }             }           }           if (done) {             cout <<  YES  << endl;             for (int i = 0; i < answer.size(); i++) {               cout << answer[i] <<    ;             }           } else {             cout <<  NO  << endl;           }         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int modexpo(long long int x, long long int y) {     if (y == 0) return 1;     if (y % 2) {       long long int viky = modexpo(x, y / 2);       return (((x * viky) % 1000000000) * viky) % 1000000000;     } else {       long long int viky = modexpo(x, y / 2);       return (viky * viky) % 1000000000;     }   }   long long int a[1111];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int t, i, j, l, m, n, r, q, k, c, x;     cin >> n;     for (i = 1; i < n; i++) {       cin >> l >> r;       a[r]++;       a[l]++;     }     c = 0;     for (i = 1; i <= n; i++) {       if (a[i] == 1) c++;     }     cout << c;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int ax, ay, bx, by, cx, cy;   double k1, k2, k3;   int main() {     long long int dis_ab, dis_ac, dis_bc, max_dis = -1;     cin >> ax >> ay >> bx >> by >> cx >> cy;     dis_ab = (ax - bx) * (ax - bx) + (ay - by) * (ay - by);     k1 = (double)(ax - bx) / (ay - by);     dis_ac = (ax - cx) * (ax - cx) + (ay - cy) * (ay - cy);     k2 = (double)(ax - cx) / (ay - cy);     dis_bc = (bx - cx) * (bx - cx) + (by - cy) * (by - cy);     k3 = (double)(bx - cx) / (by - cy);     if (k1 == k2 && k2 == k3)       cout <<  No ;     else {       if (dis_ab == dis_bc)         cout <<  Yes ;       else         cout <<  No ;     }     return 0;   }
#include <bits/stdc++.h>   int main() {     int n;     std::scanf( %d , &n);     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j) {         std::printf( %d  , j * n + (j % 2 == 0 ? i : n - i - 1) + 1);       }       std::printf(  n );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int INF = 1000000001;   const double EPS = 10e-9;   const int MAXN = 100005;   pair<int, int> t[MAXN << 1];   int MOD;   void rob() {     int n;     scanf( %d , &n);     int tmp;     for (typeof(0) i = (0); i < (n); ++i) {       scanf( %d , &tmp);       t[i] = make_pair(tmp, i);     }     for (typeof(0) i = (0); i < (n); ++i) {       scanf( %d , &tmp);       t[n + i] = make_pair(tmp, i);     }     scanf( %d , &MOD);     n <<= 1;     sort(t, t + n);     long long res = 1;     int i = 0;     int pow;     int fac;     while (i < n) {       fac = 1;       pow = 0;       for (++i; i < n; ++i) {         if (t[i].first != t[i - 1].first) break;         if (t[i].second == t[i - 1].second) ++pow;         ++fac;       }       for (typeof(1) j = (1); j <= (fac); ++j) {         if (pow && !(j & 1)) {           res = (res * (j >> 1)) % MOD;           --pow;         } else {           res = (res * j) % MOD;         }       }     }     printf( %I64d n , res);   }   int main() {     int test = 1;     while (test--) rob();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e5 + 10;   int arr[MAX];   int n;   int query(int x, int y, int z) {     cout <<  ?   << x <<     << y <<     << z << endl;     int a;     cin >> a;     return a;   }   array<int, 3> col[2];   int ans[MAX];   vector<int> v;   int main() {     int t;     cin >> t;     while (t--) {       v.clear();       col[0] = col[1] = {-1, -1, -1};       cin >> n;       for (int i = 1; i <= n; i += 3) {         arr[i] = query(i, i + 1, i + 2);         col[arr[i]] = {i, i + 1, i + 2};       }       int x = -1, y = -1;       for (int i = 0; i < 3; ++i) {         if (query(col[0][0], col[0][1], col[1][i])) {           y = col[1][i];           break;         }       }       if (y == -1) {         x = col[0][0];         if (query(col[1][0], col[1][1], x))           y = col[1][0];         else if (query(col[1][0], col[1][2], x))           y = col[1][0];         else           y = col[1][1];       } else         x = col[0][2];       ans[x] = 0, ans[y] = 1;       for (int i = 1; i <= n; i += 3) {         if (i == col[arr[i]][0]) {           for (int j = i; j <= i + 2; ++j) {             if (j == x || j == y) continue;             ans[j] = query(x, y, j);           }           continue;         }         int c = x;         if (!arr[i]) c = y;         int a = query(i, i + 1, c);         int b = query(i, i + 2, c);         int idx = -1;         if (a != arr[i] && b != arr[i])           idx = i;         else if (a != arr[i])           idx = i + 1;         else if (b != arr[i])           idx = i + 2;         for (int j = i; j <= i + 2; ++j) {           if (idx == j)             ans[j] = !arr[i];           else             ans[j] = arr[i];         }       }       for (int i = 1; i <= n; ++i) {         if (!ans[i]) v.push_back(i);       }       cout <<  !   << v.size() <<    ;       for (auto &i : v) cout << i <<    ;       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1010;   struct node {     double x;     double y;     double t;     double p;     bool operator<(const node& W) const { return t < W.t; }   } q[N];   double dp[N];   bool check(node a, node b) {     double dx = a.x - b.x;     double dy = a.y - b.y;     return sqrt(dx * dx + dy * dy) <= b.t - a.t;   }   int main() {     int n;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> q[i].x >> q[i].y >> q[i].t >> q[i].p;     }     sort(q + 1, q + n + 1);     dp[1] = q[1].p;     for (int i = 2; i <= n; i++) {       dp[i] = q[i].p;       for (int j = 1; j <= i - 1; j++)         if (check(q[j], q[i])) dp[i] = max(dp[i], dp[j] + q[i].p);     }     double res = 0;     for (int i = 1; i <= n; i++) res = max(res, dp[i]);     printf( %.6lf n , res);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k;   int x[505], y[505];   int x_koord[1005], y_koord[1005], kk, kkx, kky;   int z[1055][1055];   bool popuni(int sz) {     kk = 0;     for (int i = 1; i <= k; i++) {       int xl = x[i] - sz;       if (xl < 1) {         xl = 1;       }       int xr = x[i] + sz + 1;       if (xr > n + 1) {         xr = n + 1;       }       int yl = y[i] - sz;       if (yl < 1) {         yl = 1;       }       int yr = y[i] + sz + 1;       if (yr > m + 1) {         yr = m + 1;       }       kk++;       x_koord[kk] = xl;       y_koord[kk] = yl;       kk++;       x_koord[kk] = xr;       y_koord[kk] = yr;     }     kk++;     x_koord[kk] = 1;     y_koord[kk] = 1;     kk++;     x_koord[kk] = n + 1;     y_koord[kk] = m + 1;     sort(x_koord + 1, x_koord + kk + 1);     kkx = unique(x_koord + 1, x_koord + kk + 1) - x_koord - 1;     sort(y_koord + 1, y_koord + kk + 1);     kky = unique(y_koord + 1, y_koord + kk + 1) - y_koord - 1;     memset(z, 0, sizeof(z));     for (int i = 1; i <= k; i++) {       int xl = x[i] - sz;       if (xl < 1) {         xl = 1;       }       int xr = x[i] + sz + 1;       if (xr > n + 1) {         xr = n + 1;       }       int yl = y[i] - sz;       if (yl < 1) {         yl = 1;       }       int yr = y[i] + sz + 1;       if (yr > m + 1) {         yr = m + 1;       }       xl = lower_bound(x_koord + 1, x_koord + kkx + 1, xl) - x_koord;       xr = lower_bound(x_koord + 1, x_koord + kkx + 1, xr) - x_koord;       yl = lower_bound(y_koord + 1, y_koord + kky + 1, yl) - y_koord;       yr = lower_bound(y_koord + 1, y_koord + kky + 1, yr) - y_koord;       z[xl][yl]++;       z[xl][yr]--;       z[xr][yl]--;       z[xr][yr]++;     }     int loy = 2e9, hiy = -2e9, lox = 2e9, hix = -2e9;     int any = 0;     for (int i = 1; i < kkx; i++) {       for (int j = 1; j < kky; j++) {         z[i][j] += z[i - 1][j] + z[i][j - 1] - z[i - 1][j - 1];         if (z[i][j] == 0) {           any = 1;           lox = min(lox, x_koord[i]);           hix = max(hix, x_koord[i + 1]);           loy = min(loy, y_koord[j]);           hiy = max(hiy, y_koord[j + 1]);         }       }     }     if (!any) {       return true;     }     cerr << sz <<     << lox <<     << hix <<     << loy <<     << hiy <<   n ;     return max(hiy - loy, hix - lox) / 2 <= sz;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     cerr.tie(nullptr);     cin >> n >> m >> k;     for (int i = 1; i <= k; i++) {       cin >> x[i] >> y[i];     }     int l = 0, r = 1e9, o = 1e9;     while (l <= r) {       int m = (l + r) / 2;       if (popuni(m)) {         o = m;         r = m - 1;       } else {         l = m + 1;       }     }     cout << o;   }
#include <bits/stdc++.h>   using namespace std;   char s[1000010];   int n, p[1000010];   int main() {     scanf( %s , s), n = strlen(s);     for (int i = 0; i < n; i++)       if (s[i] ==  1 ) p[n - 1 - i] = 1;     for (int i = 0, j; i < n + 2;)       if (!p[i])         i++;       else {         j = i;         while (p[j]) j++;         if (j - i >= 2) {           p[i] = -1;           for (int k = i + 1; k < j; k++) p[k] = 0;           p[j] = 1;         }         i = j;       }     int S = 0;     for (int i = 0; i < n + 2; i++)       if (p[i] != 0) S++;     printf( %d n , S);     for (int i = 0; i < n + 2; i++)       if (p[i] != 0)         if (p[i] > 0)           printf( +2^%d n , i);         else           printf( -2^%d n , i);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int i, j, k;     int n;     cin >> n;     int x = n / 4;     string s =  abcd ;     string ans =   ;     if (n % 4 == 0)       for (i = 0; i < x; i++) ans += s;     else {       if (n % 4 == 1) {         for (i = 0; i < x; i++) ans += s;         ans +=  a ;       }       if (n % 4 == 2) {         for (i = 0; i < x; i++) ans += s;         ans +=  ab ;       }       if (n % 4 == 3) {         for (i = 0; i < x; i++) ans += s;         ans +=  abc ;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void debug_out() { cerr << endl; }   template <typename Head, typename... Tail>   void debug_out(Head H, Tail... T) {     cerr <<     << H;     debug_out(T...);   }   const int INF = 1e9;   const long long MOD = 1e9 + 7;   const int N = 1e5 + 5, MO = 350, SQ = 650;   int n, q, A[N], QL[N], QR[N], P[N], T[N], C[N], K[N], Q[N];   vector<int> B, X, Y;   bool CMP(int i, int j) {     if (QL[i] / MO != QL[j] / MO) return QL[i] < QL[j];     return (QL[i] / MO) % 2 ? QR[i] > QR[j] : QR[i] < QR[j];   }   void Update(int x, int y) { T[C[x]]--, C[x] += y, T[C[x]]++; }   void Insert(int x, int y) {     if (x >= SQ && !K[x]) Y.push_back(x);     K[x] += y;   }   int Huf() {     X.clear(), Y.clear();     for (int i : B)       if (C[i] >= SQ) X.push_back(C[i]), K[C[i]]++;     sort(X.begin(), X.end());     int huf = 0, c = 0, x = 0, y = 0;     for (int i = 1; i < SQ; i++)       if (K[i] + T[i]) {         K[i] += T[i];         if (c) huf += i + c, K[i]--, Insert(i + c, 1), c = 0;         if (K[i] & 1) c = i, K[i]--;         if (K[i]) huf += i * K[i], Insert(i + i, K[i] >> 1), K[i] = 0;       }     while (x < (int)(X.size()) || y < (int)(Y.size())) {       while (x + 1 < (int)(X.size()) && X[x + 1] == X[x]) x++;       while (y + 1 < (int)(Y.size()) && Y[y + 1] == Y[y]) y++;       int i = 0;       if (x == (int)(X.size()))         i = Y[y++];       else if (y == (int)(Y.size()))         i = X[x++];       else if (X[x] < Y[y])         i = X[x++];       else         i = Y[y++];       if (c) huf += i + c, K[i]--, Insert(i + c, 1), c = 0;       if (K[i] & 1) c = i, K[i]--;       if (K[i]) huf += i * K[i], Insert(i + i, K[i] >> 1), K[i] = 0;     }     return huf;   }   int main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     mt19937 Rnd(time(0));     cin >> n;     for (int i = 0; i < n; i++) cin >> A[i], C[A[i]]++;     for (int i = 0; i < N; i++)       if (C[i] >= SQ) B.push_back(i);     for (int i = 0; i < n; i++) C[A[i]]--;     cin >> q;     for (int i = 0; i < q; i++) cin >> QL[i] >> QR[i], QL[i]--, P[i] = i;     sort(P, P + q, CMP);     int L = 0, R = 0;     for (int i = 0; i < q; i++) {       int l = QL[P[i]], r = QR[P[i]];       while (l < L) Update(A[--L], +1);       while (R < r) Update(A[R++], +1);       while (L < l) Update(A[L++], -1);       while (r < R) Update(A[--R], -1);       Q[P[i]] = Huf();     }     for (int i = 0; i < q; i++) cout << Q[i] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     long long t, n, i, j, flag = 0, temp, nodes, a, b, m, k, sz, sm, res;     long long mn, mx;     long long l, r;     long long x, y, z;     long long c, d;     t = 1;     vector<pair<int, int>> v;     string s;     char ch;     while (t--) {       flag = 0;       v.clear();       cin >> n;       int A = INT_MAX, B = INT_MIN;       for (i = 0; i < n; i++) {         cin >> a >> b;         v.push_back({a, b});         if (a < A) A = a;         if (B < b) B = b;       }       for (i = 0; i < v.size(); i++) {         if (v[i].first == A && v[i].second == B) {           flag = 1;           break;         }       }       if (flag == 1) {         cout << i + 1 << endl;         continue;       } else {         cout <<  -1 ;         continue;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   char a[N], b[N];   int s[N][26];   void init() {     int n = strlen(a + 1);     memset(s, 0, sizeof(s));     for (int i = n; i >= 1; i--) {       for (int j = 0; j < 26; j++) {         s[i - 1][j] = s[i][j];       }       s[i - 1][a[i] -  a ] = i;     }   }   int main() {     int T;     cin >> T;     while (T--) {       scanf( %s %s , a + 1, b + 1);       init();       int flg = 0;       int p = 0;       int ans = 1;       for (int i = 1; i <= strlen(b + 1); i++) {         int t = b[i] -  a ;         int tt = s[p][t];         if (tt == 0 && p == 0) {           flg = 1;           break;         }         if (tt == 0) {           i--;           ans++;           p = 0;         } else {           p = tt;         }       }       if (flg == 1) {         printf( -1 n );         continue;       }       printf( %d n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long int N = 500009;   const long long int mod = 1000000007;   long long int n, k;   string s;   string see;   vector<long long int> v;   void pre() {     see = s;     for (auto i : s) see += i;     for (auto i : s) see += i;   }   int32_t main() {     cin >> n >> k >> s;     pre();     for (long long int i = 0; i < 3 * n;) {       long long int j = i;       long long int pahla = i;       long long int doosra = i - 1;       long long int idharhi = 0;       while (doosra < (3 * n - 1)) {         if (see[i] == see[doosra + 1])           doosra++;         else           break;       }       if (doosra == pahla) {         i++;         continue;       }       for (long long int k = i; k <= doosra; k++) {         v.push_back(k);       }       i = doosra + 1;     }     if (v.size() == 0) {       if (k % 2 == 0) {         cout << s <<   n ;         return 0;       } else {         for (auto i : s) {           if (i ==  W )             cout <<  B ;           else             cout <<  W ;         }         cout <<   n ;         return 0;       }     }     string ans =   ;     for (long long int i = n; i < 2 * n; i++) {       auto it = lower_bound(v.begin(), v.end(), i);       long long int is = it - v.begin();       if (v[is] == i) {         ans += see[i];         continue;       }       is--;       long long int dis1 = i - v[is];       is++;       long long int dis2 = v[is] - i;       assert(dis1 > 0 and dis2 > 0);       if (dis1 > k && dis2 > k) {         if (k % 2 == 0) {           ans += see[i];         } else {           if (see[i] ==  W )             ans +=  B ;           else             ans +=  W ;         }         continue;       } else if (dis1 <= k && dis1 < dis2) {         ans += see[v[is - 1]];       } else if (dis2 <= k && dis2 < dis1) {         ans += see[v[is]];       } else {         ans += see[v[is]];       }     }     assert((long long int)ans.length() == n);     cout << ans <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int nod(int a, int b) {     int c;     if (a > b) swap(a, b);     for (;;) {       c = b % a;       b = a;       a = c;       if (a == 0) return b;     }   }   int main() {     int x, y, a, b;     cin >> x >> y >> a >> b;     int d = x * y / nod(x, y);     int c = b / d - (a - 1) / d;     if (c < 0) c = 0;     cout << c;     return 0;   }