{"problem":{"name":"Patisserie ABC","description":{"content":"Takahashi became a pastry chef and opened a shop _La Confiserie d'ABC_ to celebrate AtCoder Beginner Contest 100. The shop sells $N$ kinds of cakes.   Each kind of cake has three parameters \"beauty\", ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc100_d"},"statements":[{"statement_type":"Markdown","content":"Takahashi became a pastry chef and opened a shop _La Confiserie d'ABC_ to celebrate AtCoder Beginner Contest 100.\nThe shop sells $N$ kinds of cakes.  \nEach kind of cake has three parameters \"beauty\", \"tastiness\" and \"popularity\". The $i$\\-th kind of cake has the beauty of $x_i$, the tastiness of $y_i$ and the popularity of $z_i$.  \nThese values may be zero or negative.\nRingo has decided to have $M$ pieces of cakes here. He will choose the set of cakes as follows:\n\n*   Do not have two or more pieces of the same kind of cake.\n*   Under the condition above, choose the set of cakes to maximize (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity).\n\nFind the maximum possible value of (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) for the set of cakes that Ringo chooses.\n\n## Constraints\n\n*   $N$ is an integer between $1$ and $1 \\ 000$ (inclusive).\n*   $M$ is an integer between $0$ and $N$ (inclusive).\n*   $x_i, y_i, z_i \\ (1 \\leq i \\leq N)$ are integers between $-10 \\ 000 \\ 000 \\ 000$ and $10 \\ 000 \\ 000 \\ 000$ (inclusive).\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $M$\n$x_1$ $y_1$ $z_1$\n$x_2$ $y_2$ $z_2$\n $:$  $:$\n$x_N$ $y_N$ $z_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc100_d","tags":[],"sample_group":[["5 3\n3 1 4\n1 5 9\n2 6 5\n3 5 8\n9 7 9","56\n\nConsider having the $2$\\-nd, $4$\\-th and $5$\\-th kinds of cakes. The total beauty, tastiness and popularity will be as follows:\n\n*   Beauty: $1 + 3 + 9 = 13$\n*   Tastiness: $5 + 5 + 7 = 17$\n*   Popularity: $9 + 8 + 9 = 26$\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is $13 + 17 + 26 = 56$. This is the maximum value."],["5 3\n1 -2 3\n-4 5 -6\n7 -8 -9\n-10 11 -12\n13 -14 15","54\n\nConsider having the $1$\\-st, $3$\\-rd and $5$\\-th kinds of cakes. The total beauty, tastiness and popularity will be as follows:\n\n*   Beauty: $1 + 7 + 13 = 21$\n*   Tastiness: $(-2) + (-8) + (-14) = -24$\n*   Popularity: $3 + (-9) + 15 = 9$\n\nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is $21 + 24 + 9 = 54$. This is the maximum value."],["10 5\n10 -80 21\n23 8 38\n-94 28 11\n-26 -2 18\n-69 72 79\n-26 -86 -54\n-72 -50 59\n21 65 -32\n40 -94 87\n-62 18 82","638\n\nIf we have the $3$\\-rd, $4$\\-th, $5$\\-th, $7$\\-th and $10$\\-th kinds of cakes, the total beauty, tastiness and popularity will be $-323$, $66$ and $249$, respectively.  \nThe value (the absolute value of the total beauty) + (the absolute value of the total tastiness) + (the absolute value of the total popularity) here is $323 + 66 + 249 = 638$. This is the maximum value."],["3 2\n2000000000 -9000000000 4000000000\n7000000000 -5000000000 3000000000\n6000000000 -1000000000 8000000000","30000000000\n\nThe values of the beauty, tastiness and popularity of the cakes and the value to be printed may not fit into 32-bit integers."]],"created_at":"2026-03-03 11:01:13"}}