malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   mt19937_64 random_num(       chrono::high_resolution_clock::now().time_since_epoch().count());   const int MOD = 1000000007;   const int inf = 2000000000;   const int mod = 1007050321;   const double e = 0.000001;   const int N = 200005;   const bool aut = 788480;   const int base = 521;   int n, m, p, b[N], a[N];   int poww(int n, int a) {     if (n == 1) return a;     if (n == 0) return 0;     int t = poww(n / 2, a);     t = 1LL * t * t % MOD;     if (n & 1) t = 1LL * t * a % MOD;     return t;   }   int main() {     ios_base ::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n >> m >> p;     vector<int> pack;     for (int i = 1; i <= n; ++i) cin >> a[i], pack.push_back(a[i]);     for (int i = 1; i <= m; ++i) cin >> b[i], pack.push_back(b[i]);     sort((pack).begin(), (pack).end());     for (int i = 1; i <= n; ++i)       a[i] = lower_bound((pack).begin(), (pack).end(), a[i]) - pack.begin() + 1;     for (int i = 1; i <= m; ++i)       b[i] = lower_bound((pack).begin(), (pack).end(), b[i]) - pack.begin() + 1;     vector<int> ans;     long long S = 0, T = 1;     for (int i = 1; i <= m; ++i) S += b[i], T = 1LL * T * b[i] % MOD;     for (int i = 1; i <= p; ++i) {       long long sum = 0;       int mul = 1;       if ((n - i) / p < m - 1) break;       for (int j = 0; j <= m - 1; ++j) {         sum += a[i + j * p];         mul = 1LL * mul * a[i + j * p] % MOD;       }       if (sum == S && mul == T) ans.push_back(i);       for (int j = m; i + j * p <= n; ++j) {         sum += a[i + j * p] - a[i + (j - m) * p];         mul = 1LL * mul * poww(MOD - 2, a[i + (j - m) * p]) % MOD * a[i + j * p] %               MOD;         if (mul == T && sum == S) ans.push_back(i + (j - m + 1) * p);       }     }     sort((ans).begin(), (ans).end());     cout << ans.size() <<   n ;     for (int v : ans) cout << v <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline bool chmin(T& a, T b) {     if (a > b) {       a = b;       return true;     }     return false;   }   template <class T>   inline bool chmax(T& a, T b) {     if (a < b) {       a = b;       return true;     }     return false;   }   long long select(vector<long long>& a, long long k) {     for (long long l = 0, r = a.size() - 1; l <= r;) {       long long p = a[(l + r) / 2];       long long i = l - 1, j = r + 1;       while (1) {         while (a[++i] < p)           ;         while (a[--j] > p)           ;         if (i >= j) break;         swap(a[i], a[j]);       }       if (k == i - l)         return a[i];       else if (k < i - l) {         r = i - 1;       } else if (k > i - l) {         k -= (i - l + 1);         l = j + 1;       }     }     return -99999999;   }   long long gcd(long long a, long long b) {     if (b == 0) return a;     return gcd(b, a % b);   }   long long modinv(long long a, long long m) {     long long b = m, u = 1, v = 0;     while (b) {       long long t = a / b;       a -= t * b;       swap(a, b);       u -= t * v;       swap(u, v);     }     u %= m;     if (u < 0) u += m;     return u;   }   vector<pair<long long, long long>> prim;   void pf(long long n) {     long long s = sqrt(n);     long long r = 0;     for (long long i = 2; i <= s; i++) {       if ((n % i) == 0) {         r = 0;         do {           r++;           n = n / i;         } while ((n % i) == 0);         prim.push_back({i, r});       }     }     if (n > s) {       prim.push_back({n, 1});     }   }   long long powmod(int a, int n) {     long long x = 1;     while (n > 0) {       if (n & 1) {         x = (x * a) % (long long)(1e9 + 7);       }       a = (a * a) % (long long)(1e9 + 7);       n >>= 1;     }     return x;   }   void solve() {     long long N;     cin >> N;     string s;     cin >> s;     vector<string> cs(30);     vector<string> csr(30);     long long ans = -1;     for (long long j = 0; j < (26); j++) {       char ch = j +  a ;       for (long long i = 0; i < (N); i++) {         if (s[i] != ch) {           cs[j] += s[i];         }       }       csr[j] = cs[j];       reverse(csr[j].begin(), csr[j].end());       if (csr[j] != cs[j]) continue;       long long cnt = 0;       long long x1 = 0;       long long x2 = N - 1;       while (x2 - x1 >= 1) {         if (s[x1] == s[x2]) {           x1++;           x2--;         } else if (s[x1] == ch) {           x1++;           cnt++;         } else if (s[x2] == ch) {           x2--;           cnt++;         }       }       if (ans < 0 || ans > cnt) ans = cnt;     }     cout << ans << endl;   }   int main(void) {     long long t;     cin >> t;     for (long long i = 0; i < (t); i++) solve();   }
#include <bits/stdc++.h>   using namespace std;   const int N = 1e6 + 6;   int ans[N];   int main() {     int n, k;     scanf( %d %d , &n, &k);     if (k == 1 or k * 3 > n) return !printf( -1 n );     for (int x = 1; x <= k; x += 2) {       for (int j = 0; j < 6; ++j) {         if (j == 0 or j == 1 or j == 3)           ans[(x - 1) * 3 + j + 1] = x;         else           ans[(x - 1) * 3 + j + 1] = x + 1;       }     }     for (int i = 1; i <= n; ++i)       if (ans[i] > k or ans[i] == 0) ans[i] = 1;     if (n % 3 == 0 and k % 2 == 1) ans[1] = k, ans[n] = 1;     for (int i = 1; i <= n; ++i) printf( %d  , ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3E4 + 5;   const int maxm = 1E5 + 5;   int n, m, cnt;   int ans[maxn];   bool vis[maxn];   vector<int> to[maxn];   void DFS(int u, int fa) {     vis[u] = 1;     for (int i = 0; i < to[u].size(); ++i) {       int v = to[u][i];       if (!vis[v])         DFS(v, u);       else if (v == fa) {         puts( -1 );         exit(0);       }     }     ans[++cnt] = u;   }   int main() {     scanf( %d%d , &n, &m);     while (m--) {       int x, y;       scanf( %d%d , &x, &y);       to[x].push_back(y);     }     for (int i = 1; i <= n; ++i)       if (!vis[i]) DFS(i, 0);     for (int i = 1; i <= n; ++i) printf( %d  , ans[i]);   }
#include <bits/stdc++.h>   using namespace std;   bool h[1000009];   int main() {     int n, m, k, tmp, tmp1, pos = 1;     cin >> n >> m >> k;     for (int i = 0; i < m; ++i) {       cin >> tmp;       h[tmp] = true;     }     if (h[1]) {       cout << pos << endl;       return 0;     }     for (int i = 0; i < k; ++i) {       cin >> tmp >> tmp1;       if (pos == tmp || tmp1 == pos) {         pos = (tmp == pos) ? tmp1 : tmp;         if (h[pos]) break;       }     }     cout << pos << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int a, b, c, d, i, j, k, n, m, t;     cin >> t;     while (t--) {       cin >> n;       long long int ar[n + 5];       memset(ar, -1, sizeof(ar));       int f = 0;       for (i = 0; i < n; i++) {         cin >> a;         if (ar[a] == -1)           ar[a] = i;         else {           if ((abs(i - ar[a]) - 1) >= 1) f = 1;         }       }       if (f == 0)         cout <<  NO n ;       else         cout <<  YES n ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<string> tmp;   long long num(string str) {     int len = str.size();     long long res = 0;     for (int i = 0; i < len; i++) {       res = res * 10 + str[i] -  0 ;     }     return res;   }   void solve(int N) {     queue<string> q;     q.push( 11 );     q.push( 22 );     q.push( 33 );     q.push( 44 );     q.push( 55 );     q.push( 66 );     q.push( 77 );     q.push( 88 );     q.push( 99 );     tmp.push_back( 11 );     tmp.push_back( 22 );     tmp.push_back( 33 );     tmp.push_back( 44 );     tmp.push_back( 55 );     tmp.push_back( 66 );     tmp.push_back( 77 );     tmp.push_back( 88 );     tmp.push_back( 99 );     while (!q.empty()) {       string str = q.front();       q.pop();       if (tmp.size() >= N) return;       for (int i = 0; i < 10; i++) {         char ch = i + 48;         int l = str.size() / 2;         string kp = str.substr(0, l) + ch + ch + str.substr(l, l);         tmp.push_back(kp);         q.push(kp);       }     }   }   int main() {     int k, p;     scanf( %d%d , &k, &p);     solve(k);     long long res = 0;     for (int i = 0; i < k; i++) {       res = (res + num(tmp[i])) % p;     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 2e5 + 50;   int n, cnt;   pair<int, int> poi[maxn], A[maxn];   void solve(int l, int r) {     if (l > r) return;     int mid = (l + r) >> 1;     for (int i = l; i <= r; i++)       poi[++cnt] = (pair<int, int>){A[mid].first, A[i].second};     solve(l, mid - 1);     solve(mid + 1, r);   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; i++) scanf( %d%d , &A[i].first, &A[i].second);     sort(A + 1, A + 1 + n);     solve(1, n);     sort(poi + 1, poi + 1 + cnt);     cnt = unique(poi + 1, poi + 1 + cnt) - poi - 1;     printf( %d n , cnt);     for (int i = 1; i <= cnt; i++) printf( %d %d n , poi[i].first, poi[i].second);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   using vc = vector<T>;   template <class T>   using vvc = vc<vc<T>>;   template <class T>   void mkuni(vector<T>& v) {     sort(v.begin(), v.end());     v.erase(unique(v.begin(), v.end()), v.end());   }   long long rand_int(long long l, long long r) {     static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());     return uniform_int_distribution<long long>(l, r)(gen);   }   template <class T>   void print(T x, int suc = 1) {     cout << x;     if (suc == 1)       cout <<   n ;     else       cout <<    ;   }   template <class T>   void print(const vector<T>& v, int suc = 1) {     for (int i = 0; i < v.size(); i++)       print(v[i], i == (int)(v.size()) - 1 ? suc : 2);   }   const int INF = 0x3f3f3f3f;   const int MAXN = 2e5 + 7;   const int maxn = 2e6 + 7;   int a[MAXN], b[MAXN];   int mx[maxn];   struct e {     int u, v, w;   } Edge[maxn];   bool cmp(e a, e b) { return a.w > b.w; }   int fa[maxn];   int find(int x) { return (x == fa[x] ? x : fa[x] = find(fa[x])); }   int main() {     int n, m, cnt = 0;     cin >> n >> m;     for (int i = 1; i <= n; ++i) cin >> a[i];     for (int i = 1; i <= m; ++i) cin >> b[i];     for (int i = 1; i <= n + m + 1; ++i) fa[i] = i;     long long s = 0;     for (int i = 1; i <= n; ++i) {       int sz;       cin >> sz;       for (int j = 1; j <= sz; ++j) {         int u;         cin >> u;         Edge[++cnt] = {u, i + m, a[i] + b[u]};         s += (a[i] + b[u]);       }     }     long long sum = 0;     sort(Edge + 1, Edge + cnt + 1, cmp);     for (int i = 1; i <= cnt; ++i) {       int u = Edge[i].u, v = Edge[i].v, w = Edge[i].w;       int fu = find(u), fv = find(v);       if (fu == fv) continue;       fa[fu] = fv;       sum += w;     }     cout << s - sum << endl;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int a, t, b, c, m, n, ck = 0, ans = 0, sum = 0;     cin >> t;     cin.ignore();     while (t--) {       ck = 0;       cin >> a;       cin.ignore();       string s;       cin >> s;       b = a - 10;       for (int i = 0; i < b; i++) {         if (s[i] ==  8 ) {           ck = 1;         }       }       if (ck == 1) {         cout <<  YES  << endl;       } else {         cout <<  NO  << endl;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, x;     cin >> n >> x;     if (n == 5 && x == 5) {       printf( >...v nv.<.. n..^.. n>.... n..^.< n1 1 );       return 0;     }     if (n == 3 && x == 2) {       printf( >vv n^<. n^.< n1 3 );       return 0;     }     for (int i = 0; i < 50; i++) {       for (int j = 0; j < 33; j++) printf( > );       for (int j = 0; j < 33; j++) printf( .> );       printf( v n^ );       for (int j = 0; j < 33; j++) printf( <. );       printf( . );       for (int j = 0; j < 32; j++) printf( < );       printf(  n );     }     printf( 1 1 );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   using ll = long long;   template <typename T>   void DEBUG(string label, T value) {     cerr <<  [  << label <<   =   << value <<  ] n ;   }   const int oo = 1 << 30;   void solve() {     int n;     cin >> n;     int bsize;     cin >> bsize;     vector<int> arr(n + 2);     for (int i = 1; i <= n; ++i) {       cin >> arr[i];       arr[i] -= i;     }     arr[0] = -oo;     arr[n + 1] = oo;     vector<int> b(bsize + 2);     for (int i = 1; i <= bsize; ++i) {       cin >> b[i];     }     b[0] = 0;     b[bsize + 1] = n + 1;     bsize += 2;     n += 2;     int ans = 0;     for (int i = 0; i < bsize - 1; ++i) {       if (arr[b[i]] > arr[b[i + 1]]) {         cout << -1 <<   n ;         return;       }       vector<int> dp;       for (int j = b[i] + 1; j < b[i + 1]; ++j) {         auto u = upper_bound(dp.begin(), dp.end(), arr[j]);         if (arr[j] >= arr[b[i]] && arr[j] <= arr[b[i + 1]]) {           if (u == dp.end()) {             dp.push_back(arr[j]);           } else {             *u = arr[j];           }         }       }       ans += b[i + 1] - b[i] - 1 - (int)dp.size();     }     cout << ans <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(nullptr);     int t = 1;     while (t--) solve();   }
#include <bits/stdc++.h>   using namespace std;   int dirx[] = {1, -1, 0, 0, 1, 1, -1, -1}, diry[] = {0, 0, 1, -1, 1, -1, 1, -1};   long long bigmod(long long x, long long p) {     long long res = 1;     while (p) {       if (p & 1) res = (res * x) % 1000000007;       x = (x * x) % 1000000007;       p >>= 1;     }     return res;   }   int32_t main() {     ios_base::sync_with_stdio(false);     string s;     cin >> s;     long long ans = 0;     int n = s.size();     for (long long i = 0, j = n - 1; i < n; i++, j--) {       long long bef = i * (i + 1) / 2;       bef %= 1000000007;       bef *= (s[i] -  0 );       ans = (ans + bigmod(10, j) * bef % 1000000007) % 1000000007;     }     long long cur = 0;     for (long long i = 0; i < n - 1; i++) {       cur += (s[i] -  0 );       cur %= 1000000007;       ans = (ans + bigmod(10, n - i - 2) * (n - i - 1) % 1000000007 * cur %                        1000000007) %             1000000007;     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e5 + 5;   int n, k, sz, trie[MAX][26];   bool win[MAX], lose[MAX];   char s[MAX];   void dfs(int u) {     int ady = 0;     for (int i = 0; i < 26; i++) {       if (trie[u][i] == 0) continue;       ady++;       int v = trie[u][i];       dfs(v);       win[u] |= !win[v];       lose[u] |= !lose[v];     }     if (ady == 0) {       win[u] = 0;       lose[u] = 1;     }   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 1; i <= n; i++) {       scanf( %s , s);       int l = strlen(s);       int r = 0;       for (int i = 0; i < l; i++) {         int c = s[i] -  a ;         if (trie[r][c] == 0) trie[r][c] = ++sz;         r = trie[r][c];       }     }     dfs(0);     if (win[0] && lose[0])       printf( First n );     else if (win[0] && !lose[0]) {       if (k & 1)         printf( First n );       else         printf( Second n );     } else if (!win[0] && lose[0])       printf( Second n );     else       printf( Second n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 100004;   int v[N];   int main(void) {     priority_queue<int> q;     int x, n;     cin >> n;     int res = 0;     set<pair<int, int> > S;     for (int i = 0; i < n; ++i) {       int x;       cin >> x;       S.insert(make_pair(x, i + 1));     }     int k = 1;     for (auto it : S) {       v[it.second] = k++;     }     for (int i = 1; i <= n; ++i) {       x = v[i];       q.push(x);       if (q.top() == i) {         res++;         while (q.size()) q.pop();       }     }     cout << res << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k;   vector<int> ini[100005];   vector<int> mat[100005];   int maior[100005];   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cin >> n >> m;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         int a;         cin >> a;         mat[i].push_back(a);         ini[i].push_back(0);         maior[i] = 0x3f3f3f3f;       }     for (int j = 0; j < m; j++)       for (int i = 1; i < n; i++) {         if (mat[i][j] >= mat[i - 1][j]) {           ini[i][j] = ini[i - 1][j];           if (maior[i] > ini[i][j]) maior[i] = ini[i][j];         } else {           ini[i][j] = i;         }       }     cin >> k;     for (int i = 0; i < k; i++) {       int l, r;       cin >> l >> r;       bool flag = false;       if (maior[r - 1] <= l - 1 or l == r)         cout <<  Yes  << endl;       else         cout <<  No  << endl;     }     return 0;   }
#include <bits/stdc++.h>   const int MAXN = 3e5 + 5;   const int SQ = 600;   int n, p, m, w[MAXN];   long long sum[MAXN], ans[MAXN];   std::vector<int> vec[SQ];   struct Ques {     int a, b;   } ques[MAXN];   void ss(int x) {     int step = ques[x].b;     if (step > m) {       long long res = 0;       for (int i = ques[x].a; i <= n; i += step) res += w[i];       ans[x] = res;     } else {       vec[step].push_back(x);     }   }   void solve() {     scanf( %d , &n);     m = sqrt(n);     for (int i = 1; i <= n; i++) scanf( %d , w + i);     scanf( %d , &p);     for (int i = 1; i <= p; i++) scanf( %d%d , &ques[i].a, &ques[i].b);     for (int i = 1; i <= p; i++) ss(i);     for (int i = 1; i <= m; i++) {       memset(sum, 0, sizeof(sum));       for (int j = n; j >= n - i + 1; j--) sum[j] = w[j];       for (int j = n - i; j >= 1; j--) sum[j] = w[j] + sum[j + i];       for (int x : vec[i]) ans[x] = sum[ques[x].a];     }     for (int i = 1; i <= p; i++) printf( %I64d n , ans[i]);   }   int main() {     solve();     return 0;   }
#include <bits/stdc++.h>   using namespace std;   mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());   const int N = 1e6, inf = 1e9, mod = 1000000007;   vector<pair<int, int> > ad[N + 2], tree[N + 2];   int vis[N + 2], lev[N + 2];   void dfs(int node, int par, int lv) {     vis[node] = 1, lev[node] = lv;     for (auto x : ad[node]) {       if (x.first == par) continue;       if (vis[x.first]) {       } else {         tree[node].push_back(x);         tree[x.first].push_back({node, x.second});         dfs(x.first, node, lv + 1);       }     }   }   int a[N + 2], cnt[N + 2];   void dds(int nd, int pr, int id) {     for (auto x : tree[nd]) {       if (x.first == pr) continue;       dds(x.first, nd, x.second);     }     if (pr == -1) return;     if (a[nd] == 1) {       cnt[id] ^= 1;       a[nd] = 0;       if (a[pr] != -1) a[pr] ^= 1;     }   }   int f;   int vs[N + 2];   void dfs(int nd) {     if (a[nd] == 1) {       a[nd] = 0;       f = 1;       return;     } else if (a[nd] == -1) {       f = 1;       return;     }     vs[nd] = 1;     for (int i = 0; i < (int)tree[nd].size(); i++) {       if (vs[tree[nd][i].first]) continue;       cnt[tree[nd][i].second] ^= 1;       dfs(tree[nd][i].first);       if (f) break;       cnt[tree[nd][i].second] ^= 1;     }     vs[nd] = 0;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, m;     cin >> n >> m;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= m; i++) {       int u, v;       cin >> u >> v;       ad[u].push_back({v, i});       ad[v].push_back({u, i});     }     dfs(1, -1, 0);     dds(1, -1, 0);     int ans = 0;     f = 1;     if (a[1] == 1) {       f = 0;       a[1] = 0;       dfs(1);     }     if (f == 0) cout << -1 << endl, exit(0);     for (int i = 1; i <= m; i++) ans += cnt[i];     cout << ans << endl;     for (int i = 1; i <= m; i++)       if (cnt[i]) cout << i <<    ;     cout << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   char aa[100100];   int a[550][550];   int main() {     int x, y, x0, y0;     cin >> x >> y >> x0 >> y0;     for (int i = 1; i <= x; i++)       for (int j = 1; j <= y; j++) a[i][i] = 0;     a[x0][y0] = 1;     int sum = 1;     scanf( %s , aa);     int len = strlen(aa);     cout <<  1  ;     for (int i = 0; i < len - 1; i++) {       if (aa[i] ==  U ) {         x0--;         if (x0 < 1) x0++;         if (a[x0][y0] == 1)           cout <<  0  ;         else {           cout <<  1  ;           sum++;           a[x0][y0] = 1;         }       }       if (aa[i] ==  D ) {         x0++;         if (x0 > x) x0--;         if (a[x0][y0] == 1)           cout <<  0  ;         else {           cout <<  1  ;           sum++;           a[x0][y0] = 1;         }       }       if (aa[i] ==  L ) {         y0--;         if (y0 < 1) y0++;         if (a[x0][y0] == 1)           cout <<  0  ;         else {           cout <<  1  ;           sum++;           a[x0][y0] = 1;         }       }       if (aa[i] ==  R ) {         y0++;         if (y0 > y) y0--;         if (a[x0][y0] == 1)           cout <<  0  ;         else {           cout <<  1  ;           sum++;           a[x0][y0] = 1;         }       }     }     cout << x * y - sum << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     string s;     cin >> s;     int l = s.length();     vector<char> s1;     for (int i = 0; i < l; i++) {       s1.push_back(s[i]);       int f = 0;       while (s[i] ==  /  && i < l) {         i++;         f = 1;       }       if (f == 1) i--;     }     if (s1[s1.size() - 1] ==  /  && s1.size() != 1) s1.pop_back();     for (int i = 0; i < s1.size(); i++) cout << s1[i];     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, m, k, x[100039], y[100039], z, now, cur, flag[100039];   long long d[100039], ans = 1e15;   struct yyy {     int to;     long long w;     int z;   } tmps;   struct ljb {     int head, h[100039];     yyy f[600039];     inline void add(int x, int y, long long z) {       f[++head] = (yyy){y, z, h[x]};       h[x] = head;     }   } s;   struct tree {     int x, y, num;   } f[100039];   inline bool cmp1(tree x, tree y) { return x.x < y.x; }   inline bool cmp2(tree x, tree y) { return x.y < y.y; }   inline bool cmp3(tree x, tree y) { return x.num < y.num; }   inline int calc(int a, int b) {     return ((abs(x[a] - x[b])) < (abs(y[a] - y[b])) ? (abs(x[a] - x[b]))                                                     : (abs(y[a] - y[b])));   }   inline int calc1(int a, int b) { return abs(x[a] - x[b]) + abs(y[a] - y[b]); }   struct ques {     int to;     long long w;     bool operator<(const ques &x) const { return w > x.w; }   } tmp;   priority_queue<ques> q;   int main() {     memset(d, 0x3f, sizeof(d));     memset(s.h, -1, sizeof(s.h));     register int i;     scanf( %d%d , &n, &n);     scanf( %d%d%d%d , &x[0], &y[0], &x[n + 1], &y[n + 1]);     ans = abs(x[0] - x[n + 1]) + abs(y[0] - y[n + 1]);     for (i = 1; i <= n; i++)       scanf( %d%d , &f[i].x, &f[i].y), x[i] = f[i].x, y[i] = f[i].y, f[i].num = i;     sort(f + 1, f + n + 1, cmp1);     for (i = 2; i <= n; i++)       s.add(f[i - 1].num, f[i].num, calc(f[i - 1].num, f[i].num)),           s.add(f[i].num, f[i - 1].num, calc(f[i - 1].num, f[i].num));     sort(f + 1, f + n + 1, cmp2);     for (i = 2; i <= n; i++)       s.add(f[i - 1].num, f[i].num, calc(f[i - 1].num, f[i].num)),           s.add(f[i].num, f[i - 1].num, calc(f[i - 1].num, f[i].num));     for (i = 1; i <= n; i++) s.add(0, i, calc(0, i));     for (i = 1; i <= n; i++) s.add(i, n + 1, calc1(i, n + 1));     q.push((ques){0, 0});     d[0] = 0;     while (!q.empty()) {       tmp = q.top();       q.pop();       cur = s.h[tmp.to];       while (~cur) {         tmps = s.f[cur];         if (d[tmps.to] > d[tmp.to] + tmps.w)           d[tmps.to] = d[tmp.to] + tmps.w, q.push((ques){tmps.to, d[tmps.to]});         cur = tmps.z;       }     }     printf( %lld n , ((d[n + 1]) < (ans) ? (d[n + 1]) : (ans)));   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   string a, b;   signed main() {     ios_base::sync_with_stdio(0);     cin.tie();     cout.tie();     cin >> a;     b += a;     reverse(a.begin(), a.end());     b += a;     cout << b;   }