#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 atoi(char *);
scalar_t__ existEqualTwoPartition(int *, int);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
char *strtok(char *, char *);
int main(void) {
  int T, weightArr[30], numLuggage;
  char line[2000 + 1], trash[2000 + 1], delim[] = " ", *ptrNumStr;
  scanf("%d", &T);
  gets(trash);
  while (T) {
    numLuggage = 0;
    gets(line);
    ptrNumStr = strtok(line, delim);
    do {
      if (ptrNumStr != NULL) {
        weightArr[numLuggage] = atoi(ptrNumStr);
        numLuggage++;
      }
      ptrNumStr = strtok(NULL, delim);
    } while (ptrNumStr != NULL);
    if (existEqualTwoPartition(weightArr, numLuggage))
      printf("YES\n");
    else
      printf("NO\n");
    T--;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1050,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe87(%rip),%ax
mov    %ax,-0x1042(%rbp)
lea    0xe7b(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0x1040(%rbp),%rdi
call   1050 <gets@plt>
cmpl   $0x0,-0x8(%rbp)
je     1275 <main+0x115>
movl   $0x0,-0x84(%rbp)
lea    -0x860(%rbp),%rdi
call   1050 <gets@plt>
lea    -0x860(%rbp),%rdi
lea    -0x1042(%rbp),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x1050(%rbp)
cmpq   $0x0,-0x1050(%rbp)
je     120c <main+0xac>
mov    -0x1050(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,%ecx
movslq -0x84(%rbp),%rax
mov    %ecx,-0x80(%rbp,%rax,4)
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
lea    -0x1042(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1070 <strtok@plt>
mov    %rax,-0x1050(%rbp)
cmpq   $0x0,-0x1050(%rbp)
jne    11d6 <main+0x76>
lea    -0x80(%rbp),%rdi
mov    -0x84(%rbp),%esi
call   1030 <existEqualTwoPartition@plt>
cmp    $0x0,%rax
je     125b <main+0xfb>
lea    0xdb4(%rip),%rdi
call   1040 <printf@plt>
jmp    1267 <main+0x107>
lea    0xda8(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    119c <main+0x3c>
xor    %eax,%eax
add    $0x1050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1048,%rsp
movw   $0x20,0xa(%rsp)
lea    0xe81(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
lea    0x90(%rsp),%rdi
call   1050 <gets@plt>
cmpl   $0x0,0xc(%rsp)
je     1238 <main+0xd8>
lea    0x870(%rsp),%r14
lea    0xa(%rsp),%r12
lea    0x10(%rsp),%r15
lea    0xe49(%rip),%r13
lea    0xe45(%rip),%rbp
jmp    11f0 <main+0x90>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
mov    %ebx,%esi
call   1030 <existEqualTwoPartition@plt>
test   %rax,%rax
mov    %rbp,%rdi
cmove  %r13,%rdi
call   1040 <puts@plt>
addl   $0xffffffff,0xc(%rsp)
je     1238 <main+0xd8>
mov    %r14,%rdi
call   1050 <gets@plt>
mov    %r14,%rdi
mov    %r12,%rsi
call   1070 <strtok@plt>
xor    %ebx,%ebx
jmp    121f <main+0xbf>
nopw   0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %r12,%rsi
call   1070 <strtok@plt>
test   %rax,%rax
je     11d0 <main+0x70>
test   %rax,%rax
je     1210 <main+0xb0>
mov    %rax,%rdi
call   1080 <atoi@plt>
movslq %ebx,%rbx
mov    %eax,0x10(%rsp,%rbx,4)
add    $0x1,%ebx
jmp    1210 <main+0xb0>
xor    %eax,%eax
add    $0x1048,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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