malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int N = 100002;   int n, m, ok[N], a, b, c, l[N], nr[N];   vector<pair<int, int>> G[N];   int p[20][N];   void parentDFS(int x, int par) {     p[0][x] = par;     l[x] = l[par] + 1;     for (auto it : G[x])       if (it.first != par) parentDFS(it.first, x);   }   int lca(int x, int y) {     if (l[x] < l[y]) swap(x, y);     for (int i = 0; i < 18; i++)       if (((l[x] - l[y]) & (1 << i))) x = p[i][x];     if (x == y) return x;     for (int i = 17; i >= 0; i--)       if (p[i][x] != p[i][y]) {         x = p[i][x];         y = p[i][y];       }     return p[0][x];   }   pair<int, int> dist[N], ans[N];   pair<int, int> maxx(pair<int, int> a, pair<int, int> b, int nod) {     if (a.first < 0) return b;     if (b.first < 0) return a;     if (a.first == b.first)       return {a.first, nod};     else       return max(a, b);   }   void dfs1(int x, int p) {     if (ok[x]) {       dist[x] = {0, x};     } else       dist[x] = {-1e9, -1};     for (auto it : G[x]) {       int u = it.first, c = it.second;       if (u == p) continue;       dfs1(u, x);       dist[x] = maxx(dist[x], {dist[u].first + c, dist[u].second}, x);     }   }   void dfs2(int x, int par, pair<int, int> sus) {     ans[x] = maxx(sus, dist[x], x);     if (ok[x]) {       int t = ans[x].second;       int L = lca(x, t);       nr[x]++;       nr[t]++;       nr[L]--;       if (p[0][L] != 0) nr[p[0][L]]--;     }     pair<int, int> aux;     if (ok[x])       aux = {0, x};     else       aux = {-1e9, -1};     vector<pair<int, int>> child;     vector<pair<int, int>> pr;     int j = 0;     for (auto it : G[x])       if (it.first != par) child.push_back(it);     for (auto it : child) {       int u = it.first, c = it.second;       pr.push_back(aux);       aux = maxx(aux, {dist[u].first + c, dist[u].second}, x);     }     for (int i = child.size() - 1; i >= 0; i--) {       int u = child[i].first;       int c = child[i].second;       pair<int, int> aux1 = maxx(sus, pr[i], x);       aux1.first += c;       dfs2(u, x, aux1);       sus = maxx(sus, {dist[u].first + c, dist[u].second}, x);     }   }   void mars(int x, int p) {     for (auto it : G[x]) {       int u = it.first;       if (u == p) continue;       mars(u, x);     }     nr[p] += nr[x];   }   int main() {     cin >> n >> m;     for (int i = 1; i <= m; i++) {       cin >> a;       ok[a] = 1;     }     for (int i = 1; i < n; i++) {       cin >> a >> b >> c;       G[a].push_back({b, c});       G[b].push_back({a, c});     }     parentDFS(1, 0);     for (int i = 1; i < 18; i++)       for (int j = 1; j <= n; j++) p[i][j] = p[i - 1][p[i - 1][j]];     dfs1(1, 0);     dfs2(1, 0, {-1e9, -1});     mars(1, 0);     int r = 0, sol = 0;     for (int i = 1; i <= n; i++) {       if (!ok[i]) {         if (sol < nr[i]) {           sol = nr[i];           r = 1;         } else if (sol == nr[i])           r++;       }     }     cout << sol <<     << r;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int dp[6][6][220][220], aa[50], bb[50];   void init() {     memset(dp, -1, sizeof(dp));     dp[0][0][0][0] = 0;     for (int s1 = 0; s1 < 3; ++s1)       for (int s2 = 0; s2 < 3; ++s2)         for (int j = 0; j < 220; ++j)           for (int k = 0; k < 220; ++k)             if (~dp[s1][s2][j][k]) {               int bas = (s1 + s2 == 4 ? 15 : 25);               for (int t2 = 0; t2 + k < 220; ++t2) {                 int t1 = max(bas, t2 + 2);                 if (t1 + j >= 220) break;                 dp[s1 + 1][s2][j + t1][k + t2] = t1 * 220 + t2;               }               for (int t1 = 0; t1 + j < 220; ++t1) {                 int t2 = max(bas, t1 + 2);                 if (t2 + k >= 220) break;                 dp[s1][s2 + 1][j + t1][k + t2] = t1 * 220 + t2;               }             }   }   void solve() {     int m;     scanf( %d , &m);     while (m--) {       int a, b;       scanf( %d%d , &a, &b);       int w1 = -10, w2 = -5, tp = a + b, cnt = a + b;       for (int s1 = 0; s1 <= 3; ++s1)         for (int s2 = 0; s2 <= 3; ++s2) {           if ((!(~dp[s1][s2][a][b])) || max(s1, s2) < 3) continue;           if (s1 - s2 > w1 - w2) w1 = s1, w2 = s2;         }       if (w1 < 0) {         puts( Impossible );         continue;       }       tp = cnt = w1 + w2;       printf( %d:%d n , w1, w2);       while (cnt) {         int t1 = dp[w1][w2][a][b] / 220, t2 = dp[w1][w2][a][b] % 220;         aa[cnt] = t1, bb[cnt] = t2, a -= t1, b -= t2, cnt--;         if (t1 > t2)           w1--;         else           w2--;       }       for (int i = 1; i <= tp; i++)         printf( %d:%d%c , aa[i], bb[i], i < tp ?     :   n );     }   }   int main() {     init();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string A[4][102];   string M[202];   int main() {     ios_base::sync_with_stdio(false);     int n;     cin >> n;     for (int p = 0; p < 4; p++) {       for (int i = 0; i < n; i++) {         cin >> A[p][i];       }     }     vector<int> T;     for (int i = 0; i < 4; i++) T.push_back(i);     int ans = int(1e9);     do {       for (int i = 0; i < n; i++) M[i] = A[T[0]][i] + A[T[1]][i];       for (int i = n; i < 2 * n; i++) M[i] = A[T[2]][i - n] + A[T[3]][i - n];       int op1 = 0, op2 = 0;       for (int i = 0; i < 2 * n; i++) {         int sq = (i % 2) ? 1 : 0;         for (int j = 0; j < 2 * n; j++) {           if (M[i][j] -  0  != sq) op1++;           sq ^= 1;         }       }       for (int i = 0; i < 2 * n; i++) {         int sq = (i % 2) ? 0 : 1;         for (int j = 0; j < 2 * n; j++) {           if (M[i][j] -  0  != sq) op2++;           sq ^= 1;         }       }       ans = min(ans, min(op1, op2));     } while (next_permutation(T.begin(), T.end()));     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     while (n--) {       string s, t;       cin >> s >> t;       std::map<char, bool> ms, mt;       for (int i = 0; i < s.size(); i++) {         ms[s[i]] = true;         mt[t[i]] = true;       }       for (char x =  a ; x <=  z ; x++)         if (ms[x] && mt[x]) {           cout <<  YES ;           goto flag;         }       cout <<  NO ;     flag:       cout << endl;       ;     }   }
#include<bits/stdc++.h>   using namespace std;   #define ll long long   #define endl   n    #define pb push_back   const ll INF=1e18+10;      void solve()   {       ll n,m;       cin>>n>>m;       string s;       cin>>s;       string p=s;       while(m--)       {           s=p;           for(ll i=0;i<n;i++)           {               if(p[i]== 1 ) continue;               else{               if(i==0)               {                  // cout<< YES <<endl;                   if(s[i+1]== 1 ) p[i]= 1 ;                   else p[i]= 0 ;                   //cout<<p[i]<<endl;               }              else if(i==n-1)               {                   if(s[i-1]== 1 ) p[i]= 1 ;                   else p[i]= 0 ;               }               else               {                   if((s[i-1]== 1 &&s[i+1]== 0 )||(s[i+1]== 1 &&s[i-1]== 0 )) p[i]= 1 ;                   else p[i]= 0 ;               }           }           }           if(p==s) break;       }          cout<<p<<endl;      // cout<<p[0]<<endl;      }   int main()   {       ios::sync_with_stdio(0);       cin.tie(0);       ll t;       t=1;      cin>>t;       while(t--)       {           solve();       }   }
#include <bits/stdc++.h>   using namespace std;   const int MX = 200005;   const int MD = 998244353;   void add(int& a, int b) {     a += b;     if (a >= MD) a -= MD;   }   void sub(int& a, int b) {     a -= b;     if (a < 0) a += MD;   }   int mod_sum(int a, int b) {     a += b;     if (a >= MD) a -= MD;     return a;   }   int mod_mult(long long a, long long b) { return (a * b) % MD; }   int exp(int a, int b) {     int res = 1;     while (b) {       if (b & 1) res = mod_mult(res, a);       a = mod_mult(a, a);       b /= 2;     }     return res;   }   int inv(int a) { return exp(a, MD - 2); }   int p[MX];   struct DATA {     int s, m;   };   DATA recalc(DATA L, DATA R) {     DATA res;     res.m = mod_mult(L.m, R.m);     res.s = mod_sum(mod_mult(L.s, R.m), R.s);     return res;   }   struct {     int L, R;     int pl, pr;     DATA d;   } T[2 * MX];   int tsz = 0;   int buildTree(int L, int R) {     int cur = tsz++;     T[cur].L = L;     T[cur].R = R;     if (L < R) {       T[cur].pl = buildTree(L, (L + R) / 2);       T[cur].pr = buildTree((L + R) / 2 + 1, R);       T[cur].d = recalc(T[T[cur].pl].d, T[T[cur].pr].d);     } else {       T[cur].d.m = inv(p[L]);       T[cur].d.s = inv(p[L]);     }     return cur;   }   DATA get(int L, int R, int cur) {     if (L <= T[cur].L && R >= T[cur].R) return T[cur].d;     DATA d;     bool any = false;     if (L <= T[T[cur].pl].R) {       d = get(L, R, T[cur].pl);       any = true;     }     if (R >= T[T[cur].pr].L) {       DATA tmp = get(L, R, T[cur].pr);       if (any)         d = recalc(d, tmp);       else         d = tmp;     }     return d;   }   int main() {     int n, q;     ignore = scanf( %d %d , &n, &q);     int inv_100 = inv(100);     for (int i = 1; i <= n; i++) {       ignore = scanf( %d , p + i);       p[i] = mod_mult(p[i], inv_100);     }     int rt = buildTree(1, n);     int res = T[rt].d.s;     set<int> toggled;     toggled.insert(1);     toggled.insert(n + 1);     while (q--) {       int i;       ignore = scanf( %d , &i);       if (!toggled.count(i)) {         int L = *prev(toggled.lower_bound(i));         int R = *toggled.lower_bound(i) - 1;         DATA LL = get(L, i - 1, rt);         DATA RR = get(i, R, rt);         sub(res, recalc(LL, RR).s);         add(res, LL.s);         add(res, RR.s);         toggled.insert(i);       } else {         toggled.erase(i);         int L = *prev(toggled.lower_bound(i));         int R = *toggled.lower_bound(i) - 1;         DATA LL = get(L, i - 1, rt);         DATA RR = get(i, R, rt);         add(res, recalc(LL, RR).s);         sub(res, LL.s);         sub(res, RR.s);       }       printf( %d n , res);     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 200100;   const long long INF = 0x3f3f3f3f3f3f3f3f;   long long d[MAXN], h[MAXN];   long long sd[MAXN];   struct str {     long long pfx, sfx, rnode, l, r;   };   struct st {     st *fe, *fd;     long long l, r, meio, pfx, sfx, rnode;     st(long long x, long long y) {       meio = (x + y) / 2;       pfx = sfx = rnode = 0;       l = x, r = y;       if (x == y) return;       fe = new st(x, meio);       fd = new st(meio + 1, y);     }     st(st *node) {       fe = node->fe;       fd = node->fd;       rnode = node->rnode;       pfx = node->pfx;       sfx = node->sfx;       l = node->l;       r = node->r;     }     void update(long long pos, long long novo) {       if (l == r) {         pfx = sfx = rnode = 2 * novo;         return;       }       if (pos <= meio)         fe->update(pos, novo);       else         fd->update(pos, novo);       pfx = max(fe->pfx, sd[fe->r] - sd[fe->l - 1] + fd->pfx);       sfx = max(fd->sfx, sd[fd->r - 1] - sd[fd->l - 1] + d[fe->r] + fe->sfx);       rnode = max(fe->rnode, max(fd->rnode, fe->sfx + fd->pfx + d[fe->r]));     }     str get(long long a, long long b) {       if (l >= a && r <= b) {         str resp;         resp.pfx = pfx;         resp.sfx = sfx;         resp.rnode = rnode;         resp.l = l;         resp.r = r;         return resp;       }       if (l > b || r < a) {         str at;         at.rnode = -INF;         at.pfx = -INF;         at.sfx = -INF;         return at;       }       str left = fe->get(a, b), right = fd->get(a, b);       str resp;       bool flag = false;       if (left.rnode < 0)         resp = right, flag = true;       else if (right.rnode < 0)         resp = left, flag = true;       if (flag == true) {         return resp;       }       resp.pfx = max(left.pfx, sd[left.r] - sd[left.l - 1] + right.pfx);       resp.sfx = max(right.sfx,                      sd[right.r - 1] - sd[right.l - 1] + d[left.r] + left.sfx);       resp.rnode =           max(left.rnode, max(right.rnode, left.sfx + right.pfx + d[left.r]));       resp.l = left.l, resp.r = right.r;       return resp;     }   };   st arvore(1, MAXN);   signed main() {     memset(sd, 0, sizeof sd);     long long n, q;     cin >> n >> q;     for (long long i = 1; i <= n; i++) cin >> d[i];     for (long long i = 1; i <= n; i++) cin >> h[i];     sd[0] = 0;     for (long long i = n + 1; i <= 2 * n; i++) d[i] = d[i - n], h[i] = h[i - n];     for (long long i = 1; i <= 2 * n; i++) sd[i] = sd[i - 1] + d[i];     for (long long i = 1; i <= 2 * n; i++) arvore.update(i, h[i]);     for (long long i = 1; i <= q; i++) {       long long x, y;       cin >> x >> y;       if (x > y)         cout << arvore.get(y + 1, x - 1).rnode << endl;       else         cout << arvore.get(y + 1, x + n - 1).rnode << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int n;   map<int, int, greater<int> > g;   int a;   int gcd(int a, int b) {     while (b != 0) {       a %= b;       swap(a, b);     }     return a;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     ;     cin >> n;     for (int(i) = (0); (i) < int(n * n); ++(i)) {       cin >> a;       g[a]++;     }     vector<int> ans;     while (1) {       bool done = 0;       for (auto& x : g) {         if (x.second <= 0) continue;         x.second--;         done = 1;         for (auto every : ans) {           g[gcd(every, x.first)] -= 2;         }         ans.push_back(x.first);         g[x.first]--;         break;       }       if (!done) break;     }     for (auto y : ans) cout << y <<    ;     cin.sync();     cin.get();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<int, int> > ans;   int a[305], b[305], n;   int cur[305];   map<int, vector<int> > m;   int main() {     ios_base::sync_with_stdio(0);     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n; i++) cin >> b[i];     for (int i = 0; i < n; i++) {       m[a[i]].push_back(i);     }     for (auto &x : m) reverse(x.second.begin(), x.second.end());     for (int i = 0; i < n; i++) {       cur[i] = m[b[i]].back();       m[b[i]].pop_back();     }     for (int i = 0; i < n; i++)       if (1) cerr << cur[i] <<    ;     if (1) cerr <<   n ;     for (int i = 0; i < n; i++)       for (int j = 0; j < n - 1; j++) {         if (cur[j] > cur[j + 1]) {           ans.push_back({j + 1, j + 2});           swap(cur[j], cur[j + 1]);         }       }     cout << ans.size() <<   n ;     for (auto x : ans) cout << x.first <<     << x.second <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   long long a, b;   long long remove(long long a) {     long long temp = 0L;     int tens = 1;     while (a) {       if (a % 10) {         temp += tens * (a % 10);         tens *= 10;       }       a /= 10;     }     return temp;   }   int main() {     cin >> a >> b;     long long c = a + b;     a = remove(a);     b = remove(b);     c = remove(c);     if (a + b == c)       cout <<  YES ;     else       cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int lens = s.length();     s =     + s;     s = s +    ;     int minn = -1;     int a[10000] = {0};     a[0] = 0;     int p = 1;     for (int i = 0; i <= lens + 1; i++) {       if (s[i] ==  A  || s[i] ==  E  || s[i] ==  I  || s[i] ==  O  ||           s[i] ==  U  || s[i] ==  Y ) {         a[p++] = i;       }     }     a[p++] = lens + 1;     for (int i = 0; i < p; i++) {       a[i] = a[i + 1] - a[i];       minn = max(a[i], minn);     }     cout << minn << endl;   }
#include <bits/stdc++.h>   using namespace std;   namespace std {   template <>   struct hash<pair<int, int> > {     size_t operator()(const pair<int, int>& x) const {       long long P = 38923, Q = 109797901;       return (size_t)((x.first * P + x.second) % Q);     }   };   };  // namespace std   template <class T>   using pqg = priority_queue<T, vector<T>, greater<T> >;   template <typename T, typename second>   ostream& operator<<(ostream& os, const pair<T, second>& v) {     os <<  (  << v.first <<  ,   << v.second <<  ) ;     return os;   }   template <typename T>   void print(T t) {     cout << t << endl << flush;   }   template <typename T, typename... Args>   void print(T t, Args... args) {     cout << t <<    ;     print(args...);   }   int main() {     int T;     cin >> T;     for (auto t = 0; t < T; t += 1) {       int n;       cin >> n;       vector<int> a(n);       long long A, B;       A = 0;       B = 0;       for (auto i = 0; i < n; i += 1) {         cin >> a[i];         A += a[i];         B ^= a[i];       }       print(2);       print(B, A + B);     }   }
#include <bits/stdc++.h>   int main() {     std::string first, last, create =  fffffffffffff ;     int let = 1;     std::cin >> first >> last;     create[0] = first[0];     int size = first.size();     for (int i = 1; i < size; i++) {       if (first[i] < last[0]) {         create[let] = first[i];         let++;       } else         break;     }     create[let] = last[0];     create = create.substr(0, let + 1);     std::cout << create;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, x, y, z, a[200005], o, X, Y, Z, XY, XZ, YZ;   bool ok(int t) {     X = Y = Z = XY = XZ = YZ = 0;     for (int i = o; i; i--) {       if (X + XY + XZ < t && a[i] <= x)         X++;       else if (Y + XY + YZ < t && a[i] <= y)         Y++;       else if (Z + XZ + YZ < t && a[i] <= z)         Z++;       else if (X + Y + XY + XZ + YZ < t && a[i] <= x + y)         XY++;       else if (X + Z + XY + XZ + YZ < t && a[i] <= x + z)         XZ++;       else if (Y + Z + XY + XZ + YZ < t && a[i] <= y + z)         YZ++;       else         return 0;     }     return 1;   }   int main() {     scanf( %d%d%d%d , &n, &x, &y, &z);     for (int i = 1; i <= n; i++) scanf( %d , a + i);     sort(a + 1, a + n + 1);     if (a[n] > x + y + z) {       printf( -1 n );       return 0;     }     if (x > y) swap(x, y);     if (x > z) swap(x, z);     if (y > z) swap(y, z);     o = n;     while (a[o] > y + z && o) o--;     int l = 0, r = o + 5;     while (r - l > 1) {       int m = (l + r) >> 1;       if (ok(m))         r = m;       else         l = m;     }     l -= 3;     while (!ok(l)) l++;     printf( %d n , n - o + l);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1510;   int n, arr[N], m;   int main() {     scanf( %d , &n);     int ans = 0;     for (int i = 0; i < n; i++) {       scanf( %d , &arr[i]);       for (int j = 0; j < i; j++) {         if (arr[i] < arr[j]) ans ^= 1;       }     }     scanf( %d , &m);     while (m--) {       int l, r;       scanf( %d%d , &l, &r);       int cur = (r - l) * (r - l + 1) / 2;       ans ^= (cur & 1);       if (!ans)         puts( even );       else         puts( odd );     }     return 0;   }
#include  bits/stdc++.h    using namespace std;   #define pb                push_back   #define ppb               pop_back   #define pf                push_front   #define ppf               pop_front   #define all(x)            (x).begin(),(x).end()   #define uniq(v)           (v).erase(unique(all(v)),(v).end())   #define sz(x)             (int)((x).size())   #define fr                first   #define sc                second   #define pii               pair<int,int>   #define rep(i,a,b)        for(int i=a;i<b;i++)   #define mem1(a)           memset(a,-1,sizeof(a))   #define mem0(a)           memset(a,0,sizeof(a))   #define ppc               __builtin_popcount   #define ppcll             __builtin_popcountll      template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}   template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<   <<a.sc;return out;}   template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}   template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}      const long long INF=1e18;   const int32_t M=998244353;      const int N=1005;      string x,y;   int dp[N][N][3][4];      int calc(int a,int b,int last,int started){    if(dp[a][b][last][started] != -1){     return dp[a][b][last][started];    }    int ans = (started == 3);    char pc;    if(last == 2){     pc =  z  + 1;    }    else{     pc = ((last == 0)?x[a-1]:y[b-1]);    }        if(a < sz(x) && x[a] != pc){     ans = (ans + calc(a+1,b,0,started | 1)) % M;    }        if(b < sz(y) && y[b] != pc){     ans = (ans + calc(a,b+1,1,started | 2)) % M;    }    return dp[a][b][last][started] = ans;   }      void solve(){    mem1(dp);    cin >> x >> y;        int ans = 0;    rep(i,0,sz(x)){     rep(j,0,sz(y)){            ans = (ans + calc(i,j,2,0)) % M;     }    }    cout << ans <<   n ;   }   signed main(){    ios_base::sync_with_stdio(false);    cin.tie(0);cout.tie(0);    //freopen( input.txt ,  r , stdin);    //freopen( output.txt ,  w , stdout);    #ifdef SIEVE     sieve();    #endif    #ifdef NCR     init();    #endif    int t=1;    //cin>>t;    while(t--) solve();    return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t;     cin >> t;     while (t--) {       int n, t;       cin >> n >> t;       vector<int> arr(n);       for (int i = 0; i < n; i++) {         cin >> arr[i];         if (arr[i] == 0 || arr[i] == t) continue;         arr[i] %= t;       }       set<int> s;       set<int>::iterator it;       bool selected = false;       vector<int> color(n);       for (int i = 0; i < n; i++) {         if (t % 2 == 0 && arr[i] == t / 2) {           color[i] = selected;           selected = !selected;         } else {           int opp = t - arr[i];           if (s.find(opp) == s.end()) {             color[i] = 0;             s.insert(arr[i]);           } else {             color[i] = 1;           }         }       }       for (int i = 0; i < n; i++) cout << color[i] <<    ;       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long i, T, n;     cin >> T;     while (T--) {       double h, c, t, ans;       cin >> h >> c >> t;       double res = h, freq = 1.0, diff = fabs(((h + c) / 2) - t);       if (h == t) {         cout << 1 <<   n ;         continue;       }       if ((h + c) / 2 >= t) {         cout << 2 <<   n ;         continue;       }       freq = 1 + 2 * ceil((t - h) / (h + c - 2 * t));       double freq2 = freq - 2;       if (fabs((h + (h + c) * ((freq - 1) / 2)) / (freq)-t) <           fabs((h + (h + c) * ((freq2 - 1) / 2)) / (freq2)-t)) {         if (diff < fabs((h + (h + c) * (freq / 2)) / (1 + freq) - t)) {           cout << 2 <<   n ;         } else {           cout << freq <<   n ;         }       } else {         if (diff < fabs((h + (h + c) * (freq2 / 2)) / (1 + freq2) - t)) {           cout << 2 <<   n ;         } else {           cout << freq2 <<   n ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int compare(const void* a, const void* b) {     return ((*(pair<long long, long long>*)a).first -             (*(pair<long long, long long>*)b).first);   }   string alfabet =  abcdefghijklmnopqrstuvwxyz ;   int main() {     long long n, x1, x2, k, b;     cin >> n;     cin >> x1 >> x2;     vector<pair<double, double> > lines;     pair<double, double> line;     for (int i = 0; i < n; ++i) {       cin >> k >> b;       line.first = k * x1 + b;       line.second = k * x2 + b;       lines.push_back(line);     }     sort(lines.begin(), lines.end());     for (int i = 0; i < n - 1; ++i) {       if (lines[i].second > lines[i + 1].second &&           lines[i].first != lines[i + 1].first) {         cout <<  YES ;         return 0;       }     }     cout <<  NO ;     return 0;   }