malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e5 + 10;   const int MAXN = 1e4 + 10;   const int MOD = 1e9 + 7;   const int inf = 1e9;   const double pi = acos(-1.0);   const double eps = 1e-6;   int dx[] = {0, -1, 0, 1};   int dy[] = {1, 0, -1, 0};   long long dp[510][510];   int n;   int a[510];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n; i++) dp[i][i] = 1;     for (int j = 2; j <= n; j++)       for (int i = j - 1; i >= 1; i--) {         dp[i][j] = 0;         for (int k = i + 1; k <= j; k++)           if (a[i + 1] < a[k + 1] || k == j)             (dp[i][j] += (dp[i + 1][k] * dp[k][j]) % MOD) %= MOD;       }     cout << dp[1][n];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = (long long)1e18 + 7;   int n, m;   map<char, int> ch_num;   int main() {     int n;     cin >> n;     vector<string> ee(n);     for (int i = 0; i < n; i++) {       cin >> ee[i];     }     vector<int> can_zero(27, -1);     vector<pair<int, int> > let_sum(27);     for (int i = 0; i < 26; i++) {       let_sum[i] = make_pair(0, i);     }     for (auto cp : ee) {       for (int i = 0; i < (int)cp.size(); i++) {         if (i == 0) {           can_zero[cp[i] -  a ] = 0;         } else if (can_zero[cp[i] -  a ] != 0) {           can_zero[cp[i] -  a ] = 1;         }         let_sum[cp[i] -  a ].first += pow(10, (int)cp.size() - i - 1);       }     }     sort(let_sum.begin(), let_sum.end());     reverse(let_sum.begin(), let_sum.end());     bool z_used = false;     int cur_n = 1;     for (auto cp : let_sum) {       if (can_zero[cp.second] == -1) {         break;       }       if (can_zero[cp.second] && !z_used) {         ch_num[(char)( a  + cp.second)] = 0;         z_used = true;       } else {         ch_num[(char)( a  + cp.second)] = cur_n;         cur_n++;       }     }     int ans = 0;     for (auto hui : ee) {       for (int i = 0; i < (int)hui.size(); i++) {         ans += ch_num[hui[i]] * pow(10, (int)hui.size() - i - 1);       }     }     cout << ans;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     getline(cin, s);     int k = s.length();     int flag = 0;     for (int d = 0; d < k - 1; d++) {       if (s[d] ==    ) {         continue;       }       if (s[d] ==  a  || s[d] ==  e  || s[d] ==  i  || s[d] ==  o  ||           s[d] ==  u  || s[d] ==  y  || s[d] ==  A  || s[d] ==  E  ||           s[d] ==  I  || s[d] ==  O  || s[d] ==  U  || s[d] ==  Y ) {         flag = 1;       } else {         flag = 0;       }     }     if (flag == 1) {       cout <<  YES ;     } else {       cout <<  NO ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long INF = 1000000000000000;   int main() {     int n, m;     cin >> n >> m;     vector<int> x(n);     for (int i = 0; i < n; i++) {       cin >> x[i];     }     vector<int> p(m), c(m);     for (int i = 0; i < m; i++) {       cin >> p[i] >> c[i];     }     sort(x.begin(), x.end());     vector<pair<int, int>> P(m);     for (int i = 0; i < m; i++) {       P[i] = make_pair(p[i], c[i]);     }     sort(P.begin(), P.end());     for (int i = 0; i < m; i++) {       p[i] = P[i].first;       c[i] = P[i].second;     }     int sum = 0;     for (int i = 0; i < m; i++) {       sum += c[i];     }     if (sum < n) {       cout << -1 << endl;     } else {       vector<long long> dp(n + 1, INF);       dp[0] = 0;       for (int i = 0; i < m; i++) {         vector<long long> d(n);         for (int j = 0; j < n; j++) {           d[j] = abs(x[j] - p[i]);         }         vector<long long> S(n + 1);         S[0] = 0;         for (int j = 0; j < n; j++) {           S[j + 1] = S[j] + d[j];         }         vector<long long> a(n + 1);         for (int j = 0; j <= n; j++) {           a[j] = dp[j] - S[j];         }         deque<int> dq;         for (int j = 0; j <= n; j++) {           while (!dq.empty()) {             if (a[dq.back()] >= a[j]) {               dq.pop_back();             } else {               break;             }           }           dq.push_back(j);           dp[j] = a[dq.front()] + S[j];           if (dq.front() == j - c[i]) {             dq.pop_front();           }         }       }       cout << dp[n] << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   vector<int> g[N];   int a[N], b[N], last[N], indx[N], lvl[N], ans[N];   int n, m, q;   void dfs(int node, int sz) {     lvl[sz++] = node;     for (int i = 0; i < g[node].size(); i++) {       dfs(g[node][i], sz);     }     if (sz >= n)       ans[node] = lvl[sz - n];     else       ans[node] = N;     sz--;   }   int tree[N << 2];   void build(int i, int l, int r) {     if (l == r) return void(tree[i] = ans[l]);     int mid = (l + r) >> 1;     build(i << 1, l, mid);     build(i << 1 | 1, mid + 1, r);     tree[i] = min(tree[i << 1], tree[i << 1 | 1]);   }   int get(int i, int l, int r, int a, int b) {     if (l > b || r < a) return N;     if (l >= a && r <= b) return tree[i];     int mid = (l + r) >> 1;     return min(get(i << 1, l, mid, a, b), get(i << 1 | 1, mid + 1, r, a, b));   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m >> q;     for (int i = 0; i < n; i++) cin >> a[i], indx[a[i]] = i;     for (int i = 0; i < m; i++) cin >> b[i];     memset(last, -1, sizeof last);     vector<int> roots;     for (int i = m - 1; i >= 0; i--) {       int x = a[(indx[b[i]] + 1) % n];       if (last[x] == -1)         roots.push_back(i);       else         g[last[x]].push_back(i);       last[b[i]] = i;     }     for (auto r : roots) dfs(r, 0);     build(1, 0, m - 1);     for (int i = 0, l, r; i < q; i++) {       cin >> l >> r;       l--, r--;       cout << (get(1, 0, m - 1, l, r) <= r);     }     return 0;   }
//   //  main.cpp   //  google-code-jam-2020   //   //  Created by Ali Naderi Parizi on 2/10/1400 AP.   //      #include <iostream>   #include <math.h>      int main(int argc, const char * argv[])   {       int t;       std::cin >> t;       for (int i = 0 ; i < t ; i++)       {           double r,b,d;           std::cin >> r >> b >> d;           double x = std::min(r, b) * d;              if(std::abs(r - b) <= x)           {               std::cout <<  YES  << std::endl;           }           else           {               std::cout <<  NO  << std::endl;           }       }       return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int q = 1;     while (q--) {       long long int n, i, t, j, k = 0, maxm = 0, ans;       cin >> n;       vector<long long int> v(n), v1(30), v2;       map<long long int, long long int> m;       for (long long int i = 0; i < 30; i++) v1[i] = 0;       for (long long int i = 0; i < n; i++) {         cin >> v[i];         t = v[i];         j = 0;         while (t > 0) {           v1[j] = v1[j] + t % 2;           t = t / 2;           j++;         }       }       sort(v.begin(), v.end());       for (long long int i = 0; i < 30; i++) {         if (v1[i] == 1) v2.push_back(i);       }       if (v2.size() == 0) {         for (i = n - 1; i >= 0; i--) cout << v[i] <<    ;         return 0;       }       for (long long int i = 0; i < n; i++) {         t = v[i];         j = 0;         k = 0;         while (t > 0) {           if (j == v2[k]) {             if (t % 2 != 0) m[v[i]] += pow(2, j);             k++;           }           t = t / 2;           j++;         }       }       for (auto it = m.begin(); it != m.end(); it++) {         if ((it->second) > maxm) {           maxm = it->second;           ans = it->first;         }       }       cout << ans <<    ;       for (long long int i = 0; i < n; i++) {         if (v[i] == ans)           continue;         else           cout << v[i] <<    ;       }     }   }
#include <bits/stdc++.h>   using namespace std;   const int mod = 1000003;   long double pi = 3.1415926536;   const int mx = 1000003;   long long gcd(long long x, long long y) {     if (y == 0) return x;     return gcd(y, x % y);   }   long long bp(long long a, long long b) {     long long ans = 1;     while (b > 0) {       if (b & 1) ans = (ans * a) % mod;       a = (a * a) % mod;       b >>= 1;     }     return ans;   }   long long p(long long n) {     for (long long i = 2; i * i <= n; i++) {       if (n % i == 0) {         return n / i;       }     }     return 1;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n, k;     cin >> n >> k;     long long a[n + 1], ans = 0;     for (long long i = 1; i <= n; i++) cin >> a[i];     while (1) {       bool t = 0;       for (long long i = n; i >= 1;) {         if (a[i] < k) {           long long x = a[i], j = i;           while (x == a[i] && i >= 1) {             x = a[i];             i--;           }           a[j]++;           t = 1;         } else {           i--;         }       }       if (t) ans++;       if (a[1] >= k) break;     }     cout << ans;   }
#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 - (a / b * b));   }   long long mypow(long long a, long long b) {     long long p = 1;     if (b == 0) return 1;     for (long long i = 0; i < b; i++) p *= a;     return p;   }   long long zero(long long a) {     long long za = 0;     long long temp = a;     long long tens = 0;     while (temp > 0) {       if (temp % 10 != 0) {         za += ((temp % 10) * (mypow(10, tens)));         tens++;       }       temp /= 10;     }     return za;   }   int main() {     string st;     while (getline(cin, st)) {       int i = st.length() - 2;       while (st[i] ==    ) i--;       if (st[i] < 97) st[i] += 32;       if (st[i] ==  a  || st[i] ==  e  || st[i] ==  i  || st[i] ==  o  ||           st[i] ==  u  || st[i] ==  y )         cout <<  YES  << endl;       else         cout <<  NO  << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = (1 << 30) - 1;   const long long linf = (1ll << 62) - 1;   const int N = 1e6 + 100;   int n, m;   int u[N], v[N];   set<int> g[N];   bool used[N];   int ts[N], tsLen = 0;   void topSort(int v) {     if (used[v]) {       return;     }     used[v] = true;     for (int to : g[v]) {       topSort(to);     }     ts[tsLen++] = v;   }   inline bool check(int m) {     for (int i = 0; i < n; i++) {       g[i].clear();     }     for (int i = 0; i < m; i++) {       g[u[i]].insert(v[i]);     }     fill_n(used, n, false);     tsLen = 0;     for (int i = 0; i < n; i++) {       if (!used[i]) {         topSort(i);       }     }     reverse(ts, ts + tsLen);     for (int i = 0; i < tsLen - 1; i++) {       if (g[ts[i]].count(ts[i + 1]) == 0) {         return false;       }     }     return true;   }   int main() {     cin >> n >> m;     for (int i = 0; i < m; i++) {       scanf( %d%d , &u[i], &v[i]);       u[i]--, v[i]--;     }     int l = 0, r = m;     while (r - l > 1) {       int x = (l + r) / 2;       if (check(x)) {         r = x;       } else {         l = x;       }     }     if (!check(r)) {       puts( -1 );     } else {       printf( %d n , r);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   using uint = unsigned int;   using ull = unsigned long long;   using pii = pair<int, int>;   int f[50], s[50], p[50];   ld dp[51][5000];   int main() {     cin.tie(nullptr);     cout.tie(nullptr);     ios_base::sync_with_stdio(false);     int n, r;     cin >> n >> r;     for (int i = 0; i < n; i++) cin >> f[i] >> s[i] >> p[i];     ld l = 0, h = 1e9;     int rep = 80;     while (rep--) {       ld m = (l + h) / 2;       for (int i = n - 1; i >= 0; i--) {         fill(dp[i + 1] + min(5000, r + 1), dp[i + 1] + 5000, m);         for (int j = 0; j <= r; j++) {           ld ff = (dp[i + 1][j + f[i]] + f[i]) * p[i];           ld ss = (dp[i + 1][j + s[i]] + s[i]) * (100 - p[i]);           dp[i][j] = min(m, (ff + ss) / 100);         }       }       if (dp[0][0] < m) {         h = m;       } else {         l = m;       }     }     cout << fixed << setprecision(20) << l;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   void run() {     int n;     cin >> n;     vector<long long> a(n);     for (int i = 0; i < n; i++) {       cin >> a[i];     }     if (n == 1) {       cout << 1 <<     << 1 <<   n  << -a[0] <<   n ;       cout << 1 <<     << 1 <<   n  << 0 <<   n ;       cout << 1 <<     << 1 <<   n  << 0 <<   n ;       return;     }     cout << 1 <<     << n - 1 <<   n ;     for (int i = 0; i < n - 1; i++) {       int x = a[i] % n;       a[i] += 1ll * x * (n - 1);       if (i) cout <<    ;       cout << 1ll * x * (n - 1);     }     cout <<   n ;     cout << 2 <<     << n <<   n ;     for (int i = 1; i < n; i++) {       int x = a[i] % n;       a[i] += 1ll * x * (n - 1);       if (i > 1) cout <<    ;       cout << 1ll * x * (n - 1);     }     cout <<   n ;     cout << 1 <<     << n <<   n ;     for (int i = 0; i < n; i++) {       if (i) cout <<    ;       cout << -a[i];     }     cout <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cout << fixed << setprecision(20);     run();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 5;   const int M = 1e5 + 5;   long long mod_exp(long long cur, long long power) {     long long res = 1;     while (power > 0) {       if (power % 2 == 0) {         cur = (cur * cur) % 1000000007;       } else {         res = (res * cur) % 1000000007;         cur = (cur * cur) % 1000000007;       }       power /= 2;     }     return res;   }   int main() {     ios_base::sync_with_stdio(false);     int i, j, n, m;     cin >> n >> m;     long long dp1[N], dp0[N];     dp1[0] = dp0[0] = 1;     dp1[1] = dp0[1] = 2;     for (i = 2; i < N; i++) {       dp1[i] = (dp0[i - 1] + dp0[i - 2]) % 1000000007;       dp0[i] = (dp1[i - 1] + dp1[i - 2]) % 1000000007;     }     long long foo = (dp1[m - 1] + dp0[m - 1]) % 1000000007;     foo = (foo - 2 + 1000000007) % 1000000007;     foo = (foo + dp0[n - 1] + dp1[n - 1]) % 1000000007;     cout << foo << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;      #define ll long long int      void solve(){      ll n,i,j;      cin >> n;      ll arr[n];      ll hash[65] = {0};      vector<string> vec;      for(i=0;i<n;i++){          cin >> arr[i];          ll m = arr[i];          ll id = 0;          string s =   ;          while(m > 0){              if(m & 1){                  hash[id]++;                  s +=  1 ;              }              else              s +=  0 ;              id++;              m/=2;          }          vec.push_back(s);      }      ll ans[65];ll ps= 0;      ll bin[65]={0};      for(i=0;i<65;i++){          ll a = 1;          ll p = i;          while(p > 0){              p--;              a *= 2;               a %= 1000000007;          }          bin[i]=a;          a *= hash[i];           a %= 1000000007;           ans[i]=a;           ps += ans[i];            ps %= 1000000007;      }      /*for(i=0;i<5;i++){          cout << ans[i] <<   fggg   << bin[i] <<   n ;      }*/      ll s = 0;    //  cout << ps <<   n ;      for(i=0;i<n;i++){          ll a = 0;ll b =0;          string ss = vec[i];          for(j=0;j<ss.length();j++){             if(ss[j] ==  1 ){                 a += ans[j];                  a %= 1000000007;                  b += (bin[j]*(n-hash[j]));                   b %= 1000000007;             }          }          b += ps;           b %= 1000000007;           ll ls = (a*b)%1000000007;           s += ls;            s %= 1000000007;           // cout << a <<   and or   << b <<   n ;      }      cout << s <<   n ;   }      int main() {       ios_base :: sync_with_stdio(0);       cin.tie(NULL);       int t;       cin >> t;       while(t > 0){           t--;           solve();       }   }
#include <bits/stdc++.h>   long long gcd(long long a, long long b) {     while (a && b) {       if (a > b)         a %= b;       else         b %= a;     }     return a + b;   }   long long lcm(long long a, long long b) { return (((a) / gcd(a, b))) * b; }   int phi(int n) {     int result = n;     for (int i = 2; i * i <= n; i++) {       if (n % i == 0) {         while (n % i == 0) n /= i;         result -= result / i;       }     }     if (n > 1) result -= result / n;     return result;   }   long long power(long long a, long long b, long long c) {     long long r = 1;     while (b) {       if (b & 1) r *= a;       a *= a;       a %= c;       r %= c;       b /= 2;     }     return r;   }   void nxi(int& n) {     bool min = 0;     char c;     n = 0;     while ((c = getc(stdin)) && c <= 32)       ;     if (c ==  - )       min = 1;     else       n = c - 48;     while ((c = getc(stdin)) && c > 32) n = (n << 3) + (n << 1) + c - 48;     if (min) n = -n;   }   void prl(int n) {     if (n == 0) {       puts( 0 );       return;     }     static int s[10];     int top = 0;     while (n > 0) s[top++] = n % 10, n /= 10;     while (top--) putchar(s[top] + 48);   }   using namespace std;   int n, m;   pair<int, int> mem[101010];   map<long long, vector<long long> > sv;   map<long long, long long> t;   void inc(int pos, long long val) {     for (long long i = pos; i < 1000000007; i = (i | (i + 1))) {       t[i] += val, t[i] %= 1000000007;     }   }   long long get(int r) {     long long s = 0;     for (long long i = r; i >= 0; i = (i & (i + 1)) - 1) {       if (t.count(i)) {         s += t[i];         s %= 1000000007;       }     }     return s;   }   long long get(int l, int r) {     long long x = (long long)get(r) - (l > 0 ? 1ll * get(l - 1) : 0);     x = (x + 1000000007) % 1000000007;     x = (x + 1000000007) % 1000000007;     return x;   }   int main() {     ios::sync_with_stdio(0);     cin >> n >> m;     for (int i = 0; i < m; i++) {       cin >> mem[i].first >> mem[i].second;       int x = mem[i].second;       sv[x].push_back(mem[i].first);     }     inc(0, 1);     for (map<long long, vector<long long> >::iterator it = sv.begin();          it != sv.end(); it++) {       long long s = 0;       int x = it->first;       for (int i = 0; i < it->second.size(); i++) {         s += get(it->second[i], x - 1);         s %= 1000000007;         s = (s + 1000000007) % 1000000007;         s = (s + 1000000007) % 1000000007;       }       inc(x, s);     }     cout << get(n, n) << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int T, ans;   int dfs(vector<int> G[], int node, bool visit[], int k, bool first) {     if (!visit[node]) {       visit[node] = true;       int counti = 0;       for (auto it : G[node]) {         if (!visit[it]) counti += dfs(G, it, visit, k, false);       }       ans += counti / k;       if (counti != G[node].size() - 1)         return 0;       else if (G[node].size() % k != 1)         return 0;       else {         return 1;       }     }     return 0;   }   void solve() {     int n, m, i, root, k;     ans = 0;     cin >> n >> k;     vector<int> G[n];     bool all = true;     bool visit[n];     for (i = 0; i < n - 1; i++) {       int a, b;       cin >> a >> b;       a--, b--;       G[a].push_back(b);       G[b].push_back(a);     }     for (i = 0; i < n; i++) visit[i] = false;     for (i = 0; i < n; i++) {       if (G[i].size() % k != 1) {         all = false;         root = i;         break;       }     }     if (all)       cout << (n - 1) / k <<   n ;     else if (k == 1) {       cout << n - 1 <<   n ;     } else {       dfs(G, root, visit, k, true);       cout << ans <<   n ;     }   }   int main() {     cin >> T;     while (T--) solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T, class L>   inline bool smax(T &x, L y) {     return x < y ? (x = y, 1) : 0;   }   template <class T, class L>   inline bool smin(T &x, L y) {     return y < x ? (x = y, 1) : 0;   }   const int maxn = 2e2 + 17, maxm = maxn * maxn;   int from[maxm], to[maxm], n, m;   bool bl[maxm], mark[maxn];   vector<int> g[maxn], vec;   void see(int v) {     if (mark[v]) return;     mark[v] = 1;     vec.push_back(v);     for (auto i : g[v]) see(from[i] ^ to[i] ^ v);   }   void dfs(int v) {     for (int i = g[v].size() - 1; i >= 0; i = (int)g[v].size() - 1) {       int e = g[v][i], u = from[e] ^ to[e] ^ v;       if (v != from[e]) swap(from[e], to[e]);       g[v].pop_back();       if (bl[e]) continue;       bl[e] = 1;       dfs(u);     }   }   void solve() {     cin >> n >> m;     int cm = m, ans = 0;     for (int i = 0; i < m; i++) {       cin >> from[i] >> to[i], from[i]--, to[i]--;       g[from[i]].push_back(i), g[to[i]].push_back(i);     }     for (int i = 0; i < n; i++) ans += g[i].size() % 2 == 0;     for (int i = 0; i < n; i++)       if (!mark[i]) {         vec.clear();         see(i);         int last = -1;         for (auto v : vec)           if (g[v].size() & 1)             if (last != -1)               last = v;             else {               from[m] = v, to[m] = last;               g[v].push_back(m), g[last].push_back(m);               m++, last = -1;             }         dfs(i);       }     cout << ans <<   n ;     for (int i = 0; i < cm; i++) cout << from[i] + 1 <<     << to[i] + 1 <<   n ;   }   int main() {     ios::sync_with_stdio(0), cin.tie(0);     int t;     cin >> t;     while (t--) {       memset(mark, 0, sizeof mark);       memset(bl, 0, sizeof bl);       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int comp[212345], ptr;   int idx[212345];   map<int, int> place;   int h, m, n;   int merge(int x, int y) {     if (x == -1) {       return y;     }     return x;   }   struct segtree {     int n;     vector<int> tree;     segtree(vector<int> base) {       n = base.size();       tree.resize(2 * n);       for (int i = 0; i < n; ++i) {         tree[i + n] = base[i];       }       for (int i = n - 1; i > 0; --i) {         tree[i] = merge(tree[i + i], tree[i + i + 1]);       }     }     int qry(int l) {       int x = qry(l, n);       if (x == -1) {         return qry(0, l);       }       return x;     }     int qry(int l, int r) {       int resl = -1, resr = -1;       for (l += n, r += n; l < r; l /= 2, r /= 2) {         if (l & 1) resl = merge(resl, tree[l++]);         if (r & 1) resr = merge(tree[--r], resr);       }       return merge(resl, resr);     }     void upd(int pos, int val) {       pos += n;       tree[pos] = val;       for (pos /= 2; pos > 0; pos /= 2) {         tree[pos] = merge(tree[pos + pos], tree[pos + pos + 1]);       }     }   };   vector<int> base[212345];   void dfs(int x) {     comp[x] = ptr;     idx[x] = base[ptr].size();     base[ptr].push_back(x);     int nxt = (x + m) % h;     if (comp[nxt] == -1) {       dfs(nxt);     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cin >> h >> m >> n;     long long ans = 0;     memset(comp, -1, sizeof comp);     for (int i = 0; i < h; ++i) {       if (comp[i] == -1) {         dfs(i);         ++ptr;       }     }     vector<segtree> segts;     for (int i = 0; i < ptr; ++i) {       segts.push_back(segtree(base[i]));     }     while (n--) {       char a;       int id, hash;       cin >> a >> id;       if (a ==  + ) {         cin >> hash;         int pos = segts[comp[hash]].qry(idx[hash]);         int dummy = idx[pos] - idx[hash];         if (dummy < 0) {           dummy += base[comp[hash]].size();         }         ans += dummy;         segts[comp[pos]].upd(idx[pos], -1);         place[id] = pos;       } else {         int pos = place[id];         segts[comp[pos]].upd(idx[pos], pos);       }     }     cout << ans <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   using namespace std;   int main() {     int n;     cin >> n;     if (n > 2) {       for (int i = 2; i <= n; ++i) {         cout << i <<    ;       }       cout << 1 << endl;     } else {       cout << -1 << endl;     }     return 0;   }