func_code_string: #include <bits/stdc++.h>   using namespace std;   long long max(long long a, long long b) {     if (a > b) {       return a;     } else {       return b;     }   }   long long min(long long a, long long b) {     if (a < b) {       return a;     } else {       return b;     }   }   struct P {     double x, y;     P() {}     P(double x, double y) : x(x), y(y) {}     P operator+(const P &a) const { return P(x + a.x, y + a.y); }     P operator-(const P &a) const { return P(x - a.x, y - a.y); }     double operator^(const P &a) const { return x * a.x + y * a.y; }     void in() { scanf( %lf%lf , &x, &y); }     void out() { printf( REQUIRED %.7f %.7f n , x, y); }     double dist(P a, P b) {       return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));     }     double sqdist(P a, P b) {       return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);     }   };   int n, k;   int a[9999];   int b[9999];   int cc[9999];   int bb[9999];   long long res = -100000000;   long long ma[9999];   long long query(long long l, long long r) {     int length = r - l + 1;     if (length <= k) return ma[length];     int cnt = 0;     for (int i = (1); i <= (n); i++) {       if ((i < l) || (i > r)) cc[++cnt] = a[i];     }     int cnt2 = 0;     for (int i = (l); i <= (r); i++) bb[++cnt2] = a[i];     sort(cc + 1, cc + cnt + 1);     sort(bb + 1, bb + cnt2 + 1);     int go = 0;     for (int i = (1); i <= (min(min(cnt, cnt2), k)); i++) {       if (cc[cnt - i + 1] > bb[i]) go = i;     }     for (int i = (1); i <= (go); i++) bb[i] = cc[cnt - i + 1];     long long sum = 0;     for (int i = (1); i <= (cnt2); i++) sum += bb[i];     return sum;   }   int main() {     scanf( %d%d , &n, &k);     for (int i = (1); i <= (n); i++) scanf( %d , &a[i]);     for (int i = (1); i <= (n); i++) b[i] = a[i];     sort(b + 1, b + n + 1);     ma[0] = 0;     for (int i = (n); i >= (1); i--) {       ma[n - i + 1] = ma[n - i] + b[i];     }     for (int i = (1); i <= (n); i++) {       for (int j = (i); j <= (n); j++) {         res = max(res, query(i, j));       }     }     printf( %I64d n , res);     return 0;   }   