Language: C

#define T 999
D[T][T], i, j, x, y, a, b, c, r = 9999;
main(k) {
  for (i = -1; ++i < T;)
    for (j = -1; ++j < T;)
      D[i][j] = r;
  scanf("%*d%d%d", &x, &y);
  for (D[0][0] = 0; ~scanf("%d%d%d", &a, &b, &c);)
    for (i = T; i-- > a;)
      for (j = T; j-- > b;)
        k = D[i - a][j - b] + c, D[i][j] > k ? D[i][j] = k : 0;
  for (i = x, j = y; i += x < T &&j += y < T;)
    D[i][j] < r ? r = D[i][j] : 0;
  printf("%d\n", r < 9999 ? r : -1);
}


Compiler output:
main.c:2:1: warning: data definition has no type or storage class
    2 | D[T][T], i, j, x, y, a, b, c, r = 9999;
      | ^
main.c:2:1: error: type defaults to 'int' in declaration of 'D' [-Wimplicit-int]
main.c:2:10: error: type defaults to 'int' in declaration of 'i' [-Wimplicit-int]
    2 | D[T][T], i, j, x, y, a, b, c, r = 9999;
      |          ^
main.c:2:13: error: type defaults to 'int' in declaration of 'j' [-Wimplicit-int]
    2 | D[T][T], i, j, x, y, a, b, c, r = 9999;
      |             ^
main.c:2:16: error: type defaults to 'int' in declaration of 'x' [-Wimplicit-int]
    2 | D[T][T], i, j, x, y, a, b, c, r = 9999;
      |                ^
main.c:2:19: error: type defaults to 'int' in declaration of 'y' [-Wimplicit-int]
    2 | D[T][T], i, j, x, y, a, b, c, r = 9999;
      |                   ^
main.c:2:22: error: type defaults to 'int' in declaration of 'a' [-Wimplicit-int]
    2 | D[T][T], i, j, x, y, a, b, c, r = 9999;
      |                      ^
main.c:2:25: error: type defaults to 'int' in declaration of 'b' [-Wimplicit-int]
    2 | D[T][T], i, j, x, y, a, b, c, r = 9999;
      |                         ^
main.c:2:28: error: type defaults to 'int' in declaration of 'c' [-Wimplicit-int]
    2 | D[T][T], i, j, x, y, a, b, c, r = 9999;
      |                            ^
main.c:2:31: error: type defaults to 'int' in declaration of 'r' [-Wimplicit-int]
    2 | D[T][T], i, j, x, y, a, b, c, r = 9999;
      |                               ^
main.c:3:1: error: return type defaults to 'int' [-Wimplicit-int]
    3 | main(k) {
      | ^~~~
main.c: In function 'main':
main.c:3:1: error: type of 'k' defaults to 'int' [-Wimplicit-int]
main.c:7:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    7 |   scanf("%*d%d%d", &x, &y);
      |   ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | #define T 999
main.c:7:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    7 |   scanf("%*d%d%d", &x, &y);
      |   ^~~~~
main.c:7:3: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:12:37: error: lvalue required as left operand of assignment
   12 |   for (i = x, j = y; i += x < T &&j += y < T;)
      |                                     ^~
main.c:14:3: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   14 |   printf("%d\n", r < 9999 ? r : -1);
      |   ^~~~~~
main.c:14:3: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:14:3: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:14:3: note: include '<stdio.h>' or provide a declaration of 'printf'