malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   vector<int> g1[30000 + 100], g2[30000 + 100];   set<int> st;   int Next[30000 + 100], Prev[30000 + 100];   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, m, start;     cin >> n >> m;     for (int i = 1; i <= m; i++) {       int u, v;       cin >> u >> v;       g1[u].push_back(v);       g2[v].push_back(u);     }     for (int i = 1; i <= n; i++) {       sort(g1[i].begin(), g1[i].end());       sort(g2[i].begin(), g2[i].end());     }     start = 0;     st.insert(0);     st.insert(1);     Next[start] = 1;     Prev[1] = 0;     for (int i = 2; i <= n; i++) {       vector<int> d;       bool flag = false;       for (auto it : g1[i]) {         if (it > i) continue;         int t1 = Next[it];         if (!binary_search(g1[i].begin(), g1[i].end(), t1)) {           flag = true;           Next[it] = i;           Prev[t1] = i;           Next[i] = t1;           Prev[i] = it;           break;         } else {           st.erase(it);           d.push_back(it);         }       }       if (!flag) {         for (auto it : g2[i]) {           if (it > i) continue;           int t1 = Prev[it];           if (!binary_search(g1[t1].begin(), g1[t1].end(), i)) {             flag = true;             Next[t1] = i;             Prev[it] = i;             Next[i] = it;             Prev[i] = t1;             break;           } else {             st.erase(t1);             d.push_back(t1);           }         }       }       if (!flag) {         auto it = st.begin();         int t1 = Next[*it];         Next[*it] = i;         Prev[t1] = i;         Next[i] = t1;         Prev[i] = *it;       }       for (auto it : d) {         st.insert(it);       }       st.insert(i);     }     int now = Next[0];     while (now) {       cout << now <<    ;       now = Next[now];     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)1e6 + 7;   int n;   string s;   vector<int> p;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> s;     n = (int)s.size();     for (int i = 0; i < n; i++) {       if (s[i] != s[(i + 1) % n]) {         p.push_back(i);       }     }     int ant = -1;     int yes = 0;     int no = 0;     for (int i = 1; i < (int)p.size(); i++) {       if (ant == -1 || p[i] != ant + 1) {         ant = p[i];         yes++;       }     }     if (p.back() == n - 1 && p[0] == 0) {       p.pop_back();     }     ant = -1;     for (int i = 0; i < (int)p.size(); i++) {       if (ant == -1 || p[i] != ant + 1) {         ant = p[i];         no++;       }     }     cout << max(yes, no) <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   int n;   bool isp(int a) {     for (int i = 2; i * i <= a; i++)       if (a % i == 0) return false;     return true;   }   int power[100001];   long long pow(long long a, long long b, long long MOD = n) {     long long ret = 1, c = a;     while (b) {       if (b & 1) ret = (ret * c) % MOD;       b >>= 1;       c = (c * c) % MOD;     }     return ret;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> n;     if (n < 4) {       cout <<  YES n ;       for (int i = 1; i <= n; i++) cout << i <<    ;     } else if (n == 4)       cout <<  YES n1 3 2 4  <<   n ;     else if (isp(n) == false)       cout <<  NO  <<   n ;     else {       cout <<  YES  <<   n ;       int g;       for (g = 2; g < n; g++) {         int i, j = 1;         for (i = 1;; i++) {           j = (g * j) % n;           if (j == 1) break;         }         if (i == n - 1) break;       }       power[0] = 1;       for (int i = 1; i < n; i++) power[i] = (power[i - 1] * 1ll * g) % n;       for (int i = 0; i < n - 1; i++)         cout << power[i % 2 ? i : n - i - 1] <<   n ;       cout << n <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = (int)1e5 + 17;   const int MX = (int)1e6 + 17;   const int MOD = (int)1e9 + 7;   const long long oo = LLONG_MAX;   const int INF = INT_MAX;   const long double Pi = 3.14159265358979323846264338327950288419716939937510;   const int di[4] = {-1, 0, 1, 0};   const int dj[4] = {0, 1, 0, -1};   inline long long IN() {     long long x = 0, ch = getchar(), f = 1;     while (!isdigit(ch) && (ch !=  - ) && (ch != EOF)) ch = getchar();     if (ch ==  - ) {       f = -1;       ch = getchar();     }     while (isdigit(ch)) {       x = (x << 1) + (x << 3) + ch -  0 ;       ch = getchar();     }     return x * f;   }   inline void OUT(long long x) {     if (x < 0) putchar( - ), x = -x;     if (x >= 10)       OUT(x / 10), putchar(x % 10 +  0 );     else       putchar(x +  0 );   }   void IOI2017() {     freopen(          partition           .in ,          r , stdin);     freopen(          partition           .out ,          w , stdout);   }   int n, cur = 4;   struct Week {     int w[10];   };   Week a[2 * N];   int Year(int x) {     if (x % 400 == 0 || x % 4 == 0 && x % 100) return 366;     return 365;   }   bool check(Week a, Week b) {     for (int i = 1; i <= 7; i++) {       if (a.w[i] != b.w[i]) return 0;     }     return 1;   }   int main() {     for (int i = 1000; i <= N * 2; i++) {       for (int j = 1; j <= Year(i); j++) {         a[i].w[cur]++;         cur++;         if (cur == 8) cur = 1;       }     }     ios_base::sync_with_stdio(0);     cin >> n;     for (int j = n + 1;; j++) {       if (check(a[n], a[j])) {         cout << j;         return 0;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INFL = 1LL << 60;   const int INF = 1 << 30;   const long long MOD = 998244353;   double EPS = 1e-10;   vector<long long> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};   vector<long long> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};   void pres(double A) { printf( %.12lf n , A); }   void BinarySay(long long x, long long y = 60) {     for (int i = 0; i < (y); i++) cout << (x >> (y - 1 - i) & 1);     cout << endl;   }   long long cnt_bit(long long x) { return __builtin_popcountll(x); }   long long pow_long(long long x, long long k) {     long long res = 1;     while (k > 0) {       if (k % 2) res *= x;       x *= x;       k /= 2;     }     return res;   }   long long pow_mod(long long x, long long k) {     x %= MOD;     long long res = 1;     while (k > 0) {       if (k % 2) {         res *= x;         res %= MOD;       }       x *= x;       x %= MOD;       k /= 2;     }     return res;   }   long long inverse(long long x) { return pow_mod(x, MOD - 2); };   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long lcm(long long x, long long y) {     long long res = x / gcd(x, y);     res *= y;     return res;   };   const int MAXcomb = 200010;   long long fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];   void COMinit() {     fac[0] = fac[1] = 1;     finv[0] = finv[1] = 1;     inv[1] = 1;     for (int i = 2; i < MAXcomb; i++) {       fac[i] = fac[i - 1] * i % MOD;       inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;       finv[i] = finv[i - 1] * inv[i] % MOD;     }   }   long long comb(int n, int k) {     if (n < k) return 0;     if (n < 0 || k < 0) return 0;     return fac[n] * finv[k] % MOD * finv[n - k] % MOD;   }   const int MAXkai = 200010;   long long kai_memo[MAXkai];   long long kai(long long N) {     if (kai_memo[N] != 0) return kai_memo[N];     if (N <= 1) return 1;     return kai_memo[N] = N * kai(N - 1) % MOD;   }   long long disit(long long second, long long base = 10) {     long long res = 0;     while (second) {       res++;       second /= base;     }     return res;   }   vector<long long> divisor(long long n) {     vector<long long> res(0);     for (long long i = 1; i * i <= n; i++) {       if (n % i == 0) {         res.push_back(i);         if (i != n / i) res.push_back(n / i);       }     }     sort(res.begin(), res.end());     return res;   }   void solve() {     int n;     cin >> n;     vector<int> a(n);     for (int i = 0; i < (n); i++) cin >> a[i];     sort(a.begin(), a.end());     long long sum = 0;     for (int i = 0; i < (n); i++) sum += a[i];     int m;     cin >> m;     for (int i = 0; i < (m); i++) {       int q;       cin >> q;       cout << sum - a[n - q] << endl;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0), cout.tie(0);     solve();   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 305;   struct sss {     int a, b, c;     bool operator<(const sss& a) const { return c < a.c; }   };   vector<sss> v[MAXN * MAXN];   int cost(int a, int b, int c, int d) { return abs(a - c) + abs(b - d); }   int main() {     int m, n, i, j, k, p;     cin >> m >> n >> p;     for (i = 1; i <= m; i++) {       for (j = 1; j <= n; j++) {         int num;         cin >> num;         v[num].push_back({i, j, 999999999});       }     }     i = 1;     for (j = 0; j < v[i].size(); j++) {       v[i][j].c = cost(v[i][j].a, v[i][j].b, 1, 1);     }     for (i = 2; i <= p; i++) {       sort((v[i - 1]).begin(), (v[i - 1]).end());       for (j = 0; j < v[i].size(); j++) {         for (k = 0; k < min((int)v[i - 1].size(), m + n + 2); k++) {           v[i][j].c =               min(v[i][j].c, v[i - 1][k].c + cost(v[i - 1][k].a, v[i - 1][k].b,                                                   v[i][j].a, v[i][j].b));         }       }     }     int ans = 999999999;     i = p;     for (j = 0; j < v[i].size(); j++) ans = min(ans, v[i][j].c);     cout << ans << endl;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 11;   int s[N];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &s[i]);     sort(s + 1, s + 1 + n);     for (int i = 1, j = 1; i <= n; i++) {       if (s[i] % s[j] != 0) {         printf( %d , -1);         return 0;       }     }     printf( %d n , s[1]);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T1, typename T2, typename T3>   struct pair3 {     T1 first;     T2 second;     T3 third;   };   template <typename T1, typename T2, typename T3, typename T4>   struct pair4 {     T1 first;     T2 second;     T3 third;     T4 fourth;   };   const long long MOD = 1000000007;   const long double PI = acos(-1.0);   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     long long n, m;     cin >> n;     vector<long long> ar(n);     for (long long i = 0; i < n; ++i) {       cin >> ar[i];     }     vector<vector<long long>> ans(n + 1);     for (long long len = 1; len <= n; ++len) {       vector<long long> temp;       long long mx = -1, mn = INT_MAX;       multiset<long long> st;       auto del = [&](long long val) {         auto it = temp.end();         --it;         while (1) {           if (*it == val) {             temp.erase(it);             break;           }           it -= 1;         }       };       for (long long start = 0; start < n; ++start) {         if (temp.size() < len) {           temp.push_back(ar[start]);           st.insert(ar[start]);         } else {           if (ar[start] > *st.begin()) {             del(*st.begin());             st.erase(st.begin());             st.insert(ar[start]);             temp.push_back(ar[start]);           }         }         ans[len] = temp;       }     }     cin >> m;     long long l, idx;     while (m--) {       cin >> l >> idx;       cout << ans[l][idx - 1] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m;   char s[1008][1008], last[1008][1008];   int a[58][58];   int flag[58], x[58], y[58];   int ans, tot;   bool in[8][8];   struct Tprogram {     void open() {       freopen( 1.in ,  r , stdin);       freopen( 1.out ,  w , stdout);     }     void close() {}     void init() {       scanf( %d%d , &n, &m);       for (int i = 1; i <= n; i++) scanf( %s , &s[i][1]);       for (int i = 1; i <= n; i++)         for (int j = 1; j <= m; j++) {           if (s[i][j] !=  .  && !a[i][j])             a[i][j] = a[i + 1][j] = a[i][j + 1] = a[i + 1][j + 1] = ++tot;           if (s[i][j] !=  . ) {             int t = s[i][j];             t = t <=  B  ? t - 64 : t - 94;             if (!x[t])               x[t] = a[i][j];             else               y[t] = a[i][j];           }         }     }     void dfs(int c, int d) {       if (d > 14) {         memset(in, 0, sizeof(in));         for (int i = 1; i <= 28; i++)           if (!in[flag[x[i]]][flag[y[i]]])             in[flag[x[i]]][flag[y[i]]] = in[flag[y[i]]][flag[x[i]]] = 1;           else             return;         ++ans;         if (ans == 1) {           for (int i = 1; i <= n; i++)             for (int j = 1; j <= m; j++) {               if (a[i][j])                 last[i][j] = flag[a[i][j]] - 1 +  0 ;               else                 last[i][j] =  . ;             }         }         return;       }       if (flag[d])         dfs(c, d + 1);       else {         flag[d] = c;         for (int i = d + 1; i <= 14; i++)           if (!flag[i]) {             flag[i] = c;             dfs(c + 1, d + 1);             flag[i] = 0;           }         flag[d] = 0;       }     }     void work() {       dfs(1, 1);       printf( %d n , ans * 5040);       for (int i = 1; i <= n; i++) {         for (int j = 1; j <= m; j++) printf( %c , last[i][j]);         printf(  n );       }     }   } Program;   int main() {     Program.init();     Program.work();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int t = 1;     while (t--) {       int sum, limit;       cin >> sum >> limit;       vector<pair<int, int>> v;       for (int i = 1; i <= limit; i++) {         v.push_back({1 << __builtin_ctz(i), i});       }       sort(v.rbegin(), v.rend());       vector<int> a;       int i = 0;       while (sum) {         if (i == v.size()) break;         if (sum >= v[i].first) {           a.push_back(v[i].second);           sum -= v[i].first;         }         i++;       }       if (sum != 0)         cout <<  -1 n ;       else {         cout << a.size() <<   n ;         for (auto i : a) {           cout << i <<    ;         }         cout <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int GEN_SIZE = 6;   vector<int> v, adj[50005];   int match[50005], match2[50005], vis[50005], ans[50005];   int V, Vleft;   int conv(vector<int> v, int s) {     int ans = 0;     for (int i = 0; i < v.size(); i++) {       ans *= s;       ans += v[i];     }     return ans;   }   vector<int> unconv(int p, int s) {     vector<int> v1;     for (int i = 0; i < s; i++) {       v1.push_back(p % s);       p /= s;     }     reverse(v1.begin(), v1.end());     return v1;   }   void recur(int x) {     if (x == GEN_SIZE) {       int rval = conv(v, GEN_SIZE);       for (int rem = 0; rem < GEN_SIZE; rem++) {         vector<int> tmp_v;         tmp_v.push_back(rem);         for (int i = 0; i < GEN_SIZE; i++)           if (rem != i) tmp_v.push_back(v[i]);         int lval = conv(tmp_v, GEN_SIZE);         adj[rval].push_back(lval);       }       return;     }     for (int i = 0; i < GEN_SIZE; i++) {       v.push_back(i);       recur(x + 1);       v.pop_back();     }   }   int aug(int v) {     if (vis[v]) return 0;     vis[v] = 1;     for (int j = 0; j < (int)adj[v].size(); j++) {       int r = adj[v][j];       if (match[r] == -1) {         match[r] = v;         return 1;       }     }     for (int j = 0; j < (int)adj[v].size(); j++) {       int r = adj[v][j];       if (aug(match[r])) {         match[r] = v;         return 1;       }     }     return 0;   }   int T;   vector<pair<pair<int, int>, int> > q;   int main() {     scanf( %d , &T);     for (int i = 0; i < T; i++) {       int N, R;       scanf( %d%d , &N, &R);       vector<int> v1;       v1.push_back(R - 1);       for (int j = 0; j < N - 1; j++) {         int x;         scanf( %d , &x);         v1.push_back(x - 1);       }       int val = conv(v1, N);       q.push_back(make_pair(make_pair(N, val), i));     }     sort(q.begin(), q.end());     int curN = 0;     for (int i = 0; i < q.size(); i++) {       if (curN != q[i].first.first) {         curN = q[i].first.first;         GEN_SIZE = curN;         memset(match, -1, sizeof(match));         int v = 1;         for (int i = 0; i < GEN_SIZE; i++) {           v *= GEN_SIZE;         }         for (int i = 0; i < v; i++) adj[i].clear();         recur(0);         for (int i = 0; i < v; i++) {           memset(vis, 0, sizeof(vis));           aug(i);         }         for (int i = 0; i < v; i++) match2[match[i]] = i;       }       vector<int> qv = unconv(q[i].first.second, curN);       vector<int> v1 = unconv(match[q[i].first.second], curN);       ans[q[i].second] = v1[qv[0]] + 1;     }     for (int i = 0; i < T; i++) printf( %d n , ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   int a[1000][1000];   int w, h;   int fastMax(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ y; }   int fastMin(int x, int y) { return (((y - x) >> (32 - 1)) & (x ^ y)) ^ x; }   int main() {     scanf( %d%d , &h, &w);     for (int y = 0; y < h; y++)       for (int x = 0; x < w; x++) scanf( %d , &a[y][x]);     int ans = -1;     for (int y1 = 0; y1 < h; y1++)       for (int y2 = y1 + 1; y2 < h; y2++) {         int m1 = -1, m2 = -1;         for (int x = 0; x < w; x++) {           const int v = fastMin(a[y1][x], a[y2][x]);           if (m1 < v) {             m2 = m1;             m1 = v;           } else if (m2 < v) {             m2 = v;           }         }         ans = fastMax(ans, m2);       }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, d, ff = 1, bb = 1;   long long mx;   pair<long long, long long> f[100005];   int main() {     scanf( %d%d , &n, &d);     for (int i = 1; i <= n; i++) scanf( %d%d , &f[i].first, &f[i].second);     sort(f + 1, f + n + 1);     for (int i = 2; i <= n; i++) f[i].second += f[i - 1].second;     while (true) {       while (f[bb].first - f[ff].first < d && bb != n + 1) bb++;       mx = max(mx, f[bb - 1].second - f[ff - 1].second);       ff++;       if (ff == n + 1) break;     }     printf( %I64d , mx);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 7;   const int SS = 4 * N;   long long n, q, k, a, b;   long long seg[SS][2];   void modif(int ind, int val, int s = 0, int e = n, int v = 1) {     if (ind < s || ind >= e) return;     if (e - s == 1) {       seg[v][0] += val, seg[v][0] = min(seg[v][0], a);       seg[v][1] += val, seg[v][1] = min(seg[v][1], b);       return;     }     int mid = (s + e) / 2;     modif(ind, val, s, mid, 2 * v);     modif(ind, val, mid, e, 2 * v + 1);     for (int i = 0; i < 2; i++) seg[v][i] = seg[2 * v][i] + seg[2 * v + 1][i];   }   long long get(int l, int r, int ind, int s = 0, int e = n, int v = 1) {     if (l >= e || r <= s) return 0;     if (l <= s && e <= r) return seg[v][ind];     int mid = (s + e) / 2;     long long res = 0;     res += get(l, r, ind, s, mid, 2 * v);     res += get(l, r, ind, mid, e, 2 * v + 1);     return res;   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> k >> a >> b >> q;     while (q--) {       int t;       cin >> t;       if (t == 1) {         int d, x;         cin >> d >> x;         d--;         modif(d, x);       } else {         int d;         cin >> d;         d--;         cout << get(0, d, 1) + get(d + k, n, 0) <<   n ;       }     }     return 0;   }
#include<bits/stdc++.h>   using namespace std;   #define ll long long   #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(),  , ,    ); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }      void err(istream_iterator<string> it) {}   template<typename T, typename... Args>   void err(istream_iterator<string> it, T a, Args... args)   {       cerr << *it <<   =   << a << endl;       err(++it, args...);   }      int main()   {       ll t;       cin>>t;       while(t--)       {           ll i,j,n,m,x;           cin>>n>>m>>x;           ll c=((x-1)/n)+1;           ll r=x-(c-1)*n;           ll ans=(r-1)*m+c;           cout<<ans<<endl;       }   }
#include <bits/stdc++.h>   using namespace std;   const int INF = (int)1e9;   const int maxN = 1.1e4;   vector<int> g[maxN];   map<string, int> m[maxN];   int len = 1;   void add(int v, string s) {     if (m[v][s] == 0) {       m[v][s] = len;       g[v].push_back(len);       len++;     }   }   void parse(string s) {     s = s +    ;     string cur;     int v = 0;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==      && cur.size()) {         add(v, cur);         v = m[v][cur];         cur =   ;       } else {         cur.push_back(s[i]);       }     }     cout << endl;   }   int mx[2];   pair<int, int> dfs(int v, int d) {     pair<int, int> ans = {0, g[v].size() == 0};     for (auto u : g[v]) {       pair<int, int> p = dfs(u, d + 1);       ans.first += p.first;       ans.second += p.second;     }     if (d >= 2) {       mx[0] = max(mx[0], ans.first);       mx[1] = max(mx[1], ans.second);     }     if (g[v].size()) ans.first++;     return ans;   }   int main() {     string s;     while (cin >> s) {       parse(s);     }     dfs(0, 0);     cout << mx[0] <<     << mx[1] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;      #define pb push_back   #define f first   #define s second   #define ll long long         ll MOD = 1000000007;      int main(){    ll t;    cin>>t;    while(t--){     ll n;     cin>>n;     int c =1;     if(n==1)cout<<1<<endl;     if(n==2)cout<<-1<<endl;     if(n>=3){      for(int i=0;i<n;i++){       for(int j=0;j<n;j++){        cout<<c<<   ;        c+=2;        if(c>n*n)c=2;       }       cout<<endl;      }     }    }   }
#include <bits/stdc++.h>   using namespace std;   int n;   vector<pair<int, int> > A;   int F(int i, int j) {     return (A[i].first - A[j].first) * (A[i].first - A[j].first) +            (A[i].second - A[j].second) * (A[i].second - A[j].second);   }   bool F1(vector<int> I) {     for (int(i) = (0); (i) < (4); ++(i))       for (int(j) = (0); (j) < (i); ++(j)) {         int d = F(I[i], I[j]);         vector<int> t;         for (int(k) = (0); (k) < (4); ++(k))           if (k != i && k != j) t.push_back(k);         int dd = F(I[t[0]], I[t[1]]);         if (d != dd) continue;         vector<int> v;         vector<int> q;         v.push_back(F(I[i], I[t[0]]));         q.push_back(F(I[t[0]], I[j]));         v.push_back(F(I[j], I[t[1]]));         q.push_back(F(I[t[1]], I[i]));         if (q[0] == q[1] && v[0] == v[1]) return true;       }     return false;   }   bool F2(vector<int> I) {     for (int(i) = (0); (i) < (4); ++(i))       for (int(j) = (0); (j) < (i); ++(j)) {         int d = F(I[i], I[j]);         vector<int> t;         for (int(k) = (0); (k) < (4); ++(k))           if (k != i && k != j) t.push_back(k);         int dd = F(I[t[0]], I[t[1]]);         if (d != dd) continue;         vector<int> v;         v.push_back(F(I[i], I[t[0]]));         v.push_back(F(I[t[0]], I[j]));         v.push_back(F(I[j], I[t[1]]));         v.push_back(F(I[t[1]], I[i]));         bool ok = true;         for (int(k) = (1); (k) < (4); ++(k))           if (v[k] != v[k - 1]) ok = false;         if (ok) return true;       }     return false;   }   int main() {     for (int(i) = (0); (i) < (8); ++(i)) {       int x, y;       cin >> x >> y;       A.push_back(make_pair(x, y));     }     int res = -1;     for (int(i) = (0); (i) < ((1 << 8)); ++(i)) {       vector<int> I;       vector<int> J;       for (int(j) = (0); (j) < (8); ++(j))         if ((i & (1 << j)) != 0)           I.push_back(j);         else           J.push_back(j);       if (I.size() != 4) continue;       if (F1(I) && F2(J)) res = i;     }     if (res == -1)       cout <<  NO  << endl;     else {       cout <<  YES  << endl;       for (int(i) = (0); (i) < (8); ++(i))         if ((res & (1 << i)) == 0) cout << i + 1 <<    ;       cout << endl;       for (int(i) = (0); (i) < (8); ++(i))         if ((res & (1 << i)) != 0) cout << i + 1 <<    ;       cout << endl;     }     return 0;   }