func_code_string: #include <bits/stdc++.h>   using namespace std;   void Read(int &n) {     int sign = 1;     n = 0;     char c;     do {       c = getchar();     } while (!isdigit(c) && c !=  - );     if (c ==  - ) {       c = getchar();       sign = -1;     }     do {       n = n * 10 + c - 48;       c = getchar();     } while (isdigit(c));     n *= sign;   }   void Read(long long &n) {     int sign = 1;     n = 0;     char c;     do {       c = getchar();     } while (!isdigit(c) && c !=  - );     if (c ==  - ) {       c = getchar();       sign = -1;     }     do {       n = n * 10ll + c - 48;       c = getchar();     } while (isdigit(c));     n *= sign;   }   void Write(int n) {     if (n == 0) {       putchar( 0 );       return;     } else if (n < 0)       putchar( - ), n = -n;     char C[30];     int d = 0;     while (n) {       C[++d] = (n % 10) + 48;       n /= 10;     }     for (int i = d; i >= 1; --i) putchar(C[i]);   }   void Write(long long n) {     if (n == 0) {       putchar( 0 );       return;     } else if (n < 0)       putchar( - ), n = -n;     char C[30];     int d = 0;     while (n) {       C[++d] = (n % 10ll) + 48;       n /= 10ll;     }     for (int i = d; i >= 1; --i) putchar(C[i]);   }   const int maxn = 1e4 + 5;   const long long INFL = 0x3f3f3f3f3f3f3f3f;   int n, c;   long long f[maxn], g[maxn];   int p[maxn], s[maxn];   int main() {     scanf( %d%d , &n, &c);     for (int i = 0; i < n; ++i) scanf( %d , &p[i]);     for (int i = 0; i < n; ++i) scanf( %d , &s[i]);     memset(f, INFL, sizeof f);     f[0] = 0;     for (int i = 0; i < n; ++i) {       for (int j = 0; j <= i; ++j) g[j] = f[j], f[j] = INFL;       for (int j = 0; j <= i; ++j) {         f[j + 1] = min(g[j] + s[i], f[j + 1]);         f[j] = min(f[j], g[j] + p[i] + (long long)j * c);       }     }     long long ans = INFL;     for (int i = 0; i <= n; ++i) ans = min(ans, f[i]);     printf( %I64d , ans);     return 0;   }   