Language: C

#include <stdio.h>
#include <limits.h>

typedef long long ll;

struct t {
	ll a;
	ll b;
	ll c;
};

ll abs(ll a) {
	return a > 0 ? a : -a;
}

ll sum(struct t a) {
	return a.a + a.b + a.c;
}

struct t max(struct t a, struct t b) {
	ll x = sum(a);
	ll y = sum(b);

	return x > y ? a : b;
}

struct t sum(struct t a, struct t b) {
	t result;

	result.a = a.a + b.a;
	result.b = a.b + b.b;
	result.c = a.c + b.c;

	return result;
}

struct t f[1000][1000], arr[1010];

void clear(struct t f[][1000]) {
	int i, j;

	for (i = 0; i < 1000; i++) {
		for (j = 0; j < 1000; j++) {
			f[i][j] = {0,0,0};
		}
	}
}
int main() {
	int n, m;
	int i, j;

	scanf("%d%d", &n, &m);

	for (i = 1; i <= n; i++) {
		scanf("%lld%lld%lld", &arr[i].a, &arr[i].b, &arr[i].c);
	}

	//t d = {0,0,0};
	//for (i = 0; i <= m; i++) {
	//	f[0][i] = d;
	//}

	int a, b, c;
	ll result = 0;

	for (a = -1; a < 2; a++)
		for (b = -1; b < 2; b++)
			for (c = -1; c < 2; c++) {
				
				if (a&&b&&c) {
					clear(f);
					for (i = 1; i <= n; i++) {
						for (j = 1; j <= i; j++) {
							if (j > m) break;
							struct t k = { arr[i].a*a,arr[i].b*b,arr[i].c*c };
							struct t d = sum(f[i - 1][j - 1], k);
							f[i][j] = max(f[i - 1][j], d);
						}
					}

					result = sum(f[n][m]) > result ? sum(f[n][m]) : result;
				}
			}

	printf("%lld", result);

	getchar(); getchar();
	return 0;
}

Compiler output:
main.c:12:4: warning: conflicting types for built-in function 'abs'; expected 'int(int)' [-Wbuiltin-declaration-mismatch]
   12 | ll abs(ll a) {
      |    ^~~
main.c:3:1: note: 'abs' is declared in header '<stdlib.h>'
    2 | #include <limits.h>
  +++ |+#include <stdlib.h>
    3 | 
main.c:27:10: error: conflicting types for 'sum'; have 'struct t(struct t,  struct t)'
   27 | struct t sum(struct t a, struct t b) {
      |          ^~~
main.c:16:4: note: previous definition of 'sum' with type 'll(struct t)' {aka 'long long int(struct t)'}
   16 | ll sum(struct t a) {
      |    ^~~
main.c: In function 'sum':
main.c:28:9: error: unknown type name 't'; use 'struct' keyword to refer to the type
   28 |         t result;
      |         ^
      |         struct 
main.c:30:15: error: request for member 'a' in something not a structure or union
   30 |         result.a = a.a + b.a;
      |               ^
main.c:31:15: error: request for member 'b' in something not a structure or union
   31 |         result.b = a.b + b.b;
      |               ^
main.c:32:15: error: request for member 'c' in something not a structure or union
   32 |         result.c = a.c + b.c;
      |               ^
main.c:34:16: error: incompatible types when returning type 'int' but 'struct t' was expected
   34 |         return result;
      |                ^~~~~~
main.c: In function 'clear':
main.c:44:35: error: expected expression before '{' token
   44 |                         f[i][j] = {0,0,0};
      |                                   ^
main.c: In function 'main':
main.c:81:50: error: too few arguments to function 'sum'
   81 |                                         result = sum(f[n][m]) > result ? sum(f[n][m]) : result;
      |                                                  ^~~
main.c:27:10: note: declared here
   27 | struct t sum(struct t a, struct t b) {
      |          ^~~
main.c:81:74: error: too few arguments to function 'sum'
   81 |                                         result = sum(f[n][m]) > result ? sum(f[n][m]) : result;
      |                                                                          ^~~
main.c:27:10: note: declared here
   27 | struct t sum(struct t a, struct t b) {
      |          ^~~