#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 /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int mode, numInputs;
  scanf("%d %d", &mode, &numInputs);
  if (mode == 1) {
    if (numInputs == 0) {
      printf("\n");
      return 0;
    }
    int prevNum;
    scanf("%d", &prevNum);
    int prevNumCount = 1;
    for (int i = 0; i < numInputs - 1; i++) {
      int currentNum;
      scanf("%d", &currentNum);
      if (prevNum == currentNum) {
        prevNumCount++;
      } else {
        printf("%d %d ", prevNumCount, prevNum);
        prevNumCount = 1;
        prevNum = currentNum;
      }
    }
    printf("%d %d", prevNumCount, prevNum);
  } else if (mode == 2) {
    for (int i = 0; i < numInputs; i++) {
      int numCount;
      int currentNum;
      scanf("%d %d ", &numCount, &currentNum);
      for (int j = 0; j < numCount; j++) {
        if (i == numInputs - 1 && j == numCount - 1) {
          printf("%d", currentNum);
        } else {
          printf("%d ", currentNum);
        }
      }
    }
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jne    121d <main+0xfd>
cmpl   $0x0,-0xc(%rbp)
jne    1173 <main+0x53>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f1 <main+0x1d1>
lea    0xe89(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    1204 <main+0xe4>
lea    0xe58(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    11d0 <main+0xb0>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11f1 <main+0xd1>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11f6 <main+0xd6>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1193 <main+0x73>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12dc <main+0x1bc>
cmpl   $0x2,-0x8(%rbp)
jne    12d7 <main+0x1b7>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12d2 <main+0x1b2>
lea    0xdc7(%rip),%rdi
lea    -0x24(%rbp),%rsi
lea    -0x28(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12bf <main+0x19f>
mov    -0x20(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    129b <main+0x17b>
mov    -0x2c(%rbp),%eax
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    129b <main+0x17b>
mov    -0x28(%rbp),%esi
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ac <main+0x18c>
mov    -0x28(%rbp),%esi
lea    0xd66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b1 <main+0x191>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1257 <main+0x137>
jmp    12c4 <main+0x1a4>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    122e <main+0x10e>
jmp    12d7 <main+0x1b7>
jmp    12dc <main+0x1bc>
lea    0xd23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xebb(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x14(%rsp),%eax
cmp    $0x1,%eax
je     1203 <main+0xd3>
cmp    $0x2,%eax
jne    12ac <main+0x17c>
cmpl   $0x0,0xc(%rsp)
jle    12ac <main+0x17c>
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xe7b(%rip),%rbx
lea    0xe7a(%rip),%r13
xor    %ebp,%ebp
jmp    11ad <main+0x7d>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jge    12ac <main+0x17c>
lea    0xe52(%rip),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x8(%rsp),%eax
test   %eax,%eax
jle    11a0 <main+0x70>
xor    %r14d,%r14d
jmp    11e8 <main+0xb8>
xchg   %ax,%ax
mov    0x10(%rsp),%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r14d
mov    0x8(%rsp),%eax
cmp    %eax,%r14d
jge    11a0 <main+0x70>
mov    0xc(%rsp),%ecx
add    $0xffffffff,%ecx
xor    %ebp,%ecx
add    $0xffffffff,%eax
xor    %r14d,%eax
or     %ecx,%eax
mov    %rbx,%rdi
je     11d0 <main+0xa0>
mov    %r13,%rdi
jmp    11d0 <main+0xa0>
cmpl   $0x0,0xc(%rsp)
je     12ac <main+0x17c>
lea    0xdee(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpl   $0x1,0xc(%rsp)
jle    1293 <main+0x163>
mov    $0x1,%ebx
lea    0xdcf(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xdc6(%rip),%r12
xor    %ebp,%ebp
jmp    1277 <main+0x147>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%edx
mov    %edx,0x8(%rsp)
mov    $0x1,%ebx
add    $0x1,%ebp
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    %eax,%ebp
jge    129c <main+0x16c>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x8(%rsp),%edx
cmp    0x10(%rsp),%edx
jne    1250 <main+0x120>
add    $0x1,%ebx
jmp    1269 <main+0x139>
mov    $0x1,%ebx
mov    0x8(%rsp),%edx
lea    0xd5d(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [7 x i8] c"%d %d \00"
@.str.4 = [4 x i8] c"%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
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
%12 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %48
15: ; preds = %0
%16 = load i32, i32* %3
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %90
20: ; preds = %15
%21 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
store i32 1, i32* %5
store i32 0, i32* %6
br label %22
22: ; preds = %41, %20
%23 = load i32, i32* %6
%24 = load i32, i32* %3
%25 = sub nsw i32 %24, 1
%26 = icmp slt i32 %23, %25
br i1 %26, label %27, label %44
27: ; preds = %22
%28 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%29 = load i32, i32* %4
%30 = load i32, i32* %7
%31 = icmp eq i32 %29, %30
br i1 %31, label %32, label %35
32: ; preds = %27
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %40
35: ; preds = %27
%36 = load i32, i32* %5
%37 = load i32, i32* %4
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 %36, i32 %37)
store i32 1, i32* %5
%39 = load i32, i32* %7
store i32 %39, i32* %4
br label %40
40: ; preds = %35, %32
br label %41
41: ; preds = %40
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %22
44: ; preds = %22
%45 = load i32, i32* %5
%46 = load i32, i32* %4
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %45, i32 %46)
br label %88
48: ; preds = %0
%49 = load i32, i32* %2
%50 = icmp eq i32 %49, 2
br i1 %50, label %51, label %87
51: ; preds = %48
store i32 0, i32* %8
br label %52
52: ; preds = %83, %51
%53 = load i32, i32* %8
%54 = load i32, i32* %3
%55 = icmp slt i32 %53, %54
br i1 %55, label %56, label %86
56: ; preds = %52
%57 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32* %9, i32* %10)
store i32 0, i32* %11
br label %58
58: ; preds = %79, %56
%59 = load i32, i32* %11
%60 = load i32, i32* %9
%61 = icmp slt i32 %59, %60
br i1 %61, label %62, label %82
62: ; preds = %58
%63 = load i32, i32* %8
%64 = load i32, i32* %3
%65 = sub nsw i32 %64, 1
%66 = icmp eq i32 %63, %65
br i1 %66, label %67, label %75
67: ; preds = %62
%68 = load i32, i32* %11
%69 = load i32, i32* %9
%70 = sub nsw i32 %69, 1
%71 = icmp eq i32 %68, %70
br i1 %71, label %72, label %75
72: ; preds = %67
%73 = load i32, i32* %10
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %73)
br label %78
75: ; preds = %67, %62
%76 = load i32, i32* %10
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %76)
br label %78
78: ; preds = %75, %72
br label %79
79: ; preds = %78
%80 = load i32, i32* %11
%81 = add nsw i32 %80, 1
store i32 %81, i32* %11
br label %58
82: ; preds = %58
br label %83
83: ; preds = %82
%84 = load i32, i32* %8
%85 = add nsw i32 %84, 1
store i32 %85, i32* %8
br label %52
86: ; preds = %52
br label %87
87: ; preds = %86, %48
br label %88
88: ; preds = %87, %44
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %90
90: ; preds = %88, %18
%91 = load i32, i32* %1
ret i32 %91
}

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