malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   struct Amulet {     char p[2][2];     void Read() { cin >> p[0][0] >> p[0][1] >> p[1][0] >> p[1][1]; }     Amulet Rotate() const {       Amulet ret(*this);       ret.p[0][0] = this->p[0][1];       ret.p[0][1] = this->p[1][1];       ret.p[1][0] = this->p[0][0];       ret.p[1][1] = this->p[1][0];       return ret;     }   };   bool Equiv(Amulet const& a1, Amulet const& a2) {     return a1.p[0][0] == a2.p[0][0] && a1.p[0][1] == a2.p[0][1] &&            a1.p[1][0] == a2.p[1][0] && a1.p[1][1] == a2.p[1][1];   }   bool operator==(Amulet const& a1, Amulet const& a2) {     Amulet tmp(a1);     for (int i = 0; i < 4; ++i) {       if (Equiv(tmp, a2)) return true;       tmp = tmp.Rotate();     }     return false;   }   int main() {     vector<Amulet> v;     int n;     cin >> n;     for (int i = 0; i < n; ++i) {       Amulet a;       a.Read();       vector<Amulet>::iterator it = find(v.begin(), v.end(), a);       if (it == v.end()) {         v.push_back(a);       }       char dummy;       cin >> dummy >> dummy;     }     cout << v.size() << endl;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int a;     int id;     bool operator<(const node &b) const {       if (a != b.a)         return a < b.a;       else         return id > b.id;     }   };   struct node que[305];   bool vis[305];   int main() {     int t, n, m;     scanf( %d , &t);     while (t--) {       memset(vis, 0, sizeof(vis));       scanf( %d%d , &n, &m);       for (int i = 1; i <= m; i++) {         scanf( %d , &que[i].a);         que[i].id = i;       }       sort(que + 1, que + m + 1);       long long ans = 0;       for (int i = 1; i <= m; i++) {         for (int j = 1; j < que[i].id; j++) ans += vis[j];         vis[que[i].id] = 1;       }       printf( %lld n , ans);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k;     cin >> n >> k;     int ara[2 * n + 1], count = 0;     for (int i = 0; i <= 2 * n; i++) {       cin >> ara[i];     }     for (int i = 0; count < k; i++) {       if (ara[i] + 1 < ara[i + 1] && ara[i + 1] - 1 > ara[i + 2]) {         ara[i + 1]--;         count++;       }     }     for (int i = 0; i < 2 * n; i++) {       cout << ara[i] <<    ;     }     cout << ara[2 * n] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     string s;     cin >> s;     set<char> ss;     for (char c : s) ss.insert(c);     if (ss.size() < n)       cout <<  NO  << endl;     else {       cout <<  YES  << endl;       int vis[30];       memset(vis, 0, sizeof vis);       string res =   ;       for (char c : s) {         if (n == 1)           res += c;         else {           if (res.size() > 0 and !vis[c -  a ]) {             n--;             vis[c -  a ] = 1;             cout << res << endl;             res = string(1, c);           } else {             vis[c -  a ] = 1;             res += c;           }         }       }       cout << res << endl;     }     return 0;   }
#include <bits/stdc++.h>   long long stk[300001][3], top = 1, n, m, best = 1, nownum, K, B;   long long eval(long long x) {     return (K + stk[x][0]) * stk[x][2] + B + stk[x][1];   }   double intersect(long long x, long long y) {     return (double)(stk[x][0] - stk[y][0]) / (stk[y][1] - stk[x][1]);   }   bool comp(long long x) {     return eval(top) * (stk[top][2] - stk[top - 1][2]) >=            (eval(top - 1) - eval(top)) * (x - stk[top][2]);   }   signed main() {     scanf( %I64d%I64d , &nownum, &m);     --nownum;     for (long long i = 1, opt, k, b, s; i <= m; i++) {       scanf( %I64d , &opt);       if (opt == 1) {         scanf( %I64d , &k);         top = 1;         K = B = 0;         stk[top][0] = 0;         stk[top][1] = 0;         stk[top][2] = 0;         nownum += k;       } else if (opt == 2) {         scanf( %I64d , &k);         if (eval(top) == 0) {           nownum += k;           goto loop;         }         while (top > 1 && comp(nownum + 1)) --top;         ++top;         stk[top][0] = -K;         stk[top][1] = -B;         stk[top][2] = nownum + 1;         nownum += k;       } else {         scanf( %I64d%I64d , &b, &s);         K += s;         B += b;         while (top > 1 && eval(top - 1) <= eval(top)) --top;       }     loop:       printf( %I64d %I64d n , stk[top][2] + 1, eval(top));     }   }
#include <bits/stdc++.h>   using namespace std;   int to[55][35][35][4][3];   int dx[] = {0, 1, 0, -1};   int dy[] = {1, 0, -1, 0};   int Sign(int x) { return x > 0 ? 1 : x < 0 ? -1 : 0; }   int main() {     int n, b;     cin >> n >> b;     ++b;     for (int i = 0; i < b; ++i) {       for (int j = 0; j < b; ++j) {         for (int d = 0; d < 4; ++d) {           int nx = i + dx[d], ny = j + dy[d];           to[0][i][j][d][0] = nx;           to[0][i][j][d][1] = ny;           to[0][i][j][d][2] = d;         }       }     }     for (int i = 0; i < n; ++i) {       int x0, y0, x1, y1;       cin >> x0 >> y0 >> x1 >> y1;       int dx = Sign(x1 - x0), dy = Sign(y1 - y0);       int dd = 0;       for (int j = 0; j < 4; ++j) {         if (dx == ::dx[j] && dy == ::dy[j]) {           dd = j;           break;         }       }       while (x0 != x1 || y0 != y1) {         for (int j = 0; j < 4; ++j) {           to[0][x0][y0][j][0] = x0 + dx;           to[0][x0][y0][j][1] = y0 + dy;           to[0][x0][y0][j][2] = dd;         }         x0 += dx;         y0 += dy;       }       for (int j = 0; j < 4; ++j) {         to[0][x0][y0][j][0] = x0 + dx;         to[0][x0][y0][j][1] = y0 + dy;         to[0][x0][y0][j][2] = dd;       }     }     for (int i = 1; i < 55; ++i) {       for (int x = 0; x < b; ++x) {         for (int y = 0; y < b; ++y) {           for (int j = 0; j < 4; ++j) {             int nx = to[i - 1][x][y][j][0], ny = to[i - 1][x][y][j][1],                 dd = to[i - 1][x][y][j][2];             if (nx < 0 || nx >= b || ny < 0 || ny >= b) {               to[i][x][y][j][0] = nx;               to[i][x][y][j][1] = ny;               to[i][x][y][j][2] = -1;             } else {               to[i][x][y][j][0] = to[i - 1][nx][ny][dd][0];               to[i][x][y][j][1] = to[i - 1][nx][ny][dd][1];               to[i][x][y][j][2] = to[i - 1][nx][ny][dd][2];             }           }         }       }     }     int q;     cin >> q;     for (int i = 0; i < q; ++i) {       int x, y;       char d;       long long t;       cin >> x >> y >> d >> t;       int dir = 0;       if (d ==  L ) {         dir = 3;       } else if (d ==  R ) {         dir = 1;       } else if (d ==  D ) {         dir = 2;       } else {         dir = 0;       }       for (int j = 0; t; ++j, t >>= 1) {         if (t & 1) {           int nx = to[j][x][y][dir][0];           int ny = to[j][x][y][dir][1];           dir = to[j][x][y][dir][2];           x = nx;           y = ny;         }         if (x < 0 || x >= b || y < 0 || y >= b) {           break;         }       }       x = max(0, min(x, b - 1));       y = max(0, min(y, b - 1));       cout << x <<     << y <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, k, p, x;     cin >> n >> k >> p;     int impair(k - p);     vector<int> pai, imp;     for (int i = 0; i < n; ++i) {       cin >> x;       if (x & 1)         imp.push_back(x);       else         pai.push_back(x);     }     int avpair(pai.size()), avimpair(imp.size());     avimpair -= impair;     if (avimpair < 0 || (avpair + (avimpair >> 1)) < p || (avimpair & 1)) {       cout <<  NO ;       return 0;     }     cout <<  YES n ;     vector<vector<int> > res;     res.resize(k);     int iimp(0), ipai(0);     for (int i = 0; i < impair; ++i) res[i].push_back(imp[iimp++]);     for (int i = impair; i < k; ++i)       if (ipai < pai.size())         res[i].push_back(pai[ipai++]);       else {         res[i].push_back(imp[iimp++]);         res[i].push_back(imp[iimp++]);       }     while (ipai < pai.size()) res[0].push_back(pai[ipai++]);     while (iimp < imp.size()) res[0].push_back(imp[iimp++]);     for (int i = 0; i < k; ++i) {       cout << res[i].size() <<    ;       for (int j = 0; j < res[i].size(); ++j) cout << res[i][j] <<    ;       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline void read(T &x) {     x = 0;     bool f = false;     char ch = getchar();     while (!isdigit(ch)) {       f |= ch ==  - , ch = getchar();     }     while (isdigit(ch)) {       x = (x << 1) + (x << 3) + (ch ^ 48);       ch = getchar();     }     x = f ? -x : x;     return;   }   template <typename T>   inline void write(T x) {     if (x < 0) x = -x, putchar( - );     if (x > 9) write(x / 10);     putchar(x % 10 ^ 48);     return;   }   const int N = 1e3 + 5, MOD = 998244353;   int n, m, val[N], dp[N], Ans, C[N][N];   int main() {     read(n);     for (int i = 1; i <= n; i++) read(val[i]), C[i][i] = C[i][0] = 1;     for (int i = 1; i <= n; i++)       for (int j = 1; j < i; j++)         C[i][j] = (C[i - 1][j - 1] + C[i - 1][j] > +MOD                        ? C[i - 1][j - 1] + C[i - 1][j] - MOD                        : C[i - 1][j - 1] + C[i - 1][j]);     dp[n + 1] = 1;     for (int i = n; i >= 1; i--) {       if (val[i] <= 0) continue;       for (int j = val[i] + i + 1; j <= n + 1; j++)         dp[i] = (dp[i] + 1ll * dp[j] * C[j - i - 1][val[i]] % MOD > +MOD                      ? dp[i] + 1ll * dp[j] * C[j - i - 1][val[i]] % MOD - MOD                      : dp[i] + 1ll * dp[j] * C[j - i - 1][val[i]] % MOD);     }     for (int i = 1; i <= n; i++)       Ans = (Ans + dp[i] > +MOD ? Ans + dp[i] - MOD : Ans + dp[i]);     write(Ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class t>   t mag(t a) {     return a > 0 ? a : -a;   }   template <class T, class U>   T cdiv(T num, U den) {     return (num / den) + ((num % den) > 0);   }   std::ifstream term( /dev/tty );   std::string tempstring;   using ll = int_fast64_t;   using ii = pair<int, int>;   using vi = vector<int>;   using vl = vector<ll>;   using vii = vector<ii>;   const int &sij = 400010;   const ll &mod = 998244353ll;   int n;   ll add(ll a, ll b) { return (a + b) % mod; }   int esc(int tcase) {     cin >> n;     vi vec(n);     for (auto &e : vec) cin >> e;     vl dp0(201), sdp0(201), dp1(201), sdp1(201);     for (int i = 1; i <= 200; i++) {       if (vec.back() == -1 or i == vec.back()) dp0[i] = 1;     }     partial_sum(dp0.begin(), dp0.end(), sdp0.begin(), add);     partial_sum(dp1.begin(), dp1.end(), sdp1.begin(), add);     ;     auto get0 = [&](int l, int r) -> ll {       if (r < l) return 0;       return (sdp0[r] - sdp0[l - 1] + mod) % mod;     };     auto get1 = [&](int l, int r) -> ll {       if (r < l) return 0;       return (sdp1[r] - sdp1[l - 1] + mod) % mod;     };     for (auto i = n - 2; i >= 0; i--) {       vl ndp0(201), ndp1(201);       for (int x = 1; x <= 200; x++) {         if (vec[i] == -1 or x == vec[i]) {           ndp0[x] = (get0(1, x - 1) + get1(1, x - 1)) % mod;           ndp1[x] = (get1(x + 1, 200) + get1(x, x) + get0(x, x)) % mod;         }       }       partial_sum(ndp0.begin(), ndp0.end(), sdp0.begin(), add);       partial_sum(ndp1.begin(), ndp1.end(), sdp1.begin(), add);       ;       ;       ;     }     cout << get1(1, 200) <<   n ;     return 0;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int tc = 1;     for (int i = 1; i <= tc; i++) esc(i);   }
#include <bits/stdc++.h>   using namespace std;   class Solve {    public:     int num;     int inputNum[2005];     int inversion[2005][2];     int sequence[2005];       public:     Solve() {       num = 0;       memset(inputNum, 0, sizeof(inputNum));       memset(inversion, 0, sizeof(inversion));       memset(sequence, 0, sizeof(sequence));     }     void stat() {       for (int i = 0; i < num; ++i) {         for (int j = 0; j < i; ++j) {           if (inputNum[j] < inputNum[i]) {             ++inversion[i][0];           }         }       }       for (int i = 0; i < num; ++i) {         for (int j = i + 1; j < num; ++j) {           if (inputNum[i] > inputNum[j]) {             ++inversion[i][1];           }         }       }     }     void calculate() {       for (int i = 0; i < num; ++i) {         if (inversion[i][0] < inversion[i][1]) {           sequence[i] = -inputNum[i];         } else {           sequence[i] = inputNum[i];         }       }     }     int getResult() {       int total = 0;       for (int i = 0; i < num; ++i) {         for (int j = i + 1; j < num; ++j) {           if (sequence[i] > sequence[j]) {             ++total;           }         }       }       return total;     }     void readData() {       cin >> num;       for (int i = 0; i < num; ++i) {         cin >> inputNum[i];         if (inputNum[i] < 0) {           inputNum[i] = -1 * inputNum[i];         }       }     }     int facade() {       readData();       stat();       calculate();       return getResult();     }   };   int main() {     Solve solve;     cout << solve.facade() << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, x, y;     cin >> n >> m;     y = 3 * m;     x = 2 * n;     for (int i = 6; i <= x && i <= y; i += 6) {       if (x <= y)         x += 2;       else         y += 3;     }     cout << max(x, y);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 505;   bool arr[N][N];   int dp[N][N];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n, m, k;     cin >> n >> m >> k;     for (int i = 1; i <= n; i++) {       string s;       cin >> s;       for (int j = 1; j <= m; j++) {         arr[i][j] = (int)(s[j - 1] -  0 );       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         if (arr[i][j] && arr[i - 1][j] && arr[i + 1][j] && arr[i][j - 1] &&             arr[i][j + 1]) {           dp[i][j] = 1;         }       }     }     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         dp[i][j] += dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1];       }     }     long long int ans = 0;     for (int a = 2; a < n; a++) {       for (int b = a; b < n; b++) {         int ptr = 1;         for (int c = 2; c < m; c++) {           while (ptr < m &&                  (dp[a - 1][c - 1] - dp[b][c - 1] - dp[a - 1][ptr] + dp[b][ptr] <                   k)) {             ptr++;           }           ans += (m - ptr);         }       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   static long long mi[400005][20];   static bool mark[400005][20];   static long long psum[400005];   long long f(int x, int k) {     if (k == 0) return psum[x];     if (mark[x][k]) return mi[x][k];     mark[x][k] = 1;     return mi[x][k] = min(f(x, k - 1), f(x + (1 << (k - 1)), k - 1));   }   long long qry(int l, int r) {     int t = r - l + 1;     int lg = 31 - __builtin_clz(t);     return min(f(l, lg), f(r - (1 << lg) + 1, lg));   }   int main() {     long long n, a, b, c, d, start, len;     scanf( %lld %lld %lld %lld %lld %lld %lld , &n, &a, &b, &c, &d, &start, &len);     vector<pair<long long, long long> > v;     for (long long i = 0; i < n; i++) {       long long x, y;       scanf( %lld %lld , &x, &y);       v.push_back(make_pair(y, x));     }     if (v[0].first == 0)       psum[0] = -d;     else       psum[0] = c;     for (int i = 1; i < n; i++) {       if (v[i].first)         psum[i] = psum[i - 1] + c;       else         psum[i] = psum[i - 1] - d;     }     psum[n] = 1000000000000000000;     vector<long long> t;     t.push_back(0);     for (int i = 0; i < n; i++) {       t.push_back(v[i].second + 1);       if (v[i].second - len + 1 >= 0) t.push_back(v[i].second - len + 1);     }     sort(t.begin(), t.end());     int l = 0, r = 0;     long long at = start;     for (int i = 0; i < t.size(); i++) {       while (l < v.size() && v[l].second < t[i]) {         if (v[l].first)           at += a;         else           at -= b;         if (at < 0) {           printf( -1 n );           return 0;         }         l++;       }       while (r < v.size() && v[r].second < t[i] + len) r++;       long long low = qry(l, r - 1) - (l > 0 ? psum[l - 1] : 0) + at;       if (low >= 0) {         printf( %lld n , t[i]);         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int get() {     char ch;     while (ch = getchar(), (ch <  0  || ch >  9 ) && ch !=  - )       ;     if (ch ==  - ) {       int s = 0;       while (ch = getchar(), ch >=  0  && ch <=  9 ) s = s * 10 + ch -  0 ;       return -s;     }     int s = ch -  0 ;     while (ch = getchar(), ch >=  0  && ch <=  9 ) s = s * 10 + ch -  0 ;     return s;   }   const int mo = 1e9 + 7;   const int N = 2e6 + 5;   int cnt[N];   int val[N];   int lst[N];   int pri[N], k;   int n;   int tim[N];   bool bz[N];   int main() {     n = get();     for (int i = 1; i <= n; i++) {       int x = get();       cnt[x]++;     }     lst[1] = 1;     for (int i = 2; i <= 2e6; i++) {       if (!lst[i]) pri[++k] = lst[i] = i;       for (int j = 1; j <= k; j++) {         if (1ll * pri[j] * i > 2e6) break;         lst[i * pri[j]] = pri[j];         if (i % pri[j] == 0) break;       }     }     for (int i = 1; i <= 2e6; i++) val[i] = 1;     int C = 0;     for (int i = 2e6; i >= 2; i--) {       for (int T = 1; T <= cnt[i]; T++) {         if (val[i] < i)           bz[i] = 1, tim[i] = 1, val[i] = i;         else {           bz[i - 1] = 1;           int x = i - 1;           while (x > 1) {             int v = lst[x];             int t = 1;             while (x % v == 0) {               x /= v;               t = t * v;             }             if (t > val[v]) {               val[v] = t;               tim[v] = 1;             } else if (val[v] == t)               tim[v]++;           }         }       }     }     for (int i = 1; i <= 2e6; i++)       if (bz[i]) {         bool can = 1;         for (int x = i; x > 1;) {           int v = lst[x], t = 1;           for (; x % v == 0;) x /= v, t *= v;           if (val[v] == t && tim[v] == 1) can = 0;         }         if (can) {           C = 1;           break;         }       }     int ans = 1;     for (int i = 1; i <= 2e6; i++) ans = 1ll * ans * val[i] % mo;     ans = (ans + C) % mo;     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool vis[50];   bool OK(vector<set<int> > v) {     for (int i = 0; i < (int)v.size(); i++)       if ((int)v[i].size() > 3) return 1;     return 0;   }   int Find(vector<set<int> > v, int x) {     for (int i = 0; i < (int)v.size(); i++)       if (find(v[i].begin(), v[i].end(), x) != v[i].end()) return i;     return -1;   }   int main() {     int n, q, x, y, ex, ey, c = 0;     scanf( %d %d , &n, &q);     if (n % 3) {       cout << -1;       return 0;     }     vector<set<int> > v(n / 3);     while (q--) {       scanf( %d %d , &x, &y);       vis[x] = 1, vis[y] = 1;       ex = Find(v, x), ey = Find(v, y);       if (ex != -1)         v[ex].insert(y);       else if (ey != -1)         v[ey].insert(x);       else {         if (c == n / 3) {           cout << -1;           return 0;         }         v[c].insert(x), v[c].insert(y), c++;       }     }     if (OK(v)) {       cout << -1;       return 0;     }     c = 1;     for (int i = 0; i < (int)v.size(); i++) {       for (int j = 0; j < 3 - (int)v[i].size(); j++) {         for (int k = c; k < n + 1; k++)           if (!vis[k]) {             v[i].insert(k);             c = k + 1;             j--;             break;           }       }     }     for (int i = 0; i < (int)v.size(); i++) {       for (set<int>::iterator it = v[i].begin(); it != v[i].end(); it++)         printf( %d  , *it);       printf(  n );     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long w1, h1, w2, h2;     cin >> w1 >> h1 >> w2 >> h2;     long long ans = h1 + h2 + 2;     ans += h1 + h2 + 2 + (w1 - w2);     ans += w1 + w2;     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100005;   vector<int> cnt[N];   int res[N];   int main() {     int n;     while (cin >> n) {       for (int i = 1; i < N; i++) cnt[i].clear();       for (int i = 1; i <= n; i++) {         int v;         cin >> v;         cnt[v].push_back(i);       }       bool ok = true;       for (int i = 1; i < N; i++) {         if (i > 1 && cnt[i].size() > cnt[i - 1].size()) ok = false;         for (int j = 0; j < cnt[i].size(); j++) {           res[cnt[i][j]] = j + 1;         }       }       if (!ok) {         printf( %d n , -1);       } else {         printf( %d n , cnt[1].size());         for (int i = 1; i <= n; i++) printf( %d%c , res[i], i == n ?   n  :    );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     while (n--) {       int a, s, d;       cin >> a >> s >> d;       if (a > s) swap(a, s);       if (a > d) swap(a, d);       if (s > d) swap(s, d);       if (s == d) {         cout <<  YES  << endl;         cout << a <<     << a <<     << d << endl;       } else {         cout <<  NO  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1005;   const int INF = 1e9;   pair<int, int> NULLPOINT = make_pair(INF, INF);   int n;   int gcd(int x, int y) {     while (y) {       int t = x;       x = y;       y = t % y;     }     return x;   }   struct Line {     int x, y, xx, yy;     pair<int, int> slope() {       pair<int, int> ret = {x - xx, y - yy};       if (ret.second < 0) {         ret.first *= -1;         ret.second *= -1;       }       int g = gcd(abs(ret.first), ret.second);       ret.first /= g, ret.second /= g;       return ret;     }     pair<int, int> intersect(const Line &l) const {       long long den =           1LL * (x - xx) * (l.y - l.yy) - 1LL * (y - yy) * (l.x - l.xx);       if (den == 0) return NULLPOINT;       long long c1 = 1LL * x * yy - 1LL * y * xx;       long long c2 = 1LL * l.x * l.yy - 1LL * l.y * l.xx;       long long ix = c1 * (l.x - l.xx) - (x - xx) * c2;       long long iy = c1 * (l.y - l.yy) - (y - yy) * c2;       if (ix % den != 0) return NULLPOINT;       if (iy % den != 0) return NULLPOINT;       ix /= den;       iy /= den;       if (ix < min(x, xx) || ix > max(x, xx) || ix < min(l.x, l.xx) ||           ix > max(l.x, l.xx))         return NULLPOINT;       if (iy < min(y, yy) || iy > max(y, yy) || iy < min(l.y, l.yy) ||           iy > max(l.y, l.yy))         return NULLPOINT;       return pair<int, int>(ix, iy);     }   };   Line lines[N];   int main() {     scanf( %d , &n);     for (int i = 0; i < n; ++i) {       scanf( %d %d %d %d , &lines[i].x, &lines[i].y, &lines[i].xx, &lines[i].yy);     }     long long ans = 0;     for (int i = 0; i < n; ++i) {       pair<int, int> slope = lines[i].slope();       if (slope.first == 0)         ans += abs((lines[i].y - lines[i].yy) / slope.second) + 1;       else         ans += abs((lines[i].x - lines[i].xx) / slope.first) + 1;     }     set<pair<int, int>> intersects;     intersects.insert(NULLPOINT);     for (int i = 0; i < n; ++i) {       set<pair<int, int>> lineIntersects;       lineIntersects.insert(NULLPOINT);       for (int j = 0; j < n; ++j) {         pair<int, int> p = lines[i].intersect(lines[j]);         lineIntersects.insert(p);         intersects.insert(p);       }       ans -= lineIntersects.size() - 1;     }     ans += intersects.size() - 1;     printf( %lld n , ans);     return 0;   }
#include <bits/stdc++.h>   int main() {     long long n, k;     scanf( %lld%lld , &n, &k);     if (k < 2) {       printf( %lld , n);       return 0;     }     long long s = 1;     while (s - 1 < n) s *= 2;     printf( %lld , s - 1);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     cin.sync_with_stdio(0);     cin.tie(0);     cin.exceptions(cin.failbit);     int n;     cin >> n;     vector<long long> a(n);     long long s = 0;     for (int i = 0; i < n; i++) {       cin >> a[i];       s += a[i];     }     sort(a.begin(), a.end());     reverse(a.begin(), a.end());     if (s % 2 == 1) {       cout <<  NO  << endl;       return 0;     }     if (a[0] <= s / 2) {       cout <<  YES  << endl;     } else {       cout <<  NO  << endl;     }     return 0;   }