#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 */
scalar_t__ EOF;
int is_pld(char *, int, int);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, ...);
int main(int argc, const char *argv[]) {
  int n, i, j, max, now;
  char str[1001];
  while (scanf("%d", &n) != EOF) {
    scanf("%s", str);
    max = 1;
    if (n > 1)
      for (i = 0; i < n; i++)
        for (j = i + 2; j < n; j++)
          if (now = is_pld(str, i, j), now > max)
            max = now;
    printf("%d\n", max);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb0(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    0x2e86(%rip),%rcx
cmp    (%rcx),%rax
je     121f <main+0xef>
lea    -0x410(%rbp),%rsi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x1,-0x20(%rbp)
cmpl   $0x1,-0x14(%rbp)
jle    120b <main+0xdb>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1206 <main+0xd6>
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11f3 <main+0xc3>
lea    -0x410(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1050 <is_pld@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x20(%rbp),%eax
jle    11e0 <main+0xb0>
mov    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    11e5 <main+0xb5>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ad <main+0x7d>
jmp    11f8 <main+0xc8>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1198 <main+0x68>
jmp    120b <main+0xdb>
mov    -0x20(%rbp),%esi
lea    0xdf1(%rip),%rdi
call   1030 <printf@plt>
jmp    1149 <main+0x19>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
lea    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x2e8d(%rip),%r12
cmp    (%r12),%rax
jne    1175 <main+0x45>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%r13
jmp    11b5 <main+0x85>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe6f(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
lea    0xe5b(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmp    (%r12),%rax
je     1161 <main+0x31>
lea    0xe47(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
mov    $0x1,%ebp
cmp    $0x2,%eax
jl     1190 <main+0x60>
mov    $0x1,%ebp
xor    %r14d,%r14d
jmp    11e9 <main+0xb9>
xchg   %ax,%ax
add    $0x1,%r14d
cmp    %eax,%r14d
jge    1190 <main+0x60>
lea    0x2(%r14),%r15d
cmp    %eax,%r15d
jge    11e0 <main+0xb0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %r15d,%edx
call   1050 <is_pld@plt>
cmp    %ebp,%eax
cmovg  %eax,%ebp
add    $0x1,%r15d
mov    0xc(%rsp),%eax
cmp    %eax,%r15d
jl     1200 <main+0xd0>
jmp    11e0 <main+0xb0>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [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 [1001 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %12
12: ; preds = %52, %2
%13 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%14 = load i64, i64* @EOF
%15 = icmp ne i64 %13, %14
br i1 %15, label %16, label %55
16: ; preds = %12
%17 = getelementptr inbounds [1001 x i8], [1001 x i8]* %11, i64 0, i64 0
%18 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %17)
store i32 1, i32* %9
%19 = load i32, i32* %6
%20 = icmp sgt i32 %19, 1
br i1 %20, label %21, label %52
21: ; preds = %16
store i32 0, i32* %7
br label %22
22: ; preds = %48, %21
%23 = load i32, i32* %7
%24 = load i32, i32* %6
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %51
26: ; preds = %22
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 2
store i32 %28, i32* %8
br label %29
29: ; preds = %44, %26
%30 = load i32, i32* %8
%31 = load i32, i32* %6
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %47
33: ; preds = %29
%34 = getelementptr inbounds [1001 x i8], [1001 x i8]* %11, i64 0, i64 0
%35 = load i32, i32* %7
%36 = load i32, i32* %8
%37 = call i32 @is_pld(i8* %34, i32 %35, i32 %36)
store i32 %37, i32* %10
%38 = load i32, i32* %10
%39 = load i32, i32* %9
%40 = icmp sgt i32 %38, %39
br i1 %40, label %41, label %43
41: ; preds = %33
%42 = load i32, i32* %10
store i32 %42, i32* %9
br label %43
43: ; preds = %41, %33
br label %44
44: ; preds = %43
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
br label %29
47: ; preds = %29
br label %48
48: ; preds = %47
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %22
51: ; preds = %22
br label %52
52: ; preds = %51, %16
%53 = load i32, i32* %9
%54 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %53)
br label %12
55: ; preds = %12
ret i32 0
}

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