malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   const int M = 110000;   long long a[M], b[M], c[M], be[M];   long long n, d, x;   long long getNextX() {     x = (x * 37 + 10007) % 1000000007;     return x;   }   void initAB() {     long long i;     for (i = 0; i < n; i = i + 1) {       a[i] = i + 1;     }     for (i = 0; i < n; i = i + 1) {       swap(a[i], a[getNextX() % (i + 1)]);     }     for (i = 0; i < n; i = i + 1) {       if (i < d)         b[i] = 1;       else         b[i] = 0;     }     for (i = 0; i < n; i = i + 1) {       swap(b[i], b[getNextX() % (i + 1)]);     }   }   int main() {     long long i, j, k;     while (~scanf( %I64d%I64d%I64d , &n, &d, &x)) {       initAB();       vector<int> vt;       memset(be, 0, sizeof(be));       int cnt = 0;       for (i = 0; i < n; i++)         if (b[i]) cnt++;       if (cnt <= sqrt(n)) {         for (i = 0; i < n; i++)           if (b[i]) vt.push_back(i);         for (i = 0; i < n; i++) {           long long mx = 0;           for (j = 0; j < vt.size(); j++) {             k = vt[j];             if (k > i) break;             c[i] = max(c[i], a[i - k]);           }         }       } else {         vector<pair<int, int> > vc;         for (i = 0; i < n; i++) vc.push_back(make_pair(a[i], i));         sort(vc.begin(), vc.end());         for (i = 0; i < n; i++) {           for (j = n - 1; j >= 0; j--) {             if (vc[j].second <= i && b[i - vc[j].second]) {               c[i] = vc[j].first;               break;             }           }         }       }       for (i = 0; i < n; i++) cout << c[i] << endl;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 5;   int ans[N << 1];   int main() {     int n;     cin >> n;     int b1 = n + 1;     int b2 = 2 * n - 1;     int a1 = 1;     int a2 = n;     int cnt = 1;     for (int i = 1; i <= n - 1; ++i) {       if (cnt & 1)         ans[a1++] = i, ans[a2--] = i;       else         ans[b1++] = i, ans[b2--] = i;       cnt++;     }     for (int i = 1; i <= 2 * n; ++i)       if (ans[i] == 0)         cout << n <<    ;       else         cout << ans[i] <<    ;   }
#include <bits/stdc++.h>   typedef struct {     long long s, l, r, m;   } value;   long long maxll(long long a, long long b) { return a > b ? a : b; }   void sum(value *v, value *l, value *r) {     v->s = l->s + r->s;     v->l = maxll(l->l, l->s + r->l);     v->r = maxll(r->r, r->s + l->r);     v->m = maxll(l->r + r->l, maxll(l->m, r->m));   }   value t[4 * 150000];   long long a[150000];   void build(int i, int l, int r) {     if (l == r) {       t[i].s = a[l];       t[i].l = t[i].r = t[i].m = maxll(a[l], 0);     } else {       int m = (l + r) / 2;       build(2 * i + 1, l, m);       build(2 * i + 2, m + 1, r);       sum(&t[i], &t[2 * i + 1], &t[2 * i + 2]);     }   }   value get(int ll, int rr, int i, int l, int r) {     if (rr < l || r < ll) {       value v = {0, 0, 0, 0};       return v;     }     if (ll <= l && r <= rr) return t[i];     int m = (l + r) / 2;     value lv, rv, av;     lv = get(ll, rr, 2 * i + 1, l, m);     rv = get(ll, rr, 2 * i + 2, m + 1, r);     sum(&av, &lv, &rv);     return av;   }   int main() {     int n, m, c;     scanf( %d%d%d , &n, &m, &c);     int i, x[150000];     for (i = 0; i < n; i++) scanf( %d , &x[i]);     int p[150000];     for (i = 0; i < n - 1; i++) scanf( %d , &p[i]);     for (i = 0; i < n - 1; i++) a[i] = 1LL * (x[i + 1] - x[i]) * 50 - c * p[i];     build(0, 0, n - 2);     long long s = 0;     for (i = 0; i < m; i++) {       int l, r;       scanf( %d%d , &l, &r);       l--;       r--;       r--;       s += get(l, r, 0, 0, n - 2).m;     }     printf( %.2lf n , 1. * s / 100);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <class T>   inline void read(T &x) {     x = 0;     char c = getchar();     bool f = 0;     for (; !isdigit(c); c = getchar()) f ^= c ==  - ;     for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);     x = f ? -x : x;   }   int n, x, len, res, minn = 0x7fffffff;   char s[400001];   string ans, c[6] = { RGB ,  RBG ,  BRG ,  BGR ,  GRB ,  GBR };   int main() {     read(n);     scanf( %s , s), len = strlen(s);     for (int i = 0; i < 6; i++) {       res = 0, x = 0;       for (int j = 0; j < len; j++) {         if (s[j] != c[i][x++]) res++;         if (x == 3) x = 0;       }       if (res < minn) {         minn = res;         ans = c[i];       }     }     x = 0;     cout << minn <<   n ;     for (int j = 0; j < len; j++) {       putchar(ans[x++]);       if (x == 3) x = 0;     }     putchar(  n );     return 0;   }
#include <bits/stdc++.h>   #pragma optimization_level 3   #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math,O3 )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx )   using namespace std;   const long double PI = 3.14159265358979323846;   const long long mod = 1e+9 + 7;   const int INFi = INT_MAX;   const long long INF = (long long)1e+9 + 7;   const int N = 1200300, LOGN = 30, V = N * LOGN;   long long dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};   int t = 1;   long long a, b, c, ans;   string second;   void MAIN() {     cin >> a >> b >> c;     ans = 0;     ans = max(ans, a / 3 + b / 3 + c / 3);     if (a > 0 && b > 0 && c > 0)       ans = max(ans, 1 + (a - 1) / 3 + (b - 1) / 3 + (c - 1) / 3);     if (a > 1 && b > 1 && c > 1)       ans = max(ans, 2 + (a - 2) / 3 + (b - 2) / 3 + (c - 2) / 3);     cout << ans << endl;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cout << fixed;     cout << setprecision(10);     ;     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());     ;     while (t--) {       MAIN();     }   }
#include <bits/stdc++.h>   using namespace std;   const int maxn = 3005;   int prv[maxn], nxt[maxn], cnt[maxn];   int le[maxn];   int r, c, n, k;   vector<int> pos[maxn];   signed main(void) {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> r >> c >> n >> k;     for (int i = 1; i <= n; ++i) {       int x, y;       cin >> x >> y;       pos[y].emplace_back(x);     }     long long res = 0;     for (int i = 1; i <= c; ++i) {       set<int> second;       second.insert(0);       second.insert(r + 1);       for (int j = 0; j <= r; ++j) cnt[j] = 0, le[j] = 0;       nxt[0] = r + 1;       prv[r + 1] = 0;       long long sum = 0;       for (int j = i; j <= c; ++j) {         for (int val : pos[j]) {           if (!cnt[val]) {             int l = *prev(second.lower_bound(val));             int r = *(second.upper_bound(val));             nxt[l] = val;             nxt[val] = r;             prv[r] = val;             prv[val] = l;             sum -= 1ll * le[l] * (nxt[val] - val);             second.insert(val);           }           cnt[val]++;           int cur = val, now = 0;           while (cur != 0) {             now += cnt[cur];             if (now >= k) break;             cur = prv[cur];           }           int total = cnt[val];           if (cur > le[val]) {             sum += 1ll * (cur - le[val]) * (nxt[val] - val);             le[val] = cur;           }           while (true) {             val = nxt[val];             total += cnt[val];             now += cnt[val];             if (val > r || total > k) break;             while (cur < val && now - cnt[cur] >= k) {               now -= cnt[cur];               cur = nxt[cur];             }             if (cur > le[val]) {               assert(now >= k);               sum += 1ll * (cur - le[val]) * (nxt[val] - val);               le[val] = cur;             }           }         }         res += sum;       }     }     cout << res;   }
#include <bits/stdc++.h>   using namespace std;   string s[555];   int dp[555], v[555], ones[555];   vector<pair<int, int> > vc[555];   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int n, m, k;     cin >> n >> m >> k;     for (int i = 1; i <= n; i++) {       cin >> s[i];       int cnt = 0;       for (int j = 0; j < m; j++) {         if (s[i][j] ==  1 ) ones[cnt++] = j + 1;       }       memset(v, 0, sizeof(v));       v[cnt] = m;       for (int j = 0; j < cnt; j++) {         for (int k = j; k < cnt; k++) {           int len = cnt - (k - j + 1);           int value = m - (ones[k] - ones[j] + 1);           v[len] = max(v[len], value);         }       }       for (int j = 0; j <= k; j++) {         if (v[j]) vc[i].push_back(make_pair(j, v[j]));       }     }     for (int i = 1; i <= n; i++) {       for (int j = k; j >= 0; j--) {         for (int k = 0; k < vc[i].size(); k++) {           if (j >= vc[i][k].first)             dp[j] = max(dp[j], dp[j - vc[i][k].first] + vc[i][k].second);         }       }     }     cout << n * m - dp[k] << endl;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MaxN = int(2e5) + 256;   const int INF = int(1e9);   const int mod = (int)(1e9) + 7;   const double pi = 3.1415926535897932384626433832795;   long long n, m, ans, A[MaxN], k, a, b, q;   long long t[MaxN * 8], t1[MaxN * 8];   void upd(int v, int l, int r, int pos, int val) {     if (l == r) {       t[v] += val;       t1[v] += val;       t[v] = min(a, t[v]);       t1[v] = min(t1[v], b);       return;     }     int m = (l + r) / 2;     if (pos <= m) {       upd(v + v, l, m, pos, val);     } else       upd(v + v + 1, m + 1, r, pos, val);     t[v] = t[v + v] + t[v + v + 1];     t1[v] = t1[v + v] + t1[v + v + 1];   }   long long get(int v, int l, int r, int tl, int tr) {     if (l > tr || r < tl) return 0;     if (tl <= l & r <= tr) return t[v];     int m = (l + r) / 2;     return get(v + v, l, m, tl, tr) + get(v + v + 1, m + 1, r, tl, tr);   }   long long get1(int v, int l, int r, int tl, int tr) {     if (l > tr || r < tl) return 0;     if (tl <= l & r <= tr) return t1[v];     int m = (l + r) / 2;     return get1(v + v, l, m, tl, tr) + get1(v + v + 1, m + 1, r, tl, tr);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cin >> n >> k >> a >> b >> q;     while (q--) {       int type;       cin >> type;       if (type == 1) {         int x, y;         cin >> x >> y;         upd(1, 1, n, x, y);       } else {         int p;         cin >> p;         int S = 0;         if (p > 1) {           S = get1(1, 1, n, 1, p - 1);         }         int S1 = 0;         if (p + k <= n) {           S1 = get(1, 1, n, p + k, n);         }         cout << S + S1 <<   n ;       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int n, i, j;     cin >> n;     long long int a[n], b[n], t[n];     for (i = 1; i < n; i++) cin >> a[i];     for (i = 1; i < n; i++) cin >> b[i];     for (i = 0; i < 4; i++) {       t[0] = i;       for (j = 1; j < n; j++) {         if (a[j] == 3 && b[j] == 0) {           if (t[j - 1] == 1)             t[j] = 2;           else if (t[j - 1] == 2)             t[j] = 1;           else if (t[j - 1] == 3)             t[j] = 0;           else             t[j] = 3;           continue;         }         if (a[j] < b[j]) {           cout <<  NO ;           return 0;         }         if (a[j] == 2 && b[j] == 1) {           cout <<  NO ;           return 0;         }         if (t[j - 1] == a[j])           t[j] = b[j];         else if (t[j - 1] == b[j])           t[j] = a[j];         else           break;       }       if (j == n) break;     }     if (i == 4) {       cout <<  NO ;       return 0;     }     cout <<  YES  << endl;     for (i = 0; i < n; i++) cout << t[i] <<    ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int n, depth = 0;   string loc[500];   string comm;   int main() {     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> comm;       if (comm ==  cd ) {         cin >> comm;         int pos = 0;         if (comm[0] ==  / ) {           depth = 0;           pos = 1;         }         string dir =   ;         for (; pos < comm.length(); ++pos) {           if (comm[pos] !=  / ) dir += comm[pos];           if (comm[pos] ==  /  || pos == comm.length() - 1) {             if (dir ==  .. )               depth--;             else               loc[depth++] = dir;             dir =   ;           }         }       } else {         for (int i = 0; i < depth; ++i) cout <<  /  << loc[i];         cout <<  /  << endl;       }     }   }
#include <bits/stdc++.h>   #pragma GCC optimize( O3 )   #pragma comment(linker,  /stack:200000000 )   #pragma GCC optimize( Ofast )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   using namespace std;   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int n, p;     cin >> n >> p;     if (p == 0) {       cout << __builtin_popcount(n);       return 0;     }     if (p > 0) {       long long int a = n;       long long int cnt = 0;       while (a > 0) {         long long int temp = __builtin_popcount(a);         long long int c = 0, k = 0;         while (a) {           if (a & 1) {             k += (c + 1);           }           a = a / 2;           c++;         }         if (temp <= cnt) {           if (k >= cnt) {             cout << cnt;             return 0;           }         }         cnt++;         a = n - cnt * p;       }     } else {       long long int a = n;       long long int cnt = 0;       while (cnt < 1000) {         long long int temp = __builtin_popcount(a);         long long int c = 0, k = 0;         while (a) {           if (a & 1) {             k += (c + 1);           }           a = a / 2;           c++;         }         if (temp <= cnt) {           if (k >= cnt) {             cout << cnt;             return 0;           }         }         cnt++;         a = n - cnt * p;       }     }     cout << -1;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long oo = 1000000000000000000;   const int N = 100005;   int main() {     int n, x;     scanf( %d , &n);     multiset<int> a, b;     for (int i = 0; i < int(n); i++) {       scanf( %d , &x);       a.insert(x);     }     for (int i = 0; i < int(n - 1); i++) {       scanf( %d , &x);       b.insert(x);       a.erase(a.find(x));     }     printf( %d n , *a.begin());     a.clear();     swap(a, b);     for (int i = 0; i < int(n - 2); i++) {       scanf( %d , &x);       b.insert(x);       a.erase(a.find(x));     }     printf( %d n , *a.begin());     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long double Eps = 1e-8;   char what[27] =  A??????HI???M?O????TUVWXY? ;   char str[100005];   void input() { scanf( %s , str); }   bool good() {     int N = strlen(str);     for (int i = 0; i < N; i++) {       if (str[i] != what[str[N - i - 1] -  A ]) return false;     }     return true;   }   int main() {     input();     printf(good() ?  YES n  :  NO n );   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int h, w, x, y, star = 0, sum, flag;     char arr[505][505];     cin >> h >> w;     for (int i = 1; i <= h; i++) {       for (int j = 1; j <= w; j++) {         cin >> arr[i][j];         if (arr[i][j] ==  * ) {           star++;           if (arr[i][j - 1] ==  *  && arr[i - 1][j] ==  * ) {             sum = 3;             x = i;             y = j;           }         }       }     }     if (sum == 3) {       if (arr[x][y + 1] ==  *  && arr[x + 1][y] ==  * ) {         sum = sum + 2;       }       if (sum == 5) {         flag = 1;         if (x + 2 <= h) {           for (int i = x + 2; i <= h; i++) {             if (arr[i][y] ==  * )               sum++;             else               break;           }         }         if (x - 2 > 0) {           for (int i = x - 2; i > 0; i--) {             if (arr[i][y] ==  * )               sum++;             else               break;           }         }         if (y + 2 <= w)           for (int i = y + 2; i <= w; i++) {             if (arr[x][i] ==  * )               sum++;             else               break;           }         if (y - 2 > 0) {           for (int i = y - 2; i > 0; i--) {             if (arr[x][i] ==  * )               sum++;             else               break;           }         }       }     }     if (star == sum && sum >= 5)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1e5 + 10;   int a[M], col[M], flag;   bool vis[M];   vector<int> vc[M];   vector<pair<int, int> > node[M];   void bfs(int sta) {     col[sta] = 0;     vis[sta] = true;     queue<int> q;     q.push(sta);     while (!q.empty()) {       int u = q.front();       q.pop();       int len = node[u].size();       for (int i = 0; i < len; i++) {         int co = col[u];         pair<int, int> v = node[u][i];         if (v.second == 0) {           co ^= 1;         }         if (vis[v.first] && col[v.first] != co) {           flag = false;           return;         }         if (!vis[v.first]) {           col[v.first] = co;           vis[v.first] = true;           q.push(v.first);         }       }     }   }   int main() {     int n, m;     scanf( %d%d , &n, &m);     for (int i = 1; i <= n; i++) {       scanf( %d , &a[i]);     }     for (int i = 1; i <= m; i++) {       int sz;       scanf( %d , &sz);       for (int j = 1; j <= sz; j++) {         int x;         scanf( %d , &x);         vc[x].push_back(i);       }     }     for (int i = 1; i <= n; i++) {       int u = vc[i][0], v = vc[i][1];       node[v].push_back(make_pair(u, a[i]));       node[u].push_back(make_pair(v, a[i]));     }     memset(vis, false, sizeof(vis));     memset(col, -1, sizeof(col));     flag = true;     for (int i = 1; i <= m; i++) {       if (!vis[i]) {         bfs(i);       }     }     if (flag)       printf( YES n );     else       printf( NO n );     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int i, j, k, l;   int n, m, d, a[100010][4];   int ms[11111];   double cx, cy, ccx, ccy;   int x1, stupid_cmath, x2, y2;   int main() {     cin >> n;     for (i = 0; i < n; ++i) {       cin >> x1 >> stupid_cmath >> x2 >> y2;       a[i][0] = ((x1) < (x2) ? (x1) : (x2));       a[i][1] = ((stupid_cmath) < (y2) ? (stupid_cmath) : (y2));       a[i][2] = ((x1) > (x2) ? (x1) : (x2));       a[i][3] = ((stupid_cmath) > (y2) ? (stupid_cmath) : (y2));       ms[i] = (a[i][2] - a[i][0]) * (a[i][2] - a[i][0]) * (a[i][2] - a[i][0]);     }     for (i = 0; i < n; ++i) {       for (j = i - 1; j >= 0; --j) {         cx = cy = 0;         m = 0;         for (k = j + 1; k <= i; ++k) {           cx += (a[k][0] + a[k][2]) / 2. * ms[k];           cy += (a[k][1] + a[k][3]) / 2. * ms[k];           m += ms[k];         }         cx /= m;         cy /= m;         if (cx < a[j][0] || cx > a[j][2] || cy < a[j][1] || cy > a[j][3]) {           cout << i << endl;           return 0;         }       }     }     cout << n;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int a, b, c, n;   int main() {     ios_base::sync_with_stdio(false);     ;     cin >> a >> b >> c >> n;     if (a - c < 0 || b - c < 0) return cout << -1, 0;     if (a + b - c >= n) return cout << -1, 0;     cout << n - (a + b - c);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 5e5 + 5;   int n;   string s;   int main() {     cin >> n;     cin >> s;     bool tmp = false;     for (int i = 0; i <= s.size() - 1; i++) {       if (s[i] > s[i + 1]) {         tmp = true;         s.erase(i, 1);         break;       }     }     if (!tmp) s.erase(s.size() - 1, 1);     cout << s;   }
#include <bits/stdc++.h>   using namespace std;   const int mx = 1e5 + 10;   long long len, ans, val[26], s[mx];   char str[mx];   map<pair<long long, char>, long long> dp;   int main() {     for (int i = 0; i < 26; i++) scanf( %I64d , &val[i]);     scanf( %s , str);     len = strlen(str);     s[0] = val[str[0] -  a ];     for (int i = 1; i < len; i++) s[i] = s[i - 1] + val[str[i] -  a ];     for (int i = 0; i < len; i++) {       ans += dp[make_pair(s[i - 1], str[i])];       dp[make_pair(s[i], str[i])]++;     }     printf( %I64d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, t, sum = 0, x;     cin >> n >> x;     while (n--) {       cin >> t;       sum += t;     }     if (sum < 0) sum *= -1;     int ans = sum / x + bool(sum % x);     cout << ans << endl;     return 0;   }
#include <bits/stdc++.h>   int main() {     int n;     scanf( %d , &n);     int p = 0;     int a[100100];     for (int i = 0; i < n; i++) scanf( %d , &a[i]);     int s = n + n - 1;     for (int i = 0; i < n; i++) {       s += fabs(a[i] - p);       p = a[i];     }     printf( %d n , s);   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:100000000000000 )   using namespace std;   const long long int INF = 2e9 + 1;   char s[50000], s2[50000];   struct automato {     struct leaf {       int link, len;       map<char, int> nex;       bool cl;       leaf() : cl(false) {}     };     vector<leaf> tree;     vector<int> cnt, used;     int sz, pre;     automato() {}     void init() {       sz = 1;       pre = 0;       tree.resize(2 * 50000);       cnt.resize(2 * 50000, 0);       used.resize(2 * 50000, 0);       tree[0].link = -1;       tree[0].len = 0;     };     void add_s(char c) {       int cur = sz++;       tree[cur].len = tree[pre].len + 1;       int temp = pre;       for (; temp != -1 && !tree[temp].nex.count(c); temp = tree[temp].link) {         tree[temp].nex[c] = cur;       }       if (temp == -1) {         tree[cur].link = 0;       } else {         int p = tree[temp].nex[c];         if (tree[p].len == tree[temp].len + 1) {           tree[cur].link = p;         } else {           int clone = sz++;           tree[clone].nex = tree[p].nex;           tree[clone].len = tree[temp].len + 1;           tree[clone].link = tree[p].link;           tree[clone].cl = true;           tree[p].link = clone;           tree[cur].link = clone;           for (; temp != -1 && tree[temp].nex.count(c) && tree[temp].nex[c] == p;                temp = tree[temp].link) {             tree[temp].nex[c] = clone;           }         }       }       pre = cur;     };     void add_str(char *s) {       int n = strlen(s);       for (int i = 0; i < (n); i++) {         add_s(s[i]);       }     }     void dfs() {       vector<pair<int, int> > len;       for (int i = 0; i < (sz); i++) {         len.push_back(make_pair(tree[i].len, i));       }       sort(len.begin(), len.end());       reverse(len.begin(), len.end());       for (int i = 0; i < (sz); i++) {         int id = len[i].second;         if (!tree[id].cl) cnt[id]++;         if (tree[id].link != -1) cnt[tree[id].link] += cnt[id];       }     }     int nx(int id, char c) {       if (!tree[id].nex.count(c)) return -1;       return tree[id].nex[c];     }     int get_cnt(int now) { return cnt[now]; }   };   int main() {     scanf( %s%s , &s, &s2);     int n = strlen(s), m = strlen(s2);     automato a, b;     a.init();     b.init();     a.add_str(s);     b.add_str(s2);     a.dfs();     b.dfs();     int out = INF;     for (int i = 0; i < n; i++) {       int st = 0, st2 = 0;       for (int j = i; j < n; j++) {         st = a.nx(st, s[j]);         st2 = b.nx(st2, s[j]);         if (st == -1 || st2 == -1) break;         if (a.get_cnt(st) == 1 && b.get_cnt(st2) == 1) {           out = min(out, j - i + 1);           break;         }       }     }     cout << (out == INF ? -1 : out);   }
#include <bits/stdc++.h>   using namespace std;   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     double n, k;     cin >> n >> k;     double a, b;     cin >> a >> b;     n--;     double len = 0;     while (n--) {       double x, y;       cin >> x >> y;       len += ((double)sqrt(pow(x - a, 2) + pow(y - b, 2)));       a = x;       b = y;     }     len *= k;     cout << fixed << setprecision(9) << len / (double)50 <<   n ;   }