malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long l, r;     cin >> l >> r;     long long temp = r;     long long num = 1, ans = 1;     while (temp) {       temp /= 10;       num *= 10;     }     num--;     long long left_lim = (num) / 10;     long long mid = (num + 1) / 2;     if (r <= mid) {       ans = (num - r) * r;     } else {       if (l <= mid) {         ans = (num - mid) * (mid);       } else {         ans = (num - l) * l;       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m, i, j;     cin >> n;     cin >> m;     int A[n], B[m];     for (i = 0; i < n; i++) cin >> A[i];     for (j = 0; j < m; j++) cin >> B[j];     for (j = 0; j < n; j++) {       for (i = 0; i < m; i++) {         if (A[j] == B[i]) cout << A[j] <<    ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, m, k, x, s, a[200005], b[200005], c[200005], d[200005], ans;   int bfind(int t) {     int lo = 0, hi = k - 1, mid;     while (lo < hi) {       mid = lo + (hi - lo + 1) / 2;       if (d[mid] > t)         hi = mid - 1;       else         lo = mid;     }     return lo;   }   int main() {     cin >> n >> m >> k >> x >> s;     for (int i = 0; i < m; i++) scanf( %I64d , &a[i]);     for (int i = 0; i < m; i++) scanf( %I64d , &b[i]);     for (int i = 0; i < k; i++) scanf( %I64d , &c[i]);     for (int i = 0; i < k; i++) scanf( %I64d , &d[i]);     ans = x * n;     for (int i = 0; i < m; i++) {       if (b[i] <= s) ans = min(ans, a[i] * n);     }     for (int i = 0; i < k; i++) {       if (d[i] <= s) ans = min(ans, x * (n - c[i]));     }     for (int i = 0; i < m; i++) {       if (b[i] + d[0] <= s) {         int idx = bfind(s - b[i]);         ans = min(ans, a[i] * (n - c[idx]));       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-10;   const int maxn = 100 + 10;   int n, m;   int a[maxn], b[maxn];   bitset<65> tt1[50000], tt2[50000];   vector<int> v;   map<int, int> mp;   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < m; i++) cin >> b[i];     bitset<65> *t1 = tt1 + 25000, *t2 = tt2 + 25000;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         t1[a[i] + b[j]][i] = 1;         t2[a[i] + b[j]][j] = 1;         if (!mp[a[i] + b[j]]) {           mp[a[i] + b[j]] = 1;           v.push_back(a[i] + b[j]);         }       }     }     int mine = -1;     for (int i = 0; i < v.size(); i++) {       for (int j = 0; j < v.size(); j++) {         int sum = (t1[v[i]] | t1[v[j]]).count() + (t2[v[i]] | t2[v[j]]).count();         if (sum > mine) mine = sum;       }     }     printf( %d n , mine);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a[2001000];   int Partition(int l, int r) {     int temp = l + rand() % (r - l);     swap(a[l], a[temp]);     int x = a[l], i = l - 1, j = r + 1;     while (1) {       do i++;       while (a[i] < x);       do j--;       while (a[j] > x);       if (i < j)         swap(a[i], a[j]);       else         return j;     }   }   void QuickSort(int l, int r) {     if (l < r) {       int q = Partition(l, r);       QuickSort(l, q);       QuickSort(q + 1, r);     }   }   int main() {     ios_base::sync_with_stdio(0);     int n;     cin >> n;     for (int i = 0; i < n; i++) cin >> a[i];     QuickSort(0, n - 1);     for (int i = 0, j = n - 1; i < j; i++, j--) swap(a[i], a[j]);     long long k = 0;     for (int i = 0; pow(4, i) <= n + 1; i++)       for (int j = 0; j < pow(4, i); j++) k += a[j];     cout << k << endl;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T sqr(const T &a) {     return a * a;   }   template <typename T>   inline int nread(vector<T> &a) {     int n;     cin >> n;     a.clear();     a.resize(n);     for (int i = 0; i < n; i++) cin >> a[i];     return n;   }   template <typename T>   inline void nwread(int n, vector<T> &a) {     a.clear();     a.resize(n);     for (int i = 0; i < n; i++) cin >> a[i];   }   const int N = 3001;   int gr[N][N], cg[N];   int res[N * N];   pair<int, int> que[N * N];   int main() {     int n, m, k;     cin >> n >> m >> k;     for (int i = 0; i < n; i++) cg[i] = 0;     for (int i = 0; i < m; i++) {       int x, y;       scanf( %d%d , &x, &y);       x--;       y--;       gr[x][cg[x]++] = y;       gr[y][cg[y]++] = x;     }     set<pair<pair<int, int>, int> > zapr;     for (int i = 0; i < k; i++) {       int x, y, z;       scanf( %d%d%d , &x, &y, &z);       x--;       y--;       z--;       zapr.insert(make_pair(make_pair(x, y), z));     }     map<pair<int, int>, int> path;     int qi = 0, qj = 1;     que[0] = make_pair(-1, 0);     while (qi < qj) {       pair<int, int> tek = que[qi++];       int pv = tek.first, tv = tek.second;       vector<int> nreb;       for (int i = 0; i < cg[tv];) {         int fv = gr[tv][i];         if (zapr.count(make_pair(tek, fv)))           i++;         else {           que[qj++] = make_pair(tv, fv);           path[make_pair(tv, fv)] = pv;           if (fv == n - 1) {             int lr = 2;             res[0] = fv;             res[1] = tv;             while (tv != 0) {               pv = path[make_pair(tv, fv)];               res[lr++] = pv;               fv = tv;               tv = pv;             }             reverse(res, res + lr);             cout << lr - 1 << endl;             for (int i = 0; i < lr; i++) printf( %d  , res[i] + 1);             return 0;           }           if (cg[tv]) gr[tv][i] = gr[tv][cg[tv] - 1];           cg[tv]--;         }       }     }     cout << -1;   }
#include <bits/stdc++.h>   using namespace std;   int a[210000];   long long dp[210000][2];   const long long INF = 1LL << 60;   int N;   void init() {     for (int i = 0; i < 210000; i++)       for (int j = 0; j < 2; j++) dp[i][j] = INF;   }   long long solve(int x, bool t) {     if (x <= 0 || x > N) return 0;     if (x == 1) return -1;     if (dp[x][t] == -INF) return dp[x][t] = -1;     if (dp[x][t] != INF) return dp[x][t];     dp[x][t] = -INF;     int i2 = x;     if (t)       i2 += a[x];     else       i2 -= a[x];     long long r = solve(i2, !t);     long long res;     if (r == -1)       res = -1;     else       res = a[x] + r;     return dp[x][t] = res;   }   int main() {     cin >> N;     for (int i = 2; i <= N; i++) cin >> a[i];     init();     for (int i = 1; i < N; i++) {       long long ret = solve(1 + i, false);       if (~ret) ret += i;       cout << ret << endl;     }     return 0;   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC target( sse4 )   using namespace std;   using ii = pair<int, int>;   using ll = long long;   const int N = 1e5 + 5;   const int mod = 1e9 + 7;   char str1[50005], str2[50005];   int n, m;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> str1;     n = strlen(str1);     for (int sz = 1; sz <= n / 2; sz++) {       m = sz;       int cur = 0;       for (int i = sz; i < n; i++) {         if (str1[i] == str1[i - sz])           cur++;         else           cur = 0;         str2[m++] = str1[i];         if (cur == sz) cur = 0, m -= sz;       }       for (int i = sz; i < m; i++) str1[i] = str2[i];       n = m;     }     for (int i = 0; i < n; i++) cout << str1[i];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     scanf( %d%d , &n, &m);     if (n == 1)       printf( 1 n );     else {       if (m * 2 <= n)         printf( %d n , m + 1);       else         printf( %d n , m - 1);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double pi = 3.1415926535897;   int main() {     double d, h, v, e;     cin >> d >> h >> v >> e;     double s = (-1 * h) / (e - ((4 * v) / (pi * d * d)));     if (s >= 0)       cout <<  YES  << endl << s;     else       cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   void per() { cerr << endl; }   template <typename Head, typename... Tail>   void per(Head H, Tail... T) {     cerr << H <<    ;     per(T...);   }   template <class T>   bool uin(T& a, T b) {     return a > b ? (a = b, true) : false;   }   template <class T>   bool uax(T& a, T b) {     return a < b ? (a = b, true) : false;   }   template <class U, class V>   ostream& operator<<(ostream& out, const pair<U, V>& a) {     return out <<  (  << a.first <<  ,   << a.second <<  ) ;   }   template <class U, class V>   istream& operator>>(istream& in, pair<U, V>& a) {     return in >> a.first >> a.second;   }   template <typename W,             typename T = typename enable_if<!is_same<W, string>::value,                                             typename W::value_type>::type>   ostream& operator<<(ostream& out, const W& v) {     out <<  {  ;     for (const auto& first : v) out << first <<  ,  ;     return out <<  } ;   }   template <class T>   void readArr(T from, T to) {     for (auto i = from; i != to; ++i) cin >> *i;   }   mt19937 mrand(1337);   unsigned int myRand32() { return mrand() & (unsigned int)(-1); }   unsigned long long myRand64() {     return ((unsigned long long)myRand32() << 32) ^ myRand32();   }   const int mod = 1000000007;   void add(int& a, int b) {     a += b;     if (a >= mod) a -= mod;   }   void dec(int& a, int b) {     a -= b;     if (a < 0) a += mod;   }   int mult(int a, int b) { return a * (long long)b % mod; }   int bp(int a, int b) {     int res = 1;     while (b > 0) {       if (b & 1) res = mult(res, a);       a = mult(a, a);       b >>= 1;     }     return res;   }   int main() {     int vl = 1, vr = 1000000000;     cout <<  ? 1 1  << endl;     int base1;     cin >> base1;     while (vl + 1 < vr) {       int vm = (vl + vr) >> 1;       cout <<  ? 1   << vm << endl;       int first;       cin >> first;       if (first == base1 - (vm - 1))         vl = vm;       else         vr = vm;     }     int y1 = vl;     int x1 = base1 - (y1 - 1) + 1;     cout <<  ? 1000000000 1  << endl;     int base2;     cin >> base2;     int x2 = 1000000000 - (base2 - (y1 - 1));     cout <<  ? 1 1000000000  << endl;     int base3;     cin >> base3;     int y2 = 1000000000 - (base3 - (x1 - 1));     cout <<  !   << x1 <<     << y1 <<     << x2 <<     << y2 << endl;   }
#include <bits/stdc++.h>   int main() {     int i, j, k, n, t, c1, c2, c3, c4, c5;     scanf( %d%d%d%d%d , &c1, &c2, &c3, &c4, &c5);     t = c1 + c2 + c3 + c4 + c5;     if (t == 0)       printf( -1 n );     else if (t % 5 == 0)       printf( %d n , t / 5);     else       printf( -1 n );   }
#include <bits/stdc++.h>   using namespace std;   const int BIG = 1000200;   char buf[BIG];   int skip0[BIG], skip1[BIG];   int vpre[BIG];   struct E {     int to;     char sign;     int pw;   };   vector<E> vg[BIG];   int main() {     while (scanf(  %s , buf) != EOF) {       string s(buf);       s =  00  + s;       int N = (int)((s).size());       int prev0 = 0, prev1 = 0;       memset((skip0), (-1), sizeof(skip0));       memset((skip1), (-1), sizeof(skip1));       for (int i = 0; i < (int)(N); ++i) {         skip0[i] = prev0;         skip1[i] = prev1;         if (s[i] ==  0 ) {           prev0 = i;         }         if (s[i] ==  1 ) {           prev1 = i;         }       }       for (int i = 0; i < (int)(BIG); ++i) vg[i].clear();       for (int i = 0; i < (int)(N); ++i) {         if (i == 0) continue;         vg[i].push_back((E){skip1[i],  + , N - 1 - i});         vg[i].push_back((E){skip0[i],  - , N - 1 - i});       }       int start = -1;       for (int i = 0; i < (int)(N); ++i)         if (s[N - 1 - i] ==  1 ) {           start = N - 1 - i;           break;         }       assert(start >= 0);       queue<pair<int, int> > q;       memset((vpre), (-1), sizeof(vpre));       q.push(make_pair(start, -2));       while (!q.empty()) {         int curr = q.front().first;         int prev = q.front().second;         q.pop();         if (vpre[curr] != -1) continue;         vpre[curr] = prev;         if (curr == 0) break;         for (__typeof((vg[curr]).begin()) e = (vg[curr]).begin();              e != (vg[curr]).end(); ++e) {           q.push(make_pair(e->to, curr));         }       }       assert(vpre[0] >= 0);       vector<E> outp;       for (int curr = 0; curr >= 0; curr = vpre[curr]) {         int prev = vpre[curr];         for (__typeof((vg[prev]).begin()) e = (vg[prev]).begin();              e != (vg[prev]).end(); ++e) {           if (e->to == curr) {             outp.push_back(*e);             break;           }         }       }       printf( %d n , (int)((outp).size()));       for (int i = 0; i < (int)((int)((outp).size())); ++i)         printf( %c2^%d n , outp[i].sign, outp[i].pw);     }   }
#include <bits/stdc++.h>   using namespace std;   const int NMAX = 5e3;   const double eps = 1e-14;   double dp[NMAX + 5][NMAX + 5];   int n, k;   double p[NMAX + 5];   double np[NMAX + 5];   int t[NMAX + 5];   int main() {     scanf( %d %d , &n, &k);     for (int i = 1; i <= n; i++) {       int x;       scanf( %d %d , &x, &t[i]);       p[i] = x / 100.0;       np[i] = (100 - x) / 100.0;     }     dp[0][0] = 1;     for (int i = 0; i <= n; i++) {       double prob = 1;       for (int j = 1; j <= t[i + 1]; j++) {         prob *= np[i + 1];       }       for (int j = i; j <= k; j++) {         if (dp[i][j] < eps) {           continue;         }         if (j < k) {           dp[i][j + 1] += dp[i][j] * np[i];           dp[i + 1][j + 1] += dp[i][j] * p[i + 1];           if (j <= k - t[i + 1]) {             dp[i + 1][j + t[i + 1]] += dp[i][j] * prob;             if (j <= k - t[i + 1] - 1) {               dp[i + 1][j + t[i + 1] + 1] -= dp[i][j] * prob;             }           }         }       }     }     double ans = 0;     for (int i = 1; i < n; i++) {       double prob = 1;       for (int j = k; j > k - t[i + 1]; j--) {         ans += i * dp[i][j] * prob;         prob *= (1 - p[i + 1]);       }     }     for (int j = 1; j <= k; j++) {       ans += n * dp[n][j];     }     printf( %.9f n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool cmp(long long a, long long b) {     if (a > b) return true;     return false;   }   long long n, dp[100010], res;   pair<long long, long long> a[100010];   map<long long, long long> m;   map<long long, long long>::iterator it;   int main() {     int t = 1;     while (t--) {       scanf( %lld , &n);       for (int i = 0; i < n; i++) {         scanf( %lld%lld , &a[i].first, &a[i].second);       }       sort(a, a + n);       for (int i = 0; i < n; i++) {         m[a[i].first] = i;         it = m.lower_bound(a[i].first - a[i].second);         if (it == m.begin())           dp[i] = 1;         else {           --it;           dp[i] = 1 + dp[it->second];         }         res = max(dp[i], res);       }       cout << n - res <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, i, sum1 = 0, sum2 = 0, a[200];     cin >> n;     for (i = 0; i < n; i++) {       cin >> a[i];       if (a[i] < 0) {         sum2 += a[i];       } else         sum1 += a[i];     }     cout << sum1 - sum2;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename U>   inline void smin(T &a, U b) {     if (a > b) a = b;   }   template <typename T, typename U>   inline void smax(T &a, U b) {     if (a < b) a = b;   }   int ans[200200], vst[200200], pos[200200], neg[200200];   set<int> s[200200];   priority_queue<pair<int, int> > q;   int main() {     int n, m, k, first;     cin >> n >> m;     for (int i = 1; i <= n; i++) {       scanf( %d , &k);       q.push(pair<int, int>(-k, i));       while (k--) {         scanf( %d , &first);         s[i].insert(first);         if (first > 0)           pos[first] = i;         else           neg[-first] = i;       }     }     for (int i = 1; i <= m; i++) {       if (!pos[i] || !neg[i]) {         int u = pos[i] ? pos[i] : neg[i];         vst[u] = 1;         ans[i] = (pos[i] == u);       }     }     while (!q.empty()) {       int u = q.top().second;       q.pop();       if (vst[u]) continue;       vst[u] = 1;       if (s[u].empty()) {         puts( NO );         return 0;       }       first = *s[u].begin();       if (first > 0) {         ans[first] = 1;         if (neg[first]) {           s[neg[first]].erase(-first);           q.push(pair<int, int>(-s[neg[first]].size(), neg[first]));         }       } else {         first = -first;         ans[first] = 0;         if (pos[first]) {           s[pos[first]].erase(first);           q.push(pair<int, int>(-s[pos[first]].size(), pos[first]));         }       }     }     puts( YES );     for (int i = 1; i <= m; i++) putchar(ans[i] +  0 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char s[200005];   bool b[200005];   int n, ans = 0;   void solve(int u) {     if (u == 1) {       if (u == n) {         ans = 1;         return;       }       if (s[u] ==  < ) {         b[u] = true;         ans++;       }       solve(u + 1);       if (s[u] ==  > )         if (b[u + 1]) ans++;       return;     }     if (u > n) return;     if (u == n) {       if (s[u] ==  >  | b[u - 1]) {         b[u] = true;         ans++;       }       return;     }     if (s[u] ==  < ) {       if (b[u - 1]) {         b[u] = true;         ans++;       }       solve(u + 1);     } else {       solve(u + 1);       if (b[u + 1]) {         b[u] = true;         ans++;       }     }   }   int main() {     scanf( %d , &n);     scanf( %s , s + 1);     solve(1);     printf( %d n , ans);   }
#include <bits/stdc++.h>   using namespace std;   int x[10][10];   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < m; i++) {       int a, b;       cin >> a >> b;       x[a][b] = x[b][a] = 1;     }     if (n < 7)       cout << m <<   n ;     else {       int sum = 30;       for (int i = 1; i <= 7; i++) {         for (int j = i + 1; j <= 7; j++) {           int ans = 0;           for (int o = 1; o <= 7; o++) {             if (x[i][o] == 1 && x[j][o] == 1) ans++;           }           if (ans < sum) sum = ans;         }       }       cout << m - sum <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int l = s.length();     int fc = 0;     int sc = 0;     for (int i = 0; i < l; i++) {       if (s[i] ==  4 ) fc++;       if (s[i] ==  7 ) sc++;     }     if (!fc && !sc)       cout <<  -1  << endl;     else if (sc > fc)       cout <<  7  << endl;     else       cout <<  4  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long int T;     vector<long int> sweet(3);     cin >> T;     while (T--) {       long int sum = 0;       cin >> sweet[0] >> sweet[1] >> sweet[2];       sort(sweet.begin(), sweet.end());       sum = min((sweet[2] + sweet[1] + sweet[0]) / 2,                 (sweet[2] + sweet[1] + sweet[0]) - sweet[2]);       cout << sum << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   inline bool is_palindrome(const string& s) {     return std::equal(s.begin(), s.end(), s.rbegin());   }   const long long MOD = 1000000007;   const long long INF = 1e9 + 5;   const double eps = 1e-7;   const double PI = acos(-1.0);   inline void debug_vi(vector<int> a) {     for (long long i = (long long)(0); i < (long long)(a.size()); i++)       cout << a[i] <<    ;   }   inline void debug_vll(vector<long long> a) {     for (long long i = (long long)(0); i < (long long)(a.size()); i++)       cout << a[i] <<    ;   }   const int N = 1e5 + 5;   int in[N];   int main() {     std::ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     int n, s, a, b;     cin >> n >> s;     memset(in, 0, sizeof(in));     for (long long i = (long long)(0); i < (long long)(n - 1); i++) {       cin >> a >> b;       a--;       b--;       in[a]++;       in[b]++;     }     int l = 0;     for (long long i = (long long)(0); i < (long long)(n); i++) {       if (in[i] == 1) {         l++;       }     }     double ans = 2.0 * s / l;     cout << fixed << showpoint << setprecision(15) << ans;     ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int s, v1, v2, t1, t2;     cin >> s >> v1 >> v2 >> t1 >> t2;     int res1 = (s * v1) + (t1 * 2);     int res2 = (s * v2) + (t2 * 2);     if (res1 < res2) {       cout <<  First ;     }     if (res1 > res2) {       cout <<  Second ;     }     if (res1 == res2) {       cout <<  Friendship ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1200000;   const int inf = 0x3f3f3f3f;   int n, m, k;   vector<int> g[M];   int ans;   int dfs(int u, int f) {     vector<int> v = {0, 0};     for (int to : g[u]) {       if (to == f) continue;       v.push_back(dfs(to, u));     }     sort(v.begin(), v.end());     reverse(v.begin(), v.end());     int sz = g[u].size();     ans = max(ans, v[0] + v[1] + sz + 1);     return v[0] + sz - 1;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t;     cin >> t;     for (int _ = (1); _ <= (t); ++_) {       cin >> n;       int u, v;       for (int i = (1); i <= (n); ++i) g[i].clear();       for (int i = (2); i <= (n); ++i) {         cin >> u >> v;         g[u].push_back(v);         g[v].push_back(u);       }       ans = 0;       dfs(1, 1);       cout << ans << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   class BIT {    public:     int size;     vector<long long> arr;     BIT(int n) {       size = n + 5;       arr.resize(size);     }     void add(int i, long long v) {       for (int x = i + 1; x < size; x += (x & (-x))) arr[x] += v;     }     long long sum(int i) {       i = min(i, size - 2);       long long res = 0;       for (int x = i + 1; x > 0; x -= (x & (-x))) res += arr[x];       return res;     }   };   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, w;     cin >> n >> w;     vector<pair<long long, long long>> p(n);     for (int i = 0; i < n; i++) cin >> p[i].first >> p[i].second;     sort(p.begin(), p.end(),          [&](pair<long long, long long> p0, pair<long long, long long> p1) {            if (abs(p0.first) * abs(p1.second - w) ==                abs(p1.first) * abs(p0.second - w)) {              return abs(p0.first) * abs(p1.second - w + 1) >                     abs(p1.first) * abs(p0.second - w + 1);            } else {              return abs(p0.first) * abs(p1.second - w) <                     abs(p1.first) * abs(p0.second - w);            }          });     vector<int> in(n);     for (int i = 0; i < n; i++) in[i] = i;     sort(in.begin(), in.end(), [&](int i0, int i1) {       pair<long long, long long> p0 = p[i0], p1 = p[i1];       if (abs(p0.first) * abs(p1.second + w) ==           abs(p1.first) * abs(p0.second + w)) {         return abs(p0.first) * abs(p1.second + w - 1) >                abs(p1.first) * abs(p0.second + w - 1);       } else {         return abs(p0.first) * abs(p1.second + w) <                abs(p1.first) * abs(p0.second + w);       }     });     BIT bit(n);     long long res = 0;     for (int i = n - 1; i >= 0; i--) {       res += bit.sum(in[i]);       bit.add(in[i], 1);     }     cout << res <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 50;   ;   const int M = 255;   const int mod = 998244353;   const int mo = 123;   const double pi = acos(-1.0);   int n, m;   int ans = 0;   int vis[N];   vector<int> vec;   int main() {     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) {       int res = 0;       for (int j = 0, x; j < m; j++) {         scanf( %d , &x);         if (x) res |= (1 << j);       }       if (!vis[res]) {         vec.push_back(res);         vis[res]++;       }     }     bool ok = false;     for (int i = 0; i < vec.size(); i++) {       for (int j = 0; j < vec.size(); j++) {         int x = vec[i] + vec[j];         int y = vec[i] ^ vec[j];         if (x == y) ok = true;       }     }     if (ok)       puts( YES );     else       puts( NO );     return 0;   }