#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*/ freopen(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, const char *argv[]) {
  freopen("paper.in", "r", stdin);
  freopen("paper.out", "w", stdout);
  int n, m, i, j, tmp, tot = 0;
  scanf("%i %i", &n, &m);
  for (i = 0; i < n; ++i) {
    for (j = 0; j < m; ++j) {
      scanf("%i", &tmp);
      if (tmp > 0)
        tot += tmp;
    }
  }
  printf("%i", tot);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e9b(%rip),%rax
mov    (%rax),%edx
lea    0xeaa(%rip),%rdi
lea    0xeac(%rip),%rsi
call   1040 <freopen@plt>
mov    0x2e6f(%rip),%rax
mov    (%rax),%edx
lea    0xe99(%rip),%rdi
lea    0xe9c(%rip),%rsi
call   1040 <freopen@plt>
movl   $0x0,-0x28(%rbp)
lea    0xe8b(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    120c <main+0xdc>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11f9 <main+0xc9>
lea    0xe52(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmpl   $0x0,-0x24(%rbp)
jle    11e6 <main+0xb6>
mov    -0x24(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    11eb <main+0xbb>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11b5 <main+0x85>
jmp    11fe <main+0xce>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a2 <main+0x72>
mov    -0x28(%rbp),%esi
lea    0xe04(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2ea3(%rip),%rax
mov    (%rax),%edx
lea    0xeb2(%rip),%rdi
lea    0xeb4(%rip),%rsi
call   1040 <freopen@plt>
mov    0x2e77(%rip),%rax
mov    (%rax),%edx
lea    0xea1(%rip),%rdi
lea    0xea4(%rip),%rsi
call   1040 <freopen@plt>
lea    0xe9a(%rip),%rdi
xor    %ebx,%ebx
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x10(%rsp),%eax
test   %eax,%eax
jle    11fa <main+0xca>
xor    %r13d,%r13d
mov    0xc(%rsp),%ecx
lea    0xe74(%rip),%r14
lea    0x14(%rsp),%r15
xor    %ebx,%ebx
xor    %r12d,%r12d
jmp    11c9 <main+0x99>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r12d
cmp    %eax,%r12d
jge    11fa <main+0xca>
test   %ecx,%ecx
jle    11c0 <main+0x90>
xor    %ebp,%ebp
nop
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x14(%rsp),%eax
test   %eax,%eax
cmovs  %r13d,%eax
add    %eax,%ebx
add    $0x1,%ebp
mov    0xc(%rsp),%ecx
cmp    %ecx,%ebp
jl     11d0 <main+0xa0>
mov    0x10(%rsp),%eax
jmp    11c0 <main+0x90>
lea    0xe19(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"paper.in\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [10 x i8] c"paper.out\00"
@.str.3 = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.4 = [6 x i8] c"%i %i\00"
@.str.5 = [3 x i8] c"%i\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* @stdin
%13 = call i32 @freopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = load i32, i32* @stdout
%15 = call i32 @freopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %14)
store i32 0, i32* %11
%16 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %6, i32* %7)
store i32 0, i32* %8
br label %17
17: ; preds = %39, %2
%18 = load i32, i32* %8
%19 = load i32, i32* %6
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %42
21: ; preds = %17
store i32 0, i32* %9
br label %22
22: ; preds = %35, %21
%23 = load i32, i32* %9
%24 = load i32, i32* %7
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %38
26: ; preds = %22
%27 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %10)
%28 = load i32, i32* %10
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %26
%31 = load i32, i32* %10
%32 = load i32, i32* %11
%33 = add nsw i32 %32, %31
store i32 %33, i32* %11
br label %34
34: ; preds = %30, %26
br label %35
35: ; preds = %34
%36 = load i32, i32* %9
%37 = add nsw i32 %36, 1
store i32 %37, i32* %9
br label %22
38: ; preds = %22
br label %39
39: ; preds = %38
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %17
42: ; preds = %17
%43 = load i32, i32* %11
%44 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %43)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"paper.in\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [10 x i8] c"paper.out\00"
@.str.3 = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.4 = [6 x i8] c"%i %i\00"
@.str.5 = [3 x i8] c"%i\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = load i32, i32* @stdin
%7 = tail call i32 @freopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = load i32, i32* @stdout
%9 = tail call i32 @freopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %8)
%10 = bitcast i32* %3 to i8*
%11 = bitcast i32* %4 to i8*
%12 = bitcast i32* %5 to i8*
%13 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %3, i32* %4)
%14 = load i32, i32* %3
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %43
16: ; preds = %2
%17 = load i32, i32* %4
br label %18
18: ; preds = %16, %37
%19 = phi i32 [ %38, %37 ], [ %14, %16 ]
%20 = phi i32 [ %39, %37 ], [ %17, %16 ]
%21 = phi i32 [ %40, %37 ], [ 0, %16 ]
%22 = phi i32 [ %41, %37 ], [ 0, %16 ]
%23 = icmp sgt i32 %20, 0
br i1 %23, label %24, label %37
24: ; preds = %18, %24
%25 = phi i32 [ %31, %24 ], [ %21, %18 ]
%26 = phi i32 [ %32, %24 ], [ 0, %18 ]
%27 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %5)
%28 = load i32, i32* %5
%29 = icmp sgt i32 %28, 0
%30 = select i1 %29, i32 %28, i32 0
%31 = add nsw i32 %30, %25
%32 = add nuw nsw i32 %26, 1
%33 = load i32, i32* %4
%34 = icmp slt i32 %32, %33
br i1 %34, label %24, label %35
35: ; preds = %24
%36 = load i32, i32* %3
br label %37
37: ; preds = %35, %18
%38 = phi i32 [ %19, %18 ], [ %36, %35 ]
%39 = phi i32 [ %20, %18 ], [ %33, %35 ]
%40 = phi i32 [ %21, %18 ], [ %31, %35 ]
%41 = add nuw nsw i32 %22, 1
%42 = icmp slt i32 %41, %38
br i1 %42, label %18, label %43
43: ; preds = %37, %2
%44 = phi i32 [ 0, %2 ], [ %40, %37 ]
%45 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %44)
ret i32 0
}