malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   #pragma GCC optimize( omit-frame-pointer )   #pragma GCC optimize( unroll-loops )   const int MAXINT = 2147483640;   const long long MAXLL = 9223372036854775800LL;   const long long MAXN = 1000000;   const double pi = 3.1415926535897932384626433832795;   using namespace std;   int kol[300000];   int x1[300000];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     srand(time(0));     int n, mn = 1e9;     cin >> n;     for (int i = 1; i <= n; i++) {       cin >> x1[i];       mn = min(x1[i], mn);     }     for (int i = 1; i <= n; i++) {       x1[i] -= mn;       kol[x1[i]]++;     }     if (kol[2] == 0) {       cout << n << endl;       for (int i = 1; i <= n; i++) cout << x1[i] + mn <<    ;       cout << endl;       return 0;     }     int kol1 = kol[0];     int kol2 = kol[1];     int kol3 = kol[2];     int ans = n;     if (kol2 / 2 * 2 >= min(kol1, kol3) * 2) {       ans -= kol2 / 2 * 2;       kol1 += kol2 / 2;       kol3 += kol2 / 2;       kol2 -= kol2 / 2 * 2;     } else {       int kek = min(kol1, kol3);       ans -= kek * 2;       kol2 += kek * 2;       kol1 -= kek;       kol3 -= kek;     }     cout << ans << endl;     for (int i = 1; i <= kol1; i++) cout << mn <<    ;     for (int i = 1; i <= kol2; i++) cout << mn + 1 <<    ;     for (int i = 1; i <= kol3; i++) cout << mn + 2 <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   #pragma warning(disable : 4996)   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     int n;     string a;     cin >> n >> a;     stack<char> q;     int m = 1;     int len = 0;     int he = -1;     for (int i = 0; i < n; i++) {       if (q.empty() || q.top() == a[i]) {         q.push(a[i]);         len++;         m += 2;       } else {         if (a[i] != a[i - 1]) len += 3;         if (a[i] ==  [  && a[i - 1] ==  ] ) len += 4;         q.pop();         len++;         m -= 2;       }       he = max(he, m);     }     vector<vector<char>> res(len, vector<char>(he,    ));     m = 0;     int cur = 0;     for (int i = 0; i < n; i++) {       if (i != 0 && a[i] == a[i - 1] && a[i] ==  [ )         m++;       else if (i != 0 && a[i] == a[i - 1] && a[i] ==  ] )         m--;       if (a[i] ==  [ ) {         res[cur][m] =  + ;         res[cur][he - m - 1] =  + ;         res[cur + 1][m] =  - ;         res[cur + 1][he - m - 1] =  - ;         for (int j = m + 1; j < he - m - 1; j++) res[cur][j] =  | ;       } else {         if (a[i] ==  ]  && a[i - 1] ==  [ ) cur += 3;         res[cur - 1][m] =  - ;         res[cur - 1][he - m - 1] =  - ;         res[cur][m] =  + ;         res[cur][he - m - 1] =  + ;         for (int j = m + 1; j < he - m - 1; j++) res[cur][j] =  | ;       }       cur++;     }     for (int i = 0; i < he; i++) {       for (int j = 0; j < len; j++) cout << res[j][i];       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 2000 + 10;   const int MOD = (int)(1e9) + 7;   vector<int> adj[MAXN];   int a[MAXN], f[MAXN];   bool visited[MAXN];   int d, n;   void DFS(int u, int root) {     visited[u] = true;     f[u] = 1;     for (int i = 0; i < adj[u].size(); i++) {       int v = adj[u][i];       if (!visited[v]) {         if ((a[v] < a[root]) || (a[v] > a[root] + d)) continue;         if ((a[v] == a[root]) && (v < root)) continue;         DFS(v, root);         f[u] = ((long long)(f[u]) * (f[v] + 1)) % MOD;       }     }   }   int main() {     cin >> d >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n - 1; i++) {       int u, v;       cin >> u >> v;       adj[u].push_back(v);       adj[v].push_back(u);     }     int result = 0;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= n; j++) f[j] = 0, visited[j] = false;       DFS(i, i);       result = (result + f[i]) % MOD;     }     cout << result << endl;   }
#include <bits/stdc++.h>   using namespace std;   const double eps = 1e-9;   const int INF = 1000000007;   const int MOD = 1000000007;   const int MAXN = 100055;   int dx[] = {2, 1, -1, -2, -1, 1, 2, 1, -1};   int dy[] = {0, 2, 2, 0, -2, -2, 0, 2, 2};   int main() {     long long n;     while (cin >> n) {       n++;       if (n == 1) {         cout <<  0 0  << endl;         continue;       }       long long L = (n - 1 + 2) / 3;       L = sqrt(L + 0.5);       while (3 * L * (L + 1) + 1 < n) ++L;       n -= 3 * L * (L - 1) + 1;       int side = (n - 1) / L;       n -= L * side;       long long ansx = dx[side] * L + dx[side + 2] * n;       long long ansy = dy[side] * L + dy[side + 2] * n;       cout << ansx <<     << ansy << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct Node {     int s, e, d;   };   int a[1010];   int in[1010];   int out[1010];   int vis[1010];   int d[1010][1010];   int n, p;   int cnt = 0;   int ans;   Node node[1010];   void dfs(int x) {     if (!out[x]) {       node[cnt].e = x;       node[cnt].d = ans;       return;     } else {       ans = min(ans, d[x][a[x]]);       dfs(a[x]);     }   }   int cmp(Node a, Node b) { return a.s < b.s; }   int main() {     scanf( %d %d , &n, &p);     cnt = 0;     for (int i = 0; i < p; i++) {       int ta, tb, tc;       scanf( %d %d %d , &ta, &tb, &tc);       a[ta] = tb;       out[ta]++;       in[tb]++;       d[ta][tb] = tc;       vis[ta] = vis[tb] = 1;     }     for (int i = 1; i <= n && p != 0; i++) {       if (in[i] == 0 && vis[i]) {         ans = 1 << 30;         node[cnt].s = i;         dfs(i);         cnt++;       }     }     sort(node, node + cnt, cmp);     printf( %d n , cnt);     for (int i = 0; i < cnt; i++) {       printf( %d %d %d n , node[i].s, node[i].e, node[i].d);     }   }
#include <bits/stdc++.h>   template <class T>   bool setmax(T &_a, T _b) {     if (_b > _a) {       _a = _b;       return true;     }     return false;   }   template <class T>   bool setmin(T &_a, T _b) {     if (_b < _a) {       _a = _b;       return true;     }     return false;   }   const int N = 200010;   int a[N], ox[N], oy[N], ans[N];   int n, m;   int dfs(int k, int l1, int l2) {     setmin(l2, ox[k]);     int r1 = std::max(l1 + 1, oy[k]), r2 = l2 + 4;     if (l1 > l2 || r1 > r2) return -1;     int p = dfs(k + 1, r1 + 1, r2 + 1) - 1;     if (p > 0) {       int q = std::max(l1, p - 4);       for (int i = int(q); i <= int(p); ++i) ans[i] = k;       return q;     }     return (l1 <= n + 1 && l2 >= n + 1 && k > m ? n + 1 : -1);   }   bool solve() {     std::fill(ox, ox + N, n + 1);     std::fill(oy, oy + N, -1);     m = 0;     for (int i = int(1); i <= int(n); ++i)       if (a[i] > 0) {         setmin(ox[a[i]], i);         setmax(oy[a[i]], i);         setmax(m, a[i]);       }     return dfs(1, 1, 1) > 0;   }   int main() {     scanf( %d , &n);     for (int i = int(1); i <= int(n); ++i) scanf( %d , &a[i]);     if (solve()) {       printf( %d n , ans[n]);       for (int i = int(1); i <= int(n); ++i) printf( %d  , ans[i]);       printf(  n );     } else {       printf( -1 n );     }     return 0;   }
#include <bits/stdc++.h>   const int MAXN = 2e5 + 5;   using namespace std;   struct info {     int coord;     bool taxi;   } v[MAXN];   int n, m, dist[MAXN], man[MAXN], fr[MAXN];   int main() {     cin >> n >> m;     for (int i = 1; i <= n + m; i++) {       cin >> v[i].coord;       dist[i] = 2e9;     }     for (int i = 1; i <= n + m; i++) cin >> v[i].taxi;     int cur = -1;     for (int i = 1; i <= n + m; i++) {       if (v[i].taxi) cur = i;       if (!v[i].taxi && cur != -1) {         dist[i] = v[i].coord - v[cur].coord;         man[i] = cur;       }     }     cur = -1;     for (int i = n + m; i >= 1; i--) {       if (v[i].taxi) cur = i;       if (!v[i].taxi && cur != -1) {         if (v[cur].coord - v[i].coord < dist[i]) {           dist[i] = v[cur].coord - v[i].coord;           man[i] = cur;         }       }     }     for (int i = 1; i <= n + m; i++)       if (!v[i].taxi) fr[man[i]]++;     for (int i = 1; i <= n + m; i++) {       if (v[i].taxi) cout << fr[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   const int MAX = 1000010;   const long long MOD = 1e9 + 7;   const int INF = 0x3f3f3f3f;   const long long LLINF = 0x3f3f3f3f3f3f3f3f;   const long double EPS = 1e-6;   const long double PI = acos(-1.0);   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n, x, y;     cin >> n;     cout <<  YES n ;     for (int i = 0; i < n; i++) {       cin >> x >> y;       cin >> x >> y;       if (x & 1) {         if (y & 1)           cout << 1 <<   n ;         else           cout << 2 <<   n ;       } else {         if (y & 1)           cout << 3 <<   n ;         else           cout << 4 <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   inline int rd() {     register int ans = 0, flag = 1;     register char c = getchar();     for (; c >  9  || c <  0 ; c = getchar())       if (c ==  - ) flag = -1;     for (; c >=  0  && c <=  9 ; c = getchar()) ans = ans * 10 -  0  + c;     return ans * flag;   }   const int MAXN = 1e5 + 10;   int a[MAXN];   int ans[MAXN];   int tmp[MAXN];   int _[20][MAXN];   void dfs(int now, int n) {     if (n < 2 && _[now][1] == 0) {       if (tmp[0] < ans[0]) {         ans[0] = tmp[0];         for (register int i = 1; i <= tmp[0]; ++i) {           ans[i] = tmp[i];         }       }       return;     }     if (now > 18 || tmp[0] >= ans[0]) {       return;     }     for (register int I = 1; I <= n; ++I) {       if (_[now][I] & 1) {         for (register int i = 1; i <= n; ++i) {           _[now + 1][i] = (_[now][i] - (_[now][i] & 1)) >> 1;         }         tmp[++tmp[0]] = (1 << now);         register int nn =             unique(_[now + 1] + 1, _[now + 1] + n + 1) - _[now + 1] - 1;         dfs(now + 1, nn);         --tmp[0];         for (register int i = 1; i <= n; ++i) {           _[now + 1][i] = (_[now][i] + (_[now][i] & 1)) >> 1;         }         tmp[++tmp[0]] = -(1 << now);         nn = unique(_[now + 1] + 1, _[now + 1] + n + 1) - _[now + 1] - 1;         dfs(now + 1, nn);         --tmp[0];         return;       }     }     for (register int i = 1; i <= n; ++i) {       _[now + 1][i] = _[now][i] >> 1;     }     n = unique(_[now + 1] + 1, _[now + 1] + n + 1) - _[now + 1] - 1;     dfs(now + 1, n);   }   int main() {     register int n = rd();     for (register int i = 1; i <= n; ++i) {       a[i] = rd();     }     sort(a + 1, a + n + 1);     n = unique(a + 1, a + n + 1) - a - 1;     ans[0] = 0x3f3f3f3f;     for (register int i = 1; i <= n; ++i) {       _[0][i] = a[i];     }     dfs(0, n);     printf( %d n , ans[0]);     for (register int i = 1; i <= ans[0]; ++i) {       printf( %d  , ans[i]);     }     printf(  n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double PI = 3.1415926535897932384626433832795;   const long double EPS = 1e-11;   int n, m, first, second;   bool a[110][110];   pair<long double, int> find_k(int s, int e) {     queue<int> q;     int ur[110];     long double kr[110];     memset(ur, 0xFF, sizeof(ur));     memset(kr, 0, sizeof(kr));     q.push(s);     ur[s] = 1;     kr[s] = 1.0;     int p;     while (!q.empty()) {       p = q.front();       q.pop();       for (int i = 0; i < (n); i++)         if ((a[p][i]) && (ur[i] + 1 == ur[p])) kr[p] += kr[i];       for (int i = 0; i < (n); i++)         if ((a[p][i]) && (ur[i] == -1)) {           ur[i] = ur[p] + 1;           q.push(i);         }     }     return make_pair(kr[e], ur[e] - 1);   }   int main() {     cout << setiosflags(ios::fixed) << setprecision(10);     cin >> n >> m;     for (int i = 0; i < (m); i++) {       cin >> first >> second;       first--;       second--;       a[first][second] = 1;       a[second][first] = 1;     }     pair<long double, int> k = find_k(0, n - 1);     if (k.first == 0) cout <<  LOLO ;     long double ans = 1.0;     for (int i = 1; i < n - 1; i++) {       pair<long double, int> k1 = find_k(0, i), k2 = find_k(i, n - 1);       if (k1.second + k2.second == k.second)         ans = max(ans, 2.0 * k1.first * k2.first / k.first);     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long d[40000];   char s[4005];   void input() {     int i, j, len, a, sum;     long long res;     scanf( %d %s , &a, &s);     len = strlen(s);     for ((i) = 0; (i) < (len); (i)++) {       sum = 0;       for ((j) = (i); (j) <= (len - 1); (j)++) {         sum += s[j] -  0 ;         d[sum]++;       }     }     if (a == 0) {       res = d[0] * len * (len + 1) - d[0] * d[0];       printf( %I64d n , res);       return;     }     res = 0;     for ((i) = (9 * len); (i) >= (1); (i)--)       if (a % i == 0 && a / i <= 36000) res += d[i] * d[a / i];     printf( %I64d , res);   }   int main() {     input();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, a[1000005], m, M, N, sum;   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; ++i) scanf( %d , a + i), M = max(a[i], M);     for (int i = 1; i <= n; ++i) sum += M - a[i];     if (m <= sum)       printf( %d %d n , M, M + m);     else       printf( %d %d n , (m - sum + n - 1) / n + M, M + m);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const double PI = acos(-1.0);   const long long INF = 1000 * 1000 * 1000 + 7;   const long long LINF = INF * (long long)INF;   const int MAX = 100 + 47;   int A[MAX];   vector<int> B;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int n;     cin >> n;     for (int i = (0); i < (n); i++) cin >> A[i];     int cnt = 0;     int vid = 0;     for (int i = (0); i < (n + 1); i++) {       if ((A[i] < 0 && vid == 2) || i == n) {         B.push_back(cnt);         cnt = 1;         vid = 1;         continue;       }       cnt++;       if (A[i] < 0) vid++;     }     cout << (int)B.size() << endl;     for (int i = (0); i < ((int)B.size()); i++) {       cout << B[i] <<    ;     }     cout << endl;   }
#include <bits/stdc++.h>   int main() {     std::ios_base::sync_with_stdio(false);     std::cin.tie(nullptr);     std::cout.tie(nullptr);     int tc;     std::cin >> tc;     while (tc--) {       long long x, y;       std::cin >> x >> y;       if ((x == 1 || x == 3) && y > x) {         std::cout <<  NO n ;       } else if (x == 2 && y > 3) {         std::cout <<  NO n ;       } else {         std::cout <<  YES n ;       }     }     return 0;   }
#include <bits/stdc++.h>   int main(void) {     int n;     int k;     int M;     scanf( %d%d%d , &n, &k, &M);     int number[45][45] = {0};     for (int i = 0; i < k; i++) {       int temp;       scanf( %d , &temp);       for (int j = 0; j < n; j++) {         number[j][i] = temp;       }     }     for (int i = 0; i < n; i++) {       std::sort(number[i], number[i] + k);     }     int ptrAddR = 0;     int ptrAddL = 0;     int ptrDelR = 0;     int ptrDelL = -1;     int lockR = 0;     int time = M;     int score = 0;     for (int i = 0; i < k; i++) {       for (int j = 0; j < n; j++) {         if (time >= number[j][i]) {           time -= number[j][i];           ptrDelL = j;           ptrDelR = i;         } else {           goto FAST_JUMP;         }       }     }   FAST_JUMP:     if (ptrDelL == n) {       score = (ptrDelR - 1 + 1) * n;     } else {       score = (ptrDelR - 1 + 1) * n + ptrDelL + 1;     }     if (ptrDelR == k - 1) {       lockR = ptrDelL + 1;       ptrAddL = lockR;       ptrAddR = k - 1;       score += lockR;     } else {       ptrAddR = ptrDelR + 1;       ptrAddL = 0;     }     if (ptrDelL <= lockR) {       ptrDelL = n - 1;       ptrDelR--;     }     int warning = 0;     int tptrAddR = ptrAddR;     int tptrAddL = ptrAddL;     int tptrDelR = ptrDelR;     int tptrDelL = ptrDelL;     int tlockR = lockR;     int flag = 0;     while (!(lockR >= n - 1 || ptrDelR < 0 || warning >= 2)) {       if (tptrDelL <= tlockR) {         tptrDelL = n - 1;         tptrDelR--;       }       time += number[tptrDelL][tptrDelR];       tptrDelL--;       if (tptrDelL <= tlockR) {         tptrDelL = n - 1;         tptrDelR--;       }       flag = -1;       if (tptrAddR > k - 1) {         tptrAddR = tptrDelR + 1;         tptrAddL++;         tlockR++;       }       if (tptrAddR > k - 1 || tptrAddL > n - 1) {         break;       }       if (time >= number[tptrAddL][tptrAddR]) {         time -= number[tptrAddL][tptrAddR];         flag = 0;         tptrAddR++;         if (tptrAddR > k - 1) {           tptrAddR = tptrDelR + 1;           tptrAddL++;           tlockR++;           flag = 1;         }       } else {       }       warning -= flag;       if (warning <= 0) {         score -= warning;         warning = 0;         ptrAddL = tptrAddL;         ptrAddR = tptrAddR;         ptrDelL = tptrDelL;         ptrDelR = tptrDelR;         lockR = tlockR;       }     }     printf( %d , score);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, m;     cin >> n >> m;     vector<bool> hero(n);     vector<long long> v(n);     vector<int> pos_num(n);     for (int i = 0; i < m; i++) {       int s, h;       cin >> s >> h;       hero[--s] = 1;       pos_num[s] = i;       v[s] = h;     }     for (int i = 0; i < n; i++) {       int x;       cin >> x;       if (!hero[i]) v[i] = x;     }     for (int cell = 0; cell < n; cell++) {       vector<int> order;       vector<long long> v_;       vector<bool> hero_;       for (bool x : hero) hero_.push_back(x);       for (long long x : v) v_.push_back(x);       for (int dum = 0; dum < m; dum++) {         vector<bool> can(n);         for (int i = 0; i < n; i++)           if (hero_[i]) {             int inc = i <= cell ? 1 : -1;             long long sum = 0;             int idx = i;             bool ok = 1;             while (1) {               if (idx == i || !hero_[idx]) sum += v_[idx];               if (sum < 0) ok = 0;               if (idx == cell) break;               idx += inc;             }             if (ok) can[i] = 1;           }         int idx = -1;         for (int i = 0; i < cell + 1; i++) {           if (can[i]) {             idx = i;             break;           }         }         for (int i = n - 1; i >= cell; i--)           if (can[i]) {             idx = i;             break;           }         if (idx == -1) break;         int inc = idx <= cell ? 1 : -1;         order.push_back(pos_num[idx]);         hero_[idx] = 0;         while (1) {           v_[idx] = 0;           if (idx == cell) break;           idx += inc;         }       }       if (order.size() == m) {         cout << cell + 1 <<   n ;         for (int i = 0; i < m; i++) {           if (i) cout <<    ;           cout << order[i] + 1;         }         cout <<   n ;         return 0;       }     }     cout << -1 <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5, INF = 1e9 + 7;   int n, a[N];   bool used[N];   int main() {     int q;     cin >> q;     while (q--) {       cin >> n;       for (int i = 1; i <= n * 2; i++) {         cin >> a[i];         used[i] = 0;       }       vector<pair<int, int> > vec;       for (int i = 1; i <= n * 2; i++) {         if (used[i]) continue;         for (int j = i + 1; j <= n * 2; j++) {           if ((a[i] + a[j]) % 2 == 0) {             used[j] = 1;             used[i] = 1;             vec.push_back({i, j});             break;           }         }       }       bool cond = 1;       for (int i = 1; i <= n * 2; i++) {         if (!used[i]) {           cond = 0;         }       }       for (int i = 0; i < vec.size() - cond; i++) {         cout << vec[i].first <<     << vec[i].second << endl;       }     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, q, m;     cin >> n;     int a[n];     for (int i = 0; i < n; i++) cin >> a[i];     sort(a, a + n);     cin >> q;     while (q--) {       cin >> m;       cout << upper_bound(a, a + n, m) - a << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   int32_t main() {     long long t;     cin >> t;     while (t--) {       long long a, b;       cin >> a >> b;       cout << min(max(2 * a, b) * max(2 * a, b), max(a, 2 * b) * max(a, 2 * b))            << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a, b;   int k;   int main() {     cin >> a >> b;     if (b > a) {       cout <<  -1 n ;       return 0;     }     if (a == b) {       cout << a << endl;       return 0;     }     k = a / b;     if (k & 1) k++;     double ans = (a + b) * 1.0 / k;     printf( %.10f n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int cas = 1, T;   int n, a[10010], b[10010];   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d , &a[i]);     sort(a + 1, a + 1 + n);     int l = 1, r = (n + 1) / 2 + 1;     for (int i = 1; i <= n; i++) {       if (i % 2 == 1)         printf( %d  , a[l++]);       else         printf( %d  , a[r++]);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void showvec(vector<long long> &arr);   inline void solve() {     long long n;     cin >> n;     vector<long long> arr(n);     for (long long i = 0; i < n; i++) {       cin >> arr[i];     }   }   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     vector<long long> arr(200005);     long long t = 1;     cin >> t;     while (t--) {       long long n;       cin >> n;       fill(arr.begin(), arr.end(), -1);       long long ans = INT_MAX;       for (long long i = 0; i < n; i++) {         long long ele;         cin >> ele;         if (arr[ele] != -1) {           ans = min(ans, i - arr[ele] + 1);         }         arr[ele] = i;       }       cout << (ans == INT_MAX ? -1 : ans);       cout <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long int i, l, n, m, t;     cin >> n >> m;     long int a[m + 1];     for (i = 0; i < m; i++) cin >> a[i];     sort(a, a + m);     bool flag = true;     if (a[0] == 1) flag = false;     if (a[m - 1] == n) flag = false;     for (i = 0; i < m - 2; i++)       if (a[i] == a[i + 1] - 1 && a[i + 1] + 1 == a[i + 2]) flag = false;     if (!flag)       cout <<  NO  << endl;     else       cout <<  YES  << endl;   }
#include <bits/stdc++.h>   using namespace std;   struct my {     int num;     int dmg;   } dmg[10010];   int mx, reg, rg[10010], n;   int flag[10010];   vector<pair<int, int> > v;   bool operator<(my a, my b) {     if (a.dmg > b.dmg) return 1;     return 0;   }   int main() {     cin >> n >> mx >> reg;     for (int i = 0; i < n; i++) {       cin >> rg[i] >> dmg[i].dmg;       dmg[i].num = i;     }     int time = 0, inds, kols = 0, fl = 0;     int total_dmg = 0, cur = mx;     sort(dmg, dmg + n);     while (1) {       cur += (reg - total_dmg);       if (cur > mx) cur = mx;       if (cur <= 0) {         cout <<  YES n ;         cout << time <<     << kols <<   n ;         for (int i = 0; i < (int)v.size(); i++)           cout << v[i].first <<     << v[i].second <<   n ;         return 0;       }       inds = -1;       for (int i = 0; i < n; i++) {         if (!flag[i]) {           if (cur * 100 <= rg[dmg[i].num] * mx) {             inds = i;             break;           }         }       }       if (inds != -1) {         total_dmg += dmg[inds].dmg;         flag[inds] = 1;         kols++;         v.push_back(make_pair(time, dmg[inds].num + 1));       } else {         if (reg >= total_dmg) {           cout <<  NO n ;           return 0;         }       }       time++;     }     return 0;   }
#include <bits/stdc++.h>   bool isvowel(char s) {     if (s ==  a  || s ==  A  || s ==  e  || s ==  E  || s ==  i  || s ==  I  ||         s ==  o  || s ==  O  || s ==  u  || s ==  U )       return true;     else       return false;   }   long long fact(long long n) {     long long mul = 1;     for (long long i = 1; i <= n; i++) mul = mul * i;     return mul;   }   long long gcd(long long a, long long b) {     return b == 0 ? a : gcd(b % 1000000007, (a % b) % 1000000007);   }   using namespace std;   int main() {     int n;     cin >> n;     if (n & 1)       cout <<  -1             <<   n ;     else {       for (int i = 1; i <= n; i += 2) {         cout << i + 1 <<     << i <<    ;       }     }     return 0;   }