malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int n, m, k, src, dest, dist[100001], par[100001], mark[100001], vol[100001],       vis[100001];   vector<int> v[100001];   vector<pair<int, int> > edge;   vector<int> g[100001];   int reachable() {     memset(vis, 0, sizeof vis);     vis[src] = 1;     queue<int> q;     q.push(src);     while (!q.empty()) {       int x = q.front();       q.pop();       for (auto it : g[x]) {         int y = it;         if (vis[y]) continue;         vis[y] = 1;         q.push(y);       }     }     return vis[dest];   }   int ok(int val) {     int i, x, y, cur, dis, parent, nxt;     for (i = 1; i <= n; i++) dist[i] = 10000000;     priority_queue<pair<int, pair<int, int> > > q;     for (i = 1; i <= k; i++) {       dist[vol[i]] = 0;       par[vol[i]] = vol[i];       q.push({-dist[vol[i]], {par[vol[i]], vol[i]}});     }     while (!q.empty()) {       cur = q.top().second.second;       parent = q.top().second.first;       dis = -q.top().first;       q.pop();       if (dis != dist[cur] || parent != par[cur]) continue;       for (i = 0; i < v[cur].size(); i++) {         nxt = v[cur][i];         if (dist[nxt] > dist[cur] + 1) {           dist[nxt] = dist[cur] + 1;           par[nxt] = parent;           q.push({-dist[nxt], {par[nxt], nxt}});         }       }     }     for (i = 1; i <= n; i++) g[i].clear();     for (auto it : edge) {       x = it.first;       y = it.second;       if (par[x] == par[y]) continue;       if (dist[x] + dist[y] + 1 <= val) {         g[par[x]].push_back(par[y]);         g[par[y]].push_back(par[x]);       }     }     if (reachable()) return 1;     return 0;   }   int main() {     ios::sync_with_stdio(false);     ;     cin.tie(0);     ;     int i, j, x, y, lo, mid, hi;     cin >> n >> m >> k;     for (i = 1; i <= k; i++) {       cin >> vol[i];       mark[vol[i]] = 1;     }     for (i = 1; i <= m; i++) {       cin >> x >> y;       edge.push_back({x, y});       v[x].push_back(y);       v[y].push_back(x);     }     cin >> src >> dest;     if (!mark[dest]) {       mark[dest] = 1;       k++;       vol[k] = dest;     }     lo = 0;     hi = 10000000;     if (!ok(hi)) {       cout <<  -1 ;       return 0;     }     while (hi - lo > 1) {       mid = (lo + hi) / 2;       if (ok(mid))         hi = mid;       else         lo = mid;     }     cout << hi;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   struct node {     int left, right;     int time[60];     node(int left = 0, int right = 0) : left(left), right(right) {}   } arb[4 * 100000 + 5];   inline void unite(node &a, node b, node &c) {     for (int i = 0; i < 60; i++)       a.time[i] = b.time[i] + c.time[(i + b.time[i]) % 60];   }   int a[100000 + 5];   void build(int left, int right, int pos) {     arb[pos].left = left, arb[pos].right = right;     if (left == right) {       for (int i = 0; i < 60; i++)         if (i % a[left])           arb[pos].time[i] = 1;         else           arb[pos].time[i] = 2;       return;     }     int mijl = (left + right) >> 1;     build(left, mijl, pos << 1);     build(mijl + 1, right, (pos << 1) + 1);     unite(arb[pos], arb[pos << 1], arb[(pos << 1) + 1]);   }   void update(int up_pos, int val, int pos) {     if (arb[pos].left == arb[pos].right) {       for (int i = 0; i < 60; i++)         if (i % val)           arb[pos].time[i] = 1;         else           arb[pos].time[i] = 2;       return;     }     int mijl = (arb[pos].left + arb[pos].right) >> 1;     if (up_pos <= mijl)       update(up_pos, val, pos << 1);     else       update(up_pos, val, (pos << 1) + 1);     unite(arb[pos], arb[pos << 1], arb[(pos << 1) + 1]);   }   int ans;   void query(int x, int y, int pos) {     if (arb[pos].left == x && arb[pos].right == y) {       ans += arb[pos].time[ans % 60];       return;     }     int mijl = (arb[pos].left + arb[pos].right) >> 1;     if (y <= mijl)       query(x, y, pos << 1);     else if (x > mijl)       query(x, y, (pos << 1) + 1);     else {       query(x, mijl, pos << 1);       query(mijl + 1, y, (pos << 1) + 1);     }   }   int main() {     ios_base::sync_with_stdio(false);     int n = 0;     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     build(1, n, 1);     int q = 0;     cin >> q;     char type;     int x, y;     while (q--) {       cin >> type >> x >> y;       if (type ==  A ) {         y--;         ans = 0;         query(x, y, 1);         cout << ans <<   n ;       } else         update(x, y, 1);     }     return 0;   }
#include <bits/stdc++.h>   int Fa[200010];   std::vector<int> v[200010];   int Find(int x) { return Fa[x] == x ? x : Fa[x] = Find(Fa[x]); }   bool vis[200010];   inline void merge(int a, int b) {     int f1 = Find(a), f2 = Find(b);     if (f1 != f2) {       Fa[f1] = f2;     }   }   int main() {     int n, m, q;     scanf( %d%d%d , &n, &m, &q);     for (; q; --q) {       int x, y;       scanf( %d%d , &x, &y);       v[x].push_back(y);     }     for (int i = 1; i <= m; ++i) Fa[i] = i;     int ans = 0;     for (int i = 1; i <= n; ++i) {       if (!v[i].size())         ++ans;       else {         int a = v[i][0];         for (int j = 1, _ = v[i].size(); j < _; ++j) merge(a, v[i][j]);       }     }     for (int i = 1; i <= m; ++i)       if (!vis[Find(i)]) ++ans, vis[Find(i)] = 1;     printf( %d n , ans - 1);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long int mod = 1000000007;   long long int vi[100000], m, n, k, p1, p2, p3, p, f, t;   long long int powmod(long long int a1, long long int b1) {     long long int res = 1;     a1 %= mod;     for (; b1; b1 >>= 1) {       if (b1 & 1) res = res * a1 % mod;       a1 = (a1 * a1) % mod;     }     return res;   }   vector<long long int> v[20000];   void dfs(long long int s) {     vi[s] = 1;     long long int x = v[s].size();     for (long long int i1 = 0; i1 < (int)(x); i1++)       if (!vi[v[s][i1]]) dfs(v[s][i1]);   }   int main() {     cin >> n;     for (long long int i = 0; i < (int)(n); i++) {       cin >> p1;       p1--;       v[p1].push_back(i);       v[i].push_back(p1);     }     long long int o = 0;     for (long long int i = 0; i < (int)(n); i++) {       if (!vi[i]) {         o++;         dfs(i);       }     }     cout << o;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int k, n1, n2, n3, t1, t2, t3;     cin >> k >> n1 >> n2 >> n3 >> t1 >> t2 >> t3;     multiset<int> A, B, C;     for (int i = 0; i < n1; ++i) A.insert(0);     for (int i = 0; i < n2; ++i) B.insert(0);     for (int i = 0; i < n3; ++i) C.insert(0);     for (int i = 0; i < k; ++i) {       int a = *A.begin();       int b = *B.begin();       int c = *C.begin();       int t = max(a, max(b - t1, c - t1 - t2));       A.erase(A.begin());       A.insert(t + t1);       B.erase(B.begin());       B.insert(t + t1 + t2);       C.erase(C.begin());       C.insert(t + t1 + t2 + t3);     }     int ret = *max_element(C.begin(), C.end());     cout << ret;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool comp(const pair<int, int> &a, const pair<int, int> &b) {     if (a.first > b.first) return true;     if (a.first == b.first) return a.second > b.second;     return false;   }   int main() {     int n;     scanf( %d , &n);     vector<pair<int, int> > v;     for (int i = 0; i < n; i++) {       int k;       scanf( %d , &k);       int a[100001];       int ok = 1;       for (int i = 0; i < k; i++) {         scanf( %d , &a[i]);         if (i && a[i] > a[i - 1]) ok = 0;       }       if (ok) v.push_back(make_pair(a[0], a[k - 1]));     }     sort(v.begin(), v.end(), comp);     vector<int> lo, hi;     for (auto i : v) {       hi.push_back(i.first);       lo.push_back(i.second);     }     long long ans = 0;     for (int i = 0; i < v.size(); i++) {       int m = upper_bound(hi.rbegin(), hi.rend(), lo[i]) - hi.rbegin();       ans += m;     }     printf( %lld , ((long long)n * (long long)n) - ans);   }
#include <bits/stdc++.h>   using namespace std;   signed main() {     long long n;     cin >> n;     long long arr[n];     for (long long i = 0; i < n; i++) {       cin >> arr[i];     }     long long c = 0;     long long d = 0;     long long e = 0;     long long h;     long long g;     for (long long i = 0; i < n; i++) {       if (arr[i] >= 0) {         c++;       } else {         d++;       }     }     if (n == 1) {       cout << arr[0];       return 0;     }     if (c >= 1 && d >= 1) {       for (long long i = 0; i < n; i++) {         e = e + abs(arr[i]);       }     } else if (c == 0 || d == 0) {       h = abs(arr[0]);       for (long long i = 0; i < n; i++) {         e = e + abs(arr[i]);         h = min(h, abs(arr[i]));       }       e = e - 2 * h;     }     cout << e;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int n, i, j = 1, j2 = 0, j3, k, h = 1;     string s;     cin >> s;     for (i = 1; i < s.length(); ++i) {       if (j < h) j = h;       if (h == s.length()) break;       if (s[i - 1] != s[i] && i != 0)         h++;       else if (i == 0 && s[i] != s[s.length() - 1])         h++;       else         h = 1;       if (i == s.length() - 1 && j2 == 0) {         i = -1;         j2 = 1;       }     }     if (j < h) j = h;     cout << j << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 123456;   void pre();   void post();   int n;   int mas[MAXN];   int solve[MAXN];   void read() {     cin >> n;     for (int i = 0; i < n; i++) {       scanf( %lld , &mas[i]);       solve[mas[i] - 1] = i;     }   }   int main() {     pre();     read();     int ans = 0;     int l = 0;     for (int i = 1; i < n; i++) {       if (solve[i] < solve[i - 1]) {         l = i;       }       ans = max(ans, i - l + 1);     }     ans = max(ans, n - l);     cout << n - ans;     post();     return 0;   }   void pre() {}   void post() {}
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int streak = 0;     int maxStreak = 0;     char c =  2 ;     for (int i = 0; i < s.length(); i++) {       if (c != s[i]) {         c = s[i];         streak = 0;       }       streak++;       maxStreak = streak > maxStreak ? streak : maxStreak;     }     cout << (maxStreak >= 7 ?  YES  :  NO ) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long bigmod(long long base, long long power) {     if (power == 0) return 1;     long long ret = bigmod(base, power / 2);     ret = (ret * ret) % 1000000007;     if (power & 1) ret = (ret * base) % 1000000007;     return ret;   }   long long modInverse(long long n) {     return (bigmod(n, 1000000007 - 2) % 1000000007);   }   const int MX = 1e6 + 7;   int store[MX] = {}, check[MX] = {}, id[1007], n;   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       int p;       scanf( %d , &p);       id[i] = p;       store[p]++;     }     int mx = -1;     for (int i = 0; i < MX; i++) mx = max(mx, store[i]);     for (int i = 0; i < n; i++) {       check[id[i]]++;       if (check[id[i]] == mx) {         cout << id[i] <<   n ;         break;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   void __print(int x) { cerr << x; }   void __print(long x) { cerr << x; }   void __print(long long x) { cerr << x; }   void __print(unsigned x) { cerr << x; }   void __print(unsigned long x) { cerr << x; }   void __print(unsigned long long x) { cerr << x; }   void __print(float x) { cerr << x; }   void __print(double x) { cerr << x; }   void __print(long double x) { cerr << x; }   void __print(char x) { cerr <<      << x <<     ; }   void __print(const char *x) { cerr <<     << x <<    ; }   void __print(const string &x) { cerr <<     << x <<    ; }   void __print(bool x) { cerr << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cerr <<  { ;     __print(x.first);     cerr <<  , ;     __print(x.second);     cerr <<  } ;   }   template <typename T>   void __print(const T &x) {     int f = 0;     cerr <<  { ;     for (auto &i : x) cerr << (f++ ?  ,  :   ), __print(i);     cerr <<  } ;   }   void _print() { cerr <<  ] n ; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cerr <<  ,  ;     _print(v...);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long int n;     cin >> n;     vector<long long int> array1, array2;     for (long long int i = 0; i < n; i++) {       long long int p;       cin >> p;       array1.push_back(p);       array2.push_back(p);     }     sort(array2.begin(), array2.end());     long long int count = 0;     for (long long int i = 0; i < n; i++) {       if (array1[i] != array2[i]) {         count++;       }     }     if (count == 0 || count == 2) {       cout <<  YES  << endl;     } else {       cout <<  NO  << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void Read(T &x) {     int f = 1;     char t = getchar();     while (t <  0  || t >  9 ) {       if (t ==  - ) f = -1;       t = getchar();     }     x = 0;     while (t >=  0  && t <=  9 ) {       x = x * 10 + t -  0 ;       t = getchar();     }     x *= f;   }   const int modulo = 1000000007;   const int maxn = 1000005;   int p, k;   int fst[maxn], v[maxn << 1], nxt[maxn << 1], e_cn;   bool flag[maxn], vis[maxn], cycle;   void addedge(int x, int y) {     e_cn++;     v[e_cn] = y, nxt[e_cn] = fst[x], fst[x] = e_cn;   }   void input() { Read(p), Read(k); }   int pwr(long long x, long long k) {     long long re = 1;     while (k > 0) {       if (k & 1) re = 1ll * re * x % modulo;       x = 1ll * x * x % modulo;       k >>= 1;     }     return re;   }   void dfs(int cn) {     vis[cn] = true;     cycle |= flag[cn];     for (register int i = fst[cn]; i; i = nxt[i]) {       if (!vis[v[i]]) {         dfs(v[i]);       }     }   }   void solve() {     if (k == 0) {       cout << pwr(p, p - 1) << endl;       return;     }     if (k == 1) {       cout << pwr(p, p) << endl;       return;     }     long long ans = 1;     for (register int i = 0; i < p; i++) {       int x = i, y = 1ll * i * k % p;       if (x == y)         flag[x] = true;       else         addedge(x, y), addedge(y, x);     }     for (register int i = 0; i < p; i++) {       if (!vis[i]) {         cycle = false;         dfs(i);         if (!cycle) ans = 1ll * ans * p % modulo;       }     }     cout << ans << endl;   }   int main() {     input();     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int t, x, y, a, b;   int main(void) {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cin >> t;     while (t--) {       cin >> x >> y >> a >> b;       int tmp = (y - x) / (a + b);       if (x + tmp * a == y - tmp * b)         cout << tmp <<   n ;       else         cout << -1 <<   n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     set<int> a;     int n, b, c;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> b;       a.insert(b);     }     if (a.size() == 1)       std::cout << 0 << endl;     else if (a.size() == 2) {       b = *a.begin();       c = *(--a.end());       int a1;       if ((c - b) % 2 == 1)         a1 = c - b;       else         a1 = (c - b) / 2;       cout << a1 << endl;     } else if (a.size() == 3) {       auto iter = a.begin();       int a1, a2, a3;       a1 = *iter++;       a2 = *iter++;       a3 = *iter;       if (a2 - a1 == a3 - a2)         cout << a2 - a1 << endl;       else         cout << -1 << endl;     } else       cout << -1 << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAXN = 1000 * 100 * 3 + 10;   long long int mod = 998244353;   long long int x[MAXN];   long long int y[MAXN];   pair<long long int, long long int> p[MAXN];   long long int f(long long int n) {     long long int m = 1;     for (int i = 1; i <= n; i++) {       m *= i % mod;       m = m % mod;     }     return m % mod;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     int n;     cin >> n;     for (int i = 0; i < n; i++) {       cin >> x[i] >> y[i];       p[i].first = x[i];       p[i].second = y[i];     }     sort(x, x + n);     sort(y, y + n);     sort(p, p + n);     long long int k1 = 1;     long long int k2 = 1;     long long int c = 1;     for (int i = 0; i < n - 1; i++) {       long long int t = i, cnt = 1;       bool bol = false;       while (i < n && x[t] == x[i + 1]) {         bol = true;         cnt++;         i++;       }       if (bol) {         i--;       }       k1 *= f(cnt);       k1 = k1 % mod;     }     for (int i = 0; i < n - 1; i++) {       long long int t = i, cnt = 1;       bool bol = false;       while (i < n && y[t] == y[i + 1]) {         bol = true;         cnt++;         i++;       }       if (bol) {         i--;       }       k2 *= f(cnt);       k2 = k2 % mod;     }     bool fl = false;     for (int i = 1; i < n; i++) {       if (p[i].second < p[i - 1].second) {         fl = true;       }     }     if (fl) {       c = 0;     } else {       for (int i = 0; i < n - 1; i++) {         long long int t = i, cnt = 1;         bool bol = false;         while (i < n && p[t].first == p[i + 1].first &&                p[t].second == p[i + 1].second) {           bol = true;           cnt++;           i++;         }         if (bol) {           i--;         }         c *= f(cnt);         c = c % mod;       }     }     cout << ((f(n) % mod - (k1 + k2) % mod + mod) % mod + c % mod) % mod << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int N = 1000010;   int T, n, m, flag, cnt;   vector<int> e[N], E[N];   int dfn[N], idx = 0, low[N], bl[N], lb, sta[N], top;   template <typename T>   void gi(T &x) {     x = 0;     register char c = getchar(), pre = 0;     for (; c <  0  || c >  9 ; pre = c, c = getchar())       ;     for (; c >=  0  && c <=  9 ; c = getchar()) x = x * 10ll + (c ^ 48);     if (pre ==  - ) x = -x;   }   int ksm(int x, int y = mod - 2) {     int w = 1;     for (; y; y >>= 1, x = 1ll * x * x % mod)       if (y & 1) w = 1ll * x * w % mod;     return w;   }   void tarjan(int u) {     dfn[u] = low[u] = ++idx, sta[++top] = u;     for (auto v : e[u]) {       if (!dfn[v])         tarjan(v), low[u] = min(low[u], low[v]);       else if (!bl[v])         low[u] = min(low[u], dfn[v]);     }     if (dfn[u] == low[u]) {       bl[u] = ++lb;       for (; sta[top] != u; --top) bl[sta[top]] = lb;       --top;     }   }   void solve() {     gi(n), gi(m);     for (int i = (1); i <= (n); i++)       e[i].clear(), E[i].clear(), dfn[i] = low[i] = bl[i] = 0;     for (int i = (1); i <= (m); i++) {       int x, y;       gi(x), gi(y);       if (x == y) continue;       e[y].push_back(x);     }     top = idx = lb = 0;     for (int i = (1); i <= (n); i++)       if (!dfn[i]) tarjan(i);     if (lb == 1) {       puts( No );       return;     }     puts( Yes ), cnt = 0;     for (int i = (1); i <= (n); i++)       for (auto v : e[i])         if (bl[i] != bl[v]) E[bl[i]].push_back(bl[v]);     for (int i = (1); i <= (lb); i++)       if (!E[i].size()) flag = i;     for (int i = (1); i <= (n); i++)       if (bl[i] != flag) ++cnt;     printf( %d %d n , cnt, n - cnt);     for (int i = (1); i <= (n); i++)       if (bl[i] != flag) printf( %d  , i);     puts(  );     for (int i = (1); i <= (n); i++)       if (bl[i] == flag) printf( %d  , i);     puts(  );     puts(  );   }   int main() {     for (gi(T); T; --T) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = (long long)(2 * 1e5) + 5;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     map<int, int> mp;     int n;     cin >> n;     vector<int> a(n + 1), b(n + 1), p(n + 1);     for (int i = 1; i <= n; i++) {       cin >> a[i];       p[a[i]] = i;     }     for (int i = 1; i <= n; i++) {       cin >> b[i];     }     for (int i = 1; i <= n; i++) {       int x = p[b[i]] - i;       if (x < 0) {         x += n;       }       mp[x]++;     }     int mx = 0;     for (auto i : mp) {       mx = max(mx, i.second);     }     cout << mx << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n;     cin >> n;     int sum = 0;     for (int i = 0; i < n; i++) {       int x1, x2, y1, y2;       cin >> x1 >> x2 >> y1 >> y2;       sum += (max(x1, y1) - min(x1, y1) + 1) * (max(x2, y2) - min(x2, y2) + 1);     }     cout << sum <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char buf[32];   int Solution() {     int n, m;     scanf( %d%d , &n, &m);     vector<int> mas(n);     for (int i = 0; i < n; ++i) scanf( %d , &mas[i]);     sort(mas.begin(), mas.end());     map<string, int> fr;     gets(buf);     for (int i = 0; i < m; ++i) {       gets(buf);       string f = buf;       if (fr.find(f) == fr.end())         fr.insert(make_pair(f, 1));       else         fr[f]++;     }     map<string, int>::iterator it = fr.begin();     vector<int> z;     while (it != fr.end()) {       z.push_back(it->second);       ++it;     }     sort(z.rbegin(), z.rend());     int res = 0;     for (int i = 0; i < z.size(); ++i) res += z[i] * mas[i];     printf( %d  , res);     res = 0;     for (int i = 0; i < z.size(); ++i) res += z[i] * mas[mas.size() - i - 1];     printf( %d n , res);     return 0;   }   int main() {     Solution();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 10;   const int MOD = 1e9 + 7;   long long dp[N][2];   void solve() {     memset(dp, 0, sizeof(dp));     string a, b;     cin >> a >> b;     (a == b ? dp[0][1] = 1 : dp[0][0] = 1);     int k;     cin >> k;     long long way_good = 0, way_bad = 0;     string s = a;     for (int i = 0; i < (int)(a).size(); i++) {       (s == b ? ++way_good : ++way_bad);       s = a.substr(i + 1, (int)(a).size() - i) + a.substr(0, i + 1);     }     for (int i = 1; i <= k; i++) {       dp[i][1] = (((dp[i - 1][1] * (way_good - 1)) % MOD) +                   (dp[i - 1][0] * (way_good)) % MOD) %                  MOD;       dp[i][0] = (((dp[i - 1][1] * (way_bad)) % MOD) +                   (dp[i - 1][0] * (way_bad - 1)) % MOD) %                  MOD;     }     cout << dp[k][1] % MOD <<   n ;     return;   }   int main() {     ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   long long a[100005];   void solve() {     long long n, k;     cin >> n >> k;     if (n == k) {       cout << -1 << endl;       return;     };     if (k == 0) {       cout << n <<    ;       for (__typeof((n)) i = (1); i < (n); i++) cout << i <<    ;       return;     }     if (k == n - 1) {       for (__typeof((n + 1)) i = (1); i < (n + 1); i++) cout << i <<    ;       return;     }     k = n - k;     if (k % 2) cout << k <<    ;     for (__typeof((k / 2)) i = (0); i < (k / 2); i++)       cout << 2 * i + 2 - k % 2 <<     << 2 * i + 1 + k % 2 <<    ;     for (__typeof((n + 1)) i = (k + 1); i < (n + 1); i++) cout << i <<    ;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int t = 1;     while (t--) solve();     return 0;   }