func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 1000000007;   vector<int> rec[100008];   int dp[2][100008], a[100008];   int fun(int minn, int val) {     int ll = 0, rr, ss = rec[val].size();     if (ss == 0)       return maxn;     else if (rec[val][0] >= minn)       return rec[val][0] + 1;     rr = ss;     while (ll + 1 != rr) {       int mid = (ll + rr) / 2;       if (rec[val][mid] < minn)         ll = mid;       else         rr = mid;     }     if (rr == ss) return maxn;     return rec[val][rr] + 1;   }   int main() {     int n, m, s, e, i, cc, ans;     bool f;     scanf( %d%d%d%d , &n, &m, &s, &e);     for (i = 0; i < n; i++) scanf( %d , &a[i]);     for (i = 0; i <= 100000; i++) rec[i].clear();     for (i = 0; i < m; i++) {       int tmp;       scanf( %d , &tmp);       rec[tmp].push_back(i);     }     memset(dp, 0, sizeof(dp));     cc = 1;     ans = 0;     f = true;     while (f) {       f = false;       for (i = ans; i < n; i++) {         if (i != 0 && dp[1 - cc][i - 1] != maxn) {           dp[cc][i] = fun(dp[1 - cc][i - 1], a[i]);           if (i != ans) dp[cc][i] = min(dp[cc][i], dp[cc][i - 1]);           if (dp[cc][i] + i + 1 + (ans + 1) * e <= s) f = true;         } else if (i == 0) {           dp[cc][i] = fun(0, a[i]);           if (i != ans) dp[cc][i] = min(dp[cc][i], dp[cc][i - 1]);           if (dp[cc][i] + i + 1 + (ans + 1) * e <= s) f = true;         } else           dp[cc][i] = maxn;       }       if (f) ++ans;       cc = 1 - cc;     }     printf( %d , ans);     return 0;   }   