malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, m, q;   pair<int, bool> a[400100];   int dsu[200100];   pair<int, int> query[200100];   long long ans[200100];   int last[200100];   long long prsum[400100];   int f(int x) {     if (dsu[x] < 0) return x;     int r = f(dsu[x]);     dsu[x] = r;     return r;   }   void join(int x, int y) {     int r1 = f(x);     int r2 = f(y);     if (r1 != r2) {       if (dsu[r1] > dsu[r2]) swap(r1, r2);       last[r1] = max(last[r1], last[r2]);       dsu[r1] += dsu[r2];       dsu[r2] = r1;     }   }   priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>,                  greater<pair<int, pair<int, int>>>>       pq;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long sum = 0;     cin >> n >> m >> q;     for (int i = 1; i <= n; i++) {       cin >> a[i].first;       sum += a[i].first;       a[i].second = 1;     }     for (int i = 1; i <= m; i++) {       cin >> a[i + n].first;       a[i + n].second = 0;     }     sort(a + 1, a + 1 + n + m);     for (int i = 0; i <= n + 10; i++) {       dsu[i] = -1;     }     int cur = 1;     for (int i = 1; i <= n + m; i++) {       if (a[i].second == 1) {         if (i < n + m) pq.push({a[i + 1].first - a[i].first, {i, cur}});         last[cur] = i;         cur++;       }     }     for (int i = 0; i < q; i++) {       cin >> query[i].first;       query[i].second = i;     }     sort(query, query + q);     for (int i = 1; i <= n + m; i++) {       prsum[i] = prsum[i - 1] + a[i].first;     }     for (int i = 0; i < q; i++) {       int v = query[i].first;       while (!pq.empty() && v >= pq.top().first) {         pair<int, int> tmp = pq.top().second;         pq.pop();         if (a[tmp.first + 1].second == 1) {           int r1 = f(tmp.second);           int r2 = f(tmp.second + 1);           sum += prsum[last[r2] + dsu[r2]] - prsum[last[r2] + dsu[r2] + dsu[r1]];           sum -= prsum[last[r1]] - prsum[last[r1] + dsu[r1]];           join(tmp.second, tmp.second + 1);         } else if (tmp.first + 1 == n + m) {           sum += a[tmp.first + 1].first -                  a[tmp.first + dsu[f(tmp.second)] + 1].first;           last[f(tmp.second)]++;         } else {           pq.push({a[tmp.first + 2].first - a[tmp.first + 1].first,                    {tmp.first + 1, tmp.second}});           sum += a[tmp.first + 1].first -                  a[tmp.first + dsu[f(tmp.second)] + 1].first;           last[f(tmp.second)]++;         }       }       ans[query[i].second] = sum;     }     for (int i = 0; i < q; i++) {       cout << ans[i] <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   const int maxi = 2000000000;   const int maxq = 1000000000;   const double eps = 1e-10;   const double pi = 3.1415926535897932;   const double inf = 1e+18;   const int mo = 1000000007;   using namespace std;   long long l, r;   int main() {     cin >> l >> r;     if (l == r) {       puts( 0 );       return 0;     }     for (int i = 62; i >= 0; i--) {       if ((1ll << (i)) > l && (1ll << (i)) <= r) {         cout << (1ll << (i + 1)) - 1 << endl;         return 0;       }       if ((1ll << (i)) <= l) {         l -= (1ll << (i));         r -= (1ll << (i));       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   double PI = 3.1415926535897932384626433;   double DP[(1 << 20)];   vector<double> fx, fy, lg;   double calc(double px, double py, double t, double al) {     double d = sqrt((px - t) * (px - t) + py * py);     double sina = sin(al * (PI / 180.0));     double sinb = fabs(py) / d;     double bt = asin(sinb) * (180.0 / PI);     if (px < t) bt = 180 - bt;     if (al + bt >= 180) return t + 300000.0;     double gm = 180 - bt - al;     double sinc = sin(gm * (PI / 180.0));     return t + (sina * (d / sinc));   }   int main() {     int i, mask, n, l, r, cr;     cin >> n >> l >> r;     int xx, yy, al;     double cl = l;     bool hasp = false;     for (i = 0; i < n; ++i) {       cin >> xx >> yy >> al;       if (yy == 0) {         if (hasp || xx >= r || xx <= l) {           cout << r - l <<   n ;           return 0;         }         hasp = true;         cl = xx;       } else {         fx.push_back(xx);         fy.push_back(yy);         lg.push_back(al);       }     }     n = fx.size();     DP[0] = cl;     for (mask = 1; mask < (1 << n); ++mask) {       DP[mask] = cl;       for (i = 0; i < n; ++i) {         if (mask & (1 << i)) {           cr = mask - (1 << i);           DP[mask] = max(DP[mask], calc(fx[i], fy[i], DP[cr], lg[i]));         }       }     }     printf( %.8lf n , min((double)r, DP[(1 << n) - 1]) - l);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int arr[n + 1];     vector<int> v;     for (int i = 0; i < n; i++) {       cin >> arr[i];       if (arr[i] == 1) {         v.push_back(1);       } else {         v[v.size() - 1] = max(arr[i], v[v.size() - 1]);       }     }     cout << v.size() << endl;     for (int i = 0; i < v.size(); i++) {       cout << v[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int i;   int main() {     string s;     cin >> s;     int k;     i = 0;     while (s[i] ==  0 ) {       i++;     }     int f = 0, v = 0;     bool b = false;     while (i != s.size()) {       if (s[i] ==  4 )         f++;       else if (s[i] ==  7 )         v++;       i++;     }     if (b)       cout << -1;     else {       if (f != 0 && f == v)         cout << 4;       else if (f > v)         cout << 4;       else if (v > f)         cout << 7;       else         cout << -1;     }   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   struct node {     int sz;     vector<int> m, M;     node() {       sz = 1;       for (int i = 0; i < k; ++i) {         int tmp;         scanf( %d , &tmp);         m.push_back(tmp);         M.push_back(tmp);       }     }     bool operator<(const node &nd) const {       for (int i = 0; i < k; ++i) {         if (M[i] > nd.m[i]) return false;       }       return true;     }     void merge(const node &nd) {       for (int i = 0; i < k; ++i) {         m[i] = min(m[i], nd.m[i]);         M[i] = max(M[i], nd.M[i]);       }       sz += nd.sz;     }   };   set<node> st;   int main() {     scanf( %d%d , &n, &k);     for (int i = 0; i < n; ++i) {       node nd = node();       auto lb = st.lower_bound(nd), ub = st.upper_bound(nd);       while (lb != ub) {         nd.merge(*lb);         lb = st.erase(lb);       }       st.insert(nd);       printf( %d n , (st.rbegin())->sz);     }     return 0;   }
#include <bits/stdc++.h>   const int N = 100005;   using namespace std;   int n, a[N], b[N], flag[N];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]), b[i] = 1;     int now = a[n];     for (int i = n - 1; i >= 1; i--) {       if (now > a[i])         b[i] = -1, flag[i] = 1, now = now - a[i];       else         b[i] = 1, flag[i] = -1, now = a[i] - now;     }     int yh = 1;     for (int i = 1; i <= n; i++) {       if (b[i] * yh == 1)         printf( + );       else         printf( - );       yh *= flag[i];     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 100;   const int LOG = 18;   const int inf = 1e9 + 10;   struct node {     int nex[2], val;     node() {       nex[0] = nex[1] = -1;       val = inf;     }   };   vector<node> v;   vector<int> div2[N];   bool mark[N];   int t[N];   node tmp;   int go(int curr, int t) {     if (v[curr].nex[t] != -1) return v[curr].nex[t];     v[curr].nex[t] = v.size();     v.push_back(tmp);     return v[curr].nex[t];   }   void add(int curr, int x) {     v[curr].val = min(v[curr].val, x);     for (int i = LOG - 1; i >= 0; i--) {       curr = go(curr, (x >> i) % 2);       v[curr].val = min(v[curr].val, x);     }   }   int query(int curr, int x, int maxi, int lev = LOG - 1) {     if (v[curr].val > maxi) return -1;     if (lev == -1) return (v[curr].val != inf) ? v[curr].val : -1;     int R = go(curr, 1);     int L = go(curr, 0);     if (v[R].val > maxi) {       return query(L, x, maxi, lev - 1);     } else if (v[L].val > maxi) {       return query(R, x, maxi, lev - 1);     } else {       if ((v[L].val ^ x) > (v[R].val ^ x)) {         return query(L, x, maxi, lev - 1);       } else {         return query(R, x, maxi, lev - 1);       }     }   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     memset(t, -1, sizeof t);     int q;     cin >> q;     for (int i = 1; i < N; i++) {       for (int j = i; j < N; j += i) {         div2[j].push_back(i);       }     }     for (int i = 0, tp, x, k, s, u; i < q; i++) {       cin >> tp;       if (tp == 1) {         cin >> u;         if (mark[u]) continue;         mark[u] = true;         for (auto x : div2[u]) {           if (t[x] == -1) {             t[x] = v.size();             v.push_back(tmp);           }           add(t[x], u);         }       } else {         cin >> x >> k >> s;         if (x % k != 0) {           cout <<  -1 n ;           continue;         }         s -= x;         if (t[k] == -1) {           t[k] = v.size();           v.push_back(tmp);         }         cout << query(t[k], x, s) <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e6 + 7;   const int inf = 0x3f3f3f3f;   const long long INF = 0x3f3f3f3f3f3f3f3f;   const int mod = 1000000007;   const double eps = 1e-6;   const double PI = acos(-1);   int n, k, miu[N], Pown[N], sum[N];   int Power(int a, int b) {     int ans = 1;     while (b) {       if (b & 1) ans = 1LL * ans * a % mod;       a = 1LL * a * a % mod;       b >>= 1;     }     return ans;   }   int main() {     miu[1] = 1;     for (int i = 1; i < N; i++)       for (int j = i + i; j < N; j += i) miu[j] -= miu[i];     scanf( %d%d , &n, &k);     for (int i = 1; i <= k; i++) Pown[i] = Power(i, n);     int ans = 0, tmp = 0;     for (int i = 1; i <= k; i++) {       for (int j = i; j <= k; j += i) {         sum[j] =             ((sum[j] + 1LL * miu[i] * (Pown[j / i] - Pown[j / i - 1])) % mod +              mod) %             mod;       }       tmp = (tmp + sum[i]) % mod;       ans = (ans + (tmp ^ i)) % mod;     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int q;     scanf( %d , &q);     for (int i = 0; i < q; i++) {       int l, r, d;       scanf( %d %d %d , &l, &r, &d);       if ((double)l / d > 1)         printf( %d n , d);       else {         int f = ((double)r / d) + 1;         printf( %d n , f * d);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   long long f[15], all[15];   long long n, k;   int solve(int rem) {     if (!rem) return 1;     return solve(rem - 1) * 2;   }   long long solve(int i, string& str) {     if (i == str.size()) return 1;     long long ret = solve(i + 1, str);     if (str[i] ==  1 ) ret += all[str.size() - i - 1];     return ret;   }   bool lucky(long long x) {     while (x) {       if (x % 10 != 4 && x % 10 != 7) return 0;       x /= 10;     }     return 1;   }   int main() {     all[0] = f[0] = 1;     for (int i = 1; i < 15; ++i) {       f[i] = f[i - 1] * i;       all[i] = 2ll * all[i - 1];     }     cin >> n >> k;     if (n < 15 && f[n] < k) return cout << -1, 0;     long long nn = n;     int rem = 0;     for (int i = 0; i < 14; ++i)       if (f[i] < k) rem = i;     long long ans = 0;     set<long long> rem_num;     if (n > rem + 1) {       long long m = n - rem - 1;       string cur =   , s =   ;       stringstream mycin;       mycin << m;       mycin >> cur;       bool ok = 0, is = 0;       int lstseven = -1;       for (int i = 0; i < cur.size(); ++i) {         int ch = cur[i] -  0 ;         if (ok) break;         if (ch < 4) {           is = 1;           break;         } else if (ch > 7)           ok = 1, lstseven = 1e9 + 5;         else if (ch == 7)           lstseven = max(lstseven, i);         else if (ch > 4)           ok = 1;       }       if (is && lstseven == -1) {         int sz = cur.size();         --sz;         while (sz--) s +=  1 ;       } else {         ok = 0;         for (int i = 0; i < cur.size(); ++i) {           int ch = cur[i] -  0 ;           if (ok)             s +=  1 ;           else if (is && lstseven == i)             s +=  0 , ok = 1;           else if (ch > 7)             ok = 1, s +=  1 ;           else if (ch == 7)             s +=  1 ;           else if (ch > 4)             s +=  0 , ok = 1;           else             s +=  0 ;         }       }       if (s.size()) {         ans += solve(0, s);         for (int i = 1; i < s.size(); ++i) ans += all[i];       }       for (int i = n; rem_num.size() <= rem; --i) rem_num.insert(i);       n = rem + 1;     } else       for (int i = 1; i <= n; ++i) rem_num.insert(i);     for (int i = nn - n + 1; i <= nn; ++i) {       vector<int> v;       while (f[nn - i] < k) {         k -= f[nn - i];         v.push_back(*rem_num.begin());         rem_num.erase(rem_num.begin());       }       int x = *rem_num.begin();       rem_num.erase(rem_num.begin());       for (int j : v) rem_num.insert(j);       ans += lucky(i) && lucky(x);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   const int mod = 1e9 + 7;   const int p_mod = 998244353;   using namespace std;   long long fast_pow(long long a, long long b) {     long long res = 1;     while (b) {       if (b & 1) res = (res * a) % mod;       b >>= 1;       a = (a * a) % mod;     }     return res % mod;   }   const int N = 1e5 + 5;   stack<char> s;   char str[N];   int cnt = 0;   int main() {     std::ios::sync_with_stdio(false);     std::cin.tie(0);     cin >> (str + 1);     int len = strlen(str + 1);     for (int i = 1; i <= len; i++) {       if (!s.empty() && s.top() == str[i]) {         s.pop();         cnt++;       } else         s.push(str[i]);     }     if (cnt % 2) {       cout <<  Yes  << endl;     } else       cout <<  No  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct item {     string n, c;     int a, s;   };   item make(string n, string c, int a, int s) {     item z;     z.a = a;     z.c = c;     z.n = n;     z.s = s;     return z;   }   struct rez {     string n, t, h;     int b;   };   bool f2(rez a, rez b) { return a.b > b.b; }   struct equip {     string n;     vector<string> r;     int s;   };   int n, k, s, ya[3], yb[3];   item a[3][100];   rez b[3][1000];   equip z[3];   int sum(int h, int l) {     int sss = 0;     for (int i = 0; i < l; i++) sss += b[h][i].b;     return sss;   }   int main() {     string name, clas;     int atk, def, rz, siz;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> name >> clas >> atk >> def >> rz >> siz;       if (clas ==  weapon ) {         a[0][ya[0]] = make(name, clas, atk, siz);         ya[0]++;       }       if (clas ==  armor ) {         a[1][ya[1]] = make(name, clas, def, siz);         ya[1]++;       }       if (clas ==  orb ) {         a[2][ya[2]] = make(name, clas, rz, siz);         ya[2]++;       }       s += siz;     }     cin >> k;     rez y;     for (int i = 0; i < k; i++) {       cin >> y.n >> y.t >> y.b >> y.h;       if (y.t ==  gladiator ) {         b[0][yb[0]] = y;         yb[0]++;       }       if (y.t ==  sentry ) {         b[1][yb[1]] = y;         yb[1]++;       }       if (y.t ==  physician ) {         b[2][yb[2]] = y;         yb[2]++;       }     }     for (int h = 0; h < 3; h++) sort(b[h], b[h] + yb[h], f2);     if (s == k) {       for (int h = 0; h < 3; h++) {         int mx = -1, m;         for (int i = 0; i < ya[h]; i++) {           int ss = 0;           for (int j = 0; j < yb[h]; j++)             if (b[h][j].h == a[h][i].n) ss += b[h][j].b;           if (ss + a[h][i].a > mx) {             mx = ss + a[h][i].a;             m = i;           }         }         z[h].n = a[h][m].n;         for (int i = 0; i < 3; i++)           for (int j = 0; j < yb[i]; j++)             if (b[i][j].h == z[h].n) z[h].r.push_back(b[i][j].n);       }     } else {       int m[3];       for (int h = 0; h < 3; h++) {         int mx = -1, mm, l;         for (int i = 0; i < ya[h]; i++) {           int sm = sum(h, min(a[h][i].s, yb[h]));           if (a[h][i].a + sm > mx) {             mx = a[h][i].a + sm;             mm = i;             l = min(a[h][i].s, yb[h]);           }         }         z[h].n = a[h][mm].n;         z[h].s = a[h][mm].s;         for (int i = 0; i < l; i++) z[h].r.push_back(b[h][i].n);         m[h] = l;       }       for (int h = 0; h < 3; h++)         for (int i = 0; i < 3; i++)           while (m[i] < yb[i] && z[h].r.size() < z[h].s) {             z[h].r.push_back(b[i][m[i]].n);             m[i]++;           }     }     for (int i = 0; i < 3; i++) {       cout << z[i].n <<     << z[i].r.size();       for (int j = 0; j < z[i].r.size(); j++) cout <<     << z[i].r[j];       cout << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int x, y, sum = 0;     vector<pair<int, int>> v(1e5);     map<int, int> ways;     scanf( %d , &x);     for (int i = 0; i < x; i++) {       scanf( %d , &y);       sum += y;       v[i] = pair<int, int>(y, sum);       if (i != x - 1) ways[sum]++;     }     printf( %d n , ((sum % 2) ? 0 : ways[sum / 2]));     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   bool ison[100010];   char temp[100];   int q, t;   int isprime[100010];   int prime[100010];   vector<int> pr[100010];   void preprocess() {     fill(isprime, isprime + 100010, 0);     fill(ison, ison + 100010, false);     fill(prime, prime + 100010, -1);     for (int i = 2; i < 100010; i++) {       if (isprime[i]) {         continue;       }       pr[i].push_back(i);       for (int j = i + i; j < 100010; j += i) {         pr[j].push_back(i);         isprime[j] = i;       }     }   }   void solve1(int a) {     if (ison[a]) {       printf( Already on n );       return;     }     int len = pr[a].size();     int i;     for (i = 0; i < len; i++) {       int val = pr[a][i];       if (prime[val] == -1) {         continue;       } else {         printf( Conflict with %d n , prime[val]);         return;       }     }     for (i = 0; i < len; i++) {       int val = pr[a][i];       prime[val] = a;     }     ison[a] = true;     printf( Success n );   }   void solve2(int b) {     if (!ison[b]) {       printf( Already off n );       return;     }     int len = pr[b].size();     int i, val;     for (i = 0; i < len; i++) {       val = pr[b][i];       prime[val] = -1;     }     ison[b] = false;     printf( Success n );   }   int main() {     scanf( %d%d , &n, &q);     preprocess();     for (int i = 0; i < q; i++) {       scanf( %s , temp);       scanf( %d , &t);       if (temp[0] ==  + ) {         solve1(t);       } else {         solve2(t);       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, x;   void ans(int x1, int x2, int y1, int y2, int now) {     if (x1 + 1 > x2 - 1 || y1 + 1 > y2 - 1) {       cout << 0;       return;     } else {       if (now + 1 == x) {         if ((x2 - x1 - 1) == 1 || (y2 - y1 - 1) == 1) {           if ((x2 - x1 - 1) == 1 && (y2 - y1 - 1) == 1)             cout << 1;           else             cout << ((x2 - x1 - 1) + (y2 - y1 - 1) - 1) / 2;         } else           cout << ((x2 - x1 - 1) + (y2 - y1 - 1) - 2);       } else         ans(x1 + 1, x2 - 1, y1 + 1, y2 - 1, now + 1);     }   }   int main() {     cin >> n >> m >> x;     if (n == 1 || m == 1) {       if (n == 1 && m == 1) {         if (x == 1) {           cout << 1;         } else           cout << 0;         return 0;       }       if (x == 1) {         cout << (n + m) / 2;       } else         cout << 0;       return 0;     }     if (x == 1) {       cout << (n + m - 2);       return 0;     }     ans(1, n, 1, m, 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);     long long t;     cin >> t;     while (t--) {       long long d, m;       cin >> d >> m;       long long j = 1, ans = 1, sum = 0;       while (sum + j <= d) {         ans = ans * (j + 1) % m;         sum += j;         j *= 2;       }       ans = ans * (d - sum + 1) % m;       ans += m - 1;       ans %= m;       cout << ans <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int ind = s.size() - 1;     for (int i = 0; i < s.size(); ++i) {       if (s[i] ==  0 ) {         ind = i;         break;       }     }     bool flag = 0;     for (int i = 0; i < s.size(); ++i) {       if (!flag && s[i] ==  0 ) continue;       if (s[i] ==  1 ) flag = 1;       if (flag && i != ind) printf( %c , s[i]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long solve(int n) {     int x = n;     long long cnt = 0, ans = 0;     while (x) {       x = x / 10;       cnt++;     }     ans = n * cnt + cnt - 1;     int k = 1;     for (int i = 0; i < cnt - 1; i++) {       k = k * 10;       ans = ans - k;     }     return ans;   }   int main() {     int n;     long long ans;     scanf( %d , &n);     if (n < 10) {       cout << n;     } else {       cout << solve(n);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T qmin(const T &a, const T &b) {     return a < b ? a : b;   }   template <typename T>   inline T qmax(const T &a, const T &b) {     return a > b ? a : b;   }   template <typename T>   inline void getmin(T &a, const T &b) {     if (a > b) a = b;   }   template <typename T>   inline void getmax(T &a, const T &b) {     if (a < b) a = b;   }   inline void fileio(string s) {     freopen((s +  .in ).c_str(),  r , stdin);     freopen((s +  .out ).c_str(),  w , stdout);   }   const int inf = (int)1e9 + 7;   const long long linf = (long long)1e17 + 7;   const int N = 2e5 + 7;   struct vec {     long long x, y;     inline vec(const long long &_x = 0, const long long &_y = 0) : x(_x), y(_y) {}     inline vec operator+(const vec &b) { return vec(x + b.x, y + b.y); }     inline vec operator-(const vec &b) { return vec(x - b.x, y - b.y); }     inline long long dot(const vec &b) { return x * b.x + y * b.y; }     inline long long det(const vec &b) { return x * b.y - y * b.x; }   } a[N];   long long val[N];   int n;   double ans = 1e18;   inline void calc() {     for (register int i = (n + 1); i <= (n << 1); ++i) a[i] = a[i - n];     for (register int i = (2); i <= (n << 1); ++i) val[i] = a[i].det(a[i - 1]);     for (register int i = (2); i <= (n << 1); ++i) val[i] += val[i - 1];     int lst = 2;     for (register int i = (1); i <= (n); ++i) {       vec v1 = a[i + 1] - a[i];       long long cur = v1.dot(a[lst] - a[i]), tmp;       double len = (double)((a[i + 1].x - a[i].x) * (a[i + 1].x - a[i].x)) +                    (double)((a[i + 1].y - a[i].y) * (a[i + 1].y - a[i].y));       while (lst < (n << 1) && (tmp = v1.dot(a[lst + 1] - a[i])) >= cur)         cur = tmp, ++lst;       getmin(ans, cur / len * fabs(v1.det(a[lst] - a[i])) -                       fabs(val[lst] - val[i] + a[i].det(a[lst])));     }   }   int main() {     scanf( %d , &n);     for (register int i = (1); i <= (n); ++i) scanf( %lld%lld , &a[i].x, &a[i].y);     ans = 1e18;     calc();     reverse(a + 1, a + n + 1);     calc();     printf( %.10lf n , ans / 2);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int k;     vector<int> A;     for (int i = 0; i < 4; ++i) {       cin >> k;       A.push_back(k);     }     sort(A.begin(), A.end());     if (A[0] + A[1] + A[2] == A[3] or A[0] + A[3] == A[1] + A[2]) {       cout <<  YES ;     } else {       cout <<  NO ;     }     return 0;   }