#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *, ...);
int *malloc(int);
scalar_t__ memcmp(int *, int *, int);
int main() {
  FILE *f = fopen("INP.TXT", "r");
  int n, k, *a, i, r = 1;
  fscanf(f, "%d %d", &n, &k);
  a = malloc(n * sizeof(int));
  for (i = 0; i < n; i++)
    fscanf(f, "%d", a + i);
  fclose(f);
  k = n / k;
  for (i = k; i < n; i += k)
    if (memcmp(a, a + i, k * sizeof(int))) {
      r = 0;
      break;
    }
  f = fopen("OUT.TXT", "w");
  fputs(r ? "YES\n" : "NO\n", f);
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    0xe8b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe72(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
mov    $0x0,%al
call   1050 <fscanf@plt>
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11fc <main+0x9c>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe26(%rip),%rsi
mov    $0x0,%al
call   1050 <fscanf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11c1 <main+0x61>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    126c <main+0x10c>
mov    -0x20(%rbp),%rdi
mov    -0x20(%rbp),%rsi
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
je     1259 <main+0xf9>
movl   $0x0,-0x28(%rbp)
jmp    126c <main+0x10c>
jmp    125e <main+0xfe>
mov    -0x18(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    1215 <main+0xb5>
lea    0xd9d(%rip),%rdi
lea    0xd9e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x28(%rbp),%ecx
lea    0xd92(%rip),%rdi
lea    0xd86(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
mov    -0x10(%rbp),%rsi
call   1040 <fputs@plt>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe8d(%rip),%rdi
lea    0xe8e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r12
lea    0xe81(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %rax,%rdi
xor    %eax,%eax
call   1050 <fscanf@plt>
mov    0x8(%rsp),%ebx
lea    0x0(,%rbx,4),%edi
call   1070 <malloc@plt>
mov    %rax,%r14
test   %ebx,%ebx
jle    11e2 <main+0x82>
lea    0xe52(%rip),%r15
mov    %r14,%rbx
xor    %ebp,%ebp
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <fscanf@plt>
add    $0x1,%rbp
movslq 0x8(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     11c0 <main+0x60>
mov    %r12,%rdi
call   1030 <fclose@plt>
mov    0x8(%rsp),%ecx
mov    %ecx,%eax
cltd
idivl  0xc(%rsp)
mov    %eax,0xc(%rsp)
lea    0xe1a(%rip),%r15
cmp    %ecx,%eax
jge    1238 <main+0xd8>
mov    %eax,%edx
lea    0xe12(%rip),%rbx
mov    %eax,%ebp
nop
movslq %ebp,%rax
lea    (%r14,%rax,4),%rsi
shl    $0x2,%edx
mov    %r14,%rdi
call   1060 <memcmp@plt>
test   %rax,%rax
jne    1235 <main+0xd5>
mov    0xc(%rsp),%edx
add    %edx,%ebp
cmp    0x8(%rsp),%ebp
jl     1210 <main+0xb0>
jmp    1238 <main+0xd8>
mov    %rbx,%r15
lea    0xdd1(%rip),%rdi
lea    0xdd2(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <fputs@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"INP.TXT\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"%d %d\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [8 x i8] c"OUT.TXT\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [5 x i8] c"YES\0A\00"
@.str.7 = [4 x i8] c"NO\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* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %2
store i32 1, i32* %7
%9 = load i32*, i32** %2
%10 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %3, i32* %4)
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = mul i64 %12, 4
%14 = trunc i64 %13 to i32
%15 = call i32* @malloc(i32 %14)
store i32* %15, i32** %5
store i32 0, i32* %6
br label %16
16: ; preds = %27, %0
%17 = load i32, i32* %6
%18 = load i32, i32* %3
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %30
20: ; preds = %16
%21 = load i32*, i32** %2
%22 = load i32*, i32** %5
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %22, i64 %24
%26 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %25)
br label %27
27: ; preds = %20
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %16
30: ; preds = %16
%31 = load i32*, i32** %2
%32 = call i32 @fclose(i32* %31)
%33 = load i32, i32* %3
%34 = load i32, i32* %4
%35 = sdiv i32 %33, %34
store i32 %35, i32* %4
%36 = load i32, i32* %4
store i32 %36, i32* %6
br label %37
37: ; preds = %55, %30
%38 = load i32, i32* %6
%39 = load i32, i32* %3
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %59
41: ; preds = %37
%42 = load i32*, i32** %5
%43 = load i32*, i32** %5
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %43, i64 %45
%47 = load i32, i32* %4
%48 = sext i32 %47 to i64
%49 = mul i64 %48, 4
%50 = trunc i64 %49 to i32
%51 = call i64 @memcmp(i32* %42, i32* %46, i32 %50)
%52 = icmp ne i64 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %41
store i32 0, i32* %7
br label %59
54: ; preds = %41
br label %55
55: ; preds = %54
%56 = load i32, i32* %4
%57 = load i32, i32* %6
%58 = add nsw i32 %57, %56
store i32 %58, i32* %6
br label %37
59: ; preds = %53, %37
%60 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32* %60, i32** %2
%61 = load i32, i32* %7
%62 = icmp ne i32 %61, 0
%63 = zext i1 %62 to i64
%64 = select i1 %62, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0)
%65 = load i32*, i32** %2
%66 = call i32 @fputs(i8* %64, i32* %65)
%67 = load i32*, i32** %2
%68 = call i32 @fclose(i32* %67)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"INP.TXT\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"%d %d\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [8 x i8] c"OUT.TXT\00"
@.str.5 = [2 x i8] c"w\00"
@.str.6 = [5 x i8] c"YES\0A\00"
@.str.7 = [4 x i8] c"NO\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %2)
%7 = load i32, i32* %1
%8 = shl i32 %7, 2
%9 = call i32* @malloc(i32 %8)
%10 = icmp sgt i32 %7, 0
br i1 %10, label %11, label %19
11: ; preds = %0, %11
%12 = phi i64 [ %15, %11 ], [ 0, %0 ]
%13 = getelementptr inbounds i32, i32* %9, i64 %12
%14 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %13)
%15 = add nuw nsw i64 %12, 1
%16 = load i32, i32* %1
%17 = sext i32 %16 to i64
%18 = icmp slt i64 %15, %17
br i1 %18, label %11, label %19
19: ; preds = %11, %0
%20 = call i32 @fclose(i32* %3)
%21 = load i32, i32* %1
%22 = load i32, i32* %2
%23 = sdiv i32 %21, %22
store i32 %23, i32* %2
%24 = icmp slt i32 %23, %21
br i1 %24, label %25, label %38
25: ; preds = %19, %33
%26 = phi i32 [ %34, %33 ], [ %23, %19 ]
%27 = phi i32 [ %35, %33 ], [ %23, %19 ]
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %9, i64 %28
%30 = shl i32 %26, 2
%31 = call i64 @memcmp(i32* %9, i32* %29, i32 %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %25
%34 = load i32, i32* %2
%35 = add nsw i32 %34, %27
%36 = load i32, i32* %1
%37 = icmp slt i32 %35, %36
br i1 %37, label %25, label %38
38: ; preds = %33, %25, %19
%39 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), %19 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), %25 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), %33 ]
%40 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%41 = call i32 @fputs(i8* %39, i32* %40)
%42 = call i32 @fclose(i32* %40)
ret i32 0
}