malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAX_N = (int)2e5 + 100;   const int mod = (int)1e9 + 7;   int cnt[MAX_N];   inline int mul(int x, int y) { return (long long)x * y % mod; }   inline int powMod(int x, int n) {     int ret = 1;     while (n > 0) {       if (n & 1) ret = mul(ret, x);       x = mul(x, x);       n >>= 1;     }     return ret;   }   int main() {     int m;     scanf( %d , &m);     memset(cnt, 0, sizeof(cnt));     for (int i = 0; i < m; ++i) {       int p;       scanf( %d , &p);       ++cnt[p];     }     vector<int> toMul;     for (int i = 0; i < MAX_N; ++i)       if (cnt[i] > 0) {         toMul.push_back(cnt[i] + 1);       }     bool perfectSq = true;     for (int i = 0; i < toMul.size(); ++i) {       if (toMul[i] % 2 == 0) {         toMul[i] /= 2;         perfectSq = false;         break;       }     }     int p1 = 1;     for (int i = 0; i < toMul.size(); ++i) {       p1 = (long long)p1 * toMul[i] % (mod - 1);     }     if (!perfectSq) {       int num = 1;       for (int i = 0; i < MAX_N; ++i)         if (cnt[i] > 0) {           num = mul(num, powMod(i, cnt[i]));         }       printf( %d n , powMod(num, p1));     } else {       int root = 1;       for (int i = 0; i < MAX_N; ++i)         if (cnt[i] > 0) {           root = mul(root, powMod(i, cnt[i] / 2));         }       printf( %d n , powMod(root, p1));     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     bool vi[1002];     memset(vi, 0, sizeof vi);     int a = 0, i = 0;     while (i < n) {       a = (a + i % n) % n;       if (vi[a]) {         cout <<  NO  << endl;         return 0;       };       vi[a] = 1;       i++;     }     cout <<  YES  << endl;   }
#include <bits/stdc++.h>   using namespace std;   int diez(int x) {     int x1 = 0;     int s = 0;     while (x != 0) {       x1 = x % 10;       x = x / 10;       s += x1;     }     if (s == 10)       return (1);     else       return (0);   }   int main() {     int n;     while (cin >> n) {       int s = 18;       int s1 = 0;       while (n) {         s++;         if (diez(s) == 1) {           s1 = s;           n--;         }       }       cout << s1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   long long op[1000010];   int main() {     op[1] = 1LL;     for (int i = 2; i <= 1000000; i++) {       op[i] = op[i - 1] * 2 + 1;       op[i] %= 1000000007;     }     string s;     cin >> s;     long long cnt = 0;     int a = 0;     int b = 0;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  a )         a++;       else {         cnt += op[a];         cnt %= 1000000007;       }     }     cout << cnt << endl;   }
#include <bits/stdc++.h>   using namespace std;   string rows[1000];   int dist[1000][1000];   bool disc[1000][1000];   int r, c;   void bfs(int row, int col) {     queue<pair<int, int> > q;     q.push(make_pair(row, col));     while (!q.empty()) {       pair<int, int> cur = q.front();       disc[cur.first][cur.second] = true;       q.pop();       if (cur.first > 0 && !disc[cur.first - 1][cur.second] &&           rows[cur.first - 1][cur.second] !=  T ) {         dist[cur.first - 1][cur.second] = dist[cur.first][cur.second] + 1;         disc[cur.first - 1][cur.second] = true;         q.push(make_pair(cur.first - 1, cur.second));       }       if (cur.first < r - 1 && !disc[cur.first + 1][cur.second] &&           rows[cur.first + 1][cur.second] !=  T ) {         dist[cur.first + 1][cur.second] = dist[cur.first][cur.second] + 1;         disc[cur.first + 1][cur.second] = true;         q.push(make_pair(cur.first + 1, cur.second));       }       if (cur.second < c - 1 && !disc[cur.first][cur.second + 1] &&           rows[cur.first][cur.second + 1] !=  T ) {         dist[cur.first][cur.second + 1] = dist[cur.first][cur.second] + 1;         disc[cur.first][cur.second + 1] = true;         q.push(make_pair(cur.first, cur.second + 1));       }       if (cur.second > 0 && !disc[cur.first][cur.second - 1] &&           rows[cur.first][cur.second - 1] !=  T ) {         dist[cur.first][cur.second - 1] = dist[cur.first][cur.second] + 1;         disc[cur.first][cur.second - 1] = true;         q.push(make_pair(cur.first, cur.second - 1));       }     }   }   int main(void) {     cin >> r >> c;     for (int i = 0; i < r; i++) cin >> rows[i];     memset(disc, 0, sizeof(disc));     for (int i = 0; i < r; i++)       for (int j = 0; j < c; j++)         if (rows[i][j] ==  E ) bfs(i, j);     pair<int, int> start;     for (int i = 0; i < r; i++) {       for (int j = 0; j < c; j++) {         if (rows[i][j] ==  S ) {           start.first = i;           start.second = j;         }       }     }     int kiek = 0;     for (int i = 0; i < r; i++) {       for (int j = 0; j < c; j++) {         if (isdigit(rows[i][j]) &&             dist[i][j] <= dist[start.first][start.second] && disc[i][j]) {           kiek += int(rows[i][j] -  0 );         }       }     }     cout << kiek << endl;   }
#include <bits/stdc++.h>   using namespace std;   bool flag = 0;   int work(int a, int n, int p) {     int t = a * 1ll * n / p;     if (!t) {       if (!flag) return a;       return max(a, p - a * n);     }     flag = 1;     int a1, n1, p1;     a1 = min(p % a, a - (p % a));     n1 = t;     p1 = a;     if (a * 1ll * n % p < a * 1ll * (p / a - 1)) n1--;     return work(a1, n1, p1);   }   int main() {     int t;     scanf( %d , &t);     while (t--) {       int a, n, p, h;       scanf( %d%d%d%d , &a, &n, &p, &h);       flag = 0;       if (work(a % p, n, p) <= h)         printf( YES n );       else         printf( NO n );     }     return 0;   }
#include <bits/stdc++.h>      using namespace std;      #define all(x) (x).begin(), (x).end()   #define fast ios::sync_with_stdio(false);cin.tie(0);   typedef long long ll;   typedef long double ld;   typedef unsigned long long ull;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());      map<pair<int,int>,bool> e[3];      int main(){    fast    vector<int> n(4);    for(int i=0;i<4;i++)cin>>n[i];    vector<vector<int>> c(4);    for(int i=0;i<4;i++){     c[i].resize(n[i]);     for(int j=0;j<n[i];j++)cin>>c[i][j];    }    for(int i=0;i<3;i++){     int m;     cin>>m;     for(int j=0;j<m;j++){      int a,b;      cin>>a>>b;      a--;b--;      // cerr << i <<     << a <<     << b <<   n ;      e[i][{a,b}] = true;     }    }    vector<pair<ll,int>> dp,nxt;    for(int i=0;i<n[3];i++)dp.push_back({c[3][i],i});    for(int lvl=2;lvl>=0;lvl--){     sort(all(dp));     for(int i=0;i<n[lvl];i++){      for(int j=0;j<dp.size();j++){       if(e[lvl][{i,dp[j].second}])continue;       nxt.push_back({c[lvl][i] + dp[j].first , i});       break;      }     }     dp = nxt;     nxt.clear();      }    sort(all(dp));    if(dp.empty())cout << -1 <<   n ;    else cout << dp[0].first <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int maxN = 1e5 + 5;   const int maxM = 1e6 + 5;   const long long INF = 1e18;   const long long MOD = 1e9 + 7;   long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }   long long sq(long long x) { return (x * x) % MOD; }   long long modP(long long a, long long b) {     return (!b ? 1 : (sq(modP(a, b / 2)) * (b % 2 ? a : 1)) % MOD);   }   bool on[maxN];   int n, id[maxM], TIME;   int f[maxM], sz = 0;   int Q[maxM], lt, rt;   int st[maxM], fn[maxM];   int trie[maxM][26];   long long fen[maxM];   string s[maxN], str;   vector<int> G[maxM];   void SHAHO() {     for (int i = 1; i <= n; i++) {       int curr = 0;       for (auto ch : s[i]) {         int c = ch -  a ;         if (!trie[curr][c]) trie[curr][c] = ++sz;         curr = trie[curr][c];       }       id[i] = curr;     }     for (int i = 0; i < 26; i++)       if (trie[0][i]) Q[rt++] = trie[0][i];     while (lt != rt) {       int v = Q[lt++];       for (int i = 0; i < 26; i++) {         if (trie[v][i]) {           Q[rt++] = trie[v][i];           f[trie[v][i]] = trie[f[v]][i];         } else           trie[v][i] = trie[f[v]][i];       }     }     return;   }   void DFS(int v) {     st[v] = TIME++;     for (auto u : G[v]) DFS(u);     fn[v] = TIME;     return;   }   void add(int p, int x) {     for (; p < maxM; p += p & -p) fen[p] += x;     return;   }   long long fetch(int p) {     long long res = 0;     for (; p > 0; p -= p & -p) res += fen[p];     return res;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int q;     cin >> q >> n;     for (int i = 1; i <= n; i++) cin >> s[i], on[i] = 1;     SHAHO();     for (int i = 0; i <= sz; i++)       if (i != f[i]) G[f[i]].push_back(i);     DFS(0);     for (int i = 1; i <= n; i++) {       add(st[id[i]], +1);       add(fn[id[i]], -1);     }     int v;     while (q--) {       char t;       cin >> t;       if (t ==  ? ) {         cin >> str;         v = 0;         long long ans = 0;         for (auto ch : str) {           v = trie[v][ch -  a ];           ans += fetch(st[v]);         }         cout << ans <<   n ;         continue;       }       cin >> v;       if (t ==  + ) {         add(st[id[v]], 1 - on[v]);         add(fn[id[v]], on[v] - 1);         on[v] = 1;       } else {         add(st[id[v]], -on[v]);         add(fn[id[v]], +on[v]);         on[v] = 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n;   const int prime[8] = {2, 3, 5, 7, 11, 13, 17, 19};   long long mul(long long x, long long y, long long mo) {     long long ret = 1;     while (y) {       if (y % 2 == 1) ret = ret * x % mo;       x = x * x % mo;       y /= 2;     }     return ret;   }   bool is_prime(int n) {     for (int i = 0; i <= 7; i++) {       if (n == prime[i]) return 1;       if (mul(prime[i], n - 1, n) != 1) return 0;     }     return 1;   }   int main() {     scanf( %d , &n);     if (n == 1) {       puts( YES );       puts( 1 );       return 0;     }     if (n == 4) {       puts( YES );       puts( 1 );       puts( 3 );       puts( 2 );       puts( 4 );       return 0;     }     if (!is_prime(n)) {       puts( NO );       return 0;     }     puts( YES );     puts( 1 );     for (int i = 2; i <= n; i++) {       long long now = i * mul(i - 1, n - 2, n) % n;       if (now == 0) now = n;       printf( %I64d n , now);     }     return 0;   }
#include <bits/stdc++.h>   const double INF = 1e18, eps = 1e-18;   double a, b, c, x_1, y_1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6, ans;   double sqr(double x) { return x * x; }   double dis(double x_1, double y_1, double x2, double y2) {     return sqrt(sqr(x2 - x_1) + sqr(y_1 - y2));   }   int main() {     scanf( %lf%lf%lf%lf%lf%lf%lf , &a, &b, &c, &x_1, &y_1, &x6, &y6);     if (std::abs(a - 0) > eps && std::abs(b - 0) > eps)       y2 = y_1, x2 = (-b * y2 - c) / a;     else       y2 = x2 = INF;     if (std::abs(a - 0) > eps && std::abs(b - 0) > eps)       x3 = x_1, y3 = (-a * x3 - c) / b;     else       x3 = y3 = INF;     if (std::abs(a - 0) > eps && std::abs(b - 0) > eps)       y4 = y6, x4 = (-b * y4 - c) / a;     else       x4 = y4 = INF;     if (std::abs(a - 0) > eps && std::abs(b - 0) > eps)       x5 = x6, y5 = (-a * x5 - c) / b;     else       x5 = y5 = INF;     ans = std::min(         std::min(             std::min(                 dis(x_1, y_1, x2, y2) + dis(x2, y2, x4, y4) + dis(x4, y4, x6, y6),                 dis(x_1, y_1, x2, y2) + dis(x2, y2, x5, y5) +                     dis(x5, y5, x6, y6)),             dis(x_1, y_1, x3, y3) + dis(x3, y3, x4, y4) + dis(x4, y4, x6, y6)),         dis(x_1, y_1, x3, y3) + dis(x3, y3, x5, y5) + dis(x5, y5, x6, y6));     ans = std::min(ans, std::abs(x6 - x_1) + std::abs(y6 - y_1));     printf( %.10lf , ans);     return 0;   }
#include <bits/stdc++.h>   struct Node;   Node* null;   struct Node {     Node* insert(int l, int r, int k) {       if (k < l || r < k) {         return this;       }       if (l == r) {         return new Node{count + 1, null, null};       }       int m = l + r >> 1;       return new Node{count + 1, left->insert(l, m, k),                       right->insert(m + 1, r, k)};     }     int count;     Node *left, *right;   };   int query(Node* p, Node* q, int l, int r, int limit) {     if (q->count - p->count <= limit) {       return INT_MAX;     }     if (l == r) {       return l;     }     int m = l + r >> 1;     return std::min(query(p->left, q->left, l, m, limit),                     query(p->right, q->right, m + 1, r, limit));   }   const int N = 300000;   Node* tree[N + 1];   int main() {     null = new Node{0, nullptr, nullptr};     null->left = null->right = null;     int n, q;     while (scanf( %d%d , &n, &q) == 2) {       tree[0] = null;       for (int i = 1, a; i <= n; ++i) {         scanf( %d , &a);         tree[i] = tree[i - 1]->insert(1, n, a);       }       while (q--) {         int l, r, k;         scanf( %d%d%d , &l, &r, &k);         int limit = (r - l + 1) / k;         int result = query(tree[l - 1], tree[r], 1, n, limit);         printf( %d n , result == INT_MAX ? -1 : result);       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   int T, n, m, u, v, sum, ans;   int col[N];   bool vis[N];   int cnt, head[N];   struct edge {     int next, to;   } e[N << 1];   inline void add(int u, int v) {     cnt++;     e[cnt].next = head[u];     e[cnt].to = v;     head[u] = cnt;   }   queue<int> q;   int main() {     scanf( %d , &T);     while (T--) {       scanf( %d%d , &n, &m);       cnt = 0;       for (register int i = 1; i <= n; ++i) head[i] = 0;       for (register int i = 1; i <= m; ++i)         scanf( %d%d , &u, &v), add(u, v), add(v, u);       for (register int i = 1; i <= n; ++i) vis[i] = false;       col[1] = 1;       vis[1] = true;       q.push(1);       while (q.size()) {         u = q.front();         q.pop();         for (register int i = head[u]; i; i = e[i].next)           if (!vis[e[i].to]) {             col[e[i].to] = col[u] ^ 1;             vis[e[i].to] = true;             q.push(e[i].to);           }       }       sum = 0;       for (register int i = 1; i <= n; ++i) sum += col[i];       ans = min(sum, n - sum);       printf( %d n , ans);       if (ans == sum) {         for (register int i = 1; i <= n; ++i)           if (col[i]) printf( %d  , i);       } else {         for (register int i = 1; i <= n; ++i)           if (!col[i]) printf( %d  , i);       }       puts(  );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long n, d, a, b, p[100005], x[100005], y[100005], c, ans[100005];   long long cmp(long long A, long long B) {     return x[A] * a + y[A] * b < x[B] * a + y[B] * b;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> d;     cin >> a >> b;     for (long long i = 1; i <= n; i++) cin >> x[i] >> y[i], p[i] = i;     sort(p + 1, p + 1 + n, cmp);     for (long long i = 1; i <= n; i++)       if (d >= x[p[i]] * a + y[p[i]] * b)         d -= x[p[i]] * a + y[p[i]] * b, ans[++c] = p[i];     cout << c << endl;     for (int i = 1; i <= c; i++) cout << ans[i] <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   bool mark = false;   int main() {     cin >> s;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  0  && mark == false) {         mark = true;         continue;       }       if (mark == false && i == s.size() - 1) return 0;       cout << s[i];     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, k;   struct trie {     int cnt, whole;     trie *next[26];     trie() {       cnt = 0;       for (int i = 0; i < 26; ++i) next[i] = NULL;     }   } *root = new trie();   void ins(char *s) {     trie *p = root;     for (int i = 0; s[i]; ++i) {       int c = s[i] -  a ;       if (p->next[c] == NULL) p->next[c] = new trie();       p = p->next[c];     }     p->cnt++;   }   vector<int> *dp(trie *p, int dep) {     int pos = -1, cnt = 0;     for (int i = 0; i < 26; ++i) {       if (p->next[i] != NULL) {         pos = i;         cnt++;       }     }     if (cnt == 0) {       vector<int> *ret = new vector<int>(p->cnt + 1);       for (int i = 0; i <= p->cnt; ++i) (*ret)[i] = i * (i - 1) * dep / 2;       return ret;     } else if (cnt == 1 && p->whole == p->next[pos]->whole) {       return dp(p->next[pos], dep + 1);     } else {       vector<int> *ret = new vector<int>(p->whole + 1, 0);       for (int i = 0; i <= p->cnt; ++i) (*ret)[i] = i * (i - 1) * dep / 2;       int lim = p->cnt;       for (int i = 0; i < 26; ++i) {         if (p->next[i] != NULL) {           vector<int> *tmp = dp(p->next[i], dep + 1);           for (int j = lim; j >= 0; --j)             for (int k = 1;                  k < (int)tmp->size() && j + k <= lim + p->next[i]->whole; ++k)               (*ret)[j + k] =                   max((*ret)[j + k], (*ret)[j] + (*tmp)[k] + (j * k * dep));           lim += p->next[i]->whole;         }       }       return ret;     }   }   int dfs(trie *p) {     p->whole = p->cnt;     for (int i = 0; i < 26; ++i)       if (p->next[i] != NULL) p->whole += dfs(p->next[i]);     return p->whole;   }   int main() {     char s[512];     scanf( %d%d , &n, &k);     for (int i = 0; i < n; ++i) {       scanf( %s , s);       ins(s);     }     dfs(root);     printf( %d n , (*dp(root, 0))[k]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   function<void(void)> ____ = []() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);   };   const int MAXN = 4e5 + 7;   int n;   pair<int, int> A[MAXN];   struct Disjoint_Set_Union {     int fa[MAXN], sz[MAXN];     void clear() {       for (int i = 1; i < MAXN; i++) fa[i] = i, sz[i] = 0;     }     int findx(int x) { return x == fa[x] ? x : fa[x] = findx(fa[x]); }     void merge(int x, int y) {       x = findx(x), y = findx(y);       if (x != y) sz[y] += sz[x], fa[x] = y;     }   } dsu;   struct SegmentTree {     int root[MAXN], sz[MAXN << 4], tot, ls[MAXN << 4], rs[MAXN << 4];     long long sig[MAXN << 4], sum[MAXN << 4];     void pushup(int rt) {       sz[rt] = sz[ls[rt]] + sz[rs[rt]];       sig[rt] = sig[ls[rt]] + sig[rs[rt]];       sum[rt] = sig[ls[rt]] * sz[rs[rt]] + sum[ls[rt]] + sum[rs[rt]];     }     void modify(int &rt, int pos, int L, int R) {       rt = ++tot;       if (L + 1 == R) {         sz[rt]++;         sig[rt] += pos;         return;       }       int mid = (L + R) >> 1;       if (pos < mid)         modify(ls[rt], pos, L, mid);       else         modify(rs[rt], pos, mid, R);       pushup(rt);     }     int merge(int u, int v, int L, int R) {       if (!u or !v) return u ^ v;       if (L + 1 == R) {         sz[u] += sz[v];         sig[u] += sig[v];         return u;       }       int mid = (L + R) >> 1;       ls[u] = merge(ls[u], ls[v], L, mid);       rs[u] = merge(rs[u], rs[v], mid, R);       pushup(u);       return u;     }   } seg;   void solve() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d %d , &A[i].first, &A[i].second);     dsu.clear();     long long ret = 0;     for (int i = 1; i <= n; i++) {       int a = A[i].first, b = A[i].second;       ret -= 1ll * a * b;       int rt = dsu.findx(a);       int pos = rt + dsu.sz[rt];       dsu.sz[pos] = 1;       seg.modify(seg.root[pos], b, 1, n + 1);       if (pos == rt and pos != 1 and dsu.sz[pos - 1]) rt = dsu.findx(rt - 1);       if (pos != rt) {         ret -= seg.sum[seg.root[rt]];         ret -= rt * seg.sig[seg.root[rt]];         dsu.merge(pos, rt);         seg.root[rt] = seg.merge(seg.root[rt], seg.root[pos], 1, n + 1);       }       if (dsu.sz[pos + 1]) {         ret -= seg.sum[seg.root[pos + 1]];         ret -= (pos + 1) * seg.sig[seg.root[pos + 1]];         dsu.merge(pos + 1, rt);         seg.root[rt] = seg.merge(seg.root[rt], seg.root[pos + 1], 1, n + 1);       }       ret += seg.sum[seg.root[rt]];       ret += rt * seg.sig[seg.root[rt]];       cout << ret <<   n ;     }   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1e+18;   int main() {     cin.tie(0);     ios::sync_with_stdio(0);     int n, c = 0;     cin >> n;     while (n != 0) {       string str = to_string(n);       int maxi = 0;       for (int i = 0; i < str.size(); i++) {         if ((str[i] -  0 ) > maxi) {           maxi = str[i] -  0 ;         }       }       n -= maxi;       c++;     }     cout << c <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   struct Point {     int x, y;     Point() {}     Point(int a, int b) {       x = a;       y = b;     }   };   double hypt(Point A, Point B) {     return sqrt((B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y));   }   int main() {     int k, n;     cin >> n >> k;     vector<Point> v(n);     for (int i = 0; i < n; i++) {       cin >> v[i].x >> v[i].y;     }     double ans = 0;     for (int i = 1; i < n; i++) {       ans += hypt(v[i], v[i - 1]);     }     ans *= k;     ans /= 50;     printf( %.10lf , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     vector<pair<int, int>> arr;     vector<int> t;     for (int i = 0; i < n; i++) {       int a;       cin >> a;       t.push_back(a);       arr.push_back({a, i});     }     sort(arr.begin(), arr.end());     int i, j;     for (i = 0; i < arr.size(); i++) {       if (arr[i].second != i) break;     }     for (j = arr.size() - 1; j >= 0; j--) {       if (arr[j].second != j) break;     }     if (i == arr.size() || j < 0)       cout << 0 <<     << 0 << endl;     else {       vector<int> res;       for (int k = 0; k < i; k++) res.push_back(t[k]);       for (int k = j; k >= i; k--) res.push_back(t[k]);       for (int k = j + 1; k < n; k++) res.push_back(t[k]);       bool flag = false;       for (int k = 0; k < n - 1; k++) {         if (res[k] >= res[k + 1]) {           flag = true;           break;         }       }       if (!flag)         cout << arr[j].second + 1 <<     << arr[i].second + 1 << endl;       else         cout << 0 <<     << 0 << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct point {     long double x, y;   };   point a1, a2, a3, a4, b1, b2, b3, b4, c;   int l, r, u, d;   bool corner(point b) {     if (b.x <= r && b.x >= l && b.y <= u && b.y >= d)       return true;     else       return false;   }   pair<long double, long double> line(point a, point b) {     long double m, c;     m = ((long double)b.y - a.y) / ((long double)b.x - a.x);     c = a.y - m * a.x;     return {m, c};   }   point foot(pair<long double, long double> line) {     point p;     p.x =         (line.first * (c.y + line.second) + c.x) / (1 + line.first * line.first);     p.y = line.first * p.x + line.second;     return p;   }   bool inside(point p, pair<long double, long double> l1,               pair<long double, long double> l2) {     int k = l1.first / l2.first;     if (k == -1) {       l1.first *= -1;       l1.second *= -1;     }     if ((p.x * l1.first + l1.second - p.y) * (p.x * l2.first + l2.second - p.y) <=         0)       return true;     return false;   }   int main() {     ios::sync_with_stdio(0);     cin >> a1.x >> a1.y >> a2.x >> a2.y >> a3.x >> a3.y >> a4.x >> a4.y;     c.x = (a1.x + a2.x + a3.x + a4.x) / 4;     c.y = (a1.y + a2.y + a3.y + a4.y) / 4;     l = min(min(a1.x, a2.x), a3.x);     r = max(max(a1.x, a2.x), a3.x);     d = min(min(a1.y, a2.y), a3.y);     u = max(max(a1.y, a2.y), a3.y);     cin >> b1.x >> b1.y >> b2.x >> b2.y >> b3.x >> b3.y >> b4.x >> b4.y;     int flag = 0;     if (corner(b1) || corner(b2) || corner(b3) || corner(b4)) flag = 1;     pair<long double, long double> l1, l2, l3, l4;     l1 = line(b1, b2);     l2 = line(b2, b3);     l3 = line(b3, b4);     l4 = line(b4, b1);     long double d = (r - l) / 2 * sqrt((long double)2);     if ((inside(a1, l1, l3) && inside(a1, l2, l4)) ||         (inside(a2, l1, l3) && inside(a2, l2, l4)) ||         (inside(a3, l1, l3) && inside(a3, l2, l4)) ||         (inside(a4, l1, l3) && inside(a4, l2, l4)) ||         (inside(c, l1, l3) && inside(c, l2, l4)))       flag = 1;     if (flag)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }