#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 *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *);
int *solve(int, int *, int *);
int main() {
  int n;
  scanf("%d", &n);
  int *grades = malloc(sizeof(int) * n);
  for (int grades_i = 0; grades_i < n; grades_i++) {
    scanf("%d", &grades[grades_i]);
  }
  int result_size;
  int *result = solve(n, grades, &result_size);
  for (int result_i = 0; result_i < n; result_i++) {
    if (result_i) {
      printf("\n");
    }
    printf("%d", result[result_i]);
  }
  puts("");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11be <main+0x6e>
mov    -0x10(%rbp),%rsi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe55(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1189 <main+0x39>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <solve@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1224 <main+0xd4>
cmpl   $0x0,-0x24(%rbp)
je     11fd <main+0xad>
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11d9 <main+0x89>
lea    0xdd9(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe9c(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x8(%rsp),%r12d
lea    0x0(,%r12,4),%edi
call   1060 <malloc@plt>
mov    %rax,%r14
test   %r12d,%r12d
jle    11bd <main+0x6d>
xor    %r13d,%r13d
lea    0xe6e(%rip),%r15
mov    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
add    $0x1,%r13
movslq 0x8(%rsp),%r12
add    $0x4,%rbx
cmp    %r12,%r13
jl     11a0 <main+0x50>
lea    0xc(%rsp),%rdx
mov    %r12d,%edi
mov    %r14,%rsi
call   1030 <solve@plt>
cmpl   $0x0,0x8(%rsp)
jle    1226 <main+0xd6>
mov    %rax,%r15
mov    (%rax),%esi
lea    0xe20(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x2,0x8(%rsp)
jl     1226 <main+0xd6>
mov    $0x1,%ebx
lea    0xe06(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0x8(%rsp),%rax
cmp    %rax,%rbx
jl     1200 <main+0xb0>
mov    $0xa,%edi
call   1040 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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