malteklaes/cpp-code-code_search_net-style huggingface dataset:
#include <bits/stdc++.h>   using namespace std;   int mx, cnt, k;   char s[105];   int main() {     while (~scanf(  %s , &s)) {       k = strlen(s);       mx = 0;       for (int i = 0; i < k; i++) {         for (int j = i + 1; j < k; j++) {           cnt = 0;           if (s[i] == s[j]) {             for (int o = 0; o < k; o++) {               if (s[i + o] == s[j + o])                 cnt++;               else                 break;             }           }           if (cnt > mx) mx = cnt;         }       }       printf( %d n , mx);     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int vis[2005];   int main() {     int n, m, k;     char c;     scanf( %d%d%d , &n, &m, &k);     int ans = 0;     for (int i = 0; i < n; i++) {       getchar();       int temp = 0;       for (int j = 0; j < m; j++) {         scanf( %c , &c);         if (c ==  . ) {           vis[j]++;           temp++;         } else {           vis[j] = 0;           temp = 0;         }         if (temp >= k) ans++;         if (vis[j] >= k && k != 1) ans++;       }     }     printf( %d n , ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   bool Caps(string a) {     for (int i = 0; i < a.size(); i++)       if (a.at(i) < 65 && a.at(i) > 90) return false;     return true;   }   int main() {     long long n, cnt = 0;     cin >> n;     while (n > 0) {       int rem = n % 10;       if (rem == 4 || rem == 7) {         cnt++;       }       n /= 10;     }     if (cnt == 4 || cnt == 7)       cout <<  YES ;     else       cout <<  NO ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int inf = (int)1e9;   const int mod = inf + 7;   const double eps = 1e-9;   const double pi = acos(-1.0);   int n, cnt, m;   string second, t;   vector<string> g[100];   map<string, int> id;   map<int, string> st;   bool check(string second, string t) {     string cur;     if ((int)second.size() > (int)t.size()) return 1;     for (int i = (int)t.size() - (int)second.size(); i < (int)t.size(); ++i) {       cur += t[i];     }     if (cur == second) return 0;     return 1;   }   void make(int pos) {     vector<string> v;     map<string, bool> x;     for (int i = 0; i < (int)g[pos].size(); ++i) {       if (x.count(g[pos][i]) == 0) {         v.push_back(g[pos][i]);         x[g[pos][i]] = 1;       }     }     g[pos] = v;     v.clear();     for (int i = 0; i < (int)g[pos].size(); ++i) {       bool bad = 0;       for (int j = 0; j < (int)g[pos].size(); ++j) {         if (i == j) continue;         if (!check(g[pos][i], g[pos][j])) {           bad = 1;         }       }       if (!bad) {         v.push_back(g[pos][i]);       }     }     g[pos] = v;   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0);     cin >> n;     for (int i = 0; i < n; ++i) {       cin >> second;       if (id.count(second) == 0) {         id[second] = cnt;         st[cnt] = second;         cnt++;       }       int v = id[second];       cin >> m;       for (int i = 0; i < m; ++i) {         cin >> t;         g[v].push_back(t);       }     }     for (int i = 0; i < cnt; ++i) {       make(i);     }     cout << cnt << endl;     for (int i = 0; i < cnt; ++i) {       cout << st[i] <<     << (int)g[i].size() <<    ;       for (int j = 0; j < (int)g[i].size(); ++j) {         cout << g[i][j] <<    ;       }       cout <<   n ;     }   }
#include <bits/stdc++.h>   using namespace std;   int main() {     int n, a, b;     cin >> n >> a >> b;     int ans = a;     if (b < 0) {       int t = abs(b);       while (t--) {         --a;         if (a == 0) a = n;       }     } else {       while (b--) {         ++a;         if (a == n + 1) a = 1;       }     }     cout << a << endl;   }
#include <bits/stdc++.h>   using namespace std;   map<char, int> U1;   map<char, int> U2;   map<char, int> U3;   int n, len;   int panduan(int a) {     if (a != len)       a = min(a + n, len);     else if (a == len && n == 1)       a = a - 1;     return a;   }   int main() {     cin >> n;     string a, b, c;     cin >> a;     cin >> b;     cin >> c;     int Kuro = 0, Shiro = 0, Katie = 0;     len = a.size();     for (int i = 0; i < len; i++) {       U1[a[i]]++;       if (U1[a[i]] > Kuro) Kuro = U1[a[i]];     }     for (int i = 0; i < len; i++) {       U2[b[i]]++;       if (U2[b[i]] > Shiro) Shiro = U2[b[i]];     }     for (int i = 0; i < len; i++) {       U3[c[i]]++;       if (U3[c[i]] > Katie) Katie = U3[c[i]];     }     Kuro = panduan(Kuro);     Shiro = panduan(Shiro);     Katie = panduan(Katie);     if (Kuro > Shiro && Kuro > Katie)       printf( Kuro n );     else if (Shiro > Kuro && Shiro > Katie)       printf( Shiro n );     else if (Katie > Kuro && Katie > Shiro)       printf( Katie n );     else       printf( Draw n );   }
#include <bits/stdc++.h>   using namespace std;   struct trip {     int a, b, c;   };   const int MAXINT = 100;   int n, temp;   vector<int> pos, neg;   bool zeros = false;   int main() {     cin >> n;     for (int i = 0; i < n; i++) {       cin >> temp;       if (temp > 0)         pos.push_back(temp);       else if (temp < 0)         neg.push_back(temp);       else         zeros = true;     }     if (!pos.size() && !neg.size()) cout << 0 << endl;     if (pos.size() == 0 && neg.size() == 1) {       if (zeros)         cout << 0 << endl;       else         cout << neg[0] << endl;     }     for (int e : pos) cout << e <<    ;     if (neg.size() % 2 == 0)       for (int e : neg) cout << e <<    ;     else {       sort(neg.begin(), neg.end());       int N = neg.size();       for (int i = 0; i < N - 1; i++) cout << neg[i] <<    ;     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   vector<pair<long long int, long long int> > v;   long long int indegree[300005];   long long int vis[300005];   long long int parent[300005];   long long int getpar(long long int child) {     if (parent[child] == child)       return child;     else       return parent[child] = getpar(parent[child]);   }   void merge(long long int v1, long long int v2) {     parent[getpar(v1)] = getpar(v2);   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     int TESTS = 1;     while (TESTS--) {       long long int n, m;       cin >> n >> m;       v.resize(m);       memset(indegree, 0, sizeof(indegree));       memset(vis, 0, sizeof(vis));       for (long long int i = 1; i <= n; i++) {         parent[i] = i;       }       for (long long int i = 0; i < m; i++) {         cin >> v[i].first >> v[i].second;         indegree[v[i].first]++;         indegree[v[i].second]++;       }       long long int maxi = 0, idx = -1;       for (long long int i = 1; i <= n; i++) {         if (indegree[i] >= maxi) {           maxi = indegree[i];           idx = i;         }       }       for (long long int i = 0; i < m; i++) {         if (v[i].first == idx || v[i].second == idx) {           vis[i] = 1;           merge(v[i].first, v[i].second);         }       }       for (long long int i = 0; i < m; i++) {         if (vis[i] == 0) {           if (getpar(v[i].first) != getpar(v[i].second)) {             merge(v[i].first, v[i].second);             vis[i] = 1;           }         }       }       for (long long int i = 0; i < m; i++) {         if (vis[i] == 1) {           cout << v[i].first <<     << v[i].second <<   n ;         }       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int main() {     long long int k;     cin >> k;     string str, s;     cin >> str;     s = str;     for (long long int i = 1; i < k; i++) str = str + s;     map<char, vector<long long int>> pos;     long long int i = 0;     for (auto c : str) {       pos[c].push_back(i);       i++;     }     long long int n;     cin >> n;     char c;     long long int p;     while (n--) {       cin >> p >> c;       str[pos[c][p - 1]] = 0;       pos[c].erase(pos[c].begin() + (p - 1));     }     for (auto c : str)       if (c) cout << c;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long M = 100100 * 5;   const long long N = 50005;   long long m, b, k;   map<long long, long long> fre;   int v1[M], mmax;   int main() {     ios::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cin >> m;     for (int i = 0; i < m; i++) {       cin >> b;       fre[b]++;     }     for (int i = 0; i < N; i++) {       if (fre[i]) v1[k] = i, k++, fre[i]--, mmax = max(mmax, i);     }     for (int i = mmax - 1; i >= 0; i--) {       if (fre[i]) v1[k] = i, k++;     }     cout << k << endl;     for (int i = 0; i < k; i++) cout << v1[i] <<    ;   }
#include <bits/stdc++.h>   using namespace std;   vector<int> arr, hgt, res;   int n;   int func(int i, int j) {}   int main() {     int a, b, c, d, e, f, g;     cin >> a;     while (a--) {       cin >> b;       vector<int> num;       for (int i = 0; i < b; i++) {         cin >> c;         num.push_back(c);       }       if (num[b - 1] < num[0]) {         cout <<  NO  << endl;       } else {         cout <<  YES  << endl;       }       num.clear();     }   }
#include <bits/stdc++.h>   #pragma comment(linker,  /STACK:36777216 )   using namespace std;   const int inf = 1 << 30;   const long long Inf = 1LL << 62;   const int dx[] = {-1, 0, 1, 0, -1, -1, 1, 1, 0};   const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1, 0};   const double eps = 1e-9;   const double pi = 3.1415926535897932384626433832795;   template <class T>   inline bool eq(const T &a, const T &b) {     return fabs(a - b) < eps;   }   template <class T>   inline bool deg2(const T &n) {     return (n & (n - 1)) == 0;   }   template <class T>   inline void chmax(T &a, const T &b) {     a = max(a, b);   }   inline int intRand(int l, int r) {     return ((rand() << 16) | rand()) % (r - l + 1) + l;   }   inline long long llRand(long long l, long long r) {     return (((1ll * rand()) << 48) | ((1ll * rand()) << 32) | (rand() << 16) |             rand()) %                (r - l + 1) +            l;   }   bool is[100500], dd;   int s[1000], a[100500], n, m, i, ii, cnt, j, pr[100000], pp;   char q;   bool prime(int n) {     for (int i = 2; i * i <= n; i++)       if (n % i == 0) return 0;     return 1;   }   int main() {     ios_base::sync_with_stdio(false);     srand(time(NULL));     for (i = 2; i < 100000; i++)       if (prime(i)) pr[pp++] = i;     scanf( %d%d n , &n, &m);     while (m--) {       scanf( %c%d n , &q, &i);       if (q ==  + ) {         if (is[i]) {           puts( Already on );           continue;         }         ii = i;         cnt = 0;         for (j = 0; 1ll * pr[j] * pr[j] <= 1ll * i; j++) {           dd = 0;           while (i % pr[j] == 0) {             i /= pr[j];             dd = 1;           }           if (dd) s[cnt++] = pr[j];         }         if (i > 1) s[cnt++] = i;         dd = 0;         for (j = 0; j < cnt; j++)           if (a[s[j]]) {             printf( Conflict with %d n , a[s[j]]);             dd = 1;             break;           }         if (dd) continue;         puts( Success );         for (j = 0; j < cnt; j++) a[s[j]] = ii;         is[ii] = 1;       } else {         if (!is[i]) {           printf( Already off n );           continue;         }         is[i] = 0;         for (j = 0; 1ll * pr[j] * pr[j] <= 1ll * i; j++) {           dd = 0;           while (i % pr[j] == 0) {             i /= pr[j];             a[pr[j]] = 0;           }         }         if (i > 1) a[i] = 0;         puts( Success );       }     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const long long N = 1e5 + 10, LOG = 23, MAX = 1e6 + 10, M = 1e9 + 7;   long long n;   long long mark[N], level[N], par[N][LOG + 10], arr[MAX], cnt[N], tavan[MAX];   vector<long long> g[N];   map<pair<long long, long long>, long long> mp;   void DFS(long long v) {     mark[v] = 1;     for (long long u : g[v]) {       if (!mark[u]) {         level[u] = level[v] + 1;         par[u][0] = v;         DFS(u);       }     }   }   long long DFS2(long long v) {     mark[v] = 2;     for (long long u : g[v]) {       if (mark[u] != 2) cnt[v] += DFS2(u);     }     return cnt[v];   }   long long getpar(long long v, long long dis) {     long long cnt = 0;     while (dis) {       if (dis % 2) v = par[v][cnt];       cnt++;       dis /= 2;     }     return v;   }   long long MOD(long long a) { return (((a % M) + M) % M); }   void UPDATE() {     for (long long i = 1; i <= LOG; i++) {       for (long long node = 1; node <= n; node++)         par[node][i] = par[par[node][i - 1]][i - 1];     }     tavan[0] = 1;     for (long long i = 1; i < MAX; i++) {       tavan[i] = MOD(tavan[i - 1] * 2);     }   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long u, v, x, q, ans = 0;     cin >> n;     for (long long i = 0; i < n - 1; i++) {       cin >> u >> v >> x;       mp[{u, v}] = x;       g[u].push_back(v);       g[v].push_back(u);     }     DFS(1);     UPDATE();     cin >> q;     arr[0] = 1;     for (long long i = 1; i <= q; i++) {       cin >> arr[i];       long long lca;       v = arr[i];       u = arr[i - 1];       cnt[u]++;       cnt[v]++;       if (level[v] < level[u]) swap(v, u);       v = getpar(v, level[v] - level[u]);       if (v == u)         lca = v;       else {         for (long long j = LOG; j >= 0; j--) {           if (par[v][j] != par[u][j]) {             v = par[v][j];             u = par[u][j];           }         }         lca = par[v][0];       }       cnt[lca] -= 2;     }     DFS2(1);     for (long long i = 1; i <= n; i++) {       v = i;       u = par[i][0];       if ((mp.count({v, u}) && mp[{v, u}]) || (mp.count({u, v}) && mp[{u, v}])) {         if (cnt[v] % 2 == 0)           ans += tavan[cnt[v] / 2] - 1;         else {           if (mp.count({v, u}))             ans += tavan[(cnt[v] + 1) / 2] - 1;           else             ans += tavan[cnt[v] / 2] - 1;         }         ans = MOD(ans);       }     }     cout << ans;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int MAX = 1e5 + 5;   int n;   char a[MAX];   pair<char, int> b[MAX];   int main() {     cin >> (a + 1);     n = strlen(a + 1);     for (int i = 1; i <= n; ++i) {       b[i].first = a[i];       b[i].second = i;     }     sort(b + 1, b + n + 1,          [&](const pair<char, int> &a, const pair<char, int> &b) {            if (a.first == b.first) {              return a.second < b.second;            }            return a.first > b.first;          });     for (int i = 1, j = 0; i <= n; ++i) {       if (j < b[i].second) {         cout << b[i].first;         j = b[i].second;       }     }     cout <<   n ;   }
#include <bits/stdc++.h>   using namespace std;   using ll = long long;   struct Rect {     int right, left, top, bottom;     int height() { return top - bottom; }     int width() { return right - left; }     int area() { return (top - bottom) * (right - left); }   };   void solve() {     int w, h;     cin >> w >> h;     Rect first, second;     second.bottom = 0, second.left = 0;     cin >> first.left >> first.bottom >> first.right >> first.top;     cin >> second.right >> second.top;     bool move_y = first.height() + second.height() <= h,          move_x = first.width() + second.width() <= w;     if (!move_y && !move_x) {       cout << -1 <<   n ;       return;     } else {       vector<int> moves;       if (move_x) {         moves.push_back(second.right - first.left);         moves.push_back(first.right - (w - second.width()));       }       if (move_y) {         moves.push_back(second.top - first.bottom);         moves.push_back(first.top - (h - second.height()));       }       int ans = INT_MAX;       for (auto i : moves) {         ans = min(ans, max(i, 0));       }       cout << ans;     }     cout <<   n ;   }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     int t;     cin >> t;     while (t--) {       solve();     }     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int M = 1e9 + 7;   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     int n;     cin >> n;     vector<long long> L(n), R(n), A(n);     for (int i = 0; i < n; ++i) {       cin >> L[i];     }     for (int i = 0; i < n; ++i) {       cin >> R[i];     }     for (int i = 0; i < n; ++i) {       A[i] = n - L[i] - R[i];     }     for (int i = 0; i < n; ++i) {       for (int j = i + 1; j < n; ++j) {         if (A[j] > A[i]) {           R[i]--;         }       }       for (int j = 0; j < i; ++j) {         if (A[j] > A[i]) {           L[i]--;         }       }     }     for (int i = 0; i < n; ++i) {       if (L[i] || R[i]) {         cout <<  NO               <<   n ;         return 0;       }     }     cout <<  YES           <<   n ;     for (int i : A) {       cout << i <<    ;     }     cout <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   template <typename T, typename U>   inline void smin(T &a, U b) {     if (a > b) a = b;   }   template <typename T, typename U>   inline void smax(T &a, U b) {     if (a < b) a = b;   }   template <typename T>   inline void gn(T &first) {     char c, sg = 0;     while (c = getchar(), (c >  9  || c <  0 ) && c !=  - )       ;     for ((c ==  -  ? sg = 1, c = getchar() : 0), first = 0; c >=  0  && c <=  9 ;          c = getchar())       first = (first << 1) + (first << 3) + c -  0 ;     if (sg) first = -first;   }   template <class T, class T1>   inline void gn(T &first, T1 &second) {     gn(first);     gn(second);   }   template <class T, class T1, class T2>   inline void gn(T &first, T1 &second, T2 &z) {     gn(first);     gn(second);     gn(z);   }   template <typename T>   inline void print(T first) {     if (first < 0) {       putchar( - );       return print(-first);     }     if (first < 10) {       putchar( 0  + first);       return;     }     print(first / 10);     putchar(first % 10 +  0 );   }   template <typename T>   inline void println(T first) {     print(first), putchar(  n );   }   template <typename T>   inline void printsp(T first) {     print(first), putchar(   );   }   template <class T, class T1>   inline void print(T first, T1 second) {     printsp(first), println(second);   }   template <class T, class T1, class T2>   inline void print(T first, T1 second, T2 z) {     printsp(first), printsp(second), println(z);   }   int power(int a, int b, int m, int ans = 1) {     for (; b; b >>= 1, a = 1LL * a * a % m)       if (b & 1) ans = 1LL * ans * a % m;     return ans;   }   int main() {     int a, b, p;     long long first;     gn(a, b, p);     gn(first);     long long ans = 0;     long long M = (long long)p * (p - 1);     int p1 = power(p - 1, p - 2, p);     int p2 = p == 2 ? 1 : power(p, p - 3, p - 1);     for (int r = 0; r < p - 1; r++) {       int second = (long long)b * power(a, p - 1 - r, p) % p;       long long rr =           ((long long)r * p % M * p2 + (long long)second * (p - 1) % M * p1) % M;       if (rr <= first) ans += (first - rr) / M + 1;     }     println(ans);     return 0;   }
#include <bits/stdc++.h>   using namespace std;   const int N = 505;   int n, m, qc;   bool fd[N][N];   bitset<N> bs1[N][N];   bitset<N> bs2[N][N];   struct query {     int x1, y1, x2, y2;     int id;   };   vector<query> qs;   vector<bool> ans;   void solve(vector<int>& ids, int tl, int tr) {     if (ids.size() == 0) return;     if (tl > tr) return;     vector<int> l;     vector<int> r;     int tm = (tl + tr) / 2;     for (int i = n - 1; i >= 0; i--) {       bs1[i][tm].reset();       if (!fd[i][tm]) {         bs1[i][tm][i] = true;         if (i + 1 < n) bs1[i][tm] |= bs1[i + 1][tm];       }     }     for (int i = n - 1; i >= 0; i--) {       for (int j = tm - 1; j >= tl; j--) {         bs1[i][j].reset();         if (fd[i][j]) continue;         if (i + 1 < n) bs1[i][j] |= bs1[i + 1][j];         bs1[i][j] |= bs1[i][j + 1];       }     }     for (int i = 0; i < n; i++) {       bs2[i][tm].reset();       if (!fd[i][tm]) {         bs2[i][tm][i] = true;         if (i > 0) bs2[i][tm] |= bs2[i - 1][tm];       }     }     for (int i = 0; i < n; i++) {       for (int j = tm + 1; j <= tr; j++) {         bs2[i][j].reset();         if (fd[i][j]) continue;         if (i - 1 >= 0) bs2[i][j] |= bs2[i - 1][j];         bs2[i][j] |= bs2[i][j - 1];       }     }     for (int id : ids) {       query& q = qs[id];       if (q.y1 < tm && q.y2 < tm) {         l.push_back(id);       } else if (q.y1 > tm && q.y2 > tm) {         r.push_back(id);       } else {         bitset<N> bans = bs1[q.x1][q.y1] & bs2[q.x2][q.y2];         ans[id] = bans.any();       }     }     solve(l, tl, tm - 1);     solve(r, tm + 1, tr);   }   int32_t main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     ;     cin >> n >> m;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         char c;         cin >> c;         fd[i][j] = (c ==  # );       }     }     cin >> qc;     qs.resize(qc);     for (int i = 0; i < qc; i++) {       int x1, y1, x2, y2;       cin >> x1 >> y1 >> x2 >> y2;       x1--;       y1--;       x2--;       y2--;       qs[i] = {x1, y1, x2, y2, i};     }     vector<int> ids;     ids.reserve(qc);     for (int i = 0; i < qc; i++) {       if (qs[i].x1 > qs[i].x2 || qs[i].y1 > qs[i].y2) continue;       ids.push_back(i);     }     ans.resize(qc);     solve(ids, 0, m - 1);     for (bool t : ans) cout << (t ?  Yes  :  No ) <<   n ;     return 0;   }
#include <bits/stdc++.h>   using namespace std;   int getcom(pair<int, int> a, pair<int, int> b) {     vector<int> all;     all.push_back(a.first);     all.push_back(a.second);     all.push_back(b.first);     all.push_back(b.second);     sort(all.begin(), all.end());     int com = -1;     for (int k = 1; k < 4; k++) {       if (all[k] == all[k - 1]) {         com = all[k];       }     }     return com;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(0);     int n, m;     cin >> n >> m;     vector<pair<int, int> > a;     vector<pair<int, int> > b;     for (int i = 0; i < n; i++) {       int x, y;       cin >> x >> y;       if (x > y) {         swap(x, y);       }       a.push_back(make_pair(x, y));     }     for (int i = 0; i < m; i++) {       int x, y;       cin >> x >> y;       if (x > y) {         swap(x, y);       }       b.push_back(make_pair(x, y));     }     vector<int> possible;     bool theyknow = true;     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (a[i] == b[j]) {           continue;         }         int com = getcom(a[i], b[j]);         if (com == -1) {           continue;         }         if (com != -1) {           possible.push_back(com);         }         for (int k = 0; k < m; k++) {           if (a[i] == b[k]) {             continue;           }           int com2 = getcom(a[i], b[k]);           if (com2 != -1 && com2 != com) {             theyknow = false;           }         }         for (int k = 0; k < n; k++) {           if (a[k] == b[j]) {             continue;           }           int com2 = getcom(a[k], b[j]);           if (com2 != -1 && com2 != com) {             theyknow = false;           }         }       }     }     sort(possible.begin(), possible.end());     if (possible[0] == possible[possible.size() - 1]) {       cout << possible[0] << endl;       return 0;     }     if (theyknow) {       cout << 0 << endl;     } else {       cout << -1 << endl;     }   }
#include <bits/stdc++.h>   using namespace std;   bool solve(string temp, string p) {     int i = 0, j = 0;     while (i != temp.size()) {       if (temp[i] == p[j]) {         i++;         j++;       } else         i++;       if (j == p.size()) break;     }     if (i <= temp.size() && j >= p.size())       return true;     else       return false;   }   int main() {     string s, p;     cin >> s >> p;     int n = s.size();     int arr[n];     for (int i = 0; i < n; i++) cin >> arr[i];     int lo = 0, hi = n - 1, mid = (hi + lo) / 2;     while (lo <= hi) {       string temp = s;       for (int i = 0; i < mid; i++) temp[arr[i] - 1] =  0 ;       if (solve(temp, p))         lo = mid + 1;       else         hi = mid - 1;       mid = (hi + lo) / 2;     }     cout << mid;   }