#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, char const *argv[]) {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  int N, tmp_sum, max_sum = -1, a, b;
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%d %d", &a, &b);
    tmp_sum = a + b;
    if (max_sum < tmp_sum && tmp_sum % 2 == 0) {
      max_sum = tmp_sum;
    }
  }
  printf("%d\n", max_sum);
  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    0xead(%rip),%rsi
call   1040 <freopen@plt>
mov    0x2e6f(%rip),%rax
mov    (%rax),%edx
lea    0xe9a(%rip),%rdi
lea    0xe9e(%rip),%rsi
call   1040 <freopen@plt>
movl   $0xffffffff,-0x1c(%rbp)
lea    0xe90(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1202 <main+0xd2>
lea    0xe68(%rip),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x20(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11ef <main+0xbf>
mov    -0x18(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11ef <main+0xbf>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11f4 <main+0xc4>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    119e <main+0x6e>
mov    -0x1c(%rbp),%esi
lea    0xe13(%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    0xeb5(%rip),%rsi
call   1040 <freopen@plt>
mov    0x2e77(%rip),%rax
mov    (%rax),%edx
lea    0xea2(%rip),%rdi
lea    0xea6(%rip),%rsi
call   1040 <freopen@plt>
lea    0xe9f(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    11e2 <main+0xb2>
mov    $0xffffffff,%r13d
lea    0xe7c(%rip),%r14
lea    0x14(%rsp),%r15
lea    0x10(%rsp),%r12
xor    %ebp,%ebp
mov    %r13d,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x10(%rsp),%eax
add    0x14(%rsp),%eax
test   $0x1,%al
cmove  %eax,%ebx
cmp    %eax,%r13d
cmovge %r13d,%ebx
add    $0x1,%ebp
mov    %ebx,%r13d
cmp    0xc(%rsp),%ebp
jl     11b0 <main+0x80>
jmp    11e7 <main+0xb7>
mov    $0xffffffff,%ebx
lea    0xe31(%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 = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [11 x i8] c"output.txt\00"
@.str.3 = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [6 x i8] c"%d %d\00"
@.str.6 = [4 x i8] c"%d\0A\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 ([10 x i8], [10 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 ([11 x i8], [11 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 -1, i32* %8
%16 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %6)
store i32 0, i32* %11
br label %17
17: ; preds = %36, %2
%18 = load i32, i32* %11
%19 = load i32, i32* %6
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %39
21: ; preds = %17
%22 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %9, i32* %10)
%23 = load i32, i32* %9
%24 = load i32, i32* %10
%25 = add nsw i32 %23, %24
store i32 %25, i32* %7
%26 = load i32, i32* %8
%27 = load i32, i32* %7
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %35
29: ; preds = %21
%30 = load i32, i32* %7
%31 = srem i32 %30, 2
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = load i32, i32* %7
store i32 %34, i32* %8
br label %35
35: ; preds = %33, %29, %21
br label %36
36: ; preds = %35
%37 = load i32, i32* %11
%38 = add nsw i32 %37, 1
store i32 %38, i32* %11
br label %17
39: ; preds = %17
%40 = load i32, i32* %8
%41 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [11 x i8] c"output.txt\00"
@.str.3 = [2 x i8] c"w\00"
@stdout = global i32 0
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [6 x i8] c"%d %d\00"
@.str.6 = [4 x i8] c"%d\0A\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 ([10 x i8], [10 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 ([11 x i8], [11 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 ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %3
%15 = icmp sgt i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %19, %2
%17 = phi i32 [ -1, %2 ], [ %30, %19 ]
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %17)
ret i32 0
19: ; preds = %2, %19
%20 = phi i32 [ %31, %19 ], [ 0, %2 ]
%21 = phi i32 [ %30, %19 ], [ -1, %2 ]
%22 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32* %4, i32* %5)
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = add nsw i32 %24, %23
%26 = icmp slt i32 %21, %25
%27 = and i32 %25, 1
%28 = icmp eq i32 %27, 0
%29 = and i1 %26, %28
%30 = select i1 %29, i32 %25, i32 %21
%31 = add nuw nsw i32 %20, 1
%32 = load i32, i32* %3
%33 = icmp slt i32 %31, %32
br i1 %33, label %19, label %16
}