malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int maxn = 10000;   vector<int> nei[maxn];   bool mark[maxn];   vector<int> nei2[maxn];   bool markk[maxn];   int n, m, comp = 0, comp2 = 0;   void dfs(int v) {     mark[v] = true;     for (int i = 0; i < nei[v].size(); i++) {       int u = nei[v][i];       if (!mark[u]) dfs(u);     }     return;   }   bool dfs_all() {     for (int d = 0; d < n * m; d++) {       if (!mark[d]) {         dfs(d);         comp++;       }     }     if (comp == 1)       return true;     else       return false;   }   void dfs2(int v) {     markk[v] = true;     for (int p = 0; p < nei2[v].size(); p++) {       int u = nei2[v][p];       if (!markk[u]) {         dfs2(u);       }     }     return;   }   bool dfs2_all() {     for (int j = 0; j < n * m; j++) {       if (!markk[j]) {         dfs2(j);         comp2++;       }     }     if (comp2 == 1)       return true;     else       return false;   }   int main() {     string hor, ver;     cin >> n >> m;     cin >> hor >> ver;     for (int j = 0; j < n; j++) {       if (hor[j] ==  > ) {         for (int p = j * m; p < j * m + m - 1; p++) {           nei[p].push_back(p + 1);           nei2[p + 1].push_back(p);         }       } else {         for (int p = j * m + m - 1; p > j * m; p--) {           nei[p].push_back(p - 1);           nei2[p - 1].push_back(p);         }       }     }     for (int j = 0; j < m; j++) {       if (ver[j] ==  v ) {         for (int p = j; p < (n - 1) * m + j; p += m) {           nei[p].push_back(p + m);           nei2[p + m].push_back(p);         }       } else {         for (int p = (n - 1) * m + j; p > j; p -= m) {           nei[p].push_back(p - m);           nei2[p - m].push_back(p);         }       }     }     if (dfs_all() && dfs2_all())       cout <<  YES   << endl;     else       cout <<  NO  << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int binpow(long long int a, long long int b) {     long long int res = 1;     while (b > 0) {       if (b & 1) res = res * a;       a = a * a;       b >>= 1;     }     return res;   }   void solve() {     long long int n, k;     cin >> n >> k;     vector<long long int> a(n);     for (long long int i = 0; i < a.size(); i++) {       cin >> a[i];     }     sort((a).begin(), (a).end());     long long int ans = a[n - 1];     for (long long int i = n - 2; i >= 0; i--) {       if (a[i] == 0) continue;       if (k > 0) {         ans += a[i];         k--;       } else {         break;       }     }     cout << ans <<   n ;   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long int t = 1;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long pre[2010000];   int n, i, m, j, vis[2010000], la[2010000], lr[2010000], s[2010000], q[2010000],       tr[2010000], a[2010000], tim, jid;   inline int gi() {     int s = 0;     char c = getchar();     while (c <  0  || c >  9 ) c = getchar();     while (c >=  0  && c <=  9 ) s = s * 10 + c -  0 , c = getchar();     return s;   }   void Work(long long x) {     int j = 1;     for (i = 1; i <= n + n; i++) {       while (j < min(i, n) + n && pre[j] - pre[i - 1] <= x) ++j;       la[i] = j - 1;     }     ++tim;     int ans = n + 1;     for (i = 1; i <= la[1]; i++) {       int h = 0;       if (i > n) i -= n, h = 1;       int t = 0, sum = 0, ed = i + n - 1;       for (j = i; j <= ed; j = la[j] + 1) {         if (vis[j] == tim) {           sum += s[j];           if (lr[j] < ed) sum++, j = lr[j] + 1;           q[++t] = j, tr[t] = sum;           break;         } else           q[++t] = j, tr[t] = ++sum;       }       for (j = t; j >= 1; j--)         vis[q[j]] = tim, lr[q[j]] = la[q[t]], s[q[j]] = tr[t] - tr[j - 1];       ans = min(ans, sum);       if (h) i += n;     }     i = la[1] + 1;     if (i <= n) {       int ed = i + n - 1, sum = 0;       for (j = i; j <= ed; j = la[j] + 1) ++sum;       ans = min(ans, sum);     }     printf( %d n , ans);   }   int main() {     scanf( %d%d , &n, &m);     for (i = 1; i <= n; i++) a[i] = a[i + n] = gi();     for (i = 1; i <= n + n; i++) pre[i] = pre[i - 1] + a[i];     while (m--) {       long long x;       scanf( %I64d , &x);       Work(x);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2005;   long long dp[N], a[N];   int n, k, ans;   bool check(long long x) {     for (int i = 1; i <= n; i++) {       dp[i] = i - 1;       for (int j = 1; j < i; j++) {         if (abs(a[i] - a[j]) <= (i - j) * x) {           dp[i] = min(dp[i], dp[j] + (i - j - 1));         }       }       if (dp[i] + n - i <= k) return 1;     }     return 0;   }   int main() {     scanf( %d%d , &n, &k);     long long L = 0, R = 0;     for (int i = 1; i <= n; i++) {       cin >> a[i];       if (i != 1) R = max((long long)R, abs(a[i] - a[i - 1]));     }     while (L <= R) {       long long mid = (L + R) >> 1;       if (check(mid)) {         ans = mid;         R = mid - 1;       } else         L = mid + 1;     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int N, V, M;   int Size[310], Final[310], T[310];   vector<int> G[310];   vector<pair<pair<int, int>, int> > ANS;   int source, sink, flow;   void FindSource(int node) {     if (Size[node] > Final[node]) {       source = node;       return;     }     for (vector<int>::iterator it = G[node].begin(); it != G[node].end(); ++it)       if (T[*it] == 0 && *it != sink) {         T[*it] = node;         FindSource(*it);       }   }   void Transfer(int source, int sink, int flow) {     Size[source] -= flow;     Size[sink] += flow;     ANS.push_back(make_pair(make_pair(source, sink), flow));   }   void Push(int node) {     int next = T[node];     if (next == sink) {       Transfer(node, sink, flow);       return;     }     int add = 0;     if (Size[next] < flow) {       add = flow - Size[next];       Transfer(node, next, add);     }     Push(next);     Transfer(node, next, flow - add);   }   void Fill(int node) {     sink = node;     while (Size[node] < Final[node]) {       source = 0;       memset(T, 0, sizeof(T));       FindSource(node);       if (source == 0) break;       flow = min(Size[source] - Final[source], Final[sink] - Size[sink]);       Push(source);     }   }   int main() {     cin >> N >> V >> M;     for (int i = 1; i <= N; i++) cin >> Size[i];     for (int i = 1; i <= N; i++) cin >> Final[i];     for (int i = 1; i <= M; i++) {       int a, b;       cin >> a >> b;       G[a].push_back(b);       G[b].push_back(a);     }     for (int i = 1; i <= N; i++)       if (Size[i] < Final[i]) Fill(i);     bool OK = 1;     for (int i = 1; i <= N; i++)       if (Size[i] != Final[i]) OK = 0;     if (OK == 0)       cout <<  NO  <<   n ;     else {       cout << ANS.size() <<   n ;       for (vector<pair<pair<int, int>, int> >::iterator it = ANS.begin();            it != ANS.end(); ++it)         cout << (it->first).first <<     << (it->first).second <<                  << (it->second) <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, m;     cin >> n >> m;     int flag = 0, ans = 0;     for (int i = 0; i < m; i++) {       int k;       cin >> k;       set<int> check;       flag = 1;       for (int j = 0; j < k; j++) {         int t;         cin >> t;         if (check.count(-t)) {           flag = 0;         }         check.insert(t);       }       if (flag) ans = 1;     }     if (ans) {       cout <<  YES  << endl;     } else {       cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T Abs(const T& x) {     return x < 0 ? -x : x;   }   template <class T>   inline T Sqr(const T& x) {     return x * x;   }   const int maxn = 110;   const int maxk = 210;   double a[maxn][maxn][maxk];   int n, k;   int Get(int l, int r, int pos) {     if (pos < l || pos > r) {       return pos;     } else {       return l + r - pos;     }   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> k;     vector<int> p(n);     for (int i = 0; i < n; ++i) {       cin >> p[i];     }     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j) {         a[i][j][0] = (i < j ? 1.0 : 0.0);       }     }     double cnt = 0;     for (int i = 0; i < n; ++i) {       for (int j = i; j < n; ++j) {         cnt += 1.0;       }     }     for (int iter = 1; iter <= k; ++iter) {       for (int i = 0; i < n; ++i) {         for (int j = 0; j < n; ++j) {           a[i][j][iter] = 0;           for (int l = 0; l < n; ++l) {             for (int r = l; r < n; ++r) {               int i1 = Get(l, r, i);               int j1 = Get(l, r, j);               a[i][j][iter] += 1 / cnt * a[i1][j1][iter - 1];             }           }         }       }     }     double ans = 0.0;     for (int i = 0; i < n; ++i) {       for (int j = i + 1; j < n; ++j) {         if (p[i] < p[j]) {           ans += a[j][i][k];         } else {           ans += a[i][j][k];         }       }     }     printf( %.12lf n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int N, a[100010], b[100010], posA[100010];   multiset<int> S;   int get(int x) {     multiset<int>::iterator it = S.lower_bound(x), jt = it;     return min(abs(*it - x), abs(*--jt - x));   }   int main() {     scanf( %d , &N);     for (int i = 1; i <= N; i++) scanf( %d , &a[i]), posA[a[i]] = i;     for (int i = 1; i <= N; i++) scanf( %d , &b[i]), S.insert(i - posA[b[i]]);     S.insert(-1e9);     for (int x = 1; x <= N; x++) {       printf( %d n , get(x - 1));       S.erase(S.find(x - posA[b[x]]));       S.insert(x - posA[b[x]] + N);     }   }
#include <bits/stdc++.h>   using namespace std;   double safe_sqrt(double x) { return sqrt(max((double)0.0, x)); }   long long GI(long long& x) { return scanf( %lld , &x); }   const long long MOD = 1e9 + 7;   const long long MN = 1000111;   long long gt[MN];   vector<long long> h[MN];   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout << (fixed) << setprecision(9);     const long long MOD = 1e9 + 7;     gt[0] = 1;     for (long long i = (1), _b = (MN - 1); i <= _b; ++i)       gt[i] = gt[i - 1] * i % MOD;     long long n, m;     while (GI(n) == 1 && GI(m) == 1) {       for (long long i = (1), _b = (m); i <= _b; ++i) h[i].clear();       for (long long i = (1), _b = (n); i <= _b; ++i) {         long long k;         GI(k);         while (k--) {           long long u;           GI(u);           h[u].push_back(i);         }       }       sort(h + 1, h + m + 1);       long long i = 1;       long long res = 1;       while (i <= m) {         long long j = i;         while (j < m && h[j + 1] == h[i]) j++;         res = res * gt[j - i + 1] % MOD;         i = j + 1;       }       cout << res << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int x;     int i;   };   node a[300010];   int b[300010];   map<int, int> mp;   bool cmp(node p, node q) { return (p.x < q.x); }   int main() {     int x, y, i, j, n, k;     cin >> n;     for (i = 0; i < n; i++) {       cin >> a[i].x;       mp[a[i].x]++;       a[i].i = i;     }     sort(a, a + n, cmp);     for (i = 0, j = 1; i < n; i++) {       if (i == 0)         b[a[i].i] = a[i].x;       else if ((a[i].x == a[i - 1].x)) {         j = max(j, a[i].x + 1);         while (1) {           if (j <= a[i].x || mp[j] > 0) {             j++;             continue;           }           break;         }         b[a[i].i] = j;         mp[j]++;       } else {         b[a[i].i] = a[i].x;       }     }     for (i = 0; i < n; i++) cout << b[i] <<    ;     return 0;   }
#include<bits/stdc++.h>   using namespace std;   #define forg(i,x) for(register int i=fir[x];i;i=nxt[i])   #define uu unsigned   #define scanf a14=scanf   #define rint register int   #define fre(x) freopen(#x .in , r ,stdin),freopen(#x .out , w ,stdout)   typedef long long ll;   typedef uu long long ull;   typedef pair<int,int>pii;   int a14;   inline int rd(int l,int r){return rand()%(r-l+1)+l;}      const int mxn=1e5+3,sq=400,qs=320;   int n,b[mxn],lp[mxn],rp[mxn],kn,be[mxn],po[mxn],qn;   int ju[mxn/sq+2][mxn],ad[mxn/sq+2][mxn/qs+1];   int TG;   struct shu{       int a[mxn],tg[mxn];       void add(int x){for(;x<=n;x+=x&-x){if(tg[x]!=TG)tg[x]=TG,a[x]=0;++a[x];}}       int ask(int x){           int su=0,p=0;           for(int i=1<<16;i;i>>=1){               if(p+i>=n)continue;               p+=i;if(tg[p]!=TG)tg[p]=TG,a[p]=0;               if(p+a[p]+su>=x)p-=i;else su+=a[p];           }           return p+1;       }       void gb(int t){for(int i=1;i<=n;++i){if(tg[i]!=TG)a[i]=0;ju[t][i]=ju[t][i-(i&-i)]+a[i];}for(int i=1;i<=n;++i)ju[t][i]+=i;}   }ar;   void add2(int t,int x,int y){       int k=(x-1)/qs;       for(int i=x;i<=(k+1)*qs;++i)ju[t][i]+=y;       for(++k;k*qs+1<=n;++k)ad[t][k]+=y;   }   int main(){   //cout<<(sizeof(ju)>>20)<<endl;       scanf( %d ,&n);for(int i=1;i<=n;++i)scanf( %d ,b+i),b[i]=i-b[i];scanf( %d ,&qn);       for(int l=1,r;r!=n;l=r+1){r=min(l+sq-1,n);lp[++kn]=l,rp[kn]=r;for(int i=l;i<=r;++i)be[i]=kn;}       for(int t=1;t<=kn;++t){           ++TG; for(int i=lp[t];i<=rp[t];++i)po[i]=ar.ask(b[i]),ar.add(po[i]);           ar.gb(t);       }       while(qn--){           int o,x,y;scanf( %d%d ,&o,&x);if(o==1){               scanf( %d ,&y);b[x]=x-y;int k=be[x],ls;               ++TG;for(int i=lp[k];i<=rp[k];++i){                   if(i<x)ar.add(po[i]);else{                       ls=po[i],po[i]=ar.ask(b[i]),ar.add(po[i]);                       if(ls==po[i])continue;                       if(ls==po[i]-1){--ju[k][ls];continue;}                       if(ls==po[i]+1){++ju[k][po[i]];continue;}                       assert(i==x);                       add2(k,ls,-1),add2(k,po[i],1);                   }               }           }else{               int t=be[x],re=b[x];for(int i=x+1;i<=rp[t];++i)re+=b[i]<=re;               for(++t;t<=kn;++t)re=ju[t][re]+ad[t][(re-1)/qs];               printf( %d n ,re);           }       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int ans[105], a[105], sum[105];   int main() {     int n, b;     cin >> n >> b;     for (int i = 0; i < n; i++) scanf( %d , a + i);     int t = 0, nn = 0;     for (int i = 0; i < n - 1; i++) {       if (a[i] % 2)         t++;       else         t--;       if (t == 0) {         ans[nn] = abs(a[i] - a[i + 1]);         nn++;       }     }     sort(ans, ans + nn);     sum[0] = 0;     for (int i = 0; i < nn; i++) sum[i + 1] = ans[i] + sum[i];     t = nn;     for (;; t--) {       if (sum[t] <= b) {         cout << t << endl;         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int t, n, sumaP, sumaI, ultimo, primero;     cin >> t;     while (t--) {       cin >> n;       if (n % 4 != 0)         cout <<  NO  << endl;       else {         sumaP = (n / 2) * (n / 2 + 1);         sumaI = (n / 2 - 1) * (n / 2 - 1);         ultimo = sumaP - sumaI;         cout <<  YES  << endl;         primero = 2;         for (int i = 0; i < n / 2; i++) {           cout << primero <<    ;           primero += 2;         }         primero = 1;         for (int i = n / 2; i < n - 1; i++) {           cout << primero <<    ;           primero += 2;         }         cout << ultimo << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout << setprecision(20) << fixed;     long long t;     cin >> t;     while (t--) {       long long n;       cin >> n;       long long a[n];       vector<long long> b, c;       long long s = 0, z = 0;       for (long long i = 0; i < n; i++) {         cin >> a[i];         if (a[i] > 0) {           b.push_back(a[i]);           s += a[i];         } else if (a[i] == 0)           z++;         else           c.push_back(a[i]);       }       long long f = 0;       for (long long i = 0; i < c.size(); i++) {         if (s + c[i] != 0) {           s += c[i];           b.push_back(c[i]);         } else {           f = 1;           b.push_back(c[i]);           s += c[i];         }       }       if (f == 1) reverse(b.begin(), b.end());       for (long long i = 0; i < z; i++) b.push_back(0);       if (s == 0)         cout <<  NO  << endl;       else {         cout <<  YES  << endl;         for (long long i = 0; i < n; i++) cout << b[i] <<    ;         cout << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   struct Side {     int x, y;     Side(int x, int y) : x(x), y(y) {}   };   struct Part {     int id, z;     Part() {}     Part(int id, int z) : id(id), z(z) {}   };   struct Answer {     int a, b;     Answer(){};     Answer(int a, int b) : a(a), b(b) {}   };   bool operator<(const Side &left, const Side &right) {     if (left.x != right.x) {       return left.x < right.x;     }     return left.y < right.y;   }   int min(int x, int y, int z) { return std::min(x, std::min(y, z)); }   void check(int id, int x, int y, int z, std::map<Side, Part> &sides,              Answer &ans, int &bestV) {     if (x > y) {       check(id, y, x, z, sides, ans, bestV);       return;     }     auto it = sides.find(Side(x, y));     if (it == sides.end()) {       return;     }     z += (*it).second.z;     int minV = min(x, y, z);     if (minV > bestV) {       bestV = minV;       ans.a = (*it).second.id;       ans.b = id;     }   }   void add(int id, int x, int y, int z, std::map<Side, Part> &sides) {     if (x > y) {       add(id, y, x, z, sides);       return;     }     auto it = sides.find(Side(x, y));     if (it != sides.end()) {       if ((*it).second.z >= z) {         return;       }     }     sides[Side(x, y)] = Part(id, z);   }   int main() {     std::map<Side, Part> sides;     int n;     scanf( %d , &n);     Answer ans;     int bestV = 0;     for (int i = 1; i <= n; i++) {       int x, y, z;       scanf( %d %d %d , &x, &y, &z);       int minV = min(x, y, z);       if (minV > bestV) {         bestV = minV;         ans = Answer(i, -1);       }       check(i, x, y, z, sides, ans, bestV);       check(i, x, z, y, sides, ans, bestV);       check(i, y, z, x, sides, ans, bestV);       add(i, x, y, z, sides);       add(i, x, z, y, sides);       add(i, y, z, x, sides);     }     if (ans.b == -1) {       printf( 1 n%d , ans.a);     } else {       printf( 2 n%d %d , ans.a, ans.b);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     cin.tie(0);     ios::sync_with_stdio(false);     int N, H;     cin >> N >> H;     vector<int> A(N);     for (int i = 0; i < N; i++) cin >> A[i];     vector<long long> b;     int ans = 0;     for (int i = 0; i < N; i++) {       b.push_back(A[i]);       sort(b.begin(), b.end());       long long sum = 0;       for (int i = b.size() - 1; i >= 0; i -= 2) {         sum += b[i];       }       if (sum <= H)         ans++;       else         break;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool MySort(const pair<int, int>& A, const pair<int, int>& B) {     return A.first > B.first;   }   int main() {     int T;     cin >> T;     while (T--) {       long long X, Y, K;       cin >> X >> Y >> K;       long long Ans = 0;       long long All = Y * K + K;       All--;       if (All % (X - 1) == 0) {         Ans += (All / (X - 1));       } else {         Ans += (All / (X - 1)) + 1;       }       Ans += K;       cout << Ans << endl;     }     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 n;     cin >> n;     long long arr[2 * n];     for (long long i = 0; i < 2 * n; i++) cin >> arr[i];     long long m = 0;     for (long long i = 0; i < 2 * n; i++) {       if (arr[i] != arr[i + 1]) {         for (long long j = i + 1; j < 2 * n; j++) {           if (arr[i] == arr[j]) {             for (long long k = j; k > i + 1; k--) {               swap(arr[k], arr[k - 1]);               m++;             }             break;           }         }         i++;       } else         i++;     }     cout << m;   }
#include <bits/stdc++.h>   using ll = long long;   using namespace std;   const ll N = 1e5 + 1, mod = 1e9 + 7;   struct point {     ll x, y;   } p[N];   ll n;   bool line[N];   signed main() {     ios_base::sync_with_stdio(0), cin.tie(0);     cin >> n;     for (ll i = 1; i <= n; ++i) {       cin >> p[i].x >> p[i].y;     }     if (n <= 4) {       return cout <<  YES , 0;     }     for (ll i = 1; i <= 3; ++i) {       for (ll j = i + 1; j <= 3; ++j) {         memset(line, 0, sizeof line);         ll a = p[i].y - p[j].y, b = p[j].x - p[i].x;         ll c = a * p[i].x + b * p[i].y;         for (ll k = 1; k <= n; ++k) {           if (a * p[k].x + b * p[k].y != c) {             line[k] = 1;           }         }         ll cnt0 = 0;         point p1 = {INT_MAX, 0}, p2 = {INT_MAX, 0};         for (ll k = 1; k <= n && cnt0 < 2; ++k) {           if (line[k]) {             if (!cnt0) {               p1 = p[k];             } else {               p2 = p[k];             }             cnt0++;           }         }         if (p1.x == INT_MAX || p2.x == INT_MAX) {           return cout <<  YES , 0;         }         a = p1.y - p2.y, b = p2.x - p1.x;         c = a * p1.x + b * p1.y;         bool yes = 1;         for (ll k = 1; k <= n; ++k) {           if (line[k] && a * p[k].x + b * p[k].y != c) {             yes = 0;           }         }         if (yes) {           return cout <<  YES , 0;         }       }     }     cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(int a, int b) {     if (!b) return a;     return gcd(b, a % b);   }   bool isprime(long long n) {     if (n == 2) {       return true;     }     if (n % 2 == 0) {       return false;     }     for (long long i = 3; i <= sqrt(n); i += 2) {       if (n % i == 0) {         return false;       }     }     return true;   }   long long a[1005][2];   int main() {     long long n, m;     cin >> n >> m;     long long flag[m];     memset(flag, 0, sizeof(flag));     for (int(i) = (0); (i) < (m); (i)++) {       long long k;       cin >> k;       map<int, int> m;       for (int(j) = (0); (j) < (k); (j)++) {         long long x;         cin >> x;         m[x]++;         if (m.find(-x) != m.end()) flag[i] = 1;       }     }     for (int(i) = (0); (i) < (m); (i)++) {       if (flag[i] == 0) {         cout <<  YES ;         return 0;       }     }     cout <<  NO ;   }
#include <bits/stdc++.h>   using namespace std;   struct Q {     int r, c, id;   } q[100001];   int m, n;   bool cmph(Q a, Q b) {     if (a.r != b.r) return a.r < b.r;     return a.c < b.c;   }   bool cmps(Q a, Q b) {     if (a.c != b.c) return a.c < b.c;     return a.r < b.r;   }   bool cmpp(Q a, Q b) {     if (a.r + a.c != b.r + b.c) return a.r + a.c < b.r + b.c;     return a.r < b.r;   }   bool cmpn(Q a, Q b) {     if (a.r - a.c != b.r - b.c) return a.r - a.c < b.r - b.c;     return a.r < b.r;   }   int cnt[100001];   int main(int argc, char *argv[]) {     scanf( %d%d , &m, &n);     do {       memset(cnt, 0, sizeof(cnt));     } while (0);     for (int i = 0; i < n; i++) {       scanf( %d%d , &(q[i].r), &(q[i].c));       q[i].id = i;     }     sort(q, q + n, cmph);     for (int i = 1; i < n; i++) {       if (q[i - 1].r == q[i].r) {         cnt[q[i - 1].id]++;         cnt[q[i].id]++;       }     }     sort(q, q + n, cmps);     for (int i = 1; i < n; i++) {       if (q[i - 1].c == q[i].c) {         cnt[q[i - 1].id]++;         cnt[q[i].id]++;       }     }     sort(q, q + n, cmpp);     for (int i = 1; i < n; i++) {       if (q[i - 1].r + q[i - 1].c == q[i].r + q[i].c) {         cnt[q[i - 1].id]++;         cnt[q[i].id]++;       }     }     sort(q, q + n, cmpn);     for (int i = 1; i < n; i++) {       if (q[i - 1].r - q[i - 1].c == q[i].r - q[i].c) {         cnt[q[i - 1].id]++;         cnt[q[i].id]++;       }     }     int cc[9];     do {       memset(cc, 0, sizeof(cc));     } while (0);     for (int i = 0; i < n; i++) cc[cnt[i]]++;     for (int i = 0; i < 9; i++) {       printf( %d  , cc[i]);     }     return EXIT_SUCCESS;   }