#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 main() {
  int n, m, t, j, s = 0, c[100], k = 0, l, i;
  long long int b;
  scanf("%d\n", &t);
  for (i = 0; i < t; i++) {
    scanf("%d", &m);
    scanf("%d", &n);
    for (j = 0; j < m; j++) {
      scanf("%lld", &b);
      s = s + b;
    }
    c[k] = s / n;
    k++;
    s = 0;
  }
  for (l = 0; l < k; l++)
    printf("%d\n", c[l]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1b4(%rbp)
lea    0xeb6(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x1bc(%rbp)
mov    -0x1bc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1217 <main+0xf7>
lea    0xe8f(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xe7d(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d6 <main+0xb6>
lea    0xe5b(%rip),%rdi
lea    -0x1c8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movslq -0x18(%rbp),%rax
add    -0x1c8(%rbp),%rax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1199 <main+0x79>
mov    -0x18(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %eax,%ecx
movslq -0x1b4(%rbp),%rax
mov    %ecx,-0x1b0(%rbp,%rax,4)
mov    -0x1b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b4(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x1bc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1bc(%rbp)
jmp    115f <main+0x3f>
movl   $0x0,-0x1b8(%rbp)
mov    -0x1b8(%rbp),%eax
cmp    -0x1b4(%rbp),%eax
jge    1261 <main+0x141>
movslq -0x1b8(%rbp),%rax
mov    -0x1b0(%rbp,%rax,4),%esi
lea    0xdb8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1b8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1b8(%rbp)
jmp    1221 <main+0x101>
xor    %eax,%eax
add    $0x1d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1b8,%rsp
lea    0xec8(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    1215 <main+0xf5>
mov    $0x1,%eax
lea    0xeac(%rip),%r13
lea    0x18(%rsp),%rbx
xor    %r14d,%r14d
jmp    118b <main+0x6b>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%eax
cltd
idivl  0x14(%rsp)
mov    %eax,0x20(%rsp,%r14,4)
add    $0x1,%r14
lea    0x1(%r15),%eax
cmp    %r14d,0xc(%rsp)
jle    11ee <main+0xce>
mov    %eax,%r15d
lea    0xe6f(%rip),%rbp
mov    %rbp,%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %rbp,%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0x10(%rsp)
mov    $0x0,%ebp
jle    1170 <main+0x50>
xor    %ebp,%ebp
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r13,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
add    0x18(%rsp),%ebp
add    $0x1,%r12d
cmp    0x10(%rsp),%r12d
jl     11d0 <main+0xb0>
jmp    1170 <main+0x50>
test   %r14d,%r14d
je     1215 <main+0xf5>
mov    %r15d,%ebp
xor    %ebx,%ebx
lea    0xe01(%rip),%r14
nop
mov    0x20(%rsp,%rbx,4),%esi
mov    %r14,%rdi
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1200 <main+0xe0>
xor    %eax,%eax
add    $0x1b8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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