import kotlin.math.pow

data class Modifier(val op: Char, val value: Int)
data class Condition(val divisibleBy: Int, val ifTrue: Int, val ifFalse: Int)
data class Monkey(
    val index: Int,
    val queue: MutableList<Long>,
    val modifier: Modifier,
    val condition: Condition,
    var inspectionCount: Long
)

fun main() {
    fun parse(input: List<String>): List<Monkey> {
        val chunks = input.chunked(7)
        return chunks.map { it ->
            val index = it[0].toInt()
            val items = it[1].split(',').map { x -> x.toLong() }.toMutableList()
            val modifierParts = it[2].split(' ')
            val modifier = Modifier(modifierParts[0][0], modifierParts[1].toInt())
            val divisibleBy = it[3].toInt()
            val ifTrue = it[4].toInt()
            val ifFalse = it[5].toInt()
            val condition = Condition(divisibleBy, ifTrue, ifFalse)

            Monkey(index, items, modifier, condition, 0)
        }
    }

    fun applyModifier(value: Long, modifier: Modifier): Long {
        return when (modifier.op) {
            '^' -> value.toDouble().pow(modifier.value.toDouble()).toLong()
            '+' -> value + modifier.value
            '*' -> value * modifier.value
            else -> throw RuntimeException("Unknown modifier $modifier")
        }
    }

    fun applyCondition(value: Long, condition: Condition): Int {
        return if (value % condition.divisibleBy == 0L) condition.ifTrue else condition.ifFalse
    }

    fun printState(monkeys: List<Monkey>) {
        for (monkey in monkeys) {
            println("Monkey ${monkey.index}: ${monkey.queue}")
        }
    }

    fun printCounts(monkeys: List<Monkey>) {
        for (monkey in monkeys) {
            println("Monkey ${monkey.index}: ${monkey.inspectionCount}")
        }
    }

    fun play(monkeys: List<Monkey>, iterationsCount: Int, worryReducer: (v: Long) -> Long) {
        val overflowBreaker = monkeys.map { it.condition.divisibleBy }.reduce { acc, i -> acc * i }
        for (i in 1..iterationsCount) {
            for (monkey in monkeys) {
                for (item in monkey.queue) {
                    val worryLevel = applyModifier(item, monkey.modifier)
                    val newLevel = worryReducer(worryLevel) % overflowBreaker
                    val newIndex = applyCondition(newLevel, monkey.condition)
                    monkeys[newIndex].queue.add(newLevel)
                    ++monkey.inspectionCount
                }
                monkey.queue.clear()
            }

            if (i % 20 == 0){
                println("Iteration $i")
                printCounts(monkeys)
                println()
            }
        }
    }

    fun calculateResult(monkeys: List<Monkey>): Long {
        val ordered = monkeys.sortedBy { -it.inspectionCount }
        return ordered[0].inspectionCount * ordered[1].inspectionCount
    }

    fun part1(input: List<String>): Long {
        val monkeys = parse(input)
        play(monkeys, 20) { x -> x / 3 }
        return calculateResult(monkeys)
    }

    fun part2(input: List<String>): Long {
        val monkeys = parse(input)
        play(monkeys, 10000) { x -> x }
        return calculateResult(monkeys)
    }

    val testInput = readInput("Day11_test")
    assert(part1(testInput), 10605L)
    assert(part2(testInput), 2713310158L)

    val input = readInput("Day11")
    println(part1(input))
    println(part2(input))
}

Compiled from "Comparisons.kt"
public final class Day11Kt$main$calculateResult$$inlined$sortedBy$1<T> implements java.util.Comparator {
  public Day11Kt$main$calculateResult$$inlined$sortedBy$1();
    Code:
       0: aload_0
       1: invokespecial #16                 // Method java/lang/Object."<init>":()V
       4: return

  public final int compare(T, T);
    Code:
       0: aload_1
       1: checkcast     #23                 // class Monkey
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokevirtual #27                 // Method Monkey.getInspectionCount:()J
      12: lneg
      13: invokestatic  #33                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      16: checkcast     #35                 // class java/lang/Comparable
      19: aload_2
      20: checkcast     #23                 // class Monkey
      23: astore_3
      24: astore        5
      26: iconst_0
      27: istore        4
      29: aload_3
      30: invokevirtual #27                 // Method Monkey.getInspectionCount:()J
      33: lneg
      34: invokestatic  #33                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      37: aload         5
      39: swap
      40: checkcast     #35                 // class java/lang/Comparable
      43: invokestatic  #41                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      46: ireturn
}

Compiled from "Day11.kt"
public final class Day11Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Day11_test
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)J
      10: invokestatic  #24                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      13: ldc2_w        #25                 // long 10605l
      16: invokestatic  #24                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      19: invokestatic  #30                 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V
      22: aload_0
      23: invokestatic  #33                 // Method main$part2:(Ljava/util/List;)J
      26: invokestatic  #24                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      29: ldc2_w        #34                 // long 2713310158l
      32: invokestatic  #24                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      35: invokestatic  #30                 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V
      38: ldc           #37                 // String Day11
      40: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      43: astore_1
      44: aload_1
      45: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)J
      48: lstore_2
      49: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      52: lload_2
      53: invokevirtual #49                 // Method java/io/PrintStream.println:(J)V
      56: aload_1
      57: invokestatic  #33                 // Method main$part2:(Ljava/util/List;)J
      60: lstore_2
      61: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      64: lload_2
      65: invokevirtual #49                 // Method java/io/PrintStream.println:(J)V
      68: return

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

  private static final java.util.List<Monkey> main$parse(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #62                 // class java/lang/Iterable
       4: bipush        7
       6: invokestatic  #68                 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;
       9: astore_1
      10: aload_1
      11: checkcast     #62                 // class java/lang/Iterable
      14: astore_2
      15: iconst_0
      16: istore_3
      17: aload_2
      18: astore        4
      20: new           #70                 // class java/util/ArrayList
      23: dup
      24: aload_2
      25: bipush        10
      27: invokestatic  #74                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      30: invokespecial #78                 // Method java/util/ArrayList."<init>":(I)V
      33: checkcast     #80                 // class java/util/Collection
      36: astore        5
      38: iconst_0
      39: istore        6
      41: aload         4
      43: invokeinterface #84,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      48: astore        7
      50: aload         7
      52: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      57: ifeq          405
      60: aload         7
      62: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      67: astore        8
      69: aload         5
      71: aload         8
      73: checkcast     #96                 // class java/util/List
      76: astore        9
      78: astore        23
      80: iconst_0
      81: istore        10
      83: aload         9
      85: iconst_0
      86: invokeinterface #100,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      91: checkcast     #102                // class java/lang/String
      94: invokestatic  #108                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      97: istore        11
      99: aload         9
     101: iconst_1
     102: invokeinterface #100,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     107: checkcast     #110                // class java/lang/CharSequence
     110: iconst_1
     111: newarray       char
     113: astore        12
     115: aload         12
     117: iconst_0
     118: bipush        44
     120: castore
     121: aload         12
     123: iconst_0
     124: iconst_0
     125: bipush        6
     127: aconst_null
     128: invokestatic  #116                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;
     131: checkcast     #62                 // class java/lang/Iterable
     134: astore        12
     136: iconst_0
     137: istore        13
     139: aload         12
     141: astore        14
     143: new           #70                 // class java/util/ArrayList
     146: dup
     147: aload         12
     149: bipush        10
     151: invokestatic  #74                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     154: invokespecial #78                 // Method java/util/ArrayList."<init>":(I)V
     157: checkcast     #80                 // class java/util/Collection
     160: astore        15
     162: iconst_0
     163: istore        16
     165: aload         14
     167: invokeinterface #84,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     172: astore        17
     174: aload         17
     176: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     181: ifeq          228
     184: aload         17
     186: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     191: astore        18
     193: aload         15
     195: aload         18
     197: checkcast     #102                // class java/lang/String
     200: astore        19
     202: astore        20
     204: iconst_0
     205: istore        21
     207: aload         19
     209: invokestatic  #120                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     212: nop
     213: invokestatic  #24                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     216: aload         20
     218: swap
     219: invokeinterface #124,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     224: pop
     225: goto          174
     228: aload         15
     230: checkcast     #96                 // class java/util/List
     233: nop
     234: checkcast     #80                 // class java/util/Collection
     237: invokestatic  #128                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     240: astore        22
     242: aload         9
     244: iconst_2
     245: invokeinterface #100,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     250: checkcast     #110                // class java/lang/CharSequence
     253: iconst_1
     254: newarray       char
     256: astore        13
     258: aload         13
     260: iconst_0
     261: bipush        32
     263: castore
     264: aload         13
     266: iconst_0
     267: iconst_0
     268: bipush        6
     270: aconst_null
     271: invokestatic  #116                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;
     274: astore        12
     276: new           #130                // class Modifier
     279: dup
     280: aload         12
     282: iconst_0
     283: invokeinterface #100,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     288: checkcast     #102                // class java/lang/String
     291: iconst_0
     292: invokevirtual #134                // Method java/lang/String.charAt:(I)C
     295: aload         12
     297: iconst_1
     298: invokeinterface #100,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     303: checkcast     #102                // class java/lang/String
     306: invokestatic  #108                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     309: invokespecial #137                // Method Modifier."<init>":(CI)V
     312: astore        13
     314: aload         9
     316: iconst_3
     317: invokeinterface #100,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     322: checkcast     #102                // class java/lang/String
     325: invokestatic  #108                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     328: istore        14
     330: aload         9
     332: iconst_4
     333: invokeinterface #100,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     338: checkcast     #102                // class java/lang/String
     341: invokestatic  #108                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     344: istore        15
     346: aload         9
     348: iconst_5
     349: invokeinterface #100,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     354: checkcast     #102                // class java/lang/String
     357: invokestatic  #108                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     360: istore        16
     362: new           #139                // class Condition
     365: dup
     366: iload         14
     368: iload         15
     370: iload         16
     372: invokespecial #142                // Method Condition."<init>":(III)V
     375: astore        17
     377: new           #144                // class Monkey
     380: dup
     381: iload         11
     383: aload         22
     385: aload         13
     387: aload         17
     389: lconst_0
     390: invokespecial #147                // Method Monkey."<init>":(ILjava/util/List;LModifier;LCondition;J)V
     393: aload         23
     395: swap
     396: invokeinterface #124,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     401: pop
     402: goto          50
     405: aload         5
     407: checkcast     #96                 // class java/util/List
     410: nop
     411: areturn

  private static final long main$applyModifier(long, Modifier);
    Code:
       0: aload_2
       1: invokevirtual #179                // Method Modifier.getOp:()C
       4: lookupswitch  { // 3
                    42: 64
                    43: 54
                    94: 40
               default: 74
          }
      40: lload_0
      41: l2d
      42: aload_2
      43: invokevirtual #183                // Method Modifier.getValue:()I
      46: i2d
      47: invokestatic  #189                // Method java/lang/Math.pow:(DD)D
      50: d2l
      51: goto          101
      54: lload_0
      55: aload_2
      56: invokevirtual #183                // Method Modifier.getValue:()I
      59: i2l
      60: ladd
      61: goto          101
      64: lload_0
      65: aload_2
      66: invokevirtual #183                // Method Modifier.getValue:()I
      69: i2l
      70: lmul
      71: goto          101
      74: new           #191                // class java/lang/RuntimeException
      77: dup
      78: new           #193                // class java/lang/StringBuilder
      81: dup
      82: invokespecial #195                // Method java/lang/StringBuilder."<init>":()V
      85: ldc           #197                // String Unknown modifier
      87: invokevirtual #201                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      90: aload_2
      91: invokevirtual #204                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      94: invokevirtual #208                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      97: invokespecial #211                // Method java/lang/RuntimeException."<init>":(Ljava/lang/String;)V
     100: athrow
     101: lreturn

  private static final int main$applyCondition(long, Condition);
    Code:
       0: lload_0
       1: aload_2
       2: invokevirtual #218                // Method Condition.getDivisibleBy:()I
       5: i2l
       6: lrem
       7: lconst_0
       8: lcmp
       9: ifne          19
      12: aload_2
      13: invokevirtual #221                // Method Condition.getIfTrue:()I
      16: goto          23
      19: aload_2
      20: invokevirtual #224                // Method Condition.getIfFalse:()I
      23: ireturn

  private static final void main$printState(java.util.List<Monkey>);
    Code:
       0: aload_0
       1: invokeinterface #228,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
       6: astore_1
       7: aload_1
       8: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      13: ifeq          70
      16: aload_1
      17: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      22: checkcast     #144                // class Monkey
      25: astore_2
      26: new           #193                // class java/lang/StringBuilder
      29: dup
      30: invokespecial #195                // Method java/lang/StringBuilder."<init>":()V
      33: ldc           #230                // String Monkey
      35: invokevirtual #201                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      38: aload_2
      39: invokevirtual #233                // Method Monkey.getIndex:()I
      42: invokevirtual #236                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      45: ldc           #238                // String :
      47: invokevirtual #201                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      50: aload_2
      51: invokevirtual #242                // Method Monkey.getQueue:()Ljava/util/List;
      54: invokevirtual #204                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      57: invokevirtual #208                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      60: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      63: swap
      64: invokevirtual #245                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      67: goto          7
      70: return

  private static final void main$printCounts(java.util.List<Monkey>);
    Code:
       0: aload_0
       1: invokeinterface #228,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
       6: astore_1
       7: aload_1
       8: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      13: ifeq          70
      16: aload_1
      17: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      22: checkcast     #144                // class Monkey
      25: astore_2
      26: new           #193                // class java/lang/StringBuilder
      29: dup
      30: invokespecial #195                // Method java/lang/StringBuilder."<init>":()V
      33: ldc           #230                // String Monkey
      35: invokevirtual #201                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      38: aload_2
      39: invokevirtual #233                // Method Monkey.getIndex:()I
      42: invokevirtual #236                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      45: ldc           #238                // String :
      47: invokevirtual #201                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      50: aload_2
      51: invokevirtual #253                // Method Monkey.getInspectionCount:()J
      54: invokevirtual #256                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
      57: invokevirtual #208                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      60: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
      63: swap
      64: invokevirtual #245                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      67: goto          7
      70: return

  private static final void main$play(java.util.List<Monkey>, int, kotlin.jvm.functions.Function1<? super java.lang.Long, java.lang.Long>);
    Code:
       0: aload_0
       1: checkcast     #62                 // class java/lang/Iterable
       4: astore        4
       6: iconst_0
       7: istore        5
       9: aload         4
      11: astore        6
      13: new           #70                 // class java/util/ArrayList
      16: dup
      17: aload         4
      19: bipush        10
      21: invokestatic  #74                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      24: invokespecial #78                 // Method java/util/ArrayList."<init>":(I)V
      27: checkcast     #80                 // class java/util/Collection
      30: astore        7
      32: iconst_0
      33: istore        8
      35: aload         6
      37: invokeinterface #84,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        9
      44: aload         9
      46: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          100
      54: aload         9
      56: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        10
      63: aload         7
      65: aload         10
      67: checkcast     #144                // class Monkey
      70: astore        11
      72: astore        15
      74: iconst_0
      75: istore        12
      77: aload         11
      79: invokevirtual #263                // Method Monkey.getCondition:()LCondition;
      82: invokevirtual #218                // Method Condition.getDivisibleBy:()I
      85: invokestatic  #266                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      88: aload         15
      90: swap
      91: invokeinterface #124,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      96: pop
      97: goto          44
     100: aload         7
     102: checkcast     #96                 // class java/util/List
     105: nop
     106: checkcast     #62                 // class java/lang/Iterable
     109: astore        4
     111: nop
     112: iconst_0
     113: istore        5
     115: aload         4
     117: invokeinterface #84,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     122: astore        6
     124: aload         6
     126: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     131: ifne          145
     134: new           #268                // class java/lang/UnsupportedOperationException
     137: dup
     138: ldc_w         #270                // String Empty collection can\'t be reduced.
     141: invokespecial #271                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     144: athrow
     145: aload         6
     147: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     152: astore        7
     154: aload         6
     156: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     161: ifeq          205
     164: aload         7
     166: aload         6
     168: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     173: checkcast     #273                // class java/lang/Number
     176: invokevirtual #276                // Method java/lang/Number.intValue:()I
     179: istore        8
     181: checkcast     #273                // class java/lang/Number
     184: invokevirtual #276                // Method java/lang/Number.intValue:()I
     187: istore        9
     189: iconst_0
     190: istore        10
     192: iload         9
     194: iload         8
     196: imul
     197: invokestatic  #266                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     200: astore        7
     202: goto          154
     205: aload         7
     207: checkcast     #273                // class java/lang/Number
     210: invokevirtual #276                // Method java/lang/Number.intValue:()I
     213: istore_3
     214: iconst_1
     215: istore        4
     217: iload         4
     219: iload_1
     220: if_icmpgt     453
     223: aload_0
     224: invokeinterface #228,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     229: astore        5
     231: aload         5
     233: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     238: ifeq          395
     241: aload         5
     243: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     248: checkcast     #144                // class Monkey
     251: astore        6
     253: aload         6
     255: invokevirtual #242                // Method Monkey.getQueue:()Ljava/util/List;
     258: invokeinterface #228,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     263: astore        7
     265: aload         7
     267: invokeinterface #90,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     272: ifeq          382
     275: aload         7
     277: invokeinterface #94,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     282: checkcast     #273                // class java/lang/Number
     285: invokevirtual #279                // Method java/lang/Number.longValue:()J
     288: lstore        8
     290: lload         8
     292: aload         6
     294: invokevirtual #283                // Method Monkey.getModifier:()LModifier;
     297: invokestatic  #285                // Method main$applyModifier:(JLModifier;)J
     300: lstore        10
     302: aload_2
     303: lload         10
     305: invokestatic  #24                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     308: invokeinterface #291,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
     313: checkcast     #273                // class java/lang/Number
     316: invokevirtual #279                // Method java/lang/Number.longValue:()J
     319: iload_3
     320: i2l
     321: lrem
     322: lstore        12
     324: lload         12
     326: aload         6
     328: invokevirtual #263                // Method Monkey.getCondition:()LCondition;
     331: invokestatic  #293                // Method main$applyCondition:(JLCondition;)I
     334: istore        14
     336: aload_0
     337: iload         14
     339: invokeinterface #100,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     344: checkcast     #144                // class Monkey
     347: invokevirtual #242                // Method Monkey.getQueue:()Ljava/util/List;
     350: lload         12
     352: invokestatic  #24                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     355: invokeinterface #294,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     360: pop
     361: aload         6
     363: aload         6
     365: invokevirtual #253                // Method Monkey.getInspectionCount:()J
     368: lconst_1
     369: ladd
     370: invokevirtual #297                // Method Monkey.setInspectionCount:(J)V
     373: aload         6
     375: invokevirtual #253                // Method Monkey.getInspectionCount:()J
     378: pop2
     379: goto          265
     382: aload         6
     384: invokevirtual #242                // Method Monkey.getQueue:()Ljava/util/List;
     387: invokeinterface #300,  1          // InterfaceMethod java/util/List.clear:()V
     392: goto          231
     395: iload         4
     397: bipush        20
     399: irem
     400: ifne          441
     403: new           #193                // class java/lang/StringBuilder
     406: dup
     407: invokespecial #195                // Method java/lang/StringBuilder."<init>":()V
     410: ldc_w         #302                // String Iteration
     413: invokevirtual #201                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     416: iload         4
     418: invokevirtual #236                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     421: invokevirtual #208                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     424: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
     427: swap
     428: invokevirtual #245                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     431: aload_0
     432: invokestatic  #304                // Method main$printCounts:(Ljava/util/List;)V
     435: getstatic     #43                 // Field java/lang/System.out:Ljava/io/PrintStream;
     438: invokevirtual #306                // Method java/io/PrintStream.println:()V
     441: iload         4
     443: iload_1
     444: if_icmpeq     453
     447: iinc          4, 1
     450: goto          223
     453: return

  private static final long main$calculateResult(java.util.List<Monkey>);
    Code:
       0: aload_0
       1: checkcast     #62                 // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: new           #327                // class Day11Kt$main$calculateResult$$inlined$sortedBy$1
      11: dup
      12: invokespecial #328                // Method Day11Kt$main$calculateResult$$inlined$sortedBy$1."<init>":()V
      15: checkcast     #330                // class java/util/Comparator
      18: invokestatic  #334                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
      21: astore_1
      22: aload_1
      23: iconst_0
      24: invokeinterface #100,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      29: checkcast     #144                // class Monkey
      32: invokevirtual #253                // Method Monkey.getInspectionCount:()J
      35: aload_1
      36: iconst_1
      37: invokeinterface #100,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      42: checkcast     #144                // class Monkey
      45: invokevirtual #253                // Method Monkey.getInspectionCount:()J
      48: lmul
      49: lreturn

  private static final long main$part1$lambda$5(long);
    Code:
       0: lload_0
       1: iconst_3
       2: i2l
       3: ldiv
       4: lreturn

  private static final long main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #342                // Method main$parse:(Ljava/util/List;)Ljava/util/List;
       4: astore_1
       5: aload_1
       6: bipush        20
       8: invokedynamic #358,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      13: invokestatic  #360                // Method main$play:(Ljava/util/List;ILkotlin/jvm/functions/Function1;)V
      16: aload_1
      17: invokestatic  #362                // Method main$calculateResult:(Ljava/util/List;)J
      20: lreturn

  private static final long main$part2$lambda$6(long);
    Code:
       0: lload_0
       1: lreturn

  private static final long main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #342                // Method main$parse:(Ljava/util/List;)Ljava/util/List;
       4: astore_1
       5: aload_1
       6: sipush        10000
       9: invokedynamic #367,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
      14: invokestatic  #360                // Method main$play:(Ljava/util/List;ILkotlin/jvm/functions/Function1;)V
      17: aload_1
      18: invokestatic  #362                // Method main$calculateResult:(Ljava/util/List;)J
      21: lreturn
}


class Operation(val cycles: Int, val add: Int)

fun main() {
    fun parse(input: List<String>): List<Operation> {
        return input.map { line ->
            if (line == "noop") {
                Operation(1, 0)
            } else {
                val modifier = line.split(' ')[1].toInt()
                Operation(2, modifier)
            }
        }
    }

    fun part1(input: List<String>): Long {
        val ops = parse(input)

        var x = 1
        var result = 0L
        val maxIndex = 220
        var seekIndex = 20
        val hop = 40
        var cycleCounter = 0
        for (op in ops) {
            for (cycle in 1..op.cycles) {
                ++cycleCounter
                if (cycleCounter == seekIndex) {
                    result += x * seekIndex
                    if (seekIndex == maxIndex) {
                        return result
                    }
                    seekIndex += hop
                }
            }
            x += op.add
        }

        return result
    }

    fun isSprite(cycleCounter: Int, x: Int, lineIndex: Int, hop: Int): Boolean {
        val lineValue = cycleCounter - (hop * lineIndex)
        return lineValue >= x - 1 && lineValue <= x + 1
    }

    fun part2(input: List<String>): Long {
        val ops = parse(input)

        var x = 1
        var lineIndex = 0
        val maxIndex = 240
        var seekIndex = 40
        val hop = 40
        var cycleCounter = 0
        for (op in ops) {
            for (cycle in 1..op.cycles) {
                if (isSprite(cycleCounter, x, lineIndex, hop)) {
                    print("#")
                } else {
                    print(".")
                }

                ++cycleCounter
                if (cycleCounter == seekIndex) {
                    println()

                    if (seekIndex == maxIndex) {
                        return 0
                    }
                    seekIndex += hop
                    ++lineIndex
                }
            }
            x += op.add
        }

        return 0
    }

    val testInput = readInput("Day10_test")
    assert(part1(testInput), 13140L)

    val input = readInput("Day10")
    println(part1(input))
    println(part2(input))
}

Compiled from "Day10.kt"
public final class Day10Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Day10_test
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)J
      10: invokestatic  #24                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      13: ldc2_w        #25                 // long 13140l
      16: invokestatic  #24                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      19: invokestatic  #30                 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V
      22: ldc           #32                 // String Day10
      24: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      27: astore_1
      28: aload_1
      29: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)J
      32: lstore_2
      33: getstatic     #38                 // Field java/lang/System.out:Ljava/io/PrintStream;
      36: lload_2
      37: invokevirtual #44                 // Method java/io/PrintStream.println:(J)V
      40: aload_1
      41: invokestatic  #47                 // Method main$part2:(Ljava/util/List;)J
      44: lstore_2
      45: getstatic     #38                 // Field java/lang/System.out:Ljava/io/PrintStream;
      48: lload_2
      49: invokevirtual #44                 // Method java/io/PrintStream.println:(J)V
      52: return

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

  private static final java.util.List<Operation> main$parse(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #60                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: astore_3
       9: new           #62                 // class java/util/ArrayList
      12: dup
      13: aload_1
      14: bipush        10
      16: invokestatic  #68                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      19: invokespecial #72                 // Method java/util/ArrayList."<init>":(I)V
      22: checkcast     #74                 // class java/util/Collection
      25: astore        4
      27: iconst_0
      28: istore        5
      30: aload_3
      31: invokeinterface #78,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      36: astore        6
      38: aload         6
      40: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      45: ifeq          156
      48: aload         6
      50: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      55: astore        7
      57: aload         4
      59: aload         7
      61: checkcast     #90                 // class java/lang/String
      64: astore        8
      66: astore        12
      68: iconst_0
      69: istore        9
      71: aload         8
      73: ldc           #92                 // String noop
      75: invokestatic  #98                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      78: ifeq          93
      81: new           #100                // class Operation
      84: dup
      85: iconst_1
      86: iconst_0
      87: invokespecial #103                // Method Operation."<init>":(II)V
      90: goto          143
      93: aload         8
      95: checkcast     #105                // class java/lang/CharSequence
      98: iconst_1
      99: newarray       char
     101: astore        10
     103: aload         10
     105: iconst_0
     106: bipush        32
     108: castore
     109: aload         10
     111: iconst_0
     112: iconst_0
     113: bipush        6
     115: aconst_null
     116: invokestatic  #111                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;
     119: iconst_1
     120: invokeinterface #117,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     125: checkcast     #90                 // class java/lang/String
     128: invokestatic  #123                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     131: istore        11
     133: new           #100                // class Operation
     136: dup
     137: iconst_2
     138: iload         11
     140: invokespecial #103                // Method Operation."<init>":(II)V
     143: nop
     144: aload         12
     146: swap
     147: invokeinterface #127,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     152: pop
     153: goto          38
     156: aload         4
     158: checkcast     #113                // class java/util/List
     161: nop
     162: areturn

  private static final long main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #144                // Method main$parse:(Ljava/util/List;)Ljava/util/List;
       4: astore_1
       5: iconst_1
       6: istore_2
       7: lconst_0
       8: lstore_3
       9: sipush        220
      12: istore        5
      14: bipush        20
      16: istore        6
      18: bipush        40
      20: istore        7
      22: iconst_0
      23: istore        8
      25: aload_1
      26: invokeinterface #145,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      31: astore        9
      33: aload         9
      35: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      40: ifeq          130
      43: aload         9
      45: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      50: checkcast     #100                // class Operation
      53: astore        10
      55: iconst_1
      56: istore        11
      58: aload         10
      60: invokevirtual #149                // Method Operation.getCycles:()I
      63: istore        12
      65: iload         11
      67: iload         12
      69: if_icmpgt     119
      72: iinc          8, 1
      75: iload         8
      77: iload         6
      79: if_icmpne     106
      82: lload_3
      83: iload_2
      84: iload         6
      86: imul
      87: i2l
      88: ladd
      89: lstore_3
      90: iload         6
      92: iload         5
      94: if_icmpne     99
      97: lload_3
      98: lreturn
      99: iload         6
     101: iload         7
     103: iadd
     104: istore        6
     106: iload         11
     108: iload         12
     110: if_icmpeq     119
     113: iinc          11, 1
     116: goto          72
     119: iload_2
     120: aload         10
     122: invokevirtual #152                // Method Operation.getAdd:()I
     125: iadd
     126: istore_2
     127: goto          33
     130: lload_3
     131: lreturn

  private static final boolean main$isSprite(int, int, int, int);
    Code:
       0: iload_0
       1: iload_3
       2: iload_2
       3: imul
       4: isub
       5: istore        4
       7: iload         4
       9: iload_1
      10: iconst_1
      11: isub
      12: if_icmplt     27
      15: iload         4
      17: iload_1
      18: iconst_1
      19: iadd
      20: if_icmpgt     27
      23: iconst_1
      24: goto          28
      27: iconst_0
      28: ireturn

  private static final long main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #144                // Method main$parse:(Ljava/util/List;)Ljava/util/List;
       4: astore_1
       5: iconst_1
       6: istore_2
       7: iconst_0
       8: istore_3
       9: sipush        240
      12: istore        4
      14: bipush        40
      16: istore        5
      18: bipush        40
      20: istore        6
      22: iconst_0
      23: istore        7
      25: aload_1
      26: invokeinterface #145,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      31: astore        8
      33: aload         8
      35: invokeinterface #84,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      40: ifeq          164
      43: aload         8
      45: invokeinterface #88,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      50: checkcast     #100                // class Operation
      53: astore        9
      55: iconst_1
      56: istore        10
      58: aload         9
      60: invokevirtual #149                // Method Operation.getCycles:()I
      63: istore        11
      65: iload         10
      67: iload         11
      69: if_icmpgt     153
      72: iload         7
      74: iload_2
      75: iload_3
      76: iload         6
      78: invokestatic  #169                // Method main$isSprite:(IIII)Z
      81: ifeq          96
      84: ldc           #171                // String #
      86: getstatic     #38                 // Field java/lang/System.out:Ljava/io/PrintStream;
      89: swap
      90: invokevirtual #175                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
      93: goto          105
      96: ldc           #177                // String .
      98: getstatic     #38                 // Field java/lang/System.out:Ljava/io/PrintStream;
     101: swap
     102: invokevirtual #175                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     105: iinc          7, 1
     108: iload         7
     110: iload         5
     112: if_icmpne     140
     115: getstatic     #38                 // Field java/lang/System.out:Ljava/io/PrintStream;
     118: invokevirtual #179                // Method java/io/PrintStream.println:()V
     121: iload         5
     123: iload         4
     125: if_icmpne     130
     128: lconst_0
     129: lreturn
     130: iload         5
     132: iload         6
     134: iadd
     135: istore        5
     137: iinc          3, 1
     140: iload         10
     142: iload         11
     144: if_icmpeq     153
     147: iinc          10, 1
     150: goto          72
     153: iload_2
     154: aload         9
     156: invokevirtual #152                // Method Operation.getAdd:()I
     159: iadd
     160: istore_2
     161: goto          33
     164: lconst_0
     165: lreturn
}


import kotlin.math.max

class Tree(val value: Int, var visible: Boolean)

fun main() {
    fun parse(input: List<String>): List<List<Tree>> {
        return input.map { line ->
            line.toCharArray().map {
                Tree(it.digitToInt(), false)
            }
        }
    }

    fun findVisible(trees: List<List<Tree>>): Int {
        val size = trees.size
        val lastIdx = size - 1
        for (i in 0..lastIdx) {
            var maxLeft = -1
            var maxRight = -1
            for (j in 0..lastIdx) {
                val cellLeft = trees[i][j]
                if (cellLeft.value > maxLeft) {
                    cellLeft.visible = true
                    maxLeft = cellLeft.value
                }

                val cellRight = trees[i][lastIdx - j]
                if (cellRight.value > maxRight) {
                    cellRight.visible = true
                    maxRight = cellRight.value
                }
            }
        }

        for (i in 0..lastIdx) {
            var maxTop = -1
            var maxBottom = -1
            for (j in 0..lastIdx) {
                val cellTop = trees[j][i]
                if (cellTop.value > maxTop) {
                    cellTop.visible = true
                    maxTop = cellTop.value
                }

                val cellBottom = trees[lastIdx - j][i]
                if (cellBottom.value > maxBottom) {
                    cellBottom.visible = true
                    maxBottom = cellBottom.value
                }
            }
        }

        return trees.sumOf { x -> x.count { y -> y.visible } }
    }

    fun findMax(center: Int, range: IntProgression, getter: (x: Int) -> Tree): Int {
        var count = 0
        for (i in range) {
            val cell = getter(i)
            if (cell.value >= center) {
                return count + 1
            }

            ++count
        }
        return count
    }

    fun findScenic(trees: List<List<Tree>>): Int {
        val size = trees.size
        val lastIdx = size - 1
        var maxScenic = -1
        for (i in 0..lastIdx) {
            for (j in 0..lastIdx) {
                val center = trees[i][j].value

                val left = findMax(center, j - 1 downTo 0) { x -> trees[i][x] }
                val right = findMax(center, j + 1..lastIdx) { x -> trees[i][x] }
                val top = findMax(center, i - 1 downTo 0) { x -> trees[x][j] }
                val bottom = findMax(center, i + 1..lastIdx) { x -> trees[x][j] }

                val scenic = top * left * bottom * right
                maxScenic = max(scenic, maxScenic)
            }
        }

        return maxScenic
    }

    fun part1(input: List<String>): Int {
        val trees = parse(input)
        return findVisible(trees)
    }

    fun part2(input: List<String>): Int {
        val trees = parse(input)
        return findScenic(trees)
    }

    val testInput = readInput("Day08_test")
    assert(part1(testInput), 21)
    assert(part2(testInput), 8)

    val input = readInput("Day08")
    println(part1(input))
    println(part2(input))
}

Compiled from "Day08.kt"
public final class Day08Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String Day08_test
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)I
      10: invokestatic  #24                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      13: bipush        21
      15: invokestatic  #24                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      18: invokestatic  #28                 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V
      21: aload_0
      22: invokestatic  #31                 // Method main$part2:(Ljava/util/List;)I
      25: invokestatic  #24                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      28: bipush        8
      30: invokestatic  #24                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      33: invokestatic  #28                 // Method UtilsKt.assert:(Ljava/lang/Object;Ljava/lang/Object;)V
      36: ldc           #33                 // String Day08
      38: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      41: astore_1
      42: aload_1
      43: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)I
      46: istore_2
      47: getstatic     #39                 // Field java/lang/System.out:Ljava/io/PrintStream;
      50: iload_2
      51: invokevirtual #45                 // Method java/io/PrintStream.println:(I)V
      54: aload_1
      55: invokestatic  #31                 // Method main$part2:(Ljava/util/List;)I
      58: istore_2
      59: getstatic     #39                 // Field java/lang/System.out:Ljava/io/PrintStream;
      62: iload_2
      63: invokevirtual #45                 // Method java/io/PrintStream.println:(I)V
      66: return

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

  private static final java.util.List<java.util.List<Tree>> main$parse(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #58                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: astore_3
       9: new           #60                 // class java/util/ArrayList
      12: dup
      13: aload_1
      14: bipush        10
      16: invokestatic  #66                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      19: invokespecial #69                 // Method java/util/ArrayList."<init>":(I)V
      22: checkcast     #71                 // class java/util/Collection
      25: astore        4
      27: iconst_0
      28: istore        5
      30: aload_3
      31: invokeinterface #75,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      36: astore        6
      38: aload         6
      40: invokeinterface #81,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      45: ifeq          190
      48: aload         6
      50: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      55: astore        7
      57: aload         4
      59: aload         7
      61: checkcast     #87                 // class java/lang/String
      64: astore        8
      66: astore        21
      68: iconst_0
      69: istore        9
      71: aload         8
      73: invokevirtual #91                 // Method java/lang/String.toCharArray:()[C
      76: dup
      77: ldc           #93                 // String toCharArray(...)
      79: invokestatic  #99                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      82: astore        10
      84: nop
      85: iconst_0
      86: istore        11
      88: aload         10
      90: astore        12
      92: new           #60                 // class java/util/ArrayList
      95: dup
      96: aload         10
      98: arraylength
      99: invokespecial #69                 // Method java/util/ArrayList."<init>":(I)V
     102: checkcast     #71                 // class java/util/Collection
     105: astore        13
     107: iconst_0
     108: istore        14
     110: iconst_0
     111: istore        15
     113: aload         12
     115: arraylength
     116: istore        16
     118: iload         15
     120: iload         16
     122: if_icmpge     171
     125: aload         12
     127: iload         15
     129: caload
     130: istore        17
     132: aload         13
     134: iload         17
     136: istore        18
     138: astore        19
     140: iconst_0
     141: istore        20
     143: new           #101                // class Tree
     146: dup
     147: iload         18
     149: invokestatic  #107                // Method kotlin/text/CharsKt.digitToInt:(C)I
     152: iconst_0
     153: invokespecial #110                // Method Tree."<init>":(IZ)V
     156: aload         19
     158: swap
     159: invokeinterface #114,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     164: pop
     165: iinc          15, 1
     168: goto          118
     171: aload         13
     173: checkcast     #116                // class java/util/List
     176: nop
     177: nop
     178: aload         21
     180: swap
     181: invokeinterface #114,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     186: pop
     187: goto          38
     190: aload         4
     192: checkcast     #116                // class java/util/List
     195: nop
     196: areturn

  private static final int main$findVisible(java.util.List<? extends java.util.List<Tree>>);
    Code:
       0: aload_0
       1: invokeinterface #140,  1          // InterfaceMethod java/util/List.size:()I
       6: istore_1
       7: iload_1
       8: iconst_1
       9: isub
      10: istore_2
      11: iconst_0
      12: istore_3
      13: iload_3
      14: iload_2
      15: if_icmpgt     148
      18: iconst_m1
      19: istore        4
      21: iconst_m1
      22: istore        5
      24: iconst_0
      25: istore        6
      27: iload         6
      29: iload_2
      30: if_icmpgt     137
      33: aload_0
      34: iload_3
      35: invokeinterface #144,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      40: checkcast     #116                // class java/util/List
      43: iload         6
      45: invokeinterface #144,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      50: checkcast     #101                // class Tree
      53: astore        7
      55: aload         7
      57: invokevirtual #147                // Method Tree.getValue:()I
      60: iload         4
      62: if_icmple     78
      65: aload         7
      67: iconst_1
      68: invokevirtual #151                // Method Tree.setVisible:(Z)V
      71: aload         7
      73: invokevirtual #147                // Method Tree.getValue:()I
      76: istore        4
      78: aload_0
      79: iload_3
      80: invokeinterface #144,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      85: checkcast     #116                // class java/util/List
      88: iload_2
      89: iload         6
      91: isub
      92: invokeinterface #144,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      97: checkcast     #101                // class Tree
     100: astore        8
     102: aload         8
     104: invokevirtual #147                // Method Tree.getValue:()I
     107: iload         5
     109: if_icmple     125
     112: aload         8
     114: iconst_1
     115: invokevirtual #151                // Method Tree.setVisible:(Z)V
     118: aload         8
     120: invokevirtual #147                // Method Tree.getValue:()I
     123: istore        5
     125: iload         6
     127: iload_2
     128: if_icmpeq     137
     131: iinc          6, 1
     134: goto          33
     137: iload_3
     138: iload_2
     139: if_icmpeq     148
     142: iinc          3, 1
     145: goto          18
     148: iconst_0
     149: istore_3
     150: iload_3
     151: iload_2
     152: if_icmpgt     285
     155: iconst_m1
     156: istore        4
     158: iconst_m1
     159: istore        5
     161: iconst_0
     162: istore        6
     164: iload         6
     166: iload_2
     167: if_icmpgt     274
     170: aload_0
     171: iload         6
     173: invokeinterface #144,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     178: checkcast     #116                // class java/util/List
     181: iload_3
     182: invokeinterface #144,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     187: checkcast     #101                // class Tree
     190: astore        7
     192: aload         7
     194: invokevirtual #147                // Method Tree.getValue:()I
     197: iload         4
     199: if_icmple     215
     202: aload         7
     204: iconst_1
     205: invokevirtual #151                // Method Tree.setVisible:(Z)V
     208: aload         7
     210: invokevirtual #147                // Method Tree.getValue:()I
     213: istore        4
     215: aload_0
     216: iload_2
     217: iload         6
     219: isub
     220: invokeinterface #144,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     225: checkcast     #116                // class java/util/List
     228: iload_3
     229: invokeinterface #144,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     234: checkcast     #101                // class Tree
     237: astore        8
     239: aload         8
     241: invokevirtual #147                // Method Tree.getValue:()I
     244: iload         5
     246: if_icmple     262
     249: aload         8
     251: iconst_1
     252: invokevirtual #151                // Method Tree.setVisible:(Z)V
     255: aload         8
     257: invokevirtual #147                // Method Tree.getValue:()I
     260: istore        5
     262: iload         6
     264: iload_2
     265: if_icmpeq     274
     268: iinc          6, 1
     271: goto          170
     274: iload_3
     275: iload_2
     276: if_icmpeq     285
     279: iinc          3, 1
     282: goto          155
     285: aload_0
     286: checkcast     #58                 // class java/lang/Iterable
     289: astore_3
     290: iconst_0
     291: istore        4
     293: aload_3
     294: invokeinterface #75,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     299: astore        5
     301: aload         5
     303: invokeinterface #81,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     308: ifeq          447
     311: aload         5
     313: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     318: astore        6
     320: iload         4
     322: aload         6
     324: checkcast     #116                // class java/util/List
     327: astore        7
     329: istore        16
     331: iconst_0
     332: istore        8
     334: aload         7
     336: checkcast     #58                 // class java/lang/Iterable
     339: astore        9
     341: iconst_0
     342: istore        10
     344: aload         9
     346: instanceof    #71                 // class java/util/Collection
     349: ifeq          369
     352: aload         9
     354: checkcast     #71                 // class java/util/Collection
     357: invokeinterface #154,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     362: ifeq          369
     365: iconst_0
     366: goto          434
     369: iconst_0
     370: istore        11
     372: aload         9
     374: invokeinterface #75,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     379: astore        12
     381: aload         12
     383: invokeinterface #81,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     388: ifeq          432
     391: aload         12
     393: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     398: astore        13
     400: aload         13
     402: checkcast     #101                // class Tree
     405: astore        14
     407: iconst_0
     408: istore        15
     410: aload         14
     412: invokevirtual #157                // Method Tree.getVisible:()Z
     415: ifeq          381
     418: iinc          11, 1
     421: iload         11
     423: ifge          381
     426: invokestatic  #160                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     429: goto          381
     432: iload         11
     434: nop
     435: istore        17
     437: iload         16
     439: iload         17
     441: iadd
     442: istore        4
     444: goto          301
     447: iload         4
     449: ireturn

  private static final int main$findMax(int, kotlin.ranges.IntProgression, kotlin.jvm.functions.Function1<? super java.lang.Integer, Tree>);
    Code:
       0: iconst_0
       1: istore_3
       2: aload_1
       3: invokevirtual #189                // Method kotlin/ranges/IntProgression.getFirst:()I
       6: istore        4
       8: aload_1
       9: invokevirtual #192                // Method kotlin/ranges/IntProgression.getLast:()I
      12: istore        5
      14: aload_1
      15: invokevirtual #195                // Method kotlin/ranges/IntProgression.getStep:()I
      18: istore        6
      20: iload         6
      22: ifle          32
      25: iload         4
      27: iload         5
      29: if_icmple     44
      32: iload         6
      34: ifge          93
      37: iload         5
      39: iload         4
      41: if_icmpgt     93
      44: aload_2
      45: iload         4
      47: invokestatic  #24                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      50: invokeinterface #201,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      55: checkcast     #101                // class Tree
      58: astore        7
      60: aload         7
      62: invokevirtual #147                // Method Tree.getValue:()I
      65: iload_0
      66: if_icmplt     73
      69: iload_3
      70: iconst_1
      71: iadd
      72: ireturn
      73: iinc          3, 1
      76: iload         4
      78: iload         5
      80: if_icmpeq     93
      83: iload         4
      85: iload         6
      87: iadd
      88: istore        4
      90: goto          44
      93: iload_3
      94: ireturn

  private static final Tree main$findScenic$lambda$4(java.util.List, int, int);
    Code:
       0: aload_0
       1: iload_1
       2: invokeinterface #144,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
       7: checkcast     #116                // class java/util/List
      10: iload_2
      11: invokeinterface #144,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      16: checkcast     #101                // class Tree
      19: areturn

  private static final Tree main$findScenic$lambda$5(java.util.List, int, int);
    Code:
       0: aload_0
       1: iload_1
       2: invokeinterface #144,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
       7: checkcast     #116                // class java/util/List
      10: iload_2
      11: invokeinterface #144,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      16: checkcast     #101                // class Tree
      19: areturn

  private static final Tree main$findScenic$lambda$6(java.util.List, int, int);
    Code:
       0: aload_0
       1: iload_2
       2: invokeinterface #144,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
       7: checkcast     #116                // class java/util/List
      10: iload_1
      11: invokeinterface #144,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      16: checkcast     #101                // class Tree
      19: areturn

  private static final Tree main$findScenic$lambda$7(java.util.List, int, int);
    Code:
       0: aload_0
       1: iload_2
       2: invokeinterface #144,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
       7: checkcast     #116                // class java/util/List
      10: iload_1
      11: invokeinterface #144,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      16: checkcast     #101                // class Tree
      19: areturn

  private static final int main$findScenic(java.util.List<? extends java.util.List<Tree>>);
    Code:
       0: aload_0
       1: invokeinterface #140,  1          // InterfaceMethod java/util/List.size:()I
       6: istore_1
       7: iload_1
       8: iconst_1
       9: isub
      10: istore_2
      11: iconst_m1
      12: istore_3
      13: iconst_0
      14: istore        4
      16: iload         4
      18: iload_2
      19: if_icmpgt     207
      22: iconst_0
      23: istore        5
      25: iload         5
      27: iload_2
      28: if_icmpgt     195
      31: aload_0
      32: iload         4
      34: invokeinterface #144,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      39: checkcast     #116                // class java/util/List
      42: iload         5
      44: invokeinterface #144,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      49: checkcast     #101                // class Tree
      52: invokevirtual #147                // Method Tree.getValue:()I
      55: istore        6
      57: iload         6
      59: iload         5
      61: iconst_1
      62: isub
      63: iconst_0
      64: invokestatic  #223                // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;
      67: aload_0
      68: iload         4
      70: invokedynamic #239,  0            // InvokeDynamic #0:invoke:(Ljava/util/List;I)Lkotlin/jvm/functions/Function1;
      75: invokestatic  #241                // Method main$findMax:(ILkotlin/ranges/IntProgression;Lkotlin/jvm/functions/Function1;)I
      78: istore        7
      80: iload         6
      82: new           #243                // class kotlin/ranges/IntRange
      85: dup
      86: iload         5
      88: iconst_1
      89: iadd
      90: iload_2
      91: invokespecial #246                // Method kotlin/ranges/IntRange."<init>":(II)V
      94: checkcast     #186                // class kotlin/ranges/IntProgression
      97: aload_0
      98: iload         4
     100: invokedynamic #250,  0            // InvokeDynamic #1:invoke:(Ljava/util/List;I)Lkotlin/jvm/functions/Function1;
     105: invokestatic  #241                // Method main$findMax:(ILkotlin/ranges/IntProgression;Lkotlin/jvm/functions/Function1;)I
     108: istore        8
     110: iload         6
     112: iload         4
     114: iconst_1
     115: isub
     116: iconst_0
     117: invokestatic  #223                // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;
     120: aload_0
     121: iload         5
     123: invokedynamic #254,  0            // InvokeDynamic #2:invoke:(Ljava/util/List;I)Lkotlin/jvm/functions/Function1;
     128: invokestatic  #241                // Method main$findMax:(ILkotlin/ranges/IntProgression;Lkotlin/jvm/functions/Function1;)I
     131: istore        9
     133: iload         6
     135: new           #243                // class kotlin/ranges/IntRange
     138: dup
     139: iload         4
     141: iconst_1
     142: iadd
     143: iload_2
     144: invokespecial #246                // Method kotlin/ranges/IntRange."<init>":(II)V
     147: checkcast     #186                // class kotlin/ranges/IntProgression
     150: aload_0
     151: iload         5
     153: invokedynamic #258,  0            // InvokeDynamic #3:invoke:(Ljava/util/List;I)Lkotlin/jvm/functions/Function1;
     158: invokestatic  #241                // Method main$findMax:(ILkotlin/ranges/IntProgression;Lkotlin/jvm/functions/Function1;)I
     161: istore        10
     163: iload         9
     165: iload         7
     167: imul
     168: iload         10
     170: imul
     171: iload         8
     173: imul
     174: istore        11
     176: iload         11
     178: iload_3
     179: invokestatic  #264                // Method java/lang/Math.max:(II)I
     182: istore_3
     183: iload         5
     185: iload_2
     186: if_icmpeq     195
     189: iinc          5, 1
     192: goto          31
     195: iload         4
     197: iload_2
     198: if_icmpeq     207
     201: iinc          4, 1
     204: goto          22
     207: iload_3
     208: ireturn

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #273                // Method main$parse:(Ljava/util/List;)Ljava/util/List;
       4: astore_1
       5: aload_1
       6: invokestatic  #275                // Method main$findVisible:(Ljava/util/List;)I
       9: ireturn

  private static final int main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #273                // Method main$parse:(Ljava/util/List;)Ljava/util/List;
       4: astore_1
       5: aload_1
       6: invokestatic  #277                // Method main$findScenic:(Ljava/util/List;)I
       9: ireturn
}