#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 *, int);
int /*<<< orphan*/ scanf(char *, int *, int *, int *);
int main() {
  int n, m, k, discount = 0, money, i = 0, sum = 0;
  scanf("%d\n%d\n%d", &n, &m, &k);
  money = m;
  while (i < n) {
    if (i != 0 && i % k == 0) {
      discount = discount + 2;
      m = money - (money * discount / 100);
    }
    sum = sum + m;
    i++;
  }
  printf("\n%d", sum);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xeb5(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c7 <main+0xa7>
cmpl   $0x0,-0x1c(%rbp)
je     11b0 <main+0x90>
mov    -0x1c(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    11b0 <main+0x90>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x20(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1162 <main+0x42>
mov    -0x20(%rbp),%esi
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xed5(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1040 <scanf@plt>
mov    0x14(%rsp),%r10d
test   %r10d,%r10d
jle    1159 <main+0x39>
mov    0xc(%rsp),%r8d
cmp    $0x1,%r10d
jne    116e <main+0x4e>
mov    %r8d,%esi
jmp    115b <main+0x3b>
xor    %esi,%esi
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
mov    0x10(%rsp),%r9d
xor    %r11d,%r11d
mov    $0x1,%ecx
mov    %r8d,%esi
mov    %r8d,%edi
jmp    119a <main+0x7a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    %edi,%esi
add    $0x1,%ecx
cmp    %ecx,%r10d
je     115b <main+0x3b>
mov    %ecx,%eax
cltd
idiv   %r9d
test   %edx,%edx
jne    1190 <main+0x70>
add    $0x2,%r11d
mov    %r11d,%eax
imul   %r8d,%eax
cltq
imul   $0xffffffffae147ae1,%rax,%rdi
mov    %rdi,%rax
shr    $0x3f,%rax
sar    $0x25,%rdi
add    %eax,%edi
add    %r8d,%edi
mov    %edi,0xc(%rsp)
jmp    1190 <main+0x70>

LLVM IR (-O0):
@.str = [9 x i8] c"%d\0A%d\0A%d\00"
@.str.1 = [4 x i8] c"\0A%d\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
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %7
store i32 0, i32* %8
%9 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%10 = load i32, i32* %3
store i32 %10, i32* %6
br label %11
11: ; preds = %32, %0
%12 = load i32, i32* %7
%13 = load i32, i32* %2
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %38
15: ; preds = %11
%16 = load i32, i32* %7
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %32
18: ; preds = %15
%19 = load i32, i32* %7
%20 = load i32, i32* %4
%21 = srem i32 %19, %20
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %32
23: ; preds = %18
%24 = load i32, i32* %5
%25 = add nsw i32 %24, 2
store i32 %25, i32* %5
%26 = load i32, i32* %6
%27 = load i32, i32* %6
%28 = load i32, i32* %5
%29 = mul nsw i32 %27, %28
%30 = sdiv i32 %29, 100
%31 = sub nsw i32 %26, %30
store i32 %31, i32* %3
br label %32
32: ; preds = %23, %18, %15
%33 = load i32, i32* %8
%34 = load i32, i32* %3
%35 = add nsw i32 %33, %34
store i32 %35, i32* %8
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
br label %11
38: ; preds = %11
%39 = load i32, i32* %8
%40 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %1
ret i32 %41
}

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