#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, long long);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int n, m;
  long long int count = 0;
  scanf("%d%d", &n, &m);
  while (m--) {
    long long int a, b, k;
    scanf("%lld%lld%lld", &a, &b, &k);
    count = count + (b - a + 1) * k;
  }
  printf("%lld", (count / n));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xec2(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     119c <main+0x7c>
lea    0xe9d(%rip),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x30(%rbp),%rcx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    -0x20(%rbp),%rcx
add    $0x1,%rcx
imul   -0x30(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
jmp    114d <main+0x2d>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
cqto
idiv   %rcx
mov    %rax,%rsi
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xecc(%rip),%rdi
xor    %ebx,%ebx
lea    0x4(%rsp),%rsi
mov    %rsp,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,(%rsp)
jb     11a0 <main+0x80>
lea    0xeb3(%rip),%r14
lea    0x18(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0x8(%rsp),%r13
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%rax
sub    0x18(%rsp),%rax
add    $0x1,%rax
imul   0x8(%rsp),%rax
add    %rax,%rbx
subl   $0x1,(%rsp)
jae    1170 <main+0x50>
movslq 0x4(%rsp),%rcx
mov    %rbx,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     11bb <main+0x9b>
mov    %rbx,%rax
cqto
idiv   %rcx
jmp    11c1 <main+0xa1>
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
lea    0xe45(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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