#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef scalar_t__ int64_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, scalar_t__);
int /*<<< orphan*/ scanf(char *, scalar_t__ *, scalar_t__ *, ...);
int main() {
  int64_t n, v;
  scanf("%ld %ld", &n, &v);
  int64_t best = -4294967296L;
  while (n--) {
    int64_t a, b, c, curr;
    scanf("%ld %ld %ld", &a, &b, &c);
    curr = a * b * c - v;
    if (curr > best)
      best = curr;
  }
  printf("%ld\n", best);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xece(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
movabs $0xffffffff00000000,%rax
ff ff ff
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     11b7 <main+0x97>
lea    0xe8d(%rip),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x38(%rbp),%rcx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x28(%rbp),%rax
imul   -0x30(%rbp),%rax
imul   -0x38(%rbp),%rax
sub    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
cmp    -0x20(%rbp),%rax
jle    11b2 <main+0x92>
mov    -0x40(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    1153 <main+0x33>
mov    -0x20(%rbp),%rsi
lea    0xe4a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
movabs $0xffffffff00000000,%rbx
ff ff ff
lea    0xec6(%rip),%rdi
lea    0x8(%rsp),%rsi
lea    0x28(%rsp),%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
subq   $0x1,0x8(%rsp)
jb     11a8 <main+0x88>
lea    0xea2(%rip),%r14
lea    0x20(%rsp),%r15
lea    0x18(%rsp),%r12
lea    0x10(%rsp),%r13
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x18(%rsp),%rax
imul   0x20(%rsp),%rax
imul   0x10(%rsp),%rax
sub    0x28(%rsp),%rax
cmp    %rbx,%rax
cmovg  %rax,%rbx
subq   $0x1,0x8(%rsp)
jae    1170 <main+0x50>
lea    0xe5d(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%ld %ld\00"
@.str.1 = [12 x i8] c"%ld %ld %ld\00"
@.str.2 = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %1
%9 = call i32 (i8*, i64*, i64*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64* %2, i64* %3)
store i64 -4294967296, i64* %4
br label %10
10: ; preds = %28, %0
%11 = load i64, i64* %2
%12 = add nsw i64 %11, -1
store i64 %12, i64* %2
%13 = icmp ne i64 %11, 0
br i1 %13, label %14, label %29
14: ; preds = %10
%15 = call i32 (i8*, i64*, i64*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64* %5, i64* %6, i64* %7)
%16 = load i64, i64* %5
%17 = load i64, i64* %6
%18 = mul nsw i64 %16, %17
%19 = load i64, i64* %7
%20 = mul nsw i64 %18, %19
%21 = load i64, i64* %3
%22 = sub nsw i64 %20, %21
store i64 %22, i64* %8
%23 = load i64, i64* %8
%24 = load i64, i64* %4
%25 = icmp sgt i64 %23, %24
br i1 %25, label %26, label %28
26: ; preds = %14
%27 = load i64, i64* %8
store i64 %27, i64* %4
br label %28
28: ; preds = %26, %14
br label %10
29: ; preds = %10
%30 = load i64, i64* %4
%31 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"%ld %ld\00"
@.str.1 = [12 x i8] c"%ld %ld %ld\00"
@.str.2 = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = bitcast i64* %1 to i8*
%7 = bitcast i64* %2 to i8*
%8 = call i32 (i8*, i64*, i64*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64* %1, i64* %2)
%9 = load i64, i64* %1
%10 = add nsw i64 %9, -1
store i64 %10, i64* %1
%11 = icmp eq i64 %9, 0
br i1 %11, label %31, label %12
12: ; preds = %0
%13 = bitcast i64* %3 to i8*
%14 = bitcast i64* %4 to i8*
%15 = bitcast i64* %5 to i8*
br label %16
16: ; preds = %12, %16
%17 = phi i64 [ -4294967296, %12 ], [ %27, %16 ]
%18 = call i32 (i8*, i64*, i64*, ...) @scanf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64* %3, i64* %4, i64* %5)
%19 = load i64, i64* %3
%20 = load i64, i64* %4
%21 = mul nsw i64 %20, %19
%22 = load i64, i64* %5
%23 = mul nsw i64 %21, %22
%24 = load i64, i64* %2
%25 = sub nsw i64 %23, %24
%26 = icmp sgt i64 %25, %17
%27 = select i1 %26, i64 %25, i64 %17
%28 = load i64, i64* %1
%29 = add nsw i64 %28, -1
store i64 %29, i64* %1
%30 = icmp eq i64 %28, 0
br i1 %30, label %31, label %16
31: ; preds = %16, %0
%32 = phi i64 [ -4294967296, %0 ], [ %27, %16 ]
%33 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %32)
ret i32 0
}