#include <bits/stdc++.h>   using namespace std;   inline int gi() {     int w = 0, q = 0;     char c = getchar();     while ((c <  0  || c >  9 ) && (c !=  - )) c = getchar();     if (c ==  - ) q = 1, c = getchar();     while (c >=  0  && c <=  9 ) w = w * 10 + c -  0 , c = getchar();     return q ? -w : w;   }   int n, k;   long long a[500000], d[500000];   int main() {     n = gi(), k = gi();     long long ans = 0, sum = 0;     for (int i = 1; i <= n; ++i) a[i] = gi();     for (int i = 1; i <= n; ++i) d[i] = gi();     for (int i = n; i; --i) {       sum += 1ll * a[i];       if ((i == 1) && (k == 1)) continue;       ans = max(ans, sum - d[i]);     }     if (!k) printf( %I64d n , ans), exit(0);     sum -= d[1];     for (int i = 2; i < n; ++i)       ans = max(ans, sum - a[i] + max(0ll, a[i] - d[i]));     long long mn = 5000000, mn1 = 5000000;     sum = 0;     for (int i = 1; i < n; ++i) {       sum += 1ll * a[i];       if (d[i] < mn)         mn1 = mn, mn = d[i];       else if (d[i] == mn)         mn1 = d[i];       else         mn1 = min(mn1, d[i]);     }     ans = max(ans, sum + 1ll * (max(0ll, a[n] - d[n]) - mn));     if (k == 1)       ans = max(ans, sum + 1ll * (a[n] - mn - mn1));     else       ans = max(ans, sum + 1ll * (a[n] - mn));     printf( %I64d n , ans);     return 0;   }   