malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(0);     ;     int n;     bool allSame = true;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) {       cin >> a[i];       if (i > 0 and a[i] != a[i - 1]) allSame = false;     }     sort(a, a + n);     if (n == 1) {       cout <<  -1 ;       return 0;     }     if (allSame) {       cout <<  1 n  << a[0];       return 0;     }     if (n == 2) {       if ((a[0] + a[1]) % 2 != 0)         cout <<  2 n  << a[0] - (a[1] - a[0]) <<     << a[1] + (a[1] - a[0]);       else         cout <<  3 n               << a[0] - (a[1] - a[0]) <<     << (a[0] + a[1]) / 2 <<                  << a[1] + (a[1] - a[0]);       return 0;     }     if (n == 3) {       int d1 = a[1] - a[0], d2 = a[2] - a[1];       if (d1 == d2) {         cout <<  2 n  << a[0] - d1 <<     << a[2] + d1;         return 0;       } else if (d1 == 2 * d2) {         cout <<  1 n  << a[0] + d1 / 2;         return 0;       } else if (2 * d1 == d2) {         cout <<  1 n  << a[1] + d2 / 2;         return 0;       }     }     set<int> uniq;     multiset<int> freq;     for (int i = 1; i < n; i++) {       uniq.insert(a[i] - a[i - 1]);       freq.insert(a[i] - a[i - 1]);     }     if (uniq.size() == 1) {       cout <<  2 n  << a[0] - *uniq.begin() <<     << a[n - 1] + *uniq.begin();       return 0;     } else if (uniq.size() == 2) {       int d1 = *uniq.begin();       int f1 = freq.erase(d1);       uniq.erase(d1);       int d2 = *uniq.begin();       int f2 = freq.erase(d2);       int d = f1 > f2 ? d1 : d2;       if (f1 > 1 and f2 > 1) {         cout <<  0 ;         return 0;       }       if (d1 == 0 or d2 == 0) {         cout <<  0 ;         return 0;       }       for (int i = 1; i < n; i++) {         if (a[i] - a[i - 1] == 2 * d) {           cout <<  1 n  << a[i - 1] + d;           return 0;         }       }     }     cout <<  0 ;   }
#include <bits/stdc++.h>   using namespace std;   long long t, n, k;   int main() {     ios_base::sync_with_stdio(0);     cin >> t;     while (t--) {       cin >> n >> k;       if (!n && !k)         cout << 0 <<   n ;       else         cout << 1440 - n * 60 - k <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int k;     cin >> k;     if (k < 25) {       cout << -1 << endl;     } else {       int r = 0, c = 0;       for (int i = 5; i <= sqrt(k); i++) {         if (k % i == 0) {           r = i;           c = k / i;           break;         }       }       if (r == 0 or c == 0) {         cout << -1 << endl;       } else {         char ch[] = { a ,  e ,  i ,  o ,  u };         string fr =   ;         for (int j = 0; j < r; j++) {           for (int i = 0; i < c; i++) {             fr += ch[(j + i) % 5];           }         }         cout << fr << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int s1, s2, s3, s4;     cin >> s1 >> s2 >> s3 >> s4;     unordered_set<int> s;     s.insert(s1);     s.insert(s2);     s.insert(s3);     s.insert(s4);     int si = s.size();     if (si == 4)       cout << 0;     else if (si == 3)       cout << 1;     else if (si == 2)       cout << 2;     else       cout << 3;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool sort_1(pair<int, int> &a, pair<int, int> &b) { return a.first < b.first; }   bool sort_2(pair<int, int> &a, pair<int, int> &b) { return a.first > b.first; }   int main() {     int n, cnt = 0;     scanf( %d , &n);     vector<vector<pair<int, int>>> a(1001);     for (int i = 0; i < n; ++i) {       int x, y;       scanf( %d %d , &x, &y);       a[x / 1000].push_back(make_pair(y, i + 1));     }     bool b = true;     for (int i = 0; i < 1001; ++i) {       if (b)         sort(a[i].begin(), a[i].end(), sort_1);       else         sort(a[i].begin(), a[i].end(), sort_2);       b = !b;     }     for (int i = 0; i < 1001; ++i) {       for (int j = 0; j < a[i].size(); ++j) printf( %d  , a[i][j].second);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int q;   long long r, n;   vector<int> degp[1000005];   long long answ[1000005][21];   long long m = 1000000007;   long long powmod(long long x, long long po) {     if (po == 0) {       return 1;     }     long long res = powmod(x, po / 2);     res = (res * res) % m;     if (po % 2 == 1) {       res = (res * x) % m;     }     return res;   }   int main() {     for (int i = 2; i <= 1000000; i++) {       if (degp[i].empty()) {         long long t = i;         long long u = 1;         while (t <= 1000000) {           for (int j = 1; j <= 1000000 / t; j++) {             if (j % i != 0) {               degp[t * j].push_back(u);             }           }           u++;           t = t * (long long)i;         }       }     }     for (int i = 0; i <= 1000000; i++) {       answ[i][0] = 1;     }     for (int i = 1; i < 21; i++) {       answ[0][i] = 2;       for (int j = 1; j <= 1000000; j++) {         answ[j][i] = (answ[j - 1][i] + answ[j][i - 1]) % m;       }     }     scanf( %d , &q);     for (int i = 0; i < q; i++) {       scanf( %I64d%I64d , &r, &n);       long long res = 1;       for (int k = 0; k < degp[n].size(); k++) {         res = (res * answ[r][degp[n][k]]) % m;       }       printf( %I64d n , res);     }   }
#include <bits/stdc++.h>   using namespace std;   struct no {     int x, y, r;   };   no A, B, b, a;   int dist(no u, no v) {     return (u.x - v.x) * (u.x - v.x) + (u.y - v.y) * (u.y - v.y);   }   bool contido(no v, no u) {     if (u.r < v.r) return 0;     if ((sqrt(dist(v, u)) + (double)((v.r)) - 1e-2 < (double)(u.r))) return 1;     return 0;   }   bool disjunto(no v, no u) {     if (sqrt(dist(u, v)) > (double)(v.r + u.r) - 1e-2) return 1;     return 0;   }   int main() {     cin >> a.x >> a.y >> a.r >> A.r;     A.x = a.x, A.y = a.y;     cin >> b.x >> b.y >> b.r >> B.r;     B.x = b.x, B.y = b.y;     if (B.r < A.r) {       swap(B, A);       swap(a, b);     }     int ans;     if (contido(A, B)) {       if (contido(A, b))         ans = 4;       else if (contido(a, b) || contido(b, a))         ans = 2;       else if (disjunto(b, A))         ans = 2;       else         ans = 1;     } else if (disjunto(A, B)) {       ans = 4;     } else {       if (contido(a, b) || contido(b, a))         ans = 1;       else {         ans = 0;         if (disjunto(a, B)) ans++;         if (disjunto(b, A)) ans++;       }     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   string s;   int k;   set<pair<string, int> > st;   pair<string, int> tmp;   int main() {     cin >> s >> k;     for (int i = 0; i < (int)s.length(); i++) {       string q =   ;       q += s[i];       st.insert(make_pair(q, i));     }     while (k > 1 && (int)st.size() > 0) {       tmp = *st.begin();       st.erase(st.begin());       if (tmp.second + 1 < (int)s.length()) {         tmp.second++;         tmp.first += s[tmp.second];         st.insert(tmp);       }       k--;     }     if ((int)st.size() > 0) {       tmp = *st.begin();       cout << tmp.first << endl;       return 0;     }     cout <<  No such line.  << endl;     return 0;   }
#include <bits/stdc++.h>   int n, q, maxn;   int a[200005];   std::vector<int> v[1901][105];   inline void merge(std::vector<int> &v1, std::vector<int> &v2) {     if (v1.size() < v2.size()) std::swap(v1, v2);     v1.insert(v1.end(), v2.begin(), v2.end());     v2.clear();   }   inline void assign(int i, int x, int y, int l, int r) {     static int vis[105] = {};     if ((i + 1) * maxn <= n) {       for (int j = 1; j <= 100; j++) {         for (int k : v[i][j]) vis[k] = j;         v[i][j].clear();         v[i][j].push_back(j);       }       for (int j = i * maxn; j < (i + 1) * maxn; j++) a[j] = vis[a[j]];     }     for (int j = l; j < r; j++)       if (a[j] == x) a[j] = y;   }   int main() {     scanf( %d , &n);     maxn = sqrt(n * log2(n)) + 1;     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     for (int i = 0; (i + 1) * maxn <= n; i++)       for (int j = 1; j <= 100; j++) v[i][j].push_back(j);     for (scanf( %d , &q); q--;) {       int l, r, x, y, L, R;       scanf( %d%d%d%d , &l, &r, &x, &y);       if (x != y) {         l--;         L = l / maxn, R = r / maxn;         if (L != R) {           assign(L, x, y, l, (L + 1) * maxn);           for (int i = L + 1; i < R; i++) merge(v[i][y], v[i][x]);           assign(R, x, y, R * maxn, r);         } else           assign(L, x, y, l, r);       }     }     for (int i = 0; (i + 1) * maxn <= n; i++) assign(i, 0, 0, 0, 0);     for (int i = 0; i < n; i++) printf( %d  , a[i]);   }
#include <bits/stdc++.h>   using namespace std;   const int INF = INT_MAX;   const signed long long int LINF = LLONG_MAX;   const double EPS = 1e-9;   const int MOD = 1000000007;   const int MAXN = 100001;   const int ALPH = 26;   const int DALPH = 52;   struct Node {     int l, r, m;     int minValue;     Node *lson, *rson;     Node(const int &al, const int &ar)         : l(al),           r(ar),           m((al + ar) / 2),           minValue(-1),           lson(nullptr),           rson(nullptr) {       if (l == r) {         return;       }       lson = new Node(l, m);       rson = new Node(m + 1, r);     }     ~Node() {       if (lson) {         delete lson;         delete rson;       }     }     void set(const int &index, const int &value) {       if (l == r) {         minValue = value;         return;       }       if (index < m + 1) {         lson->set(index, value);       } else {         rson->set(index, value);       }       minValue = min(lson->minValue, rson->minValue);     }     int getMin(const int &al, const int &ar) {       if (ar < l || r < al) {         return INF;       }       if (al <= l && r <= ar) {         return minValue;       }       return min(lson->getMin(al, ar), rson->getMin(al, ar));     }   };   struct pt {     int x, y;     pt() {}     pt(const int &ax, const int &ay) : x(ax), y(ay) {}     void read() { scanf( %d %d , &x, &y); }   };   bool operator<(const pt &p1, const pt &p2) { return p1.x < p2.x; }   struct query {     int id;     pt p1, p2;     bool ans;     query() {}     query(const int &aId, const pt &aP1, const pt &aP2)         : id(aId), p1(aP1), p2(aP2), ans(false) {}   };   bool operator<(const query &q1, const query &q2) { return q1.p2.x < q2.p2.x; }   bool cmpid(const query &q1, const query &q2) { return q1.id < q2.id; }   int n, m, k, q;   vector<pt> rook;   vector<query> qList;   void solve() {     sort((rook).begin(), (rook).end());     sort((qList).begin(), (qList).end());     Node *tree = new Node(1, m);     int rptr = 0, qptr = 0;     while (qptr < q) {       while (rptr < k && rook[rptr].x <= qList[qptr].p2.x) {         tree->set(rook[rptr].y, rook[rptr].x);         ++rptr;       }       if (tree->getMin(qList[qptr].p1.y, qList[qptr].p2.y) >= qList[qptr].p1.x) {         qList[qptr].ans = true;       }       ++qptr;     }     delete tree;   }   int main() {     scanf( %d %d %d %d , &n, &m, &k, &q);     rook.resize(k);     for (int i = 0; i < k; ++i) {       rook[i].read();     }     qList.resize(q);     for (int i = 0; i < q; ++i) {       pt p1, p2;       p1.read();       p2.read();       qList[i] = query(i, p1, p2);     }     solve();     for (int i = 0; i < k; ++i) {       swap(rook[i].x, rook[i].y);     }     for (int i = 0; i < q; ++i) {       swap(qList[i].p1.x, qList[i].p1.y);       swap(qList[i].p2.x, qList[i].p2.y);     }     swap(n, m);     solve();     sort((qList).begin(), (qList).end(), cmpid);     for (int i = 0; i < q; ++i) {       if (qList[i].ans) {         puts( YES );       } else {         puts( NO );       }     }   }
#include <bits/stdc++.h>   using namespace std;   int q, n, x;   void f() {     cin >> n;     vector<int> v;     for (int i = 0; i < n; i++) {       cin >> x;       v.push_back(x);     }     sort(v.begin(), v.end());     v.erase(unique(v.begin(), v.end()), v.end());     int maxi = v.back();     for (int i = v.size() - 1; i > 0 && v[i] + v[i - 1] > maxi; i--)       for (int j = i - 1; j >= 0; j--)         if (v[i] % v[j] != 0) {           maxi = max(maxi, v[i] + v[j]);           break;         }     for (int i = v.size() - 1; i > 0 && v[i] + v[i - 1] + v[i - 2] > maxi; i--)       for (int j = i - 1; j > 0; j--)         if (v[i] % v[j] != 0)           for (int k = j - 1; k >= 0; k--)             if (v[i] % v[k] != 0 && v[j] % v[k] != 0) {               maxi = max(maxi, v[i] + v[j] + v[k]);               break;             }     cout << maxi << endl;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0), cout.tie(0);     cin >> q;     for (int u = 0; u < q; u++) f();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int a, b, s;     cin >> a >> b >> s;     a < 0 ? a *= -1 : a *= 1;     b < 0 ? b *= -1 : b *= 1;     int l = min(a, b) * 2 + (max(a, b) - min(a, b));     cout << (l <= s ? l % 2 == s % 2 ?  YES  :  NO  :  NO );   }
#include <bits/stdc++.h>   using namespace std;   long long n, k, x, ans;   long long findX(long long R) {     if (R < 0) return 0;     return (R * (R + 1)) / 2;   }   int main() {     scanf( %lld %lld , &n, &k);     x = 0;     for (int i = 1; i <= n - 1; i++) {       if (findX(i - 1) <= k) x = i;     }     if (findX(x - 1) + x < k) {       printf( Impossible n );       return 0;     }     k -= findX(x - 1);     n -= x;     if (x) {       for (int i = 1; i <= x; i++) {         printf( ( );         if (i == k) {           printf( () );           n--;         }       }       for (int i = 1; i <= x; i++) {         printf( ) );       }     }     while (n) {       printf( () );       n--;     }     printf(  n );   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   int n, m, a, b, c, p[100010], cnt;   bool vis[100010], ed;   vector<pair<int, int> > V[100010];   int powmod(int x, int y) {     int res = 1, cro = x;     while (y) {       if (y % 2) res = 1ll * res * cro % mod;       cro = 1ll * cro * cro % mod;       y /= 2;     }     return res;   }   void dfs(int x) {     vis[x] = 1;     for (int i = 0; i < V[x].size(); i++) {       int y = V[x][i].first;       int z = V[x][i].second;       if (vis[y]) {         if (p[y] != p[x] ^ z) ed = 1;         continue;       } else {         p[y] = p[x] ^ z;         vis[y] = 1;         dfs(y);       }     }   }   int main() {     scanf( %d%d , &n, &m);     while (m--) {       scanf( %d%d%d , &a, &b, &c);       V[a].push_back(make_pair(b, c ^ 1));       V[b].push_back(make_pair(a, c ^ 1));     }     ed = 0;     for (int i = 1; i <= n; i++) {       if (!vis[i]) {         dfs(i);         cnt++;       }     }     if (ed)       puts( 0 );     else       printf( %d , powmod(2, cnt - 1));   }
#include <bits/stdc++.h>   using namespace std;   int dp[10000];   int main() {     int N, M;     cin >> N >> M;     int T;     double D;     int ans = 0;     for (int i = 0; i < N; i++) {       cin >> T >> D;       dp[T - 1]++;       for (int j = 0; j < T - 1; j++) dp[T - 1] = max(dp[T - 1], dp[j] + 1);     }     for (int i = 0; i < M; i++) ans = max(ans, dp[i]);     cout << N - ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     scanf( %d , &n);     if (n < 4)       printf( NO n );     else if (n % 2) {       printf( YES n );       printf( 1 + 5 = 6 n3 - 2 = 1 n4 * 6 = 24 n24 * 1 = 24 n );       for (int j = n; j > 6; j -= 2) {         printf( %d - %d = 1 n , j, j - 1);         printf( 24 * 1 = 24 n );       }     } else {       printf( YES n );       printf( 1 * 2 = 2 n2 * 3 = 6 n6 * 4 = 24 n );       for (int j = n; j > 5; j -= 2) {         printf( %d - %d = 1 n , j, j - 1);         printf( 24 * 1 = 24 n );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long mod = 1000000007;   const double PI = acos(-1.0);   const double E = exp(1.0);   const int M = 200010;   long long a[M];   long long ans[M][2];   int main() {     int n, k, x;     cin >> n >> k >> x;     long long temp = 1;     while (k--) temp *= x;     for (int i = 1; i <= n; ++i) {       scanf( %d , &a[i]);       ans[i][0] = (ans[i - 1][0] | a[i]);     }     long long mx = 0;     for (int i = n; i > 0; --i) {       mx = max(mx, ans[i + 1][1] | ans[i - 1][0] | (a[i] * temp));       ans[i][1] = ans[i + 1][1] | a[i];     }     cout << mx << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long k;   vector<pair<long long, char>> aa;   void print(long long a, char c) {     a = min(a, k);     if (a != 0) {       aa.push_back({a, c});     }     k -= a;   }   int32_t main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, m;     cin >> n >> m >> k;     if (k > 4 * n * m - 2 * n - 2 * m) {       cout <<  NO ;       return 0;     }     cout <<  YES n ;     for (long long i = 0; i < m - 1; i++) {       print(1,  R );       print(n - 1,  D );       print(n - 1,  U );     }     print(m - 1,  L );     for (long long i = 0; i < n - 1; i++) {       print(1,  D );       print(m - 1,  R );       print(m - 1,  L );     }     print(n - 1,  U );     cout << aa.size() <<   n ;     for (auto i : aa) {       cout << i.first <<     << i.second <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 2e5 + 10;   int arr[MAX];   int n;   vector<int> v[MAX];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int t;     cin >> t;     while (t--) {       cin >> n;       for (int i = 0; i < n; ++i) v[i].clear();       for (int i = 0; i < n; ++i) {         int x, y;         cin >> x >> y;         v[x].push_back(y);       }       long long ans = 0;       priority_queue<int, vector<int>, greater<int> > q;       for (int i = n - 1; i >= 0; --i) {         for (auto &j : v[i]) q.push(j);         while (q.size() > n - i) ans += q.top(), q.pop();       }       cout << ans <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int i, a[n];     long long int c = 0, ans = 0;     for (i = 0; i < n; i++) {       cin >> a[i];       c += a[i];     }     for (i = 1; i <= 5; i++) {       if ((c + i) % (n + 1) != 1) ans++;     }     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename _T>   inline void read(_T &f) {     f = 0;     _T fu = 1;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) {         fu = -1;       }       c = getchar();     }     while (c >=  0  && c <=  9 ) {       f = (f << 3) + (f << 1) + (c & 15);       c = getchar();     }     f *= fu;   }   template <typename T>   void print(T x) {     if (x < 0) putchar( - ), x = -x;     if (x < 10)       putchar(x + 48);     else       print(x / 10), putchar(x % 10 + 48);   }   template <typename T>   void print(T x, char t) {     print(x);     putchar(t);   }   const int N = 1e5 + 5;   int st1[16][N][17], st2[16][N][17];   int a[N], lg[N];   int n;   void make_st(int id) {     for (int j = 1; j <= 16; j++) {       for (int i = 1; i <= n - (1 << j) + 1; i++) {         st1[id][i][j] =             min(st1[id][i][j - 1], st1[id][i + (1 << (j - 1))][j - 1]);         st2[id][i][j] =             max(st2[id][i][j - 1], st2[id][i + (1 << (j - 1))][j - 1]);       }     }   }   int query1(int id, int l, int r) {     int k = lg[r - l + 1];     return min(st1[id][l][k], st1[id][r - (1 << k) + 1][k]);   }   int query2(int id, int l, int r) {     int k = lg[r - l + 1];     return max(st2[id][l][k], st2[id][r - (1 << k) + 1][k]);   }   int queryl(int base, int l, int r) {     int ans = query1(base, max(l, 1), min(r, n));     if (l <= 0) ans = max(-n + 1, min(ans, query1(base, l + n, n) - n));     if (r > n) ans = max(-n + 1, min(ans, query1(base, 1, r - n) + n));     return ans;   }   int queryr(int base, int l, int r) {     int ans = query2(base, max(l, 1), min(r, n));     if (l <= 0) ans = min(n * 2, max(ans, query2(base, l + n, n) - n));     if (r > n) ans = min(n * 2, max(ans, query2(base, 1, r - n) + n));     return ans;   }   int main() {     read(n);     if (n == 1) {       print(0,   n );       return 0;     }     lg[0] = -1;     for (int i = 1; i <= n; i++) {       read(a[i]);       lg[i] = lg[i >> 1] + 1;       st1[0][i][0] = i - a[i];       st2[0][i][0] = i + a[i];     }     make_st(0);     for (int base = 1; base <= 15; base++) {       for (int i = 1; i <= n; i++) {         int l = st1[base - 1][i][0], r = st2[base - 1][i][0];         st1[base][i][0] = queryl(base - 1, l, r);         st2[base][i][0] = queryr(base - 1, l, r);       }       make_st(base);     }     for (int i = 1; i <= n; i++) {       int l = i, r = i, ans = 0;       for (int j = 15; j >= 0; j--) {         int L = queryl(j, l, r), R = queryr(j, l, r);         if (R - L + 1 < n) l = L, r = R, ans |= (1 << j);       }       print(ans + 1, i == n ?   n  :    );     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, c;   vector<int> locck[567567];   const int S = 1 << 20;   int tree[2 * S];   void loduj() {     cin >> n >> c;     int x, l;     for (int i = 0; i < n; ++i) {       cin >> l;       for (int j = 0; j < l; ++j) {         cin >> x;         locck[i].push_back(x);       }     }     for (int i = 1; i < 2 * S; ++i) {       tree[i] = 1;     }   }   void forbRec(int p, int q, int pp, int qq, int no) {     if (q < pp || qq < p) {       return;     }     if (p <= pp && qq <= q) {       tree[no] = 0;       return;     }     int ss = (pp + qq) / 2;     forbRec(p, q, pp, ss, 2 * no);     forbRec(p, q, ss + 1, qq, 2 * no + 1);   }   void forb(int p, int q) { forbRec(p, q, 0, S - 1, 1); }   bool isVal(int p) {     p += S;     while (p) {       if (!tree[p]) {         return 0;       }       p /= 2;     }     return 1;   }   void cons(int x, int y) {     if (x < y) {       forb(c - y + 1, c - x);     } else {       forb(0, c - x);       forb(c - y + 1, c - 1);     }   }   void cons(vector<int> &u, vector<int> &v) {     int d = 0;     while ((d < u.size()) && (d < v.size()) && u[d] == v[d]) {       ++d;     }     if (d == u.size()) {       return;     }     if (d == v.size()) {       forb(0, c - 1);       return;     }     cons(u[d], v[d]);   }   void makeInts() {     for (int i = 0; i < n - 1; ++i) cons(locck[i], locck[i + 1]);   }   int solve() {     for (int i = 0; i < c; ++i)       if (isVal(i)) return i;     return -1;   }   int main() {     ios_base::sync_with_stdio(0);     loduj();     makeInts();     cout << solve() << endl;   }
#include <bits/stdc++.h>   using namespace std;   const unsigned long long MOD = 4207849484;   int main() {     int n, m, i, g, h, j;     char c;     scanf( %d%d , &n, &m);     vector<int> a(n + 1, 0), bl(n + 1, 0);     for (int(i) = 0; (i) < (m); ++(i)) {       getchar();       scanf( %c %d , &c, &g);       if (c ==  + ) {         if (bl[g]) {           puts( Already on );           continue;         }         h = g;         int b = 0;         for (j = 2; j * j <= h && b == 0; j++) {           if (h % j == 0) {             if (a[h / j] || a[j]) {               b = max(a[h / j], a[j]);               break;             }           }         }         b = max(b, a[g]);         if (b == 0) {           bl[g] = 1;           puts( Success );           h = g;           for (j = 2; j * j <= h; j++) {             if (h % j == 0) {               a[h / j] = a[j] = h;             }           }           a[h] = h;         } else {           printf( Conflict with %d n , b);         }       } else {         if (bl[g] == 0) {           puts( Already off );         } else {           bl[g] = 0;           h = g;           for (j = 2; j * j <= h; j++) {             if (h % j == 0) {               a[h / j] = a[j] = 0;             }           }           a[h] = 0;           puts( Success );         }       }     }     return 0;   }