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

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sscanf(char *, char *, int *, int *);
int /*<<< orphan*/ stdin;
char *strtok_r(char *, char *, char **);
int main() {
  char buf[4096];
  int table[100];
  char *token, *saveptr;
  while (1) {
    int i;
    int member, qurorum;
    int record_day = 0, record = -1;
    if (fgets(buf, sizeof(buf), stdin) == NULL)
      break;
    sscanf(buf, "%d %d", &member, &qurorum);
    if (!member && !qurorum)
      break;
    memset(table, 0, sizeof(table));
    for (i = 0; i < member; i++) {
      int j;
      int conv_days;
      if (fgets(buf, sizeof(buf), stdin) == NULL)
        break;
      token = strtok_r(buf, " ", &saveptr);
      conv_days = atoi(token);
      for (j = 0; j < conv_days; j++) {
        int conv_day;
        token = strtok_r(NULL, " ", &saveptr);
        conv_day = atoi(token);
        table[conv_day]++;
      }
    }
    for (i = 0; i < sizeof(table) / sizeof(table[0]); i++) {
      if (table[i] >= qurorum && table[i] > record) {
        record = table[i];
        record_day = i;
      }
    }
    printf("%d\n", record_day);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x11d0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x11c0(%rbp)
movl   $0xffffffff,-0x11c4(%rbp)
ff ff ff
lea    -0x1010(%rbp),%rdi
mov    0x2e54(%rip),%rax
mov    (%rax),%edx
mov    $0x1000,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    11af <main+0x4f>
jmp    13aa <main+0x24a>
lea    -0x1010(%rbp),%rdi
lea    0xe43(%rip),%rsi
lea    -0x11b8(%rbp),%rdx
lea    -0x11bc(%rbp),%rcx
call   1070 <sscanf@plt>
cmpl   $0x0,-0x11b8(%rbp)
jne    11ef <main+0x8f>
cmpl   $0x0,-0x11bc(%rbp)
jne    11ef <main+0x8f>
jmp    13aa <main+0x24a>
lea    -0x11a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1040 <memset@plt>
movl   $0x0,-0x11b4(%rbp)
mov    -0x11b4(%rbp),%eax
cmp    -0x11b8(%rbp),%eax
jge    130b <main+0x1ab>
lea    -0x1010(%rbp),%rdi
mov    0x2dbc(%rip),%rax
mov    (%rax),%edx
mov    $0x1000,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
jne    1247 <main+0xe7>
jmp    130b <main+0x1ab>
lea    -0x1010(%rbp),%rdi
lea    0xdb1(%rip),%rsi
lea    -0x11b0(%rbp),%rdx
call   1050 <strtok_r@plt>
mov    %rax,-0x11a8(%rbp)
mov    -0x11a8(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x11cc(%rbp)
movl   $0x0,-0x11c8(%rbp)
mov    -0x11c8(%rbp),%eax
cmp    -0x11cc(%rbp),%eax
jge    12f2 <main+0x192>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd65(%rip),%rsi
lea    -0x11b0(%rbp),%rdx
call   1050 <strtok_r@plt>
mov    %rax,-0x11a8(%rbp)
mov    -0x11a8(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x11d0(%rbp)
movslq -0x11d0(%rbp),%rax
mov    -0x11a0(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x11a0(%rbp,%rax,4)
mov    -0x11c8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x11c8(%rbp)
jmp    1284 <main+0x124>
jmp    12f7 <main+0x197>
mov    -0x11b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x11b4(%rbp)
jmp    120c <main+0xac>
movl   $0x0,-0x11b4(%rbp)
movslq -0x11b4(%rbp),%rax
cmp    $0x64,%rax
jae    1393 <main+0x233>
movslq -0x11b4(%rbp),%rax
mov    -0x11a0(%rbp,%rax,4),%eax
cmp    -0x11bc(%rbp),%eax
jl     137a <main+0x21a>
movslq -0x11b4(%rbp),%rax
mov    -0x11a0(%rbp,%rax,4),%eax
cmp    -0x11c4(%rbp),%eax
jle    137a <main+0x21a>
movslq -0x11b4(%rbp),%rax
mov    -0x11a0(%rbp,%rax,4),%eax
mov    %eax,-0x11c4(%rbp)
mov    -0x11b4(%rbp),%eax
mov    %eax,-0x11c0(%rbp)
jmp    137f <main+0x21f>
mov    -0x11b4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x11b4(%rbp)
jmp    1315 <main+0x1b5>
mov    -0x11c0(%rbp),%esi
lea    0xc68(%rip),%rdi
call   1030 <printf@plt>
jmp    1172 <main+0x12>
xor    %eax,%eax
add    $0x11d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x11a8,%rsp
mov    0x2e70(%rip),%rbx
mov    (%rbx),%edx
lea    0x1a0(%rsp),%rdi
mov    $0x1000,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     1307 <main+0x1a7>
lea    0x1a0(%rsp),%r15
lea    0xe62(%rip),%r12
lea    0x8(%rsp),%r13
jmp    11d8 <main+0x78>
nopl   0x0(%rax,%rax,1)
lea    0xe51(%rip),%rdi
call   1030 <printf@plt>
mov    %r14,%rbx
mov    (%r14),%edx
mov    %r15,%rdi
mov    $0x1000,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     1307 <main+0x1a7>
mov    %r15,%rdi
lea    0xe1e(%rip),%rsi
mov    %rsp,%rdx
lea    0x4(%rsp),%rcx
call   1070 <sscanf@plt>
mov    (%rsp),%eax
or     0x4(%rsp),%eax
je     1307 <main+0x1a7>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x190,%edx
call   1040 <memset@plt>
cmpl   $0x0,(%rsp)
jle    12a0 <main+0x140>
xor    %r14d,%r14d
jmp    122d <main+0xcd>
nopl   0x0(%rax)
add    $0x1,%r14d
cmp    (%rsp),%r14d
mov    %rbp,%r15
jge    12a0 <main+0x140>
mov    (%rbx),%edx
mov    %r15,%rdi
mov    $0x1000,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     12a0 <main+0x140>
mov    %r15,%rbp
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1050 <strtok_r@plt>
mov    %rax,%rdi
call   1080 <atoi@plt>
test   %eax,%eax
jle    1220 <main+0xc0>
mov    %eax,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %r12,%rsi
mov    %r13,%rdx
call   1050 <strtok_r@plt>
mov    %rax,%rdi
call   1080 <atoi@plt>
cltq
addl   $0x1,0x10(%rsp,%rax,4)
add    $0xffffffff,%r15d
jne    1270 <main+0x110>
jmp    1220 <main+0xc0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%r14
xor    %eax,%eax
mov    $0xffffffff,%edx
mov    0x4(%rsp),%r8d
xor    %esi,%esi
jmp    12d4 <main+0x174>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%esi
mov    %edi,%ebx
add    $0x2,%rax
mov    %ebx,%edx
cmp    $0x64,%rax
je     11b0 <main+0x50>
mov    0x10(%rsp,%rax,4),%edi
mov    0x14(%rsp,%rax,4),%ebx
cmp    %r8d,%edi
setge  %r9b
cmp    %edx,%edi
setg   %cl
mov    %eax,%ebp
test   %cl,%r9b
jne    12f3 <main+0x193>
mov    %esi,%ebp
mov    %edx,%edi
cmp    %r8d,%ebx
setge  %cl
cmp    %edi,%ebx
setg   %dl
test   %dl,%cl
je     12c0 <main+0x160>
lea    0x1(%rax),%esi
jmp    12c4 <main+0x164>
xor    %eax,%eax
add    $0x11a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [4096 x i8]
%3 = alloca [100 x i32]
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %1
br label %14
14: ; preds = %0, %96
store i32 0, i32* %9
store i32 -1, i32* %10
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%16 = load i32, i32* @stdin
%17 = call i32* @fgets(i8* %15, i32 4096, i32 %16)
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %20
19: ; preds = %14
br label %99
20: ; preds = %14
%21 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%22 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %7, i32* %8)
%23 = load i32, i32* %7
%24 = icmp ne i32 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %20
%26 = load i32, i32* %8
%27 = icmp ne i32 %26, 0
br i1 %27, label %29, label %28
28: ; preds = %25
br label %99
29: ; preds = %25, %20
%30 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%31 = call i32 @memset(i32* %30, i32 0, i32 400)
store i32 0, i32* %6
br label %32
32: ; preds = %64, %29
%33 = load i32, i32* %6
%34 = load i32, i32* %7
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %67
36: ; preds = %32
%37 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%38 = load i32, i32* @stdin
%39 = call i32* @fgets(i8* %37, i32 4096, i32 %38)
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %42
41: ; preds = %36
br label %67
42: ; preds = %36
%43 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%44 = call i8* @strtok_r(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %5)
store i8* %44, i8** %4
%45 = load i8*, i8** %4
%46 = call i32 @atoi(i8* %45)
store i32 %46, i32* %12
store i32 0, i32* %11
br label %47
47: ; preds = %60, %42
%48 = load i32, i32* %11
%49 = load i32, i32* %12
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %63
51: ; preds = %47
%52 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %5)
store i8* %52, i8** %4
%53 = load i8*, i8** %4
%54 = call i32 @atoi(i8* %53)
store i32 %54, i32* %13
%55 = load i32, i32* %13
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %56
%58 = load i32, i32* %57
%59 = add nsw i32 %58, 1
store i32 %59, i32* %57
br label %60
60: ; preds = %51
%61 = load i32, i32* %11
%62 = add nsw i32 %61, 1
store i32 %62, i32* %11
br label %47
63: ; preds = %47
br label %64
64: ; preds = %63
%65 = load i32, i32* %6
%66 = add nsw i32 %65, 1
store i32 %66, i32* %6
br label %32
67: ; preds = %41, %32
store i32 0, i32* %6
br label %68
68: ; preds = %93, %67
%69 = load i32, i32* %6
%70 = sext i32 %69 to i64
%71 = icmp ult i64 %70, 100
br i1 %71, label %72, label %96
72: ; preds = %68
%73 = load i32, i32* %6
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %74
%76 = load i32, i32* %75
%77 = load i32, i32* %8
%78 = icmp sge i32 %76, %77
br i1 %78, label %79, label %92
79: ; preds = %72
%80 = load i32, i32* %6
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %81
%83 = load i32, i32* %82
%84 = load i32, i32* %10
%85 = icmp sgt i32 %83, %84
br i1 %85, label %86, label %92
86: ; preds = %79
%87 = load i32, i32* %6
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %88
%90 = load i32, i32* %89
store i32 %90, i32* %10
%91 = load i32, i32* %6
store i32 %91, i32* %9
br label %92
92: ; preds = %86, %79, %72
br label %93
93: ; preds = %92
%94 = load i32, i32* %6
%95 = add nsw i32 %94, 1
store i32 %95, i32* %6
br label %68
96: ; preds = %68
%97 = load i32, i32* %9
%98 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %97)
br label %14
99: ; preds = %28, %19
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [4096 x i8]
%2 = alloca [100 x i32]
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %1, i64 0, i64 0
%7 = bitcast [100 x i32]* %2 to i8*
%8 = bitcast i8** %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = load i32, i32* @stdin
%12 = call i32* @fgets(i8* %6, i32 4096, i32 %11)
%13 = icmp eq i32* %12, null
br i1 %13, label %80, label %14
14: ; preds = %0
%15 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
br label %16
16: ; preds = %14, %75
%17 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %5)
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 0
%20 = load i32, i32* %5
%21 = icmp ne i32 %20, 0
%22 = select i1 %19, i1 true, i1 %21
br i1 %22, label %23, label %80
23: ; preds = %16
%24 = call i32 @memset(i32* %15, i32 0, i32 400)
%25 = load i32, i32* %4
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %50
27: ; preds = %23, %46
%28 = phi i32 [ %47, %46 ], [ 0, %23 ]
%29 = load i32, i32* @stdin
%30 = call i32* @fgets(i8* %6, i32 4096, i32 %29)
%31 = icmp eq i32* %30, null
br i1 %31, label %50, label %32
32: ; preds = %27
%33 = call i8* @strtok_r(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %3)
%34 = call i32 @atoi(i8* %33)
%35 = icmp sgt i32 %34, 0
br i1 %35, label %36, label %46
36: ; preds = %32, %36
%37 = phi i32 [ %44, %36 ], [ 0, %32 ]
%38 = call i8* @strtok_r(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %3)
%39 = call i32 @atoi(i8* %38)
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = add nsw i32 %42, 1
store i32 %43, i32* %41
%44 = add nuw nsw i32 %37, 1
%45 = icmp eq i32 %44, %34
br i1 %45, label %46, label %36
46: ; preds = %36, %32
%47 = add nuw nsw i32 %28, 1
%48 = load i32, i32* %4
%49 = icmp slt i32 %47, %48
br i1 %49, label %27, label %50
50: ; preds = %46, %27, %23
%51 = load i32, i32* %5
br label %52
52: ; preds = %52, %50
%53 = phi i64 [ 0, %50 ], [ %73, %52 ]
%54 = phi i32 [ -1, %50 ], [ %72, %52 ]
%55 = phi i32 [ 0, %50 ], [ %71, %52 ]
%56 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %53
%57 = load i32, i32* %56
%58 = icmp sge i32 %57, %51
%59 = icmp sgt i32 %57, %54
%60 = select i1 %58, i1 %59, i1 false
%61 = trunc i64 %53 to i32
%62 = select i1 %60, i32 %61, i32 %55
%63 = select i1 %60, i32 %57, i32 %54
%64 = or i64 %53, 1
%65 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %64
%66 = load i32, i32* %65
%67 = icmp sge i32 %66, %51
%68 = icmp sgt i32 %66, %63
%69 = select i1 %67, i1 %68, i1 false
%70 = trunc i64 %64 to i32
%71 = select i1 %69, i32 %70, i32 %62
%72 = select i1 %69, i32 %66, i32 %63
%73 = add nuw nsw i64 %53, 2
%74 = icmp eq i64 %73, 100
br i1 %74, label %75, label %52
75: ; preds = %52
%76 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %71)
%77 = load i32, i32* @stdin
%78 = call i32* @fgets(i8* %6, i32 4096, i32 %77)
%79 = icmp eq i32* %78, null
br i1 %79, label %80, label %16
80: ; preds = %16, %75, %0
ret i32 0
}