#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 teams(int *, int, int);
int main() {
  int s[100000];
  int t = 0, n = 0, k = 0;
  scanf("%d", &t);
  for (int i = 0; i < t; ++i) {
    scanf("%d %d", &n, &k);
    for (int j = 0; j < n; ++j)
      scanf("%d", s + j);
    printf("%d\n", teams(s, n, k));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x61ab0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x61a94(%rbp)
movl   $0x0,-0x61a98(%rbp)
movl   $0x0,-0x61a9c(%rbp)
lea    0xe9c(%rip),%rdi
lea    -0x61a94(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x61aa0(%rbp)
mov    -0x61aa0(%rbp),%eax
cmp    -0x61a94(%rbp),%eax
jge    123a <main+0x10a>
lea    0xe68(%rip),%rdi
lea    -0x61a98(%rbp),%rsi
lea    -0x61a9c(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
movl   $0x0,-0x61aa4(%rbp)
mov    -0x61aa4(%rbp),%eax
cmp    -0x61a98(%rbp),%eax
jge    1200 <main+0xd0>
lea    -0x61a90(%rbp),%rsi
movslq -0x61aa4(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x61aa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x61aa4(%rbp)
jmp    11b7 <main+0x87>
lea    -0x61a90(%rbp),%rdi
mov    -0x61a98(%rbp),%esi
mov    -0x61a9c(%rbp),%edx
call   1040 <teams@plt>
mov    %eax,%esi
lea    0xde5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x61aa0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x61aa0(%rbp)
jmp    117f <main+0x4f>
xor    %eax,%eax
add    $0x61ab0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x61a98,%rsp
movl   $0x0,0x8(%rsp)
movl   $0x0,0x4(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xea3(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
jle    1201 <main+0xd1>
lea    0x10(%rsp),%r14
lea    0xe80(%rip),%rbx
lea    0xe7c(%rip),%rbp
xor    %r15d,%r15d
jmp    11b1 <main+0x81>
nop
mov    0xc(%rsp),%edx
mov    %r14,%rdi
call   1040 <teams@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
add    $0x1,%r15d
cmp    0x8(%rsp),%r15d
jge    1201 <main+0xd1>
lea    0xe48(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    1190 <main+0x60>
mov    %r14,%r13
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%r12
movslq 0x4(%rsp),%rsi
add    $0x4,%r13
cmp    %rsi,%r12
jl     11e0 <main+0xb0>
jmp    1190 <main+0x60>
xor    %eax,%eax
add    $0x61a98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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