func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 2005;   const int maxz = 16005;   int l[maxn], r[maxn], n, l1, l2;   int dp[maxn][maxz], q[maxz];   bool lt[maxn][maxz];   char s[maxn];   struct ac_machine {     int ch[maxz][10], cnt;     int fail[maxz];     int tp[maxz][maxn];     void init() {       int x = 0, y = 0;       if (l1 == l2) {         for (int i = 1; i <= l1; ++i) {           if (x == y) {             for (int j = l[i] + 1; j < r[i]; ++j) {               if (!ch[x][j]) ch[x][j] = ++cnt;               tp[ch[x][j]][l1 - i]++;             }           } else {             for (int j = l[i] + 1; j <= 9; ++j) {               if (!ch[x][j]) ch[x][j] = ++cnt;               tp[ch[x][j]][l1 - i]++;             }             for (int j = (i == 1); j < r[i]; ++j) {               if (!ch[y][j]) ch[y][j] = ++cnt;               tp[ch[y][j]][l2 - i]++;             }           }           if (!ch[x][l[i]]) ch[x][l[i]] = ++cnt;           x = ch[x][l[i]];           if (!ch[y][r[i]]) ch[y][r[i]] = ++cnt;           y = ch[y][r[i]];         }         tp[x][0]++;         if (x != y) tp[y][0]++;       } else {         for (int i = 1; i <= l1; ++i) {           for (int j = l[i] + 1; j <= 9; ++j) {             if (!ch[x][j]) ch[x][j] = ++cnt;             tp[ch[x][j]][l1 - i]++;           }           if (!ch[x][l[i]]) ch[x][l[i]] = ++cnt;           x = ch[x][l[i]];         }         for (int i = 1; i <= l2; ++i) {           for (int j = (i == 1); j < r[i]; ++j) {             if (!ch[y][j]) ch[y][j] = ++cnt;             tp[ch[y][j]][l2 - i]++;           }           if (!ch[y][r[i]]) ch[y][r[i]] = ++cnt;           y = ch[y][r[i]];         }         for (int i = l1 + 1; i < l2; ++i)           for (int j = 1; j <= 9; ++j) {             if (!ch[0][j]) ch[0][j] = ++cnt;             tp[ch[0][j]][i - 1]++;           }         tp[x][0]++;         tp[y][0]++;       }     }     void build() {       int h = 1, t = 0;       for (int i = 0; i <= 9; ++i)         if (ch[0][i]) q[++t] = ch[0][i];       int x;       while (h <= t) {         x = q[h++];         for (int i = 0; i <= 9; ++i)           if (!ch[x][i])             ch[x][i] = ch[fail[x]][i];           else             fail[ch[x][i]] = ch[fail[x]][i], q[++t] = ch[x][i];       }       for (int i = 1; i <= t; ++i) {         x = q[i];         for (int j = 0; j <= n; ++j) tp[x][j] += tp[fail[x]][j];       }       for (int i = 1; i <= cnt; ++i)         for (int j = 1; j <= n; ++j) tp[i][j] += tp[i][j - 1];     }   } t;   int main() {     t.cnt = 0;     scanf( %s , s + 1);     l1 = strlen(s + 1);     for (int i = 1; i <= l1; i++) l[i] = s[i] -  0 ;     scanf( %s , s + 1);     l2 = strlen(s + 1);     for (int i = 1; i <= l2; i++) r[i] = s[i] -  0 ;     scanf( %d , &n);     memset(dp, -1, sizeof(dp));     dp[0][0] = 0;     t.init();     t.build();     for (int i = 0; i < n; ++i)       for (int j = 0; j <= t.cnt; ++j) {         if (dp[i][j] == -1) continue;         for (int k = 0; k <= 9; ++k) {           int x = t.ch[j][k];           dp[i + 1][x] = max(dp[i + 1][x], dp[i][j] + t.tp[x][n - i - 1]);         }       }     int ans = 0;     for (int i = 0; i <= t.cnt; ++i) ans = max(ans, dp[n][i]);     printf( %d n , ans);     for (int i = 0; i <= t.cnt; ++i)       if (dp[n][i] == ans) lt[n][i] = 1;     for (int i = n - 1; i >= 0; --i) {       for (int j = 0; j <= t.cnt; ++j) {         if (dp[i][j] == -1) continue;         for (int k = 0; k <= 9; ++k) {           int x = t.ch[j][k];           lt[i][j] |=               lt[i + 1][x] && (dp[i + 1][x] == dp[i][j] + t.tp[x][n - i - 1]);         }       }     }     int x = 0;     for (int i = 0; i < n; ++i) {       for (int j = 0; j <= 9; ++j) {         int y = t.ch[x][j];         if (lt[i + 1][y] && (dp[i + 1][y] == dp[i][x] + t.tp[y][n - i - 1])) {           putchar(j +  0 );           x = y;           break;         }       }     }     return 0;   }   