#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 *, char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int strlen(char *);
int main() {
  int num = 0;
  char str[1000000];
  int index = 0;
  int sec_index = 0;
  int length = 0;
  int ok = 1;
  scanf("%d", &num);
  for (;;) {
    ok = 1;
    sprintf(str, "%X", num);
    length = strlen(str);
    for (index = 0, sec_index = length - 1; index < length / 2;
         index++, sec_index--) {
      if (str[index] != str[sec_index]) {
        ok = 0;
        break;
      }
    }
    if (ok == 1) {
      break;
    } else {
      num++;
    }
  }
  printf("%s", str);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf4270,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xf4254(%rbp)
movl   $0x0,-0xf4258(%rbp)
movl   $0x0,-0xf425c(%rbp)
movl   $0x1,-0xf4260(%rbp)
lea    0xe78(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x1,-0xf4260(%rbp)
lea    -0xf4250(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe57(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0xf4250(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xf425c(%rbp)
movl   $0x0,-0xf4254(%rbp)
mov    -0xf425c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0xf4258(%rbp)
mov    -0xf4254(%rbp),%eax
mov    %eax,-0xf4264(%rbp)
mov    -0xf425c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0xf4264(%rbp),%eax
cmp    %ecx,%eax
jge    1263 <main+0x123>
movslq -0xf4254(%rbp),%rax
movsbl -0xf4250(%rbp,%rax,1),%eax
ff
movslq -0xf4258(%rbp),%rcx
movsbl -0xf4250(%rbp,%rcx,1),%ecx
ff
cmp    %ecx,%eax
je     123b <main+0xfb>
movl   $0x0,-0xf4260(%rbp)
jmp    1263 <main+0x123>
jmp    1240 <main+0x100>
mov    -0xf4254(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4254(%rbp)
mov    -0xf4258(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xf4258(%rbp)
jmp    11dc <main+0x9c>
cmpl   $0x1,-0xf4260(%rbp)
jne    1275 <main+0x135>
jmp    1283 <main+0x143>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1191 <main+0x51>
lea    -0xf4250(%rbp),%rsi
lea    0xd75(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xf4270,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0xf4258,%rsp
movl   $0x0,0xc(%rsp)
lea    0xea3(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edx
lea    0xe91(%rip),%rsi
lea    0x10(%rsp),%r12
mov    %r12,%rdi
call   1060 <sprintf@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jl     11f3 <main+0xb3>
lea    0xf(%rsp),%r15
lea    0xe6b(%rip),%r14
mov    %eax,%ecx
shr    %eax
add    %r15,%rcx
neg    %rax
xor    %edx,%edx
mov    %r12,%rsi
nopw   0x0(%rax,%rax,1)
movzbl (%rsi),%ebx
cmp    (%rcx,%rdx,1),%bl
jne    11d0 <main+0x90>
add    $0x1,%rsi
add    $0xffffffffffffffff,%rdx
cmp    %rdx,%rax
jne    11b0 <main+0x70>
jmp    11f3 <main+0xb3>
nopw   0x0(%rax,%rax,1)
mov    0xc(%rsp),%edx
add    $0x1,%edx
mov    %edx,0xc(%rsp)
mov    %r12,%rdi
mov    %r14,%rsi
call   1060 <sprintf@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jg     1198 <main+0x58>
lea    0xe0c(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xf4258,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%X\00"
@.str.2 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000000 x i8]
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %2, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = call i32 @strlen(i8* %4)
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %33
10: ; preds = %0, %27
%11 = phi i32 [ %31, %27 ], [ %8, %0 ]
%12 = lshr i32 %11, 1
%13 = zext i32 %11 to i64
%14 = zext i32 %12 to i64
br label %17
15: ; preds = %17
%16 = icmp eq i64 %26, %14
br i1 %16, label %33, label %17
17: ; preds = %10, %15
%18 = phi i64 [ 0, %10 ], [ %26, %15 ]
%19 = phi i64 [ %13, %10 ], [ %20, %15 ]
%20 = add nsw i64 %19, -1
%21 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %2, i64 0, i64 %18
%22 = load i8, i8* %21
%23 = getelementptr inbounds [1000000 x i8], [1000000 x i8]* %2, i64 0, i64 %20
%24 = load i8, i8* %23
%25 = icmp eq i8 %22, %24
%26 = add nuw nsw i64 %18, 1
br i1 %25, label %15, label %27
27: ; preds = %17
%28 = load i32, i32* %1
%29 = add nsw i32 %28, 1
store i32 %29, i32* %1
%30 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = call i32 @strlen(i8* %4)
%32 = icmp sgt i32 %31, 1
br i1 %32, label %10, label %33
33: ; preds = %27, %15, %0
%34 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %4)
ret i32 0
}