package cinema

var totalIncome = 0

fun setupCinema(): Pair<Int, Int> {
    println("Enter the number of rows:")
    val numRows: Int = readln()!!.toInt()
    println("Enter the number of seats in each row:")
    val seatsInRow: Int = readln()!!.toInt()
    return Pair(numRows, seatsInRow)
}

fun printCinema(topList: MutableList<MutableList<String>>) {
    println("Cinema:")
    print(" ")
    for (rowInit in topList[0].indices) print(" ${rowInit + 1}")
    for (rowIndex in topList.indices) {
    print("\n${rowIndex + 1}")
    for (seatIndex in topList[rowIndex].indices) print(" ${topList[rowIndex][seatIndex]}")
    }
    println()
}

fun pickSeat(numRows: Int, seatsInRow: Int, numSeats: Int, topList: MutableList<MutableList<String>>) {
    while (true) {
        println("\nEnter a row number:")
        val rowPick = readln()!!.toInt()
        println("Enter a seat number in that row:")
        val seatPick = readln()!!.toInt()
        if (rowPick !in 1..numRows || seatPick !in 1..seatsInRow) {
            println("Wrong input!")
            // pickSeat(numRows, seatsInRow, numSeats, topList)
            continue
        }
        val holdingVar = topList[rowPick - 1][seatPick - 1]
        if (holdingVar == "B") {
            println("That ticket has already been purchased!")
            // pickSeat(numRows, seatsInRow, numSeats, topList)
            continue
        }

        var seatCost = if (numSeats <= 60 || rowPick <= numRows / 2) 10 else 8
        println("Ticket price: $$seatCost")
        topList[rowPick - 1][seatPick - 1] = "B"
        totalIncome += seatCost
        break
    }
}

fun fetchStats(totalIncome: Int, topList: MutableList<MutableList<String>>, numRows: Int, seatsInRow: Int, numSeats: Int) {
    val boughtTickets = topList.flatten().count { it == "B" }
    println("Number of purchased tickets: $boughtTickets")

    val boughtRoughP = boughtTickets.toDouble() / topList.flatten().size * 100
    val boughtPercent: String = "%.2f".format(boughtRoughP)
    println("Percentage: $boughtPercent%")

    println("Current income: $$totalIncome")

    val maxIncome = if (numSeats <= 60) numSeats * 10 else {
        numRows / 2  * seatsInRow * 10 + (numRows / 2 + 1) * seatsInRow * 8
    }
    println("Total income: $$maxIncome")
}

fun main() {
    val (numRows, seatsInRow) = setupCinema()

    val topList = MutableList(numRows) { MutableList(seatsInRow) { "S" } }
    val numSeats = topList.flatten().size

    while(true) {
    println("\n1. Show the seats\n2. Buy a ticket\n3. Statistics\n0. Exit\n")

    when (readln()!!.toInt()) {
        1 -> { printCinema(topList) }
        2 -> { pickSeat(numRows, seatsInRow, numSeats, topList) }
        3 -> { fetchStats(totalIncome, topList, numRows, seatsInRow, numSeats) }
        0 -> return
    }
    }
}

Compiled from "src.kt"
public final class cinema.SrcKt {
  private static int totalIncome;

  public static final int getTotalIncome();
    Code:
       0: getstatic     #10                 // Field totalIncome:I
       3: ireturn

  public static final void setTotalIncome(int);
    Code:
       0: iload_0
       1: putstatic     #10                 // Field totalIncome:I
       4: return

  public static final kotlin.Pair<java.lang.Integer, java.lang.Integer> setupCinema();
    Code:
       0: ldc           #19                 // String Enter the number of rows:
       2: getstatic     #25                 // Field java/lang/System.out:Ljava/io/PrintStream;
       5: swap
       6: invokevirtual #31                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
       9: invokestatic  #37                 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
      12: dup
      13: invokestatic  #42                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      16: invokestatic  #48                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      19: istore_0
      20: ldc           #50                 // String Enter the number of seats in each row:
      22: getstatic     #25                 // Field java/lang/System.out:Ljava/io/PrintStream;
      25: swap
      26: invokevirtual #31                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      29: invokestatic  #37                 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
      32: dup
      33: invokestatic  #42                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      36: invokestatic  #48                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      39: istore_1
      40: new           #52                 // class kotlin/Pair
      43: dup
      44: iload_0
      45: invokestatic  #56                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      48: iload_1
      49: invokestatic  #56                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      52: invokespecial #60                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      55: areturn

  public static final void printCinema(java.util.List<java.util.List<java.lang.String>>);
    Code:
       0: aload_0
       1: ldc           #67                 // String topList
       3: invokestatic  #71                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: ldc           #73                 // String Cinema:
       8: getstatic     #25                 // Field java/lang/System.out:Ljava/io/PrintStream;
      11: swap
      12: invokevirtual #31                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      15: ldc           #75                 // String
      17: getstatic     #25                 // Field java/lang/System.out:Ljava/io/PrintStream;
      20: swap
      21: invokevirtual #78                 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
      24: iconst_0
      25: istore_1
      26: aload_0
      27: iconst_0
      28: invokeinterface #84,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      33: checkcast     #86                 // class java/util/Collection
      36: invokeinterface #89,  1           // InterfaceMethod java/util/Collection.size:()I
      41: istore_2
      42: iload_1
      43: iload_2
      44: if_icmpge     81
      47: new           #91                 // class java/lang/StringBuilder
      50: dup
      51: invokespecial #94                 // Method java/lang/StringBuilder."<init>":()V
      54: bipush        32
      56: invokevirtual #98                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      59: iload_1
      60: iconst_1
      61: iadd
      62: invokevirtual #101                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      65: invokevirtual #104                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      68: getstatic     #25                 // Field java/lang/System.out:Ljava/io/PrintStream;
      71: swap
      72: invokevirtual #78                 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
      75: iinc          1, 1
      78: goto          42
      81: iconst_0
      82: istore_1
      83: aload_0
      84: checkcast     #86                 // class java/util/Collection
      87: invokeinterface #89,  1           // InterfaceMethod java/util/Collection.size:()I
      92: istore_2
      93: iload_1
      94: iload_2
      95: if_icmpge     207
      98: new           #91                 // class java/lang/StringBuilder
     101: dup
     102: invokespecial #94                 // Method java/lang/StringBuilder."<init>":()V
     105: bipush        10
     107: invokevirtual #98                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     110: iload_1
     111: iconst_1
     112: iadd
     113: invokevirtual #101                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     116: invokevirtual #104                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     119: getstatic     #25                 // Field java/lang/System.out:Ljava/io/PrintStream;
     122: swap
     123: invokevirtual #78                 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     126: iconst_0
     127: istore_3
     128: aload_0
     129: iload_1
     130: invokeinterface #84,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     135: checkcast     #86                 // class java/util/Collection
     138: invokeinterface #89,  1           // InterfaceMethod java/util/Collection.size:()I
     143: istore        4
     145: iload_3
     146: iload         4
     148: if_icmpge     201
     151: new           #91                 // class java/lang/StringBuilder
     154: dup
     155: invokespecial #94                 // Method java/lang/StringBuilder."<init>":()V
     158: bipush        32
     160: invokevirtual #98                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     163: aload_0
     164: iload_1
     165: invokeinterface #84,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     170: checkcast     #80                 // class java/util/List
     173: iload_3
     174: invokeinterface #84,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     179: checkcast     #106                // class java/lang/String
     182: invokevirtual #109                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     185: invokevirtual #104                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     188: getstatic     #25                 // Field java/lang/System.out:Ljava/io/PrintStream;
     191: swap
     192: invokevirtual #78                 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     195: iinc          3, 1
     198: goto          145
     201: iinc          1, 1
     204: goto          93
     207: getstatic     #25                 // Field java/lang/System.out:Ljava/io/PrintStream;
     210: invokevirtual #111                // Method java/io/PrintStream.println:()V
     213: return

  public static final void pickSeat(int, int, int, java.util.List<java.util.List<java.lang.String>>);
    Code:
       0: aload_3
       1: ldc           #67                 // String topList
       3: invokestatic  #71                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: nop
       7: ldc           #120                // String \nEnter a row number:
       9: getstatic     #25                 // Field java/lang/System.out:Ljava/io/PrintStream;
      12: swap
      13: invokevirtual #31                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      16: invokestatic  #37                 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
      19: dup
      20: invokestatic  #42                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      23: invokestatic  #48                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      26: istore        4
      28: ldc           #122                // String Enter a seat number in that row:
      30: getstatic     #25                 // Field java/lang/System.out:Ljava/io/PrintStream;
      33: swap
      34: invokevirtual #31                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      37: invokestatic  #37                 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
      40: dup
      41: invokestatic  #42                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      44: invokestatic  #48                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      47: istore        5
      49: iconst_1
      50: iload         4
      52: if_icmpgt     69
      55: iload         4
      57: iload_0
      58: if_icmpgt     65
      61: iconst_1
      62: goto          70
      65: iconst_0
      66: goto          70
      69: iconst_0
      70: ifeq          97
      73: iconst_1
      74: iload         5
      76: if_icmpgt     93
      79: iload         5
      81: iload_1
      82: if_icmpgt     89
      85: iconst_1
      86: goto          94
      89: iconst_0
      90: goto          94
      93: iconst_0
      94: ifne          109
      97: ldc           #124                // String Wrong input!
      99: getstatic     #25                 // Field java/lang/System.out:Ljava/io/PrintStream;
     102: swap
     103: invokevirtual #31                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     106: goto          6
     109: aload_3
     110: iload         4
     112: iconst_1
     113: isub
     114: invokeinterface #84,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     119: checkcast     #80                 // class java/util/List
     122: iload         5
     124: iconst_1
     125: isub
     126: invokeinterface #84,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     131: checkcast     #106                // class java/lang/String
     134: astore        6
     136: aload         6
     138: ldc           #126                // String B
     140: invokestatic  #130                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     143: ifeq          158
     146: ldc           #132                // String That ticket has already been purchased!
     148: getstatic     #25                 // Field java/lang/System.out:Ljava/io/PrintStream;
     151: swap
     152: invokevirtual #31                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     155: goto          6
     158: iload_2
     159: bipush        60
     161: if_icmple     172
     164: iload         4
     166: iload_0
     167: iconst_2
     168: idiv
     169: if_icmpgt     177
     172: bipush        10
     174: goto          179
     177: bipush        8
     179: istore        7
     181: new           #91                 // class java/lang/StringBuilder
     184: dup
     185: invokespecial #94                 // Method java/lang/StringBuilder."<init>":()V
     188: ldc           #134                // String Ticket price: $
     190: invokevirtual #109                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     193: iload         7
     195: invokevirtual #101                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     198: invokevirtual #104                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     201: getstatic     #25                 // Field java/lang/System.out:Ljava/io/PrintStream;
     204: swap
     205: invokevirtual #31                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     208: aload_3
     209: iload         4
     211: iconst_1
     212: isub
     213: invokeinterface #84,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     218: checkcast     #80                 // class java/util/List
     221: iload         5
     223: iconst_1
     224: isub
     225: ldc           #126                // String B
     227: invokeinterface #138,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     232: pop
     233: getstatic     #10                 // Field totalIncome:I
     236: iload         7
     238: iadd
     239: putstatic     #10                 // Field totalIncome:I
     242: nop
     243: return

  public static final void fetchStats(int, java.util.List<java.util.List<java.lang.String>>, int, int, int);
    Code:
       0: aload_1
       1: ldc           #67                 // String topList
       3: invokestatic  #71                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #149                // class java/lang/Iterable
      10: invokestatic  #155                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
      13: checkcast     #149                // class java/lang/Iterable
      16: astore        6
      18: iconst_0
      19: istore        7
      21: aload         6
      23: instanceof    #86                 // class java/util/Collection
      26: ifeq          46
      29: aload         6
      31: checkcast     #86                 // class java/util/Collection
      34: invokeinterface #159,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      39: ifeq          46
      42: iconst_0
      43: goto          113
      46: iconst_0
      47: istore        8
      49: aload         6
      51: invokeinterface #163,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      56: astore        9
      58: aload         9
      60: invokeinterface #168,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      65: ifeq          111
      68: aload         9
      70: invokeinterface #172,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      75: astore        10
      77: aload         10
      79: checkcast     #106                // class java/lang/String
      82: astore        11
      84: iconst_0
      85: istore        12
      87: aload         11
      89: ldc           #126                // String B
      91: invokestatic  #130                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      94: ifeq          58
      97: iinc          8, 1
     100: iload         8
     102: ifge          58
     105: invokestatic  #175                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     108: goto          58
     111: iload         8
     113: istore        5
     115: new           #91                 // class java/lang/StringBuilder
     118: dup
     119: invokespecial #94                 // Method java/lang/StringBuilder."<init>":()V
     122: ldc           #177                // String Number of purchased tickets:
     124: invokevirtual #109                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     127: iload         5
     129: invokevirtual #101                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     132: invokevirtual #104                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     135: getstatic     #25                 // Field java/lang/System.out:Ljava/io/PrintStream;
     138: swap
     139: invokevirtual #31                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     142: iload         5
     144: i2d
     145: aload_1
     146: checkcast     #149                // class java/lang/Iterable
     149: invokestatic  #155                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
     152: invokeinterface #178,  1          // InterfaceMethod java/util/List.size:()I
     157: i2d
     158: ddiv
     159: bipush        100
     161: i2d
     162: dmul
     163: dstore        6
     165: ldc           #180                // String %.2f
     167: astore        9
     169: iconst_1
     170: anewarray     #4                  // class java/lang/Object
     173: astore        10
     175: aload         10
     177: iconst_0
     178: dload         6
     180: invokestatic  #185                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     183: aastore
     184: aload         10
     186: astore        10
     188: aload         9
     190: aload         10
     192: aload         10
     194: arraylength
     195: invokestatic  #191                // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;
     198: invokestatic  #195                // Method java/lang/String.format:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
     201: dup
     202: ldc           #197                // String format(...)
     204: invokestatic  #200                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     207: astore        8
     209: new           #91                 // class java/lang/StringBuilder
     212: dup
     213: invokespecial #94                 // Method java/lang/StringBuilder."<init>":()V
     216: ldc           #202                // String Percentage:
     218: invokevirtual #109                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     221: aload         8
     223: invokevirtual #109                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     226: bipush        37
     228: invokevirtual #98                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     231: invokevirtual #104                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     234: getstatic     #25                 // Field java/lang/System.out:Ljava/io/PrintStream;
     237: swap
     238: invokevirtual #31                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     241: new           #91                 // class java/lang/StringBuilder
     244: dup
     245: invokespecial #94                 // Method java/lang/StringBuilder."<init>":()V
     248: ldc           #204                // String Current income: $
     250: invokevirtual #109                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     253: iload_0
     254: invokevirtual #101                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     257: invokevirtual #104                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     260: getstatic     #25                 // Field java/lang/System.out:Ljava/io/PrintStream;
     263: swap
     264: invokevirtual #31                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     267: iload         4
     269: bipush        60
     271: if_icmpgt     282
     274: iload         4
     276: bipush        10
     278: imul
     279: goto          301
     282: iload_2
     283: iconst_2
     284: idiv
     285: iload_3
     286: imul
     287: bipush        10
     289: imul
     290: iload_2
     291: iconst_2
     292: idiv
     293: iconst_1
     294: iadd
     295: iload_3
     296: imul
     297: bipush        8
     299: imul
     300: iadd
     301: istore        9
     303: new           #91                 // class java/lang/StringBuilder
     306: dup
     307: invokespecial #94                 // Method java/lang/StringBuilder."<init>":()V
     310: ldc           #206                // String Total income: $
     312: invokevirtual #109                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     315: iload         9
     317: invokevirtual #101                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     320: invokevirtual #104                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     323: getstatic     #25                 // Field java/lang/System.out:Ljava/io/PrintStream;
     326: swap
     327: invokevirtual #31                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     330: return

  public static final void main();
    Code:
       0: invokestatic  #224                // Method setupCinema:()Lkotlin/Pair;
       3: astore_0
       4: aload_0
       5: invokevirtual #227                // Method kotlin/Pair.component1:()Ljava/lang/Object;
       8: checkcast     #229                // class java/lang/Number
      11: invokevirtual #232                // Method java/lang/Number.intValue:()I
      14: istore_1
      15: aload_0
      16: invokevirtual #235                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      19: checkcast     #229                // class java/lang/Number
      22: invokevirtual #232                // Method java/lang/Number.intValue:()I
      25: istore_2
      26: new           #237                // class java/util/ArrayList
      29: dup
      30: iload_1
      31: invokespecial #239                // Method java/util/ArrayList."<init>":(I)V
      34: astore        4
      36: iconst_0
      37: istore        5
      39: iload         5
      41: iload_1
      42: if_icmpge     128
      45: iload         5
      47: istore        6
      49: aload         4
      51: iload         6
      53: istore        7
      55: astore        15
      57: iconst_0
      58: istore        8
      60: new           #237                // class java/util/ArrayList
      63: dup
      64: iload_2
      65: invokespecial #239                // Method java/util/ArrayList."<init>":(I)V
      68: astore        9
      70: iconst_0
      71: istore        10
      73: iload         10
      75: iload_2
      76: if_icmpge     109
      79: iload         10
      81: istore        11
      83: aload         9
      85: iload         11
      87: istore        12
      89: astore        13
      91: iconst_0
      92: istore        14
      94: ldc           #241                // String S
      96: aload         13
      98: swap
      99: invokevirtual #245                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     102: pop
     103: iinc          10, 1
     106: goto          73
     109: aload         9
     111: checkcast     #80                 // class java/util/List
     114: nop
     115: aload         15
     117: swap
     118: invokevirtual #245                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     121: pop
     122: iinc          5, 1
     125: goto          39
     128: aload         4
     130: checkcast     #80                 // class java/util/List
     133: astore_3
     134: aload_3
     135: checkcast     #149                // class java/lang/Iterable
     138: invokestatic  #155                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
     141: invokeinterface #178,  1          // InterfaceMethod java/util/List.size:()I
     146: istore        4
     148: nop
     149: ldc           #247                // String \n1. Show the seats\n2. Buy a ticket\n3. Statistics\n0. Exit\n
     151: getstatic     #25                 // Field java/lang/System.out:Ljava/io/PrintStream;
     154: swap
     155: invokevirtual #31                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     158: invokestatic  #37                 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
     161: dup
     162: invokestatic  #42                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     165: invokestatic  #48                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     168: tableswitch   { // 0 to 3
                     0: 232
                     1: 200
                     2: 207
                     3: 218
               default: 233
          }
     200: aload_3
     201: invokestatic  #249                // Method printCinema:(Ljava/util/List;)V
     204: goto          148
     207: iload_1
     208: iload_2
     209: iload         4
     211: aload_3
     212: invokestatic  #251                // Method pickSeat:(IIILjava/util/List;)V
     215: goto          148
     218: getstatic     #10                 // Field totalIncome:I
     221: aload_3
     222: iload_1
     223: iload_2
     224: iload         4
     226: invokestatic  #253                // Method fetchStats:(ILjava/util/List;III)V
     229: goto          148
     232: return
     233: goto          148

  public static void main(java.lang.String[]);
    Code:
       0: invokestatic  #258                // Method main:()V
       3: return

  static {};
    Code:
       0: return
}


package cinema

const val STANDARD: Int = 10
const val DISCOUNT: Int = 8
const val B_SYMBOL: Char = 'B'
const val S_SYMBOL: Char = 'S'
const val SMALL_ROOM: Int = 60

enum class Cinema(var number: Int) {
    ROW(7), SEATS(8),
    TOTAL_SEATS(ROW.number * SEATS.number),
    SELECT_ROW(0), SELECT_SEAT(0),
    PURCHASED_TICKET(0), CURRENT_INCOME(0),
    TOTAL_INCOME(0),
}

var mappingSeats = MutableList(Cinema.ROW.number) { MutableList(Cinema.SEATS.number) { S_SYMBOL } }

fun userInput() {
    println("Enter the number of rows:")
    Cinema.ROW.number = readln().toInt()

    println("Enter the number of seats in each row:")
    Cinema.SEATS.number = readln().toInt()

    Cinema.TOTAL_SEATS.number = Cinema.ROW.number * Cinema.SEATS.number
    mappingSeats = MutableList(Cinema.ROW.number) { MutableList(Cinema.SEATS.number) { S_SYMBOL } }

    if (Cinema.TOTAL_SEATS.number <= SMALL_ROOM) {
        Cinema.TOTAL_INCOME.number = Cinema.TOTAL_SEATS.number * STANDARD
    } else {
        val frontHalf = (Cinema.ROW.number / 2) * Cinema.SEATS.number * STANDARD
        val backHalf = ((Cinema.ROW.number / 2) + (Cinema.ROW.number % 2)) * Cinema.SEATS.number * DISCOUNT
        Cinema.TOTAL_INCOME.number = frontHalf + backHalf
    }
    seatsPreview(mappingSeats)
}

fun buyTicket() {
    try {
        println("Enter a row number:")
        Cinema.SELECT_ROW.number = readln().toInt()

        println("Enter a seat number in that row:")
        Cinema.SELECT_SEAT.number = readln().toInt()

        println("Ticket price: $${ticketPrice()}")

        if (mappingSeats[Cinema.SELECT_ROW.number - 1][Cinema.SELECT_SEAT.number - 1] == B_SYMBOL) {
            throw Exception()
        } else {
            mappingSeats[Cinema.SELECT_ROW.number - 1][Cinema.SELECT_SEAT.number - 1] = B_SYMBOL
        }
        Cinema.PURCHASED_TICKET.number += 1

    } catch (e: IndexOutOfBoundsException) {
        println("Wrong input!")
        buyTicket()
    } catch (e: Exception) {
        println("That ticket has already been purchased")
        buyTicket()
    }
    Cinema.CURRENT_INCOME.number += ticketPrice()
}

fun seatsPreview(mappingSeats: MutableList<MutableList<Char>>) {
    print("Cinema:\n  ")
    (1..mappingSeats[0].size).forEach { print("$it ") }
    println()
    for (i in 1..mappingSeats.size) {
        print("$i ")
        println(mappingSeats[i - 1].joinToString(separator = " "))
    }
}

fun ticketPrice(): Int {
    val ticketPrice =
        if (Cinema.TOTAL_SEATS.number <= SMALL_ROOM || Cinema.SELECT_ROW.number <= mappingSeats.size / 2) {
            STANDARD
        } else {
            DISCOUNT
        }
    return ticketPrice
}

fun main() {
    userInput()
    cinema@ while (true) {
        println(
            """
        1. Show the seats
        2. Buy a ticket
        0. Exit
    """.trimIndent()
        )

        when (readln()) {
            "1" -> seatsPreview(mappingSeats)
            "2" -> buyTicket()
            "0" -> break@cinema
        }
    }
}

Compiled from "Main.kt"
public final class cinema.MainKt {
  public static final int STANDARD;

  public static final int DISCOUNT;

  public static final char B_SYMBOL;

  public static final char S_SYMBOL;

  public static final int SMALL_ROOM;

  private static java.util.List<java.util.List<java.lang.Character>> mappingSeats;

  public static final java.util.List<java.util.List<java.lang.Character>> getMappingSeats();
    Code:
       0: getstatic     #12                 // Field mappingSeats:Ljava/util/List;
       3: areturn

  public static final void setMappingSeats(java.util.List<java.util.List<java.lang.Character>>);
    Code:
       0: aload_0
       1: ldc           #17                 // String <set-?>
       3: invokestatic  #23                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: putstatic     #12                 // Field mappingSeats:Ljava/util/List;
      10: return

  public static final void userInput();
    Code:
       0: ldc           #27                 // String Enter the number of rows:
       2: getstatic     #33                 // Field java/lang/System.out:Ljava/io/PrintStream;
       5: swap
       6: invokevirtual #39                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
       9: getstatic     #45                 // Field cinema/Cinema.ROW:Lcinema/Cinema;
      12: invokestatic  #51                 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
      15: invokestatic  #57                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      18: invokevirtual #61                 // Method cinema/Cinema.setNumber:(I)V
      21: ldc           #63                 // String Enter the number of seats in each row:
      23: getstatic     #33                 // Field java/lang/System.out:Ljava/io/PrintStream;
      26: swap
      27: invokevirtual #39                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      30: getstatic     #66                 // Field cinema/Cinema.SEATS:Lcinema/Cinema;
      33: invokestatic  #51                 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
      36: invokestatic  #57                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      39: invokevirtual #61                 // Method cinema/Cinema.setNumber:(I)V
      42: getstatic     #69                 // Field cinema/Cinema.TOTAL_SEATS:Lcinema/Cinema;
      45: getstatic     #45                 // Field cinema/Cinema.ROW:Lcinema/Cinema;
      48: invokevirtual #73                 // Method cinema/Cinema.getNumber:()I
      51: getstatic     #66                 // Field cinema/Cinema.SEATS:Lcinema/Cinema;
      54: invokevirtual #73                 // Method cinema/Cinema.getNumber:()I
      57: imul
      58: invokevirtual #61                 // Method cinema/Cinema.setNumber:(I)V
      61: getstatic     #45                 // Field cinema/Cinema.ROW:Lcinema/Cinema;
      64: invokevirtual #73                 // Method cinema/Cinema.getNumber:()I
      67: istore_0
      68: new           #75                 // class java/util/ArrayList
      71: dup
      72: iload_0
      73: invokespecial #78                 // Method java/util/ArrayList."<init>":(I)V
      76: astore_1
      77: iconst_0
      78: istore_2
      79: iload_2
      80: iload_0
      81: if_icmpge     176
      84: iload_2
      85: istore_3
      86: aload_1
      87: iload_3
      88: istore        4
      90: astore        13
      92: iconst_0
      93: istore        5
      95: getstatic     #66                 // Field cinema/Cinema.SEATS:Lcinema/Cinema;
      98: invokevirtual #73                 // Method cinema/Cinema.getNumber:()I
     101: istore        6
     103: new           #75                 // class java/util/ArrayList
     106: dup
     107: iload         6
     109: invokespecial #78                 // Method java/util/ArrayList."<init>":(I)V
     112: astore        7
     114: iconst_0
     115: istore        8
     117: iload         8
     119: iload         6
     121: if_icmpge     157
     124: iload         8
     126: istore        9
     128: aload         7
     130: iload         9
     132: istore        10
     134: astore        11
     136: iconst_0
     137: istore        12
     139: bipush        83
     141: invokestatic  #84                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     144: aload         11
     146: swap
     147: invokevirtual #88                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     150: pop
     151: iinc          8, 1
     154: goto          117
     157: aload         7
     159: checkcast     #90                 // class java/util/List
     162: nop
     163: aload         13
     165: swap
     166: invokevirtual #88                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     169: pop
     170: iinc          2, 1
     173: goto          79
     176: aload_1
     177: checkcast     #90                 // class java/util/List
     180: putstatic     #12                 // Field mappingSeats:Ljava/util/List;
     183: getstatic     #69                 // Field cinema/Cinema.TOTAL_SEATS:Lcinema/Cinema;
     186: invokevirtual #73                 // Method cinema/Cinema.getNumber:()I
     189: bipush        60
     191: if_icmpgt     212
     194: getstatic     #93                 // Field cinema/Cinema.TOTAL_INCOME:Lcinema/Cinema;
     197: getstatic     #69                 // Field cinema/Cinema.TOTAL_SEATS:Lcinema/Cinema;
     200: invokevirtual #73                 // Method cinema/Cinema.getNumber:()I
     203: bipush        10
     205: imul
     206: invokevirtual #61                 // Method cinema/Cinema.setNumber:(I)V
     209: goto          268
     212: getstatic     #45                 // Field cinema/Cinema.ROW:Lcinema/Cinema;
     215: invokevirtual #73                 // Method cinema/Cinema.getNumber:()I
     218: iconst_2
     219: idiv
     220: getstatic     #66                 // Field cinema/Cinema.SEATS:Lcinema/Cinema;
     223: invokevirtual #73                 // Method cinema/Cinema.getNumber:()I
     226: imul
     227: bipush        10
     229: imul
     230: istore_0
     231: getstatic     #45                 // Field cinema/Cinema.ROW:Lcinema/Cinema;
     234: invokevirtual #73                 // Method cinema/Cinema.getNumber:()I
     237: iconst_2
     238: idiv
     239: getstatic     #45                 // Field cinema/Cinema.ROW:Lcinema/Cinema;
     242: invokevirtual #73                 // Method cinema/Cinema.getNumber:()I
     245: iconst_2
     246: irem
     247: iadd
     248: getstatic     #66                 // Field cinema/Cinema.SEATS:Lcinema/Cinema;
     251: invokevirtual #73                 // Method cinema/Cinema.getNumber:()I
     254: imul
     255: bipush        8
     257: imul
     258: istore_1
     259: getstatic     #93                 // Field cinema/Cinema.TOTAL_INCOME:Lcinema/Cinema;
     262: iload_0
     263: iload_1
     264: iadd
     265: invokevirtual #61                 // Method cinema/Cinema.setNumber:(I)V
     268: getstatic     #12                 // Field mappingSeats:Ljava/util/List;
     271: invokestatic  #96                 // Method seatsPreview:(Ljava/util/List;)V
     274: return

  public static final void buyTicket();
    Code:
       0: nop
       1: ldc           #109                // String Enter a row number:
       3: getstatic     #33                 // Field java/lang/System.out:Ljava/io/PrintStream;
       6: swap
       7: invokevirtual #39                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      10: getstatic     #112                // Field cinema/Cinema.SELECT_ROW:Lcinema/Cinema;
      13: invokestatic  #51                 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
      16: invokestatic  #57                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      19: invokevirtual #61                 // Method cinema/Cinema.setNumber:(I)V
      22: ldc           #114                // String Enter a seat number in that row:
      24: getstatic     #33                 // Field java/lang/System.out:Ljava/io/PrintStream;
      27: swap
      28: invokevirtual #39                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      31: getstatic     #117                // Field cinema/Cinema.SELECT_SEAT:Lcinema/Cinema;
      34: invokestatic  #51                 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
      37: invokestatic  #57                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      40: invokevirtual #61                 // Method cinema/Cinema.setNumber:(I)V
      43: new           #119                // class java/lang/StringBuilder
      46: dup
      47: invokespecial #121                // Method java/lang/StringBuilder."<init>":()V
      50: ldc           #123                // String Ticket price: $
      52: invokevirtual #127                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      55: invokestatic  #130                // Method ticketPrice:()I
      58: invokevirtual #133                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      61: invokevirtual #136                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      64: getstatic     #33                 // Field java/lang/System.out:Ljava/io/PrintStream;
      67: swap
      68: invokevirtual #39                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      71: getstatic     #12                 // Field mappingSeats:Ljava/util/List;
      74: getstatic     #112                // Field cinema/Cinema.SELECT_ROW:Lcinema/Cinema;
      77: invokevirtual #73                 // Method cinema/Cinema.getNumber:()I
      80: iconst_1
      81: isub
      82: invokeinterface #140,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      87: checkcast     #90                 // class java/util/List
      90: getstatic     #117                // Field cinema/Cinema.SELECT_SEAT:Lcinema/Cinema;
      93: invokevirtual #73                 // Method cinema/Cinema.getNumber:()I
      96: iconst_1
      97: isub
      98: invokeinterface #140,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     103: checkcast     #80                 // class java/lang/Character
     106: invokevirtual #144                // Method java/lang/Character.charValue:()C
     109: bipush        66
     111: if_icmpne     122
     114: new           #107                // class java/lang/Exception
     117: dup
     118: invokespecial #145                // Method java/lang/Exception."<init>":()V
     121: athrow
     122: getstatic     #12                 // Field mappingSeats:Ljava/util/List;
     125: getstatic     #112                // Field cinema/Cinema.SELECT_ROW:Lcinema/Cinema;
     128: invokevirtual #73                 // Method cinema/Cinema.getNumber:()I
     131: iconst_1
     132: isub
     133: invokeinterface #140,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     138: checkcast     #90                 // class java/util/List
     141: getstatic     #117                // Field cinema/Cinema.SELECT_SEAT:Lcinema/Cinema;
     144: invokevirtual #73                 // Method cinema/Cinema.getNumber:()I
     147: iconst_1
     148: isub
     149: bipush        66
     151: invokestatic  #84                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     154: invokeinterface #149,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     159: pop
     160: getstatic     #152                // Field cinema/Cinema.PURCHASED_TICKET:Lcinema/Cinema;
     163: astore_0
     164: aload_0
     165: aload_0
     166: invokevirtual #73                 // Method cinema/Cinema.getNumber:()I
     169: iconst_1
     170: iadd
     171: invokevirtual #61                 // Method cinema/Cinema.setNumber:(I)V
     174: goto          206
     177: astore_0
     178: ldc           #154                // String Wrong input!
     180: getstatic     #33                 // Field java/lang/System.out:Ljava/io/PrintStream;
     183: swap
     184: invokevirtual #39                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     187: invokestatic  #156                // Method buyTicket:()V
     190: goto          206
     193: astore_0
     194: ldc           #158                // String That ticket has already been purchased
     196: getstatic     #33                 // Field java/lang/System.out:Ljava/io/PrintStream;
     199: swap
     200: invokevirtual #39                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     203: invokestatic  #156                // Method buyTicket:()V
     206: getstatic     #161                // Field cinema/Cinema.CURRENT_INCOME:Lcinema/Cinema;
     209: astore_0
     210: aload_0
     211: aload_0
     212: invokevirtual #73                 // Method cinema/Cinema.getNumber:()I
     215: invokestatic  #130                // Method ticketPrice:()I
     218: iadd
     219: invokevirtual #61                 // Method cinema/Cinema.setNumber:(I)V
     222: return
    Exception table:
       from    to  target type
           0   174   177   Class java/lang/IndexOutOfBoundsException
           0   174   193   Class java/lang/Exception

  public static final void seatsPreview(java.util.List<java.util.List<java.lang.Character>>);
    Code:
       0: aload_0
       1: ldc           #165                // String mappingSeats
       3: invokestatic  #23                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: ldc           #167                // String Cinema:\n
       8: getstatic     #33                 // Field java/lang/System.out:Ljava/io/PrintStream;
      11: swap
      12: invokevirtual #170                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
      15: new           #172                // class kotlin/ranges/IntRange
      18: dup
      19: iconst_1
      20: aload_0
      21: iconst_0
      22: invokeinterface #140,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      27: checkcast     #90                 // class java/util/List
      30: invokeinterface #175,  1          // InterfaceMethod java/util/List.size:()I
      35: invokespecial #178                // Method kotlin/ranges/IntRange."<init>":(II)V
      38: checkcast     #180                // class java/lang/Iterable
      41: astore_1
      42: iconst_0
      43: istore_2
      44: aload_1
      45: invokeinterface #184,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      50: astore_3
      51: aload_3
      52: invokeinterface #190,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      57: ifeq          108
      60: aload_3
      61: checkcast     #192                // class kotlin/collections/IntIterator
      64: invokevirtual #195                // Method kotlin/collections/IntIterator.nextInt:()I
      67: istore        4
      69: iload         4
      71: istore        5
      73: iconst_0
      74: istore        6
      76: new           #119                // class java/lang/StringBuilder
      79: dup
      80: invokespecial #121                // Method java/lang/StringBuilder."<init>":()V
      83: iload         5
      85: invokevirtual #133                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      88: bipush        32
      90: invokevirtual #198                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      93: invokevirtual #136                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      96: getstatic     #33                 // Field java/lang/System.out:Ljava/io/PrintStream;
      99: swap
     100: invokevirtual #170                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     103: nop
     104: nop
     105: goto          51
     108: nop
     109: getstatic     #33                 // Field java/lang/System.out:Ljava/io/PrintStream;
     112: invokevirtual #200                // Method java/io/PrintStream.println:()V
     115: iconst_1
     116: istore_1
     117: aload_0
     118: invokeinterface #175,  1          // InterfaceMethod java/util/List.size:()I
     123: istore_2
     124: iload_1
     125: iload_2
     126: if_icmpgt     201
     129: new           #119                // class java/lang/StringBuilder
     132: dup
     133: invokespecial #121                // Method java/lang/StringBuilder."<init>":()V
     136: iload_1
     137: invokevirtual #133                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     140: bipush        32
     142: invokevirtual #198                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     145: invokevirtual #136                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     148: getstatic     #33                 // Field java/lang/System.out:Ljava/io/PrintStream;
     151: swap
     152: invokevirtual #170                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     155: aload_0
     156: iload_1
     157: iconst_1
     158: isub
     159: invokeinterface #140,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     164: checkcast     #180                // class java/lang/Iterable
     167: ldc           #202                // String
     169: checkcast     #204                // class java/lang/CharSequence
     172: aconst_null
     173: aconst_null
     174: iconst_0
     175: aconst_null
     176: aconst_null
     177: bipush        62
     179: aconst_null
     180: invokestatic  #210                // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
     183: getstatic     #33                 // Field java/lang/System.out:Ljava/io/PrintStream;
     186: swap
     187: invokevirtual #39                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     190: iload_1
     191: iload_2
     192: if_icmpeq     201
     195: iinc          1, 1
     198: goto          129
     201: return

  public static final int ticketPrice();
    Code:
       0: getstatic     #69                 // Field cinema/Cinema.TOTAL_SEATS:Lcinema/Cinema;
       3: invokevirtual #73                 // Method cinema/Cinema.getNumber:()I
       6: bipush        60
       8: if_icmple     30
      11: getstatic     #112                // Field cinema/Cinema.SELECT_ROW:Lcinema/Cinema;
      14: invokevirtual #73                 // Method cinema/Cinema.getNumber:()I
      17: getstatic     #12                 // Field mappingSeats:Ljava/util/List;
      20: invokeinterface #175,  1          // InterfaceMethod java/util/List.size:()I
      25: iconst_2
      26: idiv
      27: if_icmpgt     35
      30: bipush        10
      32: goto          37
      35: bipush        8
      37: istore_0
      38: iload_0
      39: ireturn

  public static final void main();
    Code:
       0: invokestatic  #219                // Method userInput:()V
       3: nop
       4: ldc           #221                // String 1. Show the seats\n2. Buy a ticket\n0. Exit
       6: astore_0
       7: getstatic     #33                 // Field java/lang/System.out:Ljava/io/PrintStream;
      10: aload_0
      11: invokevirtual #39                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      14: invokestatic  #51                 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;
      17: astore_0
      18: aload_0
      19: invokevirtual #226                // Method java/lang/String.hashCode:()I
      22: tableswitch   { // 48 to 50
                    48: 48
                    49: 60
                    50: 72
               default: 102
          }
      48: aload_0
      49: ldc           #228                // String 0
      51: invokevirtual #231                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      54: ifne          99
      57: goto          3
      60: aload_0
      61: ldc           #233                // String 1
      63: invokevirtual #231                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      66: ifne          84
      69: goto          3
      72: aload_0
      73: ldc           #235                // String 2
      75: invokevirtual #231                // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      78: ifne          93
      81: goto          3
      84: getstatic     #12                 // Field mappingSeats:Ljava/util/List;
      87: invokestatic  #96                 // Method seatsPreview:(Ljava/util/List;)V
      90: goto          3
      93: invokestatic  #156                // Method buyTicket:()V
      96: goto          3
      99: goto          105
     102: goto          3
     105: return

  public static void main(java.lang.String[]);
    Code:
       0: invokestatic  #238                // Method main:()V
       3: return

  static {};
    Code:
       0: getstatic     #45                 // Field cinema/Cinema.ROW:Lcinema/Cinema;
       3: invokevirtual #73                 // Method cinema/Cinema.getNumber:()I
       6: istore_0
       7: new           #75                 // class java/util/ArrayList
      10: dup
      11: iload_0
      12: invokespecial #78                 // Method java/util/ArrayList."<init>":(I)V
      15: astore_1
      16: iconst_0
      17: istore_2
      18: iload_2
      19: iload_0
      20: if_icmpge     115
      23: iload_2
      24: istore_3
      25: aload_1
      26: iload_3
      27: istore        4
      29: astore        13
      31: iconst_0
      32: istore        5
      34: getstatic     #66                 // Field cinema/Cinema.SEATS:Lcinema/Cinema;
      37: invokevirtual #73                 // Method cinema/Cinema.getNumber:()I
      40: istore        6
      42: new           #75                 // class java/util/ArrayList
      45: dup
      46: iload         6
      48: invokespecial #78                 // Method java/util/ArrayList."<init>":(I)V
      51: astore        7
      53: iconst_0
      54: istore        8
      56: iload         8
      58: iload         6
      60: if_icmpge     96
      63: iload         8
      65: istore        9
      67: aload         7
      69: iload         9
      71: istore        10
      73: astore        11
      75: iconst_0
      76: istore        12
      78: bipush        83
      80: invokestatic  #84                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      83: aload         11
      85: swap
      86: invokevirtual #88                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      89: pop
      90: iinc          8, 1
      93: goto          56
      96: aload         7
      98: checkcast     #90                 // class java/util/List
     101: nop
     102: aload         13
     104: swap
     105: invokevirtual #88                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     108: pop
     109: iinc          2, 1
     112: goto          18
     115: aload_1
     116: checkcast     #90                 // class java/util/List
     119: putstatic     #12                 // Field mappingSeats:Ljava/util/List;
     122: return
}


package search

import java.io.File

const val MENU = "=== Menu ===\n" +
        "1. Find a person\n" +
        "2. Print all people\n" +
        "0. Exit"

fun findPerson(people: List<String> ,pIndex: Map<String, Set<Int>>) {
    println("\nSelect a matching strategy: ALL, ANY, NONE")
    val strategy = readLine()!!.uppercase()
    println("\nEnter a name or email to search all matching people.")
    val query = readLine()!!.lowercase()
    when (strategy) {
        "ALL" -> printResult(people, searchAll(people, pIndex, query))
        "ANY" -> printResult(people, searchAny(people, pIndex, query))
        "NONE" -> printResult(people, searchNone(people, pIndex, query))
        else -> println("\nNo such strategy: $strategy")
    }
}

fun searchAll(people: List<String>, pIndex: Map<String, Set<Int>>, query: String): Set<Int> {
    var result = people.indices.toSet()
    for (q in query.split(" ")) result = result.intersect((pIndex[q] ?: emptySet()).toSet())
    return result
}

fun searchAny(people: List<String>, pIndex: Map<String, Set<Int>>, query: String): Set<Int> {
    var result = emptySet<Int>()
    for (q in query.split(" ")) result = result.union((pIndex[q] ?: emptySet()).toSet())
    return result
}

fun searchNone(people: List<String>, pIndex: Map<String, Set<Int>>, query: String): Set<Int> {
    return people.indices.toSet().subtract(searchAny(people, pIndex, query))
}

fun printResult(people: List<String>, result: Set<Int>) {
    if (result.isNotEmpty()) {
        println("\n${result.size} person${if (result.size > 1) "s" else ""} found:")
        for (index in result) println(people[index])
    } else {
        println("\nNo matching people found.")
    }
}

fun printAll(people: List<String>) {
    println("\n=== List of people ===")
    println(people.joinToString("\n"))
}

fun createIndex(people: List<String>): Map<String, Set<Int>> {
    val peopleIndex = emptyMap<String, Set<Int>>().toMutableMap()
    for (index in people.indices)
        for (entry in people[index].lowercase().split(" "))
            peopleIndex[entry] = peopleIndex[entry]?.plus(index) ?: setOf(index)
    return peopleIndex
}

fun main(args: Array<String>) {
    val filename = args[args.indexOf("--data") + 1]
    val people = File(filename).readLines()
    val peopleIndex = createIndex(people)
    while (true) {
        println("\n$MENU")
        when (readLine()!!) {
            "0" -> break
            "1" -> findPerson(people, peopleIndex)
            "2" -> printAll(people)
            else -> println("\nIncorrect option! Try again.")
        }
    }
    println("\nBye!")
}

Compiled from "Main.kt"
public final class search.MainKt {
  public static final java.lang.String MENU;

  public static final void findPerson(java.util.List<java.lang.String>, java.util.Map<java.lang.String, ? extends java.util.Set<java.lang.Integer>>);
    Code:
       0: aload_0
       1: ldc           #10                 // String people
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #18                 // String pIndex
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: ldc           #20                 // String \nSelect a matching strategy: ALL, ANY, NONE
      14: getstatic     #26                 // Field java/lang/System.out:Ljava/io/PrintStream;
      17: swap
      18: invokevirtual #32                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      21: invokestatic  #38                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
      24: dup
      25: invokestatic  #41                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      28: getstatic     #47                 // Field java/util/Locale.ROOT:Ljava/util/Locale;
      31: invokevirtual #53                 // Method java/lang/String.toUpperCase:(Ljava/util/Locale;)Ljava/lang/String;
      34: dup
      35: ldc           #55                 // String toUpperCase(...)
      37: invokestatic  #58                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      40: astore_2
      41: ldc           #60                 // String \nEnter a name or email to search all matching people.
      43: getstatic     #26                 // Field java/lang/System.out:Ljava/io/PrintStream;
      46: swap
      47: invokevirtual #32                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      50: invokestatic  #38                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
      53: dup
      54: invokestatic  #41                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      57: getstatic     #47                 // Field java/util/Locale.ROOT:Ljava/util/Locale;
      60: invokevirtual #63                 // Method java/lang/String.toLowerCase:(Ljava/util/Locale;)Ljava/lang/String;
      63: dup
      64: ldc           #65                 // String toLowerCase(...)
      66: invokestatic  #58                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      69: astore_3
      70: aload_2
      71: astore        4
      73: aload         4
      75: invokevirtual #69                 // Method java/lang/String.hashCode:()I
      78: lookupswitch  { // 3
                 64897: 112
                 64972: 125
               2402104: 138
               default: 190
          }
     112: aload         4
     114: ldc           #71                 // String ALL
     116: invokevirtual #75                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     119: ifne          151
     122: goto          190
     125: aload         4
     127: ldc           #77                 // String ANY
     129: invokevirtual #75                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     132: ifne          164
     135: goto          190
     138: aload         4
     140: ldc           #79                 // String NONE
     142: invokevirtual #75                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     145: ifne          177
     148: goto          190
     151: aload_0
     152: aload_0
     153: aload_1
     154: aload_3
     155: invokestatic  #83                 // Method searchAll:(Ljava/util/List;Ljava/util/Map;Ljava/lang/String;)Ljava/util/Set;
     158: invokestatic  #87                 // Method printResult:(Ljava/util/List;Ljava/util/Set;)V
     161: goto          216
     164: aload_0
     165: aload_0
     166: aload_1
     167: aload_3
     168: invokestatic  #90                 // Method searchAny:(Ljava/util/List;Ljava/util/Map;Ljava/lang/String;)Ljava/util/Set;
     171: invokestatic  #87                 // Method printResult:(Ljava/util/List;Ljava/util/Set;)V
     174: goto          216
     177: aload_0
     178: aload_0
     179: aload_1
     180: aload_3
     181: invokestatic  #93                 // Method searchNone:(Ljava/util/List;Ljava/util/Map;Ljava/lang/String;)Ljava/util/Set;
     184: invokestatic  #87                 // Method printResult:(Ljava/util/List;Ljava/util/Set;)V
     187: goto          216
     190: new           #95                 // class java/lang/StringBuilder
     193: dup
     194: invokespecial #99                 // Method java/lang/StringBuilder."<init>":()V
     197: ldc           #101                // String \nNo such strategy:
     199: invokevirtual #105                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     202: aload_2
     203: invokevirtual #105                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     206: invokevirtual #108                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     209: getstatic     #26                 // Field java/lang/System.out:Ljava/io/PrintStream;
     212: swap
     213: invokevirtual #32                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     216: return

  public static final java.util.Set<java.lang.Integer> searchAll(java.util.List<java.lang.String>, java.util.Map<java.lang.String, ? extends java.util.Set<java.lang.Integer>>, java.lang.String);
    Code:
       0: aload_0
       1: ldc           #10                 // String people
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #18                 // String pIndex
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_2
      13: ldc           #115                // String query
      15: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: aload_0
      19: checkcast     #117                // class java/util/Collection
      22: invokestatic  #123                // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
      25: checkcast     #125                // class java/lang/Iterable
      28: invokestatic  #129                // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
      31: astore_3
      32: aload_2
      33: checkcast     #131                // class java/lang/CharSequence
      36: iconst_1
      37: anewarray     #49                 // class java/lang/String
      40: astore        5
      42: aload         5
      44: iconst_0
      45: ldc           #133                // String
      47: aastore
      48: aload         5
      50: iconst_0
      51: iconst_0
      52: bipush        6
      54: aconst_null
      55: invokestatic  #139                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      58: invokeinterface #145,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      63: astore        4
      65: aload         4
      67: invokeinterface #151,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      72: ifeq          126
      75: aload         4
      77: invokeinterface #155,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      82: checkcast     #49                 // class java/lang/String
      85: astore        5
      87: aload_3
      88: checkcast     #125                // class java/lang/Iterable
      91: aload_1
      92: aload         5
      94: invokeinterface #161,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      99: checkcast     #163                // class java/util/Set
     102: dup
     103: ifnonnull     110
     106: pop
     107: invokestatic  #169                // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;
     110: checkcast     #125                // class java/lang/Iterable
     113: invokestatic  #129                // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     116: checkcast     #125                // class java/lang/Iterable
     119: invokestatic  #173                // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
     122: astore_3
     123: goto          65
     126: aload_3
     127: areturn

  public static final java.util.Set<java.lang.Integer> searchAny(java.util.List<java.lang.String>, java.util.Map<java.lang.String, ? extends java.util.Set<java.lang.Integer>>, java.lang.String);
    Code:
       0: aload_0
       1: ldc           #10                 // String people
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #18                 // String pIndex
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_2
      13: ldc           #115                // String query
      15: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: invokestatic  #169                // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;
      21: astore_3
      22: aload_2
      23: checkcast     #131                // class java/lang/CharSequence
      26: iconst_1
      27: anewarray     #49                 // class java/lang/String
      30: astore        5
      32: aload         5
      34: iconst_0
      35: ldc           #133                // String
      37: aastore
      38: aload         5
      40: iconst_0
      41: iconst_0
      42: bipush        6
      44: aconst_null
      45: invokestatic  #139                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      48: invokeinterface #145,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      53: astore        4
      55: aload         4
      57: invokeinterface #151,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      62: ifeq          116
      65: aload         4
      67: invokeinterface #155,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      72: checkcast     #49                 // class java/lang/String
      75: astore        5
      77: aload_3
      78: checkcast     #125                // class java/lang/Iterable
      81: aload_1
      82: aload         5
      84: invokeinterface #161,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      89: checkcast     #163                // class java/util/Set
      92: dup
      93: ifnonnull     100
      96: pop
      97: invokestatic  #169                // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;
     100: checkcast     #125                // class java/lang/Iterable
     103: invokestatic  #129                // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     106: checkcast     #125                // class java/lang/Iterable
     109: invokestatic  #179                // Method kotlin/collections/CollectionsKt.union:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
     112: astore_3
     113: goto          55
     116: aload_3
     117: areturn

  public static final java.util.Set<java.lang.Integer> searchNone(java.util.List<java.lang.String>, java.util.Map<java.lang.String, ? extends java.util.Set<java.lang.Integer>>, java.lang.String);
    Code:
       0: aload_0
       1: ldc           #10                 // String people
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #18                 // String pIndex
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_2
      13: ldc           #115                // String query
      15: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: aload_0
      19: checkcast     #117                // class java/util/Collection
      22: invokestatic  #123                // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
      25: checkcast     #125                // class java/lang/Iterable
      28: invokestatic  #129                // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
      31: checkcast     #125                // class java/lang/Iterable
      34: aload_0
      35: aload_1
      36: aload_2
      37: invokestatic  #90                 // Method searchAny:(Ljava/util/List;Ljava/util/Map;Ljava/lang/String;)Ljava/util/Set;
      40: checkcast     #125                // class java/lang/Iterable
      43: invokestatic  #182                // Method kotlin/collections/CollectionsKt.subtract:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
      46: areturn

  public static final void printResult(java.util.List<java.lang.String>, java.util.Set<java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #10                 // String people
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #184                // String result
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: checkcast     #117                // class java/util/Collection
      16: invokeinterface #187,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      21: ifne          28
      24: iconst_1
      25: goto          29
      28: iconst_0
      29: ifeq          139
      32: new           #95                 // class java/lang/StringBuilder
      35: dup
      36: invokespecial #99                 // Method java/lang/StringBuilder."<init>":()V
      39: bipush        10
      41: invokevirtual #190                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      44: aload_1
      45: invokeinterface #193,  1          // InterfaceMethod java/util/Set.size:()I
      50: invokevirtual #196                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      53: ldc           #198                // String  person
      55: invokevirtual #105                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      58: aload_1
      59: invokeinterface #193,  1          // InterfaceMethod java/util/Set.size:()I
      64: iconst_1
      65: if_icmple     73
      68: ldc           #200                // String s
      70: goto          75
      73: ldc           #202                // String
      75: invokevirtual #105                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      78: ldc           #204                // String  found:
      80: invokevirtual #105                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      83: invokevirtual #108                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      86: getstatic     #26                 // Field java/lang/System.out:Ljava/io/PrintStream;
      89: swap
      90: invokevirtual #32                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      93: aload_1
      94: invokeinterface #205,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
      99: astore_2
     100: aload_2
     101: invokeinterface #151,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     106: ifeq          148
     109: aload_2
     110: invokeinterface #155,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     115: checkcast     #207                // class java/lang/Number
     118: invokevirtual #210                // Method java/lang/Number.intValue:()I
     121: istore_3
     122: aload_0
     123: iload_3
     124: invokeinterface #213,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     129: getstatic     #26                 // Field java/lang/System.out:Ljava/io/PrintStream;
     132: swap
     133: invokevirtual #32                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     136: goto          100
     139: ldc           #215                // String \nNo matching people found.
     141: getstatic     #26                 // Field java/lang/System.out:Ljava/io/PrintStream;
     144: swap
     145: invokevirtual #32                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     148: return

  public static final void printAll(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #10                 // String people
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: ldc           #222                // String \n=== List of people ===
       8: getstatic     #26                 // Field java/lang/System.out:Ljava/io/PrintStream;
      11: swap
      12: invokevirtual #32                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      15: aload_0
      16: checkcast     #125                // class java/lang/Iterable
      19: ldc           #224                // String \n
      21: checkcast     #131                // class java/lang/CharSequence
      24: aconst_null
      25: aconst_null
      26: iconst_0
      27: aconst_null
      28: aconst_null
      29: bipush        62
      31: aconst_null
      32: invokestatic  #228                // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
      35: getstatic     #26                 // Field java/lang/System.out:Ljava/io/PrintStream;
      38: swap
      39: invokevirtual #32                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      42: return

  public static final java.util.Map<java.lang.String, java.util.Set<java.lang.Integer>> createIndex(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #10                 // String people
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: invokestatic  #237                // Method kotlin/collections/MapsKt.emptyMap:()Ljava/util/Map;
       9: invokestatic  #241                // Method kotlin/collections/MapsKt.toMutableMap:(Ljava/util/Map;)Ljava/util/Map;
      12: astore_1
      13: iconst_0
      14: istore_2
      15: aload_0
      16: checkcast     #117                // class java/util/Collection
      19: invokeinterface #242,  1          // InterfaceMethod java/util/Collection.size:()I
      24: istore_3
      25: iload_2
      26: iload_3
      27: if_icmpge     166
      30: aload_0
      31: iload_2
      32: invokeinterface #213,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      37: checkcast     #49                 // class java/lang/String
      40: getstatic     #47                 // Field java/util/Locale.ROOT:Ljava/util/Locale;
      43: invokevirtual #63                 // Method java/lang/String.toLowerCase:(Ljava/util/Locale;)Ljava/lang/String;
      46: dup
      47: ldc           #65                 // String toLowerCase(...)
      49: invokestatic  #58                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      52: checkcast     #131                // class java/lang/CharSequence
      55: iconst_1
      56: anewarray     #49                 // class java/lang/String
      59: astore        5
      61: aload         5
      63: iconst_0
      64: ldc           #133                // String
      66: aastore
      67: aload         5
      69: iconst_0
      70: iconst_0
      71: bipush        6
      73: aconst_null
      74: invokestatic  #139                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      77: invokeinterface #145,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      82: astore        4
      84: aload         4
      86: invokeinterface #151,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      91: ifeq          160
      94: aload         4
      96: invokeinterface #155,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     101: checkcast     #49                 // class java/lang/String
     104: astore        5
     106: aload_1
     107: astore        6
     109: aload_1
     110: aload         5
     112: invokeinterface #161,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     117: checkcast     #163                // class java/util/Set
     120: dup
     121: ifnull        135
     124: iload_2
     125: invokestatic  #248                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     128: invokestatic  #252                // Method kotlin/collections/SetsKt.plus:(Ljava/util/Set;Ljava/lang/Object;)Ljava/util/Set;
     131: dup
     132: ifnonnull     143
     135: pop
     136: iload_2
     137: invokestatic  #248                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     140: invokestatic  #256                // Method kotlin/collections/SetsKt.setOf:(Ljava/lang/Object;)Ljava/util/Set;
     143: astore        7
     145: aload         6
     147: aload         5
     149: aload         7
     151: invokeinterface #260,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     156: pop
     157: goto          84
     160: iinc          2, 1
     163: goto          25
     166: aload_1
     167: areturn

  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc_w         #266                // String args
       4: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: aload_0
       9: ldc_w         #268                // String --data
      12: invokestatic  #274                // Method kotlin/collections/ArraysKt.indexOf:([Ljava/lang/Object;Ljava/lang/Object;)I
      15: iconst_1
      16: iadd
      17: aaload
      18: astore_1
      19: new           #276                // class java/io/File
      22: dup
      23: aload_1
      24: invokespecial #279                // Method java/io/File."<init>":(Ljava/lang/String;)V
      27: aconst_null
      28: iconst_1
      29: aconst_null
      30: invokestatic  #285                // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      33: astore_2
      34: aload_2
      35: invokestatic  #287                // Method createIndex:(Ljava/util/List;)Ljava/util/Map;
      38: astore_3
      39: nop
      40: ldc_w         #289                // String \n=== Menu ===\n1. Find a person\n2. Print all people\n0. Exit
      43: getstatic     #26                 // Field java/lang/System.out:Ljava/io/PrintStream;
      46: swap
      47: invokevirtual #32                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      50: invokestatic  #38                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
      53: dup
      54: invokestatic  #41                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      57: astore        4
      59: aload         4
      61: invokevirtual #69                 // Method java/lang/String.hashCode:()I
      64: tableswitch   { // 48 to 50
                    48: 92
                    49: 106
                    50: 120
               default: 152
          }
      92: aload         4
      94: ldc_w         #291                // String 0
      97: invokevirtual #75                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     100: ifne          134
     103: goto          152
     106: aload         4
     108: ldc_w         #293                // String 1
     111: invokevirtual #75                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     114: ifne          137
     117: goto          152
     120: aload         4
     122: ldc_w         #295                // String 2
     125: invokevirtual #75                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     128: ifne          145
     131: goto          152
     134: goto          165
     137: aload_2
     138: aload_3
     139: invokestatic  #297                // Method findPerson:(Ljava/util/List;Ljava/util/Map;)V
     142: goto          39
     145: aload_2
     146: invokestatic  #299                // Method printAll:(Ljava/util/List;)V
     149: goto          39
     152: ldc_w         #301                // String \nIncorrect option! Try again.
     155: getstatic     #26                 // Field java/lang/System.out:Ljava/io/PrintStream;
     158: swap
     159: invokevirtual #32                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     162: goto          39
     165: ldc_w         #303                // String \nBye!
     168: getstatic     #26                 // Field java/lang/System.out:Ljava/io/PrintStream;
     171: swap
     172: invokevirtual #32                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     175: return
}


package _004.kotlin

/**
 * @author relish
 * @since 2018/10/20
 */
class Solution {
    fun findMedianSortedArrays(nums1: IntArray, nums2: IntArray): Double {
        val len = nums1.size + nums2.size
        return if (len % 2 == 0) {
            (fix(nums1, 0, nums2, 0, len / 2) + fix(nums1, 0, nums2, 0, len / 2 + 1)) / 2.0
        } else {
            fix(nums1, 0, nums2, 0, len / 2 + 1).toDouble()
        }
    }

    fun fix(nums1: IntArray, n: Int, nums2: IntArray, m: Int, k: Int): Int {
        if (n >= nums1.size) return nums2[m + k - 1]
        if (m >= nums2.size) return nums1[n + k - 1]
        if (k == 1) return Math.min(nums1[n], nums2[m])

        val i1 = n + k / 2 - 1
        val i2 = m + k / 2 - 1
        val v1 = if (i1 < nums1.size) nums1[i1] else Int.MAX_VALUE
        val v2 = if (i2 < nums2.size) nums2[i2] else Int.MAX_VALUE
        return if (v1 < v2) {
            fix(nums1, n + k / 2, nums2, m, k - k / 2)
        } else {
            fix(nums1, n, nums2, m + k / 2, k - k / 2)
        }
    }
}

fun main(args: Array<String>) {
    val solution = Solution()
    println(solution.findMedianSortedArrays(intArrayOf(2), intArrayOf(0)))
    println(solution.findMedianSortedArrays(intArrayOf(1, 2), intArrayOf(3, 4)))
    println(solution.findMedianSortedArrays(intArrayOf(1, 2), intArrayOf(-1, 3)))
}

Compiled from "Solution.kt"
public final class _004.kotlin.Solution {
  public _004.kotlin.Solution();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final double findMedianSortedArrays(int[], int[]);
    Code:
       0: aload_1
       1: ldc           #15                 // String nums1
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #23                 // String nums2
       9: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: arraylength
      14: aload_2
      15: arraylength
      16: iadd
      17: istore_3
      18: iload_3
      19: iconst_2
      20: irem
      21: ifne          57
      24: aload_0
      25: aload_1
      26: iconst_0
      27: aload_2
      28: iconst_0
      29: iload_3
      30: iconst_2
      31: idiv
      32: invokevirtual #27                 // Method fix:([II[III)I
      35: aload_0
      36: aload_1
      37: iconst_0
      38: aload_2
      39: iconst_0
      40: iload_3
      41: iconst_2
      42: idiv
      43: iconst_1
      44: iadd
      45: invokevirtual #27                 // Method fix:([II[III)I
      48: iadd
      49: i2d
      50: ldc2_w        #28                 // double 2.0d
      53: ddiv
      54: goto          71
      57: aload_0
      58: aload_1
      59: iconst_0
      60: aload_2
      61: iconst_0
      62: iload_3
      63: iconst_2
      64: idiv
      65: iconst_1
      66: iadd
      67: invokevirtual #27                 // Method fix:([II[III)I
      70: i2d
      71: dreturn

  public final int fix(int[], int, int[], int, int);
    Code:
       0: aload_1
       1: ldc           #15                 // String nums1
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_3
       7: ldc           #23                 // String nums2
       9: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: iload_2
      13: aload_1
      14: arraylength
      15: if_icmplt     28
      18: aload_3
      19: iload         4
      21: iload         5
      23: iadd
      24: iconst_1
      25: isub
      26: iaload
      27: ireturn
      28: iload         4
      30: aload_3
      31: arraylength
      32: if_icmplt     44
      35: aload_1
      36: iload_2
      37: iload         5
      39: iadd
      40: iconst_1
      41: isub
      42: iaload
      43: ireturn
      44: iload         5
      46: iconst_1
      47: if_icmpne     61
      50: aload_1
      51: iload_2
      52: iaload
      53: aload_3
      54: iload         4
      56: iaload
      57: invokestatic  #38                 // Method java/lang/Math.min:(II)I
      60: ireturn
      61: iload_2
      62: iload         5
      64: iconst_2
      65: idiv
      66: iadd
      67: iconst_1
      68: isub
      69: istore        6
      71: iload         4
      73: iload         5
      75: iconst_2
      76: idiv
      77: iadd
      78: iconst_1
      79: isub
      80: istore        7
      82: iload         6
      84: aload_1
      85: arraylength
      86: if_icmpge     96
      89: aload_1
      90: iload         6
      92: iaload
      93: goto          98
      96: ldc           #39                 // int 2147483647
      98: istore        8
     100: iload         7
     102: aload_3
     103: arraylength
     104: if_icmpge     114
     107: aload_3
     108: iload         7
     110: iaload
     111: goto          116
     114: ldc           #39                 // int 2147483647
     116: istore        9
     118: iload         8
     120: iload         9
     122: if_icmpge     149
     125: aload_0
     126: aload_1
     127: iload_2
     128: iload         5
     130: iconst_2
     131: idiv
     132: iadd
     133: aload_3
     134: iload         4
     136: iload         5
     138: iload         5
     140: iconst_2
     141: idiv
     142: isub
     143: invokevirtual #27                 // Method fix:([II[III)I
     146: goto          170
     149: aload_0
     150: aload_1
     151: iload_2
     152: aload_3
     153: iload         4
     155: iload         5
     157: iconst_2
     158: idiv
     159: iadd
     160: iload         5
     162: iload         5
     164: iconst_2
     165: idiv
     166: isub
     167: invokevirtual #27                 // Method fix:([II[III)I
     170: ireturn
}

Compiled from "Solution.kt"
public final class _004.kotlin.SolutionKt {
  public static final void main(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String args
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #17                 // class _004/kotlin/Solution
       9: dup
      10: invokespecial #21                 // Method _004/kotlin/Solution."<init>":()V
      13: astore_1
      14: aload_1
      15: iconst_1
      16: newarray       int
      18: astore_2
      19: aload_2
      20: iconst_0
      21: iconst_2
      22: iastore
      23: aload_2
      24: iconst_1
      25: newarray       int
      27: astore_2
      28: aload_2
      29: iconst_0
      30: iconst_0
      31: iastore
      32: aload_2
      33: invokevirtual #25                 // Method _004/kotlin/Solution.findMedianSortedArrays:([I[I)D
      36: dstore_2
      37: getstatic     #31                 // Field java/lang/System.out:Ljava/io/PrintStream;
      40: dload_2
      41: invokevirtual #37                 // Method java/io/PrintStream.println:(D)V
      44: aload_1
      45: iconst_2
      46: newarray       int
      48: astore_2
      49: aload_2
      50: iconst_0
      51: iconst_1
      52: iastore
      53: aload_2
      54: iconst_1
      55: iconst_2
      56: iastore
      57: aload_2
      58: iconst_2
      59: newarray       int
      61: astore_2
      62: aload_2
      63: iconst_0
      64: iconst_3
      65: iastore
      66: aload_2
      67: iconst_1
      68: iconst_4
      69: iastore
      70: aload_2
      71: invokevirtual #25                 // Method _004/kotlin/Solution.findMedianSortedArrays:([I[I)D
      74: dstore_2
      75: getstatic     #31                 // Field java/lang/System.out:Ljava/io/PrintStream;
      78: dload_2
      79: invokevirtual #37                 // Method java/io/PrintStream.println:(D)V
      82: aload_1
      83: iconst_2
      84: newarray       int
      86: astore_2
      87: aload_2
      88: iconst_0
      89: iconst_1
      90: iastore
      91: aload_2
      92: iconst_1
      93: iconst_2
      94: iastore
      95: aload_2
      96: iconst_2
      97: newarray       int
      99: astore_2
     100: aload_2
     101: iconst_0
     102: iconst_m1
     103: iastore
     104: aload_2
     105: iconst_1
     106: iconst_3
     107: iastore
     108: aload_2
     109: invokevirtual #25                 // Method _004/kotlin/Solution.findMedianSortedArrays:([I[I)D
     112: dstore_2
     113: getstatic     #31                 // Field java/lang/System.out:Ljava/io/PrintStream;
     116: dload_2
     117: invokevirtual #37                 // Method java/io/PrintStream.println:(D)V
     120: return
}