malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   void DBG() { cerr <<  ] n ; }   template <typename T, typename... Args>   void DBG(T first, Args... args) {     cerr << first;     if (sizeof...(args)) cerr <<  ,  ;     DBG(args...);   }   void solve() {     long long int x0, y0, ax, ay, bx, by, sx, sy, t;     cin >> x0 >> y0 >> ax >> ay >> bx >> by >> sx >> sy >> t;     vector<long long int> px, py;     px.push_back(x0);     py.push_back(y0);     while (true) {       long long bound = 0;       if (px.back() > sx) {         bound += px.back() - sx;       }       if (py.back() > sy) {         bound += py.back() - sy;       }       if (bound > t) {         px.pop_back();         py.pop_back();         break;       }       px.push_back(px.back() * ax + bx);       py.push_back(py.back() * ay + by);     }     long long int n = px.size();     long long int g = 0;     for (long long int i = 0; i < n; i++) {       for (long long int j = i; j < n; j++) {         long long int from_i = abs(sx - px[i]) + abs(sy - py[i]);         long long int from_j = abs(sx - px[j]) + abs(sy - py[j]);         long long int cnt =             min(from_i, from_j) + abs(px[i] - px[j]) + abs(py[i] - py[j]);         if (cnt <= t) {           g = max(g, j - i + 1);         }       }     }     cout << g <<   n ;   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     long long int t = 1;     for (long long int tt = 1; tt <= t; tt++) {       solve();     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 1000000 + 100;   int n, root, u, Sum;   int num[maxn], sum[maxn];   vector<int> G[maxn];   int ans1, ans2;   void dfs1(int x) {     sum[x] = num[x];     int len = G[x].size();     for (int i = 0; i < len; ++i) {       int pos = G[x][i];       dfs1(pos);       if (ans1 != 0) {         return;       }       sum[x] += sum[pos];     }     if (sum[x] == Sum / 3) {       ans1 = x;     }   }   void dfs2(int x) {     num[x] = 0;     int len = G[x].size();     for (int i = 0; i < len; ++i) {       int pos = G[x][i];       dfs2(pos);     }   }   void dfs3(int x) {     sum[x] = num[x];     int len = G[x].size();     for (int i = 0; i < len; ++i) {       int pos = G[x][i];       if (pos != ans1) {         dfs3(pos);         if (ans2 != 0) {           return;         }         sum[x] += sum[pos];       }     }     if (sum[x] == Sum / 3) {       ans2 = x;     }   }   int main() {     ios::sync_with_stdio(false);     while (scanf( %d , &n) != EOF) {       for (int i = 1; i <= n; ++i) {         G[i].clear();       }       Sum = 0;       ans1 = ans2 = 0;       for (int i = 1; i <= n; ++i) {         scanf( %d%d , &u, &num[i]);         Sum += num[i];         if (u != 0) {           G[u].push_back(i);         } else {           root = i;         }       }       if (Sum % 3 != 0) {         printf( -1 n );         continue;       }       dfs1(root);       if (ans1 == 0 || ans1 == root) {         printf( -1 n );         continue;       }       dfs2(ans1);       dfs3(root);       if (ans2 == 0 || ans2 == root) {         printf( -1 n );       } else {         printf( %d %d n , ans1, ans2);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a, n, m, mis, cri;   int main() {     cin >> a;     for (int i = 0; i < a; i++) {       cin >> n >> m;       if (n > m) {         mis++;       } else if (n < m) {         cri++;       }     }     if (mis > cri) {       cout <<  Mishka ;     } else if (cri > mis) {       cout <<  Chris ;     } else {       cout <<  Friendship is magic!^^ ;     }   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   using ii = pair<int, int>;   using vi = vector<int>;   using vb = vector<bool>;   using vvi = vector<vi>;   using vii = vector<ii>;   using vvii = vector<vii>;   const int INF = 2000000000;   const ll LLINF = 9000000000000000000;   struct T {     ld mat[2][2];     ld dx = 0, dy = 0;     T() {       for (int i = 0; i < 2; ++i)         for (int j = 0; j < 2; ++j) mat[i][j] = i == j;     }     T(const T &o) {       for (int i = 0; i < 2; ++i)         for (int j = 0; j < 2; ++j) mat[i][j] = o.mat[i][j];       dx = o.dx;       dy = o.dy;     }   };   T op(T l, T r) {     T m;     m.mat[0][0] = l.mat[0][0] * r.mat[0][0] + l.mat[0][1] * r.mat[1][0];     m.mat[0][1] = l.mat[0][0] * r.mat[0][1] + l.mat[0][1] * r.mat[1][1];     m.mat[1][0] = l.mat[1][0] * r.mat[0][0] + l.mat[1][1] * r.mat[1][0];     m.mat[1][1] = l.mat[1][0] * r.mat[0][1] + l.mat[1][1] * r.mat[1][1];     m.dx = l.mat[0][0] * r.dx + l.mat[0][1] * r.dy + l.dx;     m.dy = l.mat[1][0] * r.dx + l.mat[1][1] * r.dy + l.dy;     return m;   }   T ident;   struct SegmentTree {     struct Node {       T val;       int l, r;       Node(T _val, int _l, int _r) : val(_val), l(_l), r(_r){};     };     int n;     vector<Node> tree;     SegmentTree(int p, vector<T> &init) : n(1 << p) {       tree.assign(2 * n, Node(ident, 0, n - 1));       for (int j = 1; j < n; ++j) {         int m = (tree[j].l + tree[j].r) / 2;         tree[2 * j].l = tree[j].l;         tree[2 * j].r = m;         tree[2 * j + 1].l = m + 1;         tree[2 * j + 1].r = tree[j].r;       }       for (int j = 2 * n - 1; j > 0; --j) {         if (j >= n)           tree[j].val = init[j - n];         else           tree[j].val = op(tree[2 * j].val, tree[2 * j + 1].val);       }     }     void update(int i, T val) {       for (tree[i + n].val = val, i = (i + n) / 2; i > 0; i /= 2)         tree[i].val = op(tree[2 * i].val, tree[2 * i + 1].val);     }     T query(int l, int r) {       T lhs, rhs;       for (l += n, r += n; l < r; l >>= 1, r >>= 1) {         if (l & 1) lhs = op(lhs, tree[l++].val);         if (!(r & 1)) rhs = op(tree[r--].val, rhs);       }       return op(l == r ? op(lhs, tree[l].val) : lhs, rhs);     }   };   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     int n, m;     cin >> n >> m;     int p = 1;     while ((1 << p) < 2 * n) ++p;     vector<T> init(1 << p, T());     for (int i = 0; i < n; ++i) {       init[2 * i + 1].dx = 1;     }     SegmentTree st(p, init);     vector<ld> curdeg(n, 0.0);     while (m--) {       int x, y, z;       cin >> x >> y >> z;       --y;       if (x == 1) {         T cur = st.query(2 * y + 1, 2 * y + 1);         cur.dx += z;         st.update(2 * y + 1, cur);       } else {         curdeg[y] -= ld(z) / 180.0 * 3.14159265358979323846;         T m;         m.mat[0][0] = m.mat[1][1] = cos(curdeg[y]);         m.mat[1][0] = sin(curdeg[y]);         m.mat[0][1] = -m.mat[1][0];         st.update(2 * y, m);       }       T f = st.query(0, 2 * n - 1);       printf( %.7lf %.7lf n , double(f.dx), double(f.dy));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long arr[166666][6];   multiset<long long> s[6];   signed main() {     long long n;     scanf( %lld , &n);     for (long long i = 1; i <= n; i++) {       for (long long j = 1; j <= 4; j++) {         scanf( %lld , &arr[i][j]);         s[j].insert(arr[i][j]);       }     }     for (long long i = 1; i <= n; i++) {       for (long long j = 1; j <= 4; j++) {         s[j].erase(s[j].find(arr[i][j]));       }       if (*s[1].rbegin() <= *s[3].begin() && *s[2].rbegin() <= *s[4].begin()) {         cout << *s[1].rbegin() <<     << *s[2].rbegin();         return 0;       }       for (long long j = 1; j <= 4; j++) {         s[j].insert(arr[i][j]);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     long long int k, a[26], i, max = -1, l, sum = 0;     cin >> s;     cin >> k;     l = s.length();     for (i = 0; i < 26; i++) {       cin >> a[i];       if (max < a[i]) max = a[i];     }     for (i = 0; i < l; i++) {       sum = sum + (i + 1) * a[s[i] -  a ];     }     for (i = 0; i < k; i++) {       sum += (i + l + 1) * max;     }     cout << sum;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long Set(long long N, long long pos) { return N = N | (1 << pos); }   long long reset(long long N, long long pos) { return N = N & ~(1 << pos); }   bool check(long long N, long long pos) { return (bool)(N & (1 << pos)); }   void CI(long long &_x) { scanf( %d , &_x); }   void CO(long long &_x) { cout << _x; }   template <typename T>   void getarray(T a[], long long n) {     for (long long i = 0; i < n; i++) cin >> a[i];   }   template <typename T>   void prLLIarray(T a[], long long n) {     for (long long i = 0; i < n - 1; i++) cout << a[i] <<    ;     cout << a[n - 1] << endl;   }   const double EPS = 1e-9;   const long long INF = 0x7f7f7f7f;   long long dr8[8] = {1, -1, 0, 0, 1, -1, -1, 1};   long long dc8[8] = {0, 0, -1, 1, 1, 1, -1, -1};   long long dr4[4] = {0, 0, 1, -1};   long long dc4[4] = {-1, 1, 0, 0};   long long kn8r[8] = {1, 2, 2, 1, -1, -2, -2, -1};   long long kn8c[8] = {2, 1, -1, -2, -2, -1, 1, 2};   int main() {     double a, b, m;     cin >> a >> b >> m;     double vx, vy, vz;     cin >> vx >> vy >> vz;     double tt = m / vy;     tt = fabs(tt);     double x = (a / 2.0) + (tt * vx);     double z = vz * tt;     while (x < 0) {       x += 2.0 * a;     }     while (x > (2 * a)) x -= (2.0 * a);     if (x > a) x = (2.0 * a) - x;     while (z < 0) z += (2.0 * b);     while (z > (2 * b)) z -= (2.0 * b);     if (z > b) z = (2.0 * b) - z;     cout << fixed << setprecision(9) << x <<     << z <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   int len(const T &c) {     return (int)c.size();   }   template <class T>   void cmin(T &a, T b) {     if (b < a) a = b;   }   template <class T>   void cmax(T &a, T b) {     if (b > a) a = b;   }   int n;   int main() {     cin >> n;     if (n == 3) {       cout << 5;       return 0;     }     int t;     for (int i = 1;; i += 2) {       t = i * i;       t++;       t /= 2;       if (t >= n) {         cout << i << endl;         return 0;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 200005;   vector<int> adj[N];   int sum[N];   void dfs1(int node) {     if (adj[node].size() == 0) sum[node] = 1;     for (int i = 0; i < adj[node].size(); i++) {       int a = adj[node][i];       dfs1(a);       sum[node] += sum[a];     }   }   int mx(int node);   int mn(int node);   int Mx(int node);   int Mn(int node);   int mx(int node) {     if (adj[node].size() == 0) return 1;     int ret = 1;     for (int i = 0; i < adj[node].size(); i++) {       int a = adj[node][i];       ret = max(ret, sum[node] - sum[a] + mn(a));     }     return ret;   }   int mn(int node) {     if (adj[node].size() == 0) return 1;     int ret = 0;     for (int i = 0; i < adj[node].size(); i++) {       int a = adj[node][i];       ret += mx(a) - 1;     }     return ret + 1;   }   int Mx(int node) {     if (adj[node].size() == 0) return 1;     int ret = 0;     for (int i = 0; i < adj[node].size(); i++) {       int a = adj[node][i];       ret += Mn(a);     }     return ret;   }   int Mn(int node) {     if (adj[node].size() == 0) return 1;     int ret = N;     for (int i = 0; i < adj[node].size(); i++) {       int a = adj[node][i];       ret = min(ret, Mx(a));     }     return ret;   }   int main() {     int n, a, b;     scanf( %d , &n);     for (int i = 0; i < n - 1; i++) {       scanf( %d%d , &a, &b);       adj[a].push_back(b);     }     dfs1(1);     cout << mx(1) <<     << Mx(1);     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops )   #pragma GCC optimize( no-stack-protector,fast-math )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   template <class S, class T>   inline S smax(S &l, T r) {     return l = max(l, (S)r);   }   template <class S, class T>   inline S smin(S &l, T r) {     return l = min(l, (S)r);   }   const int N = 1e6 + 10;   int nex[N][26], sz, cnt[N], lvl[N];   inline void In(string &s) {     int now = 0;     for (auto c : s) {       c -=  a ;       if (!nex[now][c]) {         nex[now][c] = ++sz;         lvl[sz] = lvl[now] + 1;       }       now = nex[now][c];     }     cnt[now]++;   }   vector<int> dp[N];   inline int f(int i) { return i * (i - 1) / 2; }   inline void merge(int v, int u) {     vector<int> tmp(dp[v].size() + dp[u].size() - 1);     for (int i = 0; i < (int)dp[v].size(); i++)       for (int j = 0; j < (int)dp[u].size(); j++)         tmp[i + j] = max(tmp[i + j], dp[v][i] + dp[u][j] + i * j * lvl[v]);     dp[v] = tmp;   }   void dfs(int v) {     for (int i = 0; i <= cnt[v]; i++) dp[v].emplace_back(lvl[v] * f(i));     for (int i = 0; i < 26; i++)       if (nex[v][i]) {         dfs(nex[v][i]);         merge(v, nex[v][i]);       }   }   int32_t main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     int n, k;     cin >> n >> k;     for (int i = 0; i < n; ++i) {       string s;       cin >> s;       In(s);     }     dfs(0);     cout << dp[0][k] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int dx[] = {-1, 0, 1, 0};   const int dy[] = {0, 1, 0, -1};   int inp[100005];   int main() {     int n, a, b;     cin >> n;     int flag = 0;     string str;     for (int i = 0; i < n; i++) {       cin >> str;       int a, b;       cin >> a >> b;       if (a >= 2400 && b > 2400 && b - a > 0) {         flag = 1;       }     }     if (flag)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long a, b, c, d;     cin >> a >> b >> c >> d;     long long sum = (a + b + c + d) / 3;     if (sum == a)       cout << sum - b <<     << sum - c <<     << sum - d;     else if (sum == b)       cout << sum - a <<     << sum - c <<     << sum - d;     else if (sum == c)       cout << sum - a <<     << sum - b <<     << sum - d;     else       cout << sum - a <<     << sum - b <<     << sum - c;   }
#include<bits/stdc++.h>   using namespace std;      typedef long long ll;   typedef vector<int> vi;   typedef pair<int, int> pi;      #define rep(i,k,n) for (int i = k; i < n; ++i)   #define repr(i,k,n) for (int i = k; i >= n; --i)      int main()   {       ios_base::sync_with_stdio(false);    cin.tie(NULL);      #ifndef ONLINE_JUDGE    freopen( input.txt ,  r , stdin);    freopen( output.txt ,  w , stdout);   #endif    int t;    cin >> t;    while (t--)    {     int n; cin >> n;     string r, b;     cin >> r >> b;     int count1 = 0, count2 = 0;     rep(i, 0, n)     {      if (r[i] > b[i])      {       count1++;      }      else if (b[i] > r[i])      {       count2++;      }      else      {       count1++;       count2++;      }     }     if (count1 > count2)     {      cout <<  RED  << endl;     }     else if (count2 > count1)     {      cout <<  BLUE  << endl;     }     else cout <<  EQUAL  << endl;    }   }
#include <bits/stdc++.h>   using namespace std;   long long n, l, r;   long long getMin() {     long long ret = 0ll;     for (long long i = 1, p = 1; i <= min(l, n); i++, p *= 2) {       ret += p;     }     ret += max(0ll, (n - l));     return ret;   }   long long getMax() {     long long ret = 0ll, p = 1ll;     for (long long i = 1; i <= min(r, n); i++, p *= 2) {       ret += p;     }     p /= 2ll;     ret += max(0ll, (n - r)) * p;     return ret;   }   int main() {     scanf( %lld %lld %lld , &n, &l, &r);     printf( %lld %lld n , getMin(), getMax());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-6;   void __print(int x) { cerr << x; }   void __print(long x) { cerr << x; }   void __print(long long x) { cerr << x; }   void __print(unsigned x) { cerr << x; }   void __print(unsigned long x) { cerr << x; }   void __print(unsigned long long x) { cerr << x; }   void __print(float x) { cerr << x; }   void __print(double x) { cerr << x; }   void __print(long double x) { cerr << x; }   void __print(char x) { cerr <<      << x <<     ; }   void __print(const char *x) { cerr <<     << x <<    ; }   void __print(const string &x) { cerr <<     << x <<    ; }   void __print(bool x) { cerr << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cerr <<  { ;     __print(x.first);     cerr <<  , ;     __print(x.second);     cerr <<  } ;   }   template <typename T>   void __print(const T &x) {     int f = 0;     cerr <<  { ;     for (auto &i : x) cerr << (f++ ?  ,  :   ), __print(i);     cerr <<  } ;   }   void _print() { cerr <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cerr <<  ,  ;     _print(v...);   }   void solve() {     long long n, i, j;     cin >> n;     long long x[n];     for (i = 0; i < n; i++) {       cin >> x[i];     }     long long m;     cin >> m;     long long y[m];     for (i = 0; i < m; i++) {       cin >> y[i];     }     long long k;     cin >> k;     long long z[k];     for (i = 0; i < k; i++) {       cin >> z[i];     }     long long a, b;     sort(x, x + n);     sort(y, y + m);     sort(z, z + k);     cin >> a >> b;     double r = double(x[n - 1] * sqrt((double(b * y[m - 1])) /                                       double(a * z[0] + b * y[m - 1])));     cout << fixed << setprecision(18) << r <<   n ;   }   signed main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     ;     long long t = 1;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const ll N = 2e5 + 10;   const ll inf = 1e18;   const ll MOD = 1e9 + 100;   int n;   int main() {     int t;     cin >> t;     while (t--) {       cin >> n;       if (n < 4)         printf( -1 n );       else {         deque<int> q;         q = {3, 1, 4, 2};         for (int i = 5; i <= n; i++) {           if (i % 2) {             q.push_back(i);           } else             q.push_front(i);         }         for (int i = 0; i < q.size(); i++) printf( %d  , q[i]);         printf(  n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<vector<long long> > g;   long long vis[200005], w[200005];   long long cycle[200005];   long long taken[200005];   long long s;   void dfs(long long x, long long par) {     vis[x] = 1;     for (long long i = 0; i < g[x].size(); i++) {       long long y = g[x][i];       if (y == par) continue;       if (vis[y] == 1)         cycle[y] = 1, cycle[x] = 1;       else if (vis[y] == 0) {         dfs(y, x);         if (cycle[y] == 1) cycle[x] = 1;       }     }     vis[x] = 2;   }   long long maxi;   long long dfs2(long long x) {     vis[x] = 1;     long long ans = 0, res = 0;     for (long long i = 0; i < g[x].size(); i++) {       long long y = g[x][i];       if (cycle[x] == 1) {         if (!vis[y]) {           if (cycle[y])             ans += dfs2(y);           else {             maxi = max(maxi, dfs2(y));           }         }       } else {         if (!vis[y]) {           res = max(res, dfs2(y));         }       }     }     if (x == s - 1) {       return ans + maxi + w[x];     }     if (cycle[x] == 0) ans += res, maxi = max(maxi, ans + w[x]);     return w[x] + ans;   }   int32_t main() {     ios::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     long long n, m;     cin >> n >> m;     vector<long long> v;     for (long long i = 0; i < n; i++) g.push_back(v);     maxi = 0;     for (long long i = 0; i < n; i++) cin >> w[i];     for (long long i = 0; i < m; i++) {       long long x, y;       cin >> x >> y;       x--, y--;       g[x].push_back(y), g[y].push_back(x);     }     cin >> s;     dfs(s - 1, -1);     for (long long i = 0; i < n; i++) vis[i] = 0;     cout << dfs2(s - 1) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     vector<int> a(n);     for (int &i : a) cin >> i;     int ans = -1, now = 0;     vector<bool> vis(n);     while (now < n) {       ans++;       if (ans % 2)         for (int i = n - 1; i >= 0; i--)           if (!vis[i] && a[i] <= now)             vis[i] = true, now++;           else             ;       else         for (int i = 0; i < n; i++)           if (!vis[i] && a[i] <= now)             vis[i] = true, now++;           else             ;     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k, el[101];   set<int> st;   int main() {     cin >> n >> k;     for (int i = 1; i < (int)n + 1; ++i) st.insert(i);     set<int>::iterator it = st.begin(), er;     for (int i = 0; i < (int)k; ++i) {       int a;       cin >> a;       int ind = ((a) % (int)(st).size());       for (; ind--;) {         if (++it == st.end()) it = st.begin();       }       cout << *it <<    ;       er = it;       if (++it == st.end()) it = st.begin();       st.erase(er);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   const int MaxN = 2e5 + 10;   int endd, vis[MaxN];   int main() {     int tt;     cin >> tt;     while (tt--) {       cin >> s;       stack<int> sta;       for (int i = 0; i < s.size(); i++) {         sta.push(s[i]);         if (sta.top() ==  B  && sta.size() > 1) {           sta.pop();           sta.pop();         }       }       cout << sta.size() << endl;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( Ofast )   #pragma GCC target( avx,avx2,fma )   #pragma GCC optimization( unroll-loops )   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   void naive(int x, int y) {     if (x == y) {       cout <<  Yes n ;       return;     }     for (int i = 2; i * i <= x; i++) {       while (x % i == 0) {         if (y % (i * i) == 0) {           y /= i * i;           x /= i;         } else if (x % (i * i) == 0 && y % i == 0) {           x /= i * i;           y /= i;         } else {           cout <<  No n ;           return;         }       }     }     if (x == y * y || x * x == y)       cout <<  Yes n ;     else       cout <<  No n ;   }   void fast(long long x, long long y) {     long long p = x * y;     long long l = 1, r = 1e6 + 42;     while (r - l > 1) {       long long m = ((r + l) >> 1);       if (m * m * m > p)         r = m;       else         l = m;     }     if (l * l * l == p && x % l == 0 && y % l == 0)       cout <<  Yes n ;     else if (r * r * r == p && x % r == 0 && y % r == 0)       cout <<  Yes n ;     else       cout <<  No n ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n = 0;     cin >> n;     while (n--) {       long long a, b;       cin >> a >> b;       if (a > b) swap(a, b);       fast(a, b);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int ent;     long long int a, b;     cin >> ent;     while (ent--) {       int div = 0, pls = 0;       cin >> a >> b;       if (a % b == 0) {         cout << 0 << endl;         continue;       }       div = a / b;       pls = (div + 1) * b;       cout << pls - a << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long n;   double t, ans, x, y;   map<pair<double, double>, bool> b;   pair<double, double> p[1005];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> n >> t;     for (int i = 1; i <= n; i++) {       cin >> x >> y;       p[i].first = x - y / 2;       p[i].second = x + y / 2;     }     sort(p + 1, p + 1 + n);     p[0].second = -1e18;     for (int i = 1; i <= n; i++) {       if (p[i].first - p[i - 1].second >= t &&           b[{p[i].first - t, p[i].first}] == false) {         b[{p[i].first - t, p[i].first}] = true;         ans++;       }       if (p[i].second + t <= p[i + 1].first) {         b[{p[i].second, p[i].second + t}] = true;         ans++;       }     }     ans++;     cout << ans <<   n ;     return 0;   }