func_code_string: #include <bits/stdc++.h>   using namespace std;   const int md = 1000000007;   const int maxn = 30303;   const int maxk = 220;   const int maxn4 = 4 * maxn;   const long long inf = 2020202020202020202LL;   int n, k, a[maxn];   int ans[maxn][maxk], ansp[maxn][maxk], ansm[maxn][maxk], t1, t2, t3, t4, t5, t6;   int main() {     ios::ios_base::sync_with_stdio(false);     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> a[i + 1];     int mx = -md, mn = -md;     for (int i = 0; i < maxn; i++)       for (int j = 0; j < maxk; j++) {         ansp[i][j] = -md;         ansm[i][j] = -md;         ans[i][j] = -md;       }     for (int i = 1; i <= n; i++) {       mx = max(mx + a[i], a[i]);       ansp[i][1] = mx;       mn = max(mn - a[i], -a[i]);       ansm[i][1] = mn;     }     for (int w = 2; w <= k; w++) {       t1 = ansp[w - 1][w - 1];       t2 = ansm[w - 1][w - 1];       t3 = ansm[w - 1][w - 1];       t4 = ansp[w - 1][w - 1];       t5 = ansm[w - 1][w - 1];       t6 = ansp[w - 1][w - 1];       for (int i = w; i <= n; i++) {         ans[i][w] = max(t5 + a[i], t6 - a[i]);         ansp[i][w] = max(t1, t3 + 2 * a[i]);         ansm[i][w] = max(t2, t4 - 2 * a[i]);         t1 = max(t1, ansp[i][w - 1]);         t2 = max(t2, ansm[i][w - 1]);         t3 = max(t3 + 2 * a[i], ansm[i][w - 1]);         t4 = max(t4 - 2 * a[i], ansp[i][w - 1]);         t5 = max(t5 + a[i], ansm[i][w - 1]);         t6 = max(t6 - a[i], ansp[i][w - 1]);       }     }     int an = -md;     for (int i = 1; i <= n; i++) an = max(an, ans[i][k]);     cout << an;     return 0;   }   