#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 *);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int h, w, n;
  scanf("%d %d %d", &h, &w, &n);
  int status = 0;
  int next, current_row = w;
  while (n-- > 0) {
    scanf("%d", &next);
    if (!status) {
      if (next > current_row)
        status = -1;
      else {
        current_row -= next;
        if (current_row == 0) {
          current_row = w;
          h--;
        }
        if (h == 0)
          status = 1;
      }
    }
  }
  if (status == -1)
    printf("NO\n");
  else
    printf("YES\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x10(%rbp)
cmp    $0x0,%eax
jle    11e2 <main+0xc2>
lea    0xe95(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x0,-0x14(%rbp)
jne    11dd <main+0xbd>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jle    119e <main+0x7e>
movl   $0xffffffff,-0x14(%rbp)
jmp    11d8 <main+0xb8>
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    11c2 <main+0xa2>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11d3 <main+0xb3>
movl   $0x1,-0x14(%rbp)
jmp    11d8 <main+0xb8>
jmp    11dd <main+0xbd>
jmp    1156 <main+0x36>
cmpl   $0xffffffff,-0x14(%rbp)
jne    11fd <main+0xdd>
lea    0xe16(%rip),%rdi
call   1030 <printf@plt>
jmp    1209 <main+0xe9>
lea    0xe09(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xecf(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%ebp
mov    0x8(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x8(%rsp)
test   %eax,%eax
jle    11c5 <main+0xa5>
lea    0xea5(%rip),%r14
lea    0x14(%rsp),%r15
xor    %ebx,%ebx
jmp    118f <main+0x6f>
mov    0xc(%rsp),%ecx
xor    %ebx,%ebx
test   %ecx,%ecx
sete   %bl
mov    %eax,%ebp
nopw   0x0(%rax,%rax,1)
mov    0x8(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x8(%rsp)
test   %eax,%eax
jle    11c0 <main+0xa0>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
test   %ebx,%ebx
jne    1180 <main+0x60>
mov    $0xffffffff,%ebx
mov    %ebp,%eax
sub    0x14(%rsp),%eax
jl     1180 <main+0x60>
jne    116a <main+0x4a>
mov    0x10(%rsp),%eax
mov    0xc(%rsp),%ecx
add    $0xffffffff,%ecx
mov    %ecx,0xc(%rsp)
jmp    116e <main+0x4e>
cmp    $0xffffffff,%ebx
je     11ce <main+0xae>
lea    0xe3d(%rip),%rdi
jmp    11d5 <main+0xb5>
lea    0xe38(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [9 x i8] c"%d %d %d\00"
@.str.1 = [3 x i8] c"%d\00"
@str = [4 x i8] c"YES\00"
@str.4 = [3 x i8] c"NO\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%9 = bitcast i32* %4 to i8*
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = add nsw i32 %11, -1
store i32 %12, i32* %3
%13 = icmp sgt i32 %11, 0
br i1 %13, label %14, label %44
14: ; preds = %0, %36
%15 = phi i32 [ %38, %36 ], [ %10, %0 ]
%16 = phi i32 [ %37, %36 ], [ 0, %0 ]
%17 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%18 = icmp eq i32 %16, 0
br i1 %18, label %19, label %36
19: ; preds = %14
%20 = load i32, i32* %4
%21 = icmp slt i32 %15, %20
br i1 %21, label %36, label %22
22: ; preds = %19
%23 = sub nsw i32 %15, %20
%24 = icmp eq i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = load i32, i32* %1
br label %31
27: ; preds = %22
%28 = load i32, i32* %2
%29 = load i32, i32* %1
%30 = add nsw i32 %29, -1
store i32 %30, i32* %1
br label %31
31: ; preds = %25, %27
%32 = phi i32 [ %30, %27 ], [ %26, %25 ]
%33 = phi i32 [ %28, %27 ], [ %23, %25 ]
%34 = icmp eq i32 %32, 0
%35 = zext i1 %34 to i32
br label %36
36: ; preds = %31, %19, %14
%37 = phi i32 [ %16, %14 ], [ -1, %19 ], [ %35, %31 ]
%38 = phi i32 [ %15, %14 ], [ %15, %19 ], [ %33, %31 ]
%39 = load i32, i32* %3
%40 = add nsw i32 %39, -1
store i32 %40, i32* %3
%41 = icmp sgt i32 %39, 0
br i1 %41, label %14, label %42
42: ; preds = %36
%43 = icmp eq i32 %37, -1
br i1 %43, label %45, label %44
44: ; preds = %0, %42
br label %45
45: ; preds = %42, %44
%46 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0), %44 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @str.4, i64 0, i64 0), %42 ]
%47 = call i32 @puts(i8* dereferenceable(1) %46)
ret i32 0
}