Problem: F: Substring decomposition

problem

Given the two strings S and T and the integer k. Considering consecutive substrings of length k or more of T, determine if S can be constructed by concatenating them.

Where the string s = s_1 s_2 ... s_n is a contiguous substring s [l, r] = s_l s_ {l + 1} ... s_r (1 \ leq l \ leq r \ leq n) , S refers to a character string created by cutting out the l-th to r-th characters of s, and its length is r --l + 1.

Input format


S
T
k


Constraint

* S and T consist of lowercase alphabets
* 1 \ leq | S |, | T | \ leq 2 \ times 10 ^ 5
* 1 \ leq k \ leq | T |



Output format

Print `Yes` when S can be configured, and` No` on one line otherwise.

Input example 1


abracadabra
cadabra
Four


Output example 1


Yes

You can construct `abracadabra` by concatenating` abra` and `cadabra`, which are substrings of T with a length of 4 or more, which is a string equal to S.

Input example 2


abcd
zcba
1


Output example 2


No

Input example 3


abc
zcba
1


Output example 3


Yes

Input example 4


abcdefg
abcddefg
Four


Output example 4


No





Example

Input

abracadabra
cadabra
4


Output

Yes

Solution (in CPP):

Solution:
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */
// 引用：https://ei1333.github.io/luzhiled/snippets/string/suffix-array.html

// quoted from beet-aizu
template <typename T, typename E, typename F, typename G>
struct SegmentTree{
    // using F = function<T(T, T)>
    // using G = function<T(T, E)>
    int n;
    F f;
    G g;
    T ti;
    vector<T> dat;
    SegmentTree(){};
    SegmentTree(F f,G g,T ti):f(f),g(g),ti(ti){}
    void init(int n_){    
        n=1;
        while(n<n_) n<<=1;
        dat.assign(n<<1,ti);
    }
    void build(const vector<T> &v){
        int n_=v.size();
        init(n_);
        for(int i=0;i<n_;i++) dat[n+i]=v[i];
        for(int i=n-1;i;i--)
            dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
    }
    void update(int k,const E &x){
        k += n;
        dat[k] = g(dat[k], x);
        while(k>>=1)
            dat[k]=f(dat[(k<<1)|0],dat[(k<<1)|1]);    
    }
    T operator [](int k) const { return dat[k+n]; }
    T query(int a,int b) const {
        T vl=ti,vr=ti;
        for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
            if(l&1) vl=f(vl,dat[l++]);
            if(r&1) vr=f(dat[--r],vr);
        }
        return f(vl,vr);
    }

    /* TODO わからない 聞く 
    template<typename C>
    int find(int a,int b,C &check,int k,int l,int r){
        if(!check(dat[k])||r<=a||b<=l) return -1;
        if(k>=n) return k-n;
        int m=(l+r)>>1;
        int vl=find(a,b,check,(k<<1)|0,l,m);
        if(~vl) return vl;
        return find(a,b,check,(k<<1)|1,m,r);
    }
    template<typename C>
    int find(int a,int b,C &check){
        return find(a,b,check,1,0,n);
    }*/
    
};


/**  テンプレ
int main(){
  using T = ***;  // type T
  using E = ***;  // type E
  auto f = [](T a, T b){ // return type T value
    return ***;
  };
  auto g = [](T a, E b){ // return type T value
    return ***;  // return b;
  };
  T ti = ***;  // identity element
  SegmentTree<T, E, decltype(f), decltype(g)> sg(f, g, ti);  // don't change
  sg.build(***);
}
**/

struct SuffixArray {
  vector< int > SA;
  const string s;

  SuffixArray(const string &str) : s(str) {
    SA.resize(s.size());
    iota(begin(SA), end(SA), 0);
    sort(begin(SA), end(SA), [&](int a, int b) {
      return s[a] == s[b] ? a > b : s[a] < s[b];
    });
    vector< int > classes(s.size()), c(s.begin(), s.end()), cnt(s.size());
    for(int len = 1; len < s.size(); len <<= 1) {
      for(int i = 0; i < s.size(); i++) {
        if(i > 0 && c[SA[i - 1]] == c[SA[i]] && SA[i - 1] + len < s.size() && c[SA[i - 1] + len / 2] == c[SA[i] + len / 2]) {
          classes[SA[i]] = classes[SA[i - 1]];
        } else {
          classes[SA[i]] = i;
        }
      }
      iota(begin(cnt), end(cnt), 0);
      copy(begin(SA), end(SA), begin(c));
      for(int i = 0; i < s.size(); i++) {
        int s1 = c[i] - len;
        if(s1 >= 0) SA[cnt[classes[s1]]++] = s1;
      }
      classes.swap(c);
    }
  }

  int operator[](int k) const {
    return SA[k];
  }

  size_t size() const {
    return s.size();
  }

  bool lt_substr(const string &t, int si = 0, int ti = 0) {
    int sn = (int) s.size(), tn = (int) t.size();
    while(si < sn && ti < tn) {
      if(s[si] < t[ti]) return true;
      if(s[si] > t[ti]) return false;
      ++si, ++ti;
    }
    return si >= sn && ti < tn;
  }

  int lower_bound(const string &t) {
    int low = -1, high = (int) SA.size();
    while(high - low > 1) {
      int mid = (low + high) / 2;
      if(lt_substr(t, SA[mid])) low = mid;
      else high = mid;
    }
    return high;
  }

  pair< int, int > lower_upper_bound(string &t) {
    int idx = lower_bound(t);
    int low = idx - 1, high = (int) SA.size();
    t.back()++;
    while(high - low > 1) {
      int mid = (low + high) / 2;
      if(lt_substr(t, SA[mid])) low = mid;
      else high = mid;
    }
    t.back()--;
    return {idx, high};
  }

  void output() {
    for(int i = 0; i < size(); i++) {
      cout << i << ": " << s.substr(SA[i]) << " " << SA[i] << endl;
    }
  }
};

struct LongestCommonPrefixArray {
  const SuffixArray &SA;
  vector< int > LCP, rank;

  LongestCommonPrefixArray(const SuffixArray &SA) : SA(SA), LCP(SA.size()) {
    rank.resize(SA.size());
    for(int i = 0; i < SA.size(); i++) {
      rank[SA[i]] = i;
    }
    for(int i = 0, h = 0; i < SA.size(); i++) {
      if(rank[i] + 1 < SA.size()) {
        for(int j = SA[rank[i] + 1]; max(i, j) + h < SA.size() && SA.s[i + h] == SA.s[j + h]; ++h);
        LCP[rank[i] + 1] = h;
        if(h > 0) --h;
      }
    }
  }

  int operator[](int k) const {
    return LCP[k];
  }

  size_t size() const {
    return LCP.size();
  }

  void output() {
    for(int i = 0; i < size(); i++) {
      cout << i << ": " << LCP[i] << " " << SA.s.substr(SA[i]) << " " << SA[i] << endl;
    }
  }

  void solve(int len_s, int len_t, int k) {
    // やること
    // 文字列長をみて，s か t かを判定
    // s に一番近い t を見つける（高々二つ）
    // それらの lcp を計算，max をとる（それより離れたところはダメ（単調性））
    // そのあと DP する
    
    int n = size();
    using T = int;  // type T
    using E = int;  // type E
    auto f = [](T a, T b){ // return type T value
      return min(a, b);
    };
    auto g = [](T a, E b){ // return type T value
      return b;  // return b;
    };
    T ti = inf;  // identity element
    SegmentTree<T, E, decltype(f), decltype(g)> sg(f, g, ti);  // don't change
    sg.build(LCP);

    // 自分より上の id
    vector<int> up(n, -1);
    int id = -1;
    for (int i = 0; i < n; i++) {
      int len = n - SA[i];
      if (len <= len_t) {
        id = i;
      } else if (len > len_t + 1) {
        up[i] = id;
      }
    }

    vector<int> down(n, -1);
    id = -1;
    for (int i = n - 1; i >= 0; i--) {
      int len = n - SA[i];
      if (len <= len_t) {
        id = i;
      } else if (len > len_t + 1) {
        down[i] = id;
      }
    }

    for (int i = 0; i < n; i++) {
      //cerr << up[i] << " " << down[i] << endl;
    }

    vector<int> maxLen(len_s, 0);
    for (int i = 0; i < n; i++) {
      int len = n - SA[i];
      if (len > len_t + 1) {
        lint maxLcp = 0;
        if (down[i] != -1) {
          lint tmp = sg.query(i + 1, down[i] + 1);
          maxLcp = max(tmp, maxLcp);
        }
        if (up[i] != -1) {
          lint tmp = sg.query(up[i] + 1, i + 1);
          maxLcp = max(tmp, maxLcp);
        }

        maxLen[SA[i]] = maxLcp;
      }
    }

    for (int i = 0; i < len_s; i++) {
      //cerr << i << ": " << maxLen[i] << endl;
    }
  
    vector<int> dp(len_s + 2, 0);
    dp[0] = 1;
    dp[1] = -1;
    for (int i = 0; i < len_s; i++) {
      if (i != 0) dp[i] += dp[i - 1];
      //cerr << "i : " << i << " dp[i] = " << dp[i] << endl; 
      if (dp[i] == 0) continue;
      lint maxLcp = maxLen[i];
      //cerr << "maxLcp = " << maxLcp << endl;
      if (maxLcp < k) continue;
      int l = i + k;
      int r = i + maxLcp + 1;
      if (l > len_s) continue;
      r = min(r, len_s + 1);

      //cerr << i << " " << l << " " << r << endl;
      dp[l]++;
      dp[r]--;
    }

    dp[len_s] += dp[len_s - 1];
    
    //for (int i = 0; i <= len_s; i++) {
      //cerr << dp[i] << " ";
    //}
    //cerr << endl;

    if (dp[len_s] >= 1) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
};

int main() {
  
  string s;
  string t;
  int k;
  cin >> s >> t >> k;

  string str = s + "#" + t;
  SuffixArray sa(str);
  LongestCommonPrefixArray lcp(sa);
  lcp.solve(s.size(), t.size(), k);

  return 0;
}