private const val RPS_SIZE = 3

private fun String.toInt() = when (this) {
    "A", "X" -> 1
    "B", "Y" -> 2
    "C", "Z" -> 3
    else -> error("Incorrect input")
}

private fun Pair<Int, Int>.game1() = second + when {
    first % RPS_SIZE + 1 == second -> 6
    first == second -> 3
    (first + 1) % RPS_SIZE + 1 == second -> 0
    else -> error("Incorrect input game 1")
}

private fun Pair<Int, Int>.game2() = when (second) {
    1 -> (first + 1) % RPS_SIZE + 1
    2 -> 3 + first
    3 -> 6 + first % RPS_SIZE + 1
    else -> error("Incorrect input game 2")
}

private fun parseInput(input: List<String>) =
    input.map { it.trim().split(' ', limit = 2) }.map { it.first().toInt() to it.last().toInt() }

fun main() {
    fun part1(input: List<String>) = parseInput(input).sumOf { it.game1() }

    fun part2(input: List<String>) = parseInput(input).sumOf { it.game2() }

    // test if implementation meets criteria from the description, like:
    val testInput = readInput("Day02_test")
    check(part1(testInput) == 15)
    check(part2(testInput) == 12)

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

Compiled from "Day02.kt"
public final class Day02Kt {
  private static final int RPS_SIZE;

  private static final int toInt(java.lang.String);
    Code:
       0: aload_0
       1: astore_1
       2: aload_1
       3: invokevirtual #12                 // Method java/lang/String.hashCode:()I
       6: lookupswitch  { // 6
                    65: 64
                    66: 76
                    67: 88
                    88: 100
                    89: 112
                    90: 124
               default: 148
          }
      64: aload_1
      65: ldc           #14                 // String A
      67: invokevirtual #18                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      70: ifne          136
      73: goto          148
      76: aload_1
      77: ldc           #20                 // String B
      79: invokevirtual #18                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      82: ifne          140
      85: goto          148
      88: aload_1
      89: ldc           #22                 // String C
      91: invokevirtual #18                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
      94: ifne          144
      97: goto          148
     100: aload_1
     101: ldc           #24                 // String X
     103: invokevirtual #18                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     106: ifne          136
     109: goto          148
     112: aload_1
     113: ldc           #26                 // String Y
     115: invokevirtual #18                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     118: ifne          140
     121: goto          148
     124: aload_1
     125: ldc           #28                 // String Z
     127: invokevirtual #18                 // Method java/lang/String.equals:(Ljava/lang/Object;)Z
     130: ifne          144
     133: goto          148
     136: iconst_1
     137: goto          161
     140: iconst_2
     141: goto          161
     144: iconst_3
     145: goto          161
     148: new           #30                 // class java/lang/IllegalStateException
     151: dup
     152: ldc           #32                 // String Incorrect input
     154: invokevirtual #36                 // Method java/lang/Object.toString:()Ljava/lang/String;
     157: invokespecial #40                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     160: athrow
     161: ireturn

  private static final int game1(kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: invokevirtual #51                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
       4: checkcast     #53                 // class java/lang/Number
       7: invokevirtual #56                 // Method java/lang/Number.intValue:()I
      10: aload_0
      11: invokevirtual #59                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      14: checkcast     #53                 // class java/lang/Number
      17: invokevirtual #56                 // Method java/lang/Number.intValue:()I
      20: iconst_3
      21: irem
      22: iconst_1
      23: iadd
      24: aload_0
      25: invokevirtual #51                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      28: checkcast     #53                 // class java/lang/Number
      31: invokevirtual #56                 // Method java/lang/Number.intValue:()I
      34: if_icmpne     42
      37: bipush        6
      39: goto          115
      42: aload_0
      43: invokevirtual #59                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      46: checkcast     #53                 // class java/lang/Number
      49: invokevirtual #56                 // Method java/lang/Number.intValue:()I
      52: aload_0
      53: invokevirtual #51                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      56: checkcast     #53                 // class java/lang/Number
      59: invokevirtual #56                 // Method java/lang/Number.intValue:()I
      62: if_icmpne     69
      65: iconst_3
      66: goto          115
      69: aload_0
      70: invokevirtual #59                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      73: checkcast     #53                 // class java/lang/Number
      76: invokevirtual #56                 // Method java/lang/Number.intValue:()I
      79: iconst_1
      80: iadd
      81: iconst_3
      82: irem
      83: iconst_1
      84: iadd
      85: aload_0
      86: invokevirtual #51                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      89: checkcast     #53                 // class java/lang/Number
      92: invokevirtual #56                 // Method java/lang/Number.intValue:()I
      95: if_icmpne     102
      98: iconst_0
      99: goto          115
     102: new           #30                 // class java/lang/IllegalStateException
     105: dup
     106: ldc           #61                 // String Incorrect input game 1
     108: invokevirtual #36                 // Method java/lang/Object.toString:()Ljava/lang/String;
     111: invokespecial #40                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     114: athrow
     115: iadd
     116: ireturn

  private static final int game2(kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: invokevirtual #51                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
       4: checkcast     #53                 // class java/lang/Number
       7: invokevirtual #56                 // Method java/lang/Number.intValue:()I
      10: tableswitch   { // 1 to 3
                     1: 36
                     2: 55
                     3: 70
               default: 90
          }
      36: aload_0
      37: invokevirtual #59                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      40: checkcast     #53                 // class java/lang/Number
      43: invokevirtual #56                 // Method java/lang/Number.intValue:()I
      46: iconst_1
      47: iadd
      48: iconst_3
      49: irem
      50: iconst_1
      51: iadd
      52: goto          103
      55: iconst_3
      56: aload_0
      57: invokevirtual #59                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      60: checkcast     #53                 // class java/lang/Number
      63: invokevirtual #56                 // Method java/lang/Number.intValue:()I
      66: iadd
      67: goto          103
      70: bipush        6
      72: aload_0
      73: invokevirtual #59                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      76: checkcast     #53                 // class java/lang/Number
      79: invokevirtual #56                 // Method java/lang/Number.intValue:()I
      82: iconst_3
      83: irem
      84: iadd
      85: iconst_1
      86: iadd
      87: goto          103
      90: new           #30                 // class java/lang/IllegalStateException
      93: dup
      94: ldc           #66                 // String Incorrect input game 2
      96: invokevirtual #36                 // Method java/lang/Object.toString:()Ljava/lang/String;
      99: invokespecial #40                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     102: athrow
     103: ireturn

  private static final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> parseInput(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #72                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: astore_3
       9: new           #74                 // class java/util/ArrayList
      12: dup
      13: aload_1
      14: bipush        10
      16: invokestatic  #80                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      19: invokespecial #83                 // Method java/util/ArrayList."<init>":(I)V
      22: checkcast     #85                 // class java/util/Collection
      25: astore        4
      27: iconst_0
      28: istore        5
      30: aload_3
      31: invokeinterface #89,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      36: astore        6
      38: aload         6
      40: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      45: ifeq          117
      48: aload         6
      50: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      55: astore        7
      57: aload         4
      59: aload         7
      61: checkcast     #8                  // class java/lang/String
      64: astore        8
      66: astore        11
      68: iconst_0
      69: istore        9
      71: aload         8
      73: checkcast     #100                // class java/lang/CharSequence
      76: invokestatic  #106                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      79: invokevirtual #36                 // Method java/lang/Object.toString:()Ljava/lang/String;
      82: checkcast     #100                // class java/lang/CharSequence
      85: iconst_1
      86: newarray       char
      88: astore        10
      90: aload         10
      92: iconst_0
      93: bipush        32
      95: castore
      96: aload         10
      98: iconst_0
      99: iconst_2
     100: iconst_2
     101: aconst_null
     102: invokestatic  #110                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;
     105: aload         11
     107: swap
     108: invokeinterface #113,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     113: pop
     114: goto          38
     117: aload         4
     119: checkcast     #115                // class java/util/List
     122: nop
     123: checkcast     #72                 // class java/lang/Iterable
     126: astore_1
     127: nop
     128: iconst_0
     129: istore_2
     130: aload_1
     131: astore_3
     132: new           #74                 // class java/util/ArrayList
     135: dup
     136: aload_1
     137: bipush        10
     139: invokestatic  #80                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     142: invokespecial #83                 // Method java/util/ArrayList."<init>":(I)V
     145: checkcast     #85                 // class java/util/Collection
     148: astore        4
     150: iconst_0
     151: istore        5
     153: aload_3
     154: invokeinterface #89,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     159: astore        6
     161: aload         6
     163: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     168: ifeq          237
     171: aload         6
     173: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     178: astore        7
     180: aload         4
     182: aload         7
     184: checkcast     #115                // class java/util/List
     187: astore        8
     189: astore        11
     191: iconst_0
     192: istore        9
     194: aload         8
     196: invokestatic  #119                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     199: checkcast     #8                  // class java/lang/String
     202: invokestatic  #121                // Method toInt:(Ljava/lang/String;)I
     205: invokestatic  #127                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     208: aload         8
     210: invokestatic  #130                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     213: checkcast     #8                  // class java/lang/String
     216: invokestatic  #121                // Method toInt:(Ljava/lang/String;)I
     219: invokestatic  #127                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     222: invokestatic  #136                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     225: aload         11
     227: swap
     228: invokeinterface #113,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     233: pop
     234: goto          161
     237: aload         4
     239: checkcast     #115                // class java/util/List
     242: nop
     243: areturn

  public static final void main();
    Code:
       0: ldc           #155                // String Day02_test
       2: invokestatic  #161                // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #165                // Method main$part1:(Ljava/util/List;)I
      10: bipush        15
      12: if_icmpne     19
      15: iconst_1
      16: goto          20
      19: iconst_0
      20: ifne          33
      23: new           #30                 // class java/lang/IllegalStateException
      26: dup
      27: ldc           #167                // String Check failed.
      29: invokespecial #40                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      32: athrow
      33: aload_0
      34: invokestatic  #170                // Method main$part2:(Ljava/util/List;)I
      37: bipush        12
      39: if_icmpne     46
      42: iconst_1
      43: goto          47
      46: iconst_0
      47: ifne          60
      50: new           #30                 // class java/lang/IllegalStateException
      53: dup
      54: ldc           #167                // String Check failed.
      56: invokespecial #40                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      59: athrow
      60: ldc           #172                // String Day02
      62: invokestatic  #161                // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      65: astore_1
      66: aload_1
      67: invokestatic  #165                // Method main$part1:(Ljava/util/List;)I
      70: istore_2
      71: getstatic     #178                // Field java/lang/System.out:Ljava/io/PrintStream;
      74: iload_2
      75: invokevirtual #183                // Method java/io/PrintStream.println:(I)V
      78: aload_1
      79: invokestatic  #170                // Method main$part2:(Ljava/util/List;)I
      82: istore_2
      83: getstatic     #178                // Field java/lang/System.out:Ljava/io/PrintStream;
      86: iload_2
      87: invokevirtual #183                // Method java/io/PrintStream.println:(I)V
      90: return

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

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #192                // Method parseInput:(Ljava/util/List;)Ljava/util/List;
       4: checkcast     #72                 // class java/lang/Iterable
       7: astore_1
       8: iconst_0
       9: istore_2
      10: aload_1
      11: invokeinterface #89,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      16: astore_3
      17: aload_3
      18: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      23: ifeq          63
      26: aload_3
      27: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      32: astore        4
      34: iload_2
      35: aload         4
      37: checkcast     #47                 // class kotlin/Pair
      40: astore        5
      42: istore        7
      44: iconst_0
      45: istore        6
      47: aload         5
      49: invokestatic  #194                // Method game1:(Lkotlin/Pair;)I
      52: istore        8
      54: iload         7
      56: iload         8
      58: iadd
      59: istore_2
      60: goto          17
      63: iload_2
      64: ireturn

  private static final int main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #192                // Method parseInput:(Ljava/util/List;)Ljava/util/List;
       4: checkcast     #72                 // class java/lang/Iterable
       7: astore_1
       8: iconst_0
       9: istore_2
      10: aload_1
      11: invokeinterface #89,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      16: astore_3
      17: aload_3
      18: invokeinterface #95,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      23: ifeq          63
      26: aload_3
      27: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      32: astore        4
      34: iload_2
      35: aload         4
      37: checkcast     #47                 // class kotlin/Pair
      40: astore        5
      42: istore        7
      44: iconst_0
      45: istore        6
      47: aload         5
      49: invokestatic  #197                // Method game2:(Lkotlin/Pair;)I
      52: istore        8
      54: iload         7
      56: iload         8
      58: iadd
      59: istore_2
      60: goto          17
      63: iload_2
      64: ireturn
}


var start = 0 to 0
var end = 0 to 0

private fun heights(input: List<String>) =
    input.mapIndexed { i, line ->
        line.mapIndexed { j, char ->
            when (char) {
                'S' -> 'a'.also { start = i to j }
                'E' -> 'z'.also { end = i to j }
                else -> char
            } - 'a'
        }
    }

private fun dijkstra(heights: List<List<Int>>, start: Pair<Int, Int>): List<List<Int>> {
    val distances = List(heights.size) { MutableList(heights.first().size) { Int.MAX_VALUE } }
    val unvisited = distances.indexPairs().toMutableSet()

    distances[start] = 0
    var cur = start

    while (true) {
        unvisited.remove(cur)

        neighbours(cur).filter { (i, j) -> i in distances.indices && j in distances.first().indices }
            .filter { unvisited.contains(it) }.forEach {
                if (heights[it] <= heights[cur] + 1) {
                    distances[it] = distances[it].coerceAtMost(distances[cur] + 1)
                }
            }

        val next = unvisited.minByOrNull { distances[it] }
        if (next == null || distances[next] == Int.MAX_VALUE) break

        cur = next
    }

    return distances
}

fun main() {
    fun part1(input: List<String>) = dijkstra(heights(input), start)[end]

    fun part2(input: List<String>): Int {
        val heights = heights(input)

        return heights.indexPairs { it == 0 }.minOf { dijkstra(heights, it)[end] }
    }

    // test if implementation meets criteria from the description, like:
    val testInput = readInput("Day12_test")
    check(part1(testInput) == 31)
    check(part2(testInput) == 29)

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

Compiled from "Day12.kt"
public final class Day12Kt {
  private static kotlin.Pair<java.lang.Integer, java.lang.Integer> start;

  private static kotlin.Pair<java.lang.Integer, java.lang.Integer> end;

  public static final kotlin.Pair<java.lang.Integer, java.lang.Integer> getStart();
    Code:
       0: getstatic     #12                 // Field start:Lkotlin/Pair;
       3: areturn

  public static final void setStart(kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    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 start:Lkotlin/Pair;
      10: return

  public static final kotlin.Pair<java.lang.Integer, java.lang.Integer> getEnd();
    Code:
       0: getstatic     #27                 // Field end:Lkotlin/Pair;
       3: areturn

  public static final void setEnd(kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    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     #27                 // Field end:Lkotlin/Pair;
      10: return

  private static final java.util.List<java.util.List<java.lang.Integer>> heights(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #33                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: astore_3
       9: new           #35                 // class java/util/ArrayList
      12: dup
      13: aload_1
      14: bipush        10
      16: invokestatic  #41                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      19: invokespecial #45                 // Method java/util/ArrayList."<init>":(I)V
      22: checkcast     #47                 // class java/util/Collection
      25: astore        4
      27: iconst_0
      28: istore        5
      30: iconst_0
      31: istore        6
      33: aload_3
      34: invokeinterface #51,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      39: astore        7
      41: aload         7
      43: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      48: ifeq          311
      51: aload         7
      53: invokeinterface #61,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      58: astore        8
      60: aload         4
      62: iload         6
      64: iinc          6, 1
      67: istore        9
      69: iload         9
      71: ifge          77
      74: invokestatic  #65                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      77: iload         9
      79: aload         8
      81: checkcast     #67                 // class java/lang/String
      84: astore        10
      86: istore        11
      88: astore        28
      90: iconst_0
      91: istore        12
      93: aload         10
      95: checkcast     #69                 // class java/lang/CharSequence
      98: astore        13
     100: iconst_0
     101: istore        14
     103: aload         13
     105: astore        15
     107: new           #35                 // class java/util/ArrayList
     110: dup
     111: aload         13
     113: invokeinterface #73,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     118: invokespecial #45                 // Method java/util/ArrayList."<init>":(I)V
     121: checkcast     #47                 // class java/util/Collection
     124: astore        16
     126: iconst_0
     127: istore        17
     129: iconst_0
     130: istore        18
     132: iconst_0
     133: istore        19
     135: iload         19
     137: aload         15
     139: invokeinterface #73,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     144: if_icmpge     292
     147: aload         15
     149: iload         19
     151: invokeinterface #77,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     156: istore        20
     158: aload         16
     160: iload         18
     162: iinc          18, 1
     165: iload         20
     167: istore        21
     169: istore        22
     171: astore        23
     173: iconst_0
     174: istore        24
     176: iload         21
     178: lookupswitch  { // 2
                    69: 236
                    83: 204
               default: 268
          }
     204: bipush        97
     206: istore        25
     208: iload         25
     210: istore        26
     212: iconst_0
     213: istore        27
     215: iload         11
     217: invokestatic  #83                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     220: iload         22
     222: invokestatic  #83                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     225: invokestatic  #89                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     228: putstatic     #12                 // Field start:Lkotlin/Pair;
     231: iload         25
     233: goto          270
     236: bipush        122
     238: istore        25
     240: iload         25
     242: istore        26
     244: iconst_0
     245: istore        27
     247: iload         11
     249: invokestatic  #83                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     252: iload         22
     254: invokestatic  #83                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     257: invokestatic  #89                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     260: putstatic     #27                 // Field end:Lkotlin/Pair;
     263: iload         25
     265: goto          270
     268: iload         21
     270: bipush        97
     272: isub
     273: nop
     274: invokestatic  #83                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     277: aload         23
     279: swap
     280: invokeinterface #93,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     285: pop
     286: iinc          19, 1
     289: goto          135
     292: aload         16
     294: checkcast     #95                 // class java/util/List
     297: nop
     298: nop
     299: aload         28
     301: swap
     302: invokeinterface #93,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     307: pop
     308: goto          41
     311: aload         4
     313: checkcast     #95                 // class java/util/List
     316: nop
     317: areturn

  private static final java.util.List<java.util.List<java.lang.Integer>> dijkstra(java.util.List<? extends java.util.List<java.lang.Integer>>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: invokeinterface #126,  1          // InterfaceMethod java/util/List.size:()I
       6: istore_3
       7: new           #35                 // class java/util/ArrayList
      10: dup
      11: iload_3
      12: invokespecial #45                 // Method java/util/ArrayList."<init>":(I)V
      15: astore        4
      17: iconst_0
      18: istore        5
      20: iload         5
      22: iload_3
      23: if_icmpge     128
      26: iload         5
      28: istore        6
      30: aload         4
      32: iload         6
      34: istore        7
      36: astore        16
      38: iconst_0
      39: istore        8
      41: aload_0
      42: invokestatic  #130                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      45: checkcast     #95                 // class java/util/List
      48: invokeinterface #126,  1          // InterfaceMethod java/util/List.size:()I
      53: istore        9
      55: new           #35                 // class java/util/ArrayList
      58: dup
      59: iload         9
      61: invokespecial #45                 // Method java/util/ArrayList."<init>":(I)V
      64: astore        10
      66: iconst_0
      67: istore        11
      69: iload         11
      71: iload         9
      73: if_icmpge     109
      76: iload         11
      78: istore        12
      80: aload         10
      82: iload         12
      84: istore        13
      86: astore        14
      88: iconst_0
      89: istore        15
      91: ldc           #131                // int 2147483647
      93: invokestatic  #83                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      96: aload         14
      98: swap
      99: invokevirtual #132                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     102: pop
     103: iinc          11, 1
     106: goto          69
     109: aload         10
     111: checkcast     #95                 // class java/util/List
     114: nop
     115: aload         16
     117: swap
     118: invokevirtual #132                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     121: pop
     122: iinc          5, 1
     125: goto          20
     128: aload         4
     130: checkcast     #95                 // class java/util/List
     133: astore_2
     134: aload_2
     135: aconst_null
     136: iconst_1
     137: aconst_null
     138: invokestatic  #138                // Method UtilsKt.indexPairs$default:(Ljava/util/List;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/util/List;
     141: checkcast     #33                 // class java/lang/Iterable
     144: invokestatic  #142                // Method kotlin/collections/CollectionsKt.toMutableSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     147: astore_3
     148: aload_2
     149: aload_1
     150: iconst_0
     151: invokestatic  #83                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     154: invokestatic  #146                // Method UtilsKt.set:(Ljava/util/List;Lkotlin/Pair;Ljava/lang/Object;)V
     157: aconst_null
     158: astore        4
     160: aload_1
     161: astore        4
     163: nop
     164: aload_3
     165: aload         4
     167: invokeinterface #151,  2          // InterfaceMethod java/util/Set.remove:(Ljava/lang/Object;)Z
     172: pop
     173: aload         4
     175: invokestatic  #155                // Method UtilsKt.neighbours:(Lkotlin/Pair;)Ljava/util/List;
     178: checkcast     #33                 // class java/lang/Iterable
     181: astore        5
     183: iconst_0
     184: istore        6
     186: aload         5
     188: astore        7
     190: new           #35                 // class java/util/ArrayList
     193: dup
     194: invokespecial #157                // Method java/util/ArrayList."<init>":()V
     197: checkcast     #47                 // class java/util/Collection
     200: astore        8
     202: iconst_0
     203: istore        9
     205: aload         7
     207: invokeinterface #51,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     212: astore        10
     214: aload         10
     216: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     221: ifeq          357
     224: aload         10
     226: invokeinterface #61,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     231: astore        11
     233: aload         11
     235: checkcast     #159                // class kotlin/Pair
     238: astore        12
     240: iconst_0
     241: istore        13
     243: aload         12
     245: invokevirtual #162                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     248: checkcast     #164                // class java/lang/Number
     251: invokevirtual #167                // Method java/lang/Number.intValue:()I
     254: istore        14
     256: aload         12
     258: invokevirtual #170                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     261: checkcast     #164                // class java/lang/Number
     264: invokevirtual #167                // Method java/lang/Number.intValue:()I
     267: istore        15
     269: iconst_0
     270: iload         14
     272: if_icmpgt     297
     275: iload         14
     277: aload_2
     278: checkcast     #47                 // class java/util/Collection
     281: invokeinterface #171,  1          // InterfaceMethod java/util/Collection.size:()I
     286: if_icmpge     293
     289: iconst_1
     290: goto          298
     293: iconst_0
     294: goto          298
     297: iconst_0
     298: ifeq          340
     301: iconst_0
     302: iload         15
     304: if_icmpgt     332
     307: iload         15
     309: aload_2
     310: invokestatic  #130                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     313: checkcast     #47                 // class java/util/Collection
     316: invokeinterface #171,  1          // InterfaceMethod java/util/Collection.size:()I
     321: if_icmpge     328
     324: iconst_1
     325: goto          333
     328: iconst_0
     329: goto          333
     332: iconst_0
     333: ifeq          340
     336: iconst_1
     337: goto          341
     340: iconst_0
     341: ifeq          214
     344: aload         8
     346: aload         11
     348: invokeinterface #93,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     353: pop
     354: goto          214
     357: aload         8
     359: checkcast     #95                 // class java/util/List
     362: nop
     363: checkcast     #33                 // class java/lang/Iterable
     366: astore        5
     368: nop
     369: iconst_0
     370: istore        6
     372: aload         5
     374: astore        7
     376: new           #35                 // class java/util/ArrayList
     379: dup
     380: invokespecial #157                // Method java/util/ArrayList."<init>":()V
     383: checkcast     #47                 // class java/util/Collection
     386: astore        8
     388: iconst_0
     389: istore        9
     391: aload         7
     393: invokeinterface #51,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     398: astore        10
     400: aload         10
     402: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     407: ifeq          453
     410: aload         10
     412: invokeinterface #61,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     417: astore        11
     419: aload         11
     421: checkcast     #159                // class kotlin/Pair
     424: astore        12
     426: iconst_0
     427: istore        13
     429: aload_3
     430: aload         12
     432: invokeinterface #174,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     437: ifeq          400
     440: aload         8
     442: aload         11
     444: invokeinterface #93,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     449: pop
     450: goto          400
     453: aload         8
     455: checkcast     #95                 // class java/util/List
     458: nop
     459: checkcast     #33                 // class java/lang/Iterable
     462: astore        5
     464: nop
     465: iconst_0
     466: istore        6
     468: aload         5
     470: invokeinterface #51,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     475: astore        7
     477: aload         7
     479: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     484: ifeq          578
     487: aload         7
     489: invokeinterface #61,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     494: astore        8
     496: aload         8
     498: checkcast     #159                // class kotlin/Pair
     501: astore        9
     503: iconst_0
     504: istore        10
     506: aload_0
     507: aload         9
     509: invokestatic  #178                // Method UtilsKt.get:(Ljava/util/List;Lkotlin/Pair;)Ljava/lang/Object;
     512: checkcast     #164                // class java/lang/Number
     515: invokevirtual #167                // Method java/lang/Number.intValue:()I
     518: aload_0
     519: aload         4
     521: invokestatic  #178                // Method UtilsKt.get:(Ljava/util/List;Lkotlin/Pair;)Ljava/lang/Object;
     524: checkcast     #164                // class java/lang/Number
     527: invokevirtual #167                // Method java/lang/Number.intValue:()I
     530: iconst_1
     531: iadd
     532: if_icmpgt     573
     535: aload_2
     536: aload         9
     538: aload_2
     539: aload         9
     541: invokestatic  #178                // Method UtilsKt.get:(Ljava/util/List;Lkotlin/Pair;)Ljava/lang/Object;
     544: checkcast     #164                // class java/lang/Number
     547: invokevirtual #167                // Method java/lang/Number.intValue:()I
     550: aload_2
     551: aload         4
     553: invokestatic  #178                // Method UtilsKt.get:(Ljava/util/List;Lkotlin/Pair;)Ljava/lang/Object;
     556: checkcast     #164                // class java/lang/Number
     559: invokevirtual #167                // Method java/lang/Number.intValue:()I
     562: iconst_1
     563: iadd
     564: invokestatic  #184                // Method kotlin/ranges/RangesKt.coerceAtMost:(II)I
     567: invokestatic  #83                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     570: invokestatic  #146                // Method UtilsKt.set:(Ljava/util/List;Lkotlin/Pair;Ljava/lang/Object;)V
     573: nop
     574: nop
     575: goto          477
     578: nop
     579: aload_3
     580: checkcast     #33                 // class java/lang/Iterable
     583: astore        6
     585: iconst_0
     586: istore        7
     588: aload         6
     590: invokeinterface #51,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     595: astore        8
     597: aload         8
     599: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     604: ifne          611
     607: aconst_null
     608: goto          719
     611: aload         8
     613: invokeinterface #61,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     618: astore        9
     620: aload         8
     622: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     627: ifne          635
     630: aload         9
     632: goto          719
     635: aload         9
     637: checkcast     #159                // class kotlin/Pair
     640: astore        10
     642: iconst_0
     643: istore        11
     645: aload_2
     646: aload         10
     648: invokestatic  #178                // Method UtilsKt.get:(Ljava/util/List;Lkotlin/Pair;)Ljava/lang/Object;
     651: checkcast     #164                // class java/lang/Number
     654: invokevirtual #167                // Method java/lang/Number.intValue:()I
     657: istore        10
     659: aload         8
     661: invokeinterface #61,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     666: astore        11
     668: aload         11
     670: checkcast     #159                // class kotlin/Pair
     673: astore        12
     675: iconst_0
     676: istore        13
     678: aload_2
     679: aload         12
     681: invokestatic  #178                // Method UtilsKt.get:(Ljava/util/List;Lkotlin/Pair;)Ljava/lang/Object;
     684: checkcast     #164                // class java/lang/Number
     687: invokevirtual #167                // Method java/lang/Number.intValue:()I
     690: istore        12
     692: iload         10
     694: iload         12
     696: if_icmple     707
     699: aload         11
     701: astore        9
     703: iload         12
     705: istore        10
     707: aload         8
     709: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     714: ifne          659
     717: aload         9
     719: checkcast     #159                // class kotlin/Pair
     722: astore        5
     724: aload         5
     726: ifnull        756
     729: aload_2
     730: aload         5
     732: invokestatic  #178                // Method UtilsKt.get:(Ljava/util/List;Lkotlin/Pair;)Ljava/lang/Object;
     735: checkcast     #164                // class java/lang/Number
     738: invokevirtual #167                // Method java/lang/Number.intValue:()I
     741: ldc           #131                // int 2147483647
     743: if_icmpne     749
     746: goto          756
     749: aload         5
     751: astore        4
     753: goto          163
     756: aload_2
     757: areturn

  public static final void main();
    Code:
       0: ldc           #213                // String Day12_test
       2: invokestatic  #217                // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #221                // Method main$part1:(Ljava/util/List;)I
      10: bipush        31
      12: if_icmpne     19
      15: iconst_1
      16: goto          20
      19: iconst_0
      20: ifne          33
      23: new           #223                // class java/lang/IllegalStateException
      26: dup
      27: ldc           #225                // String Check failed.
      29: invokespecial #228                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      32: athrow
      33: aload_0
      34: invokestatic  #231                // Method main$part2:(Ljava/util/List;)I
      37: bipush        29
      39: if_icmpne     46
      42: iconst_1
      43: goto          47
      46: iconst_0
      47: ifne          60
      50: new           #223                // class java/lang/IllegalStateException
      53: dup
      54: ldc           #225                // String Check failed.
      56: invokespecial #228                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      59: athrow
      60: ldc           #233                // String Day12
      62: invokestatic  #217                // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      65: astore_1
      66: aload_1
      67: invokestatic  #221                // Method main$part1:(Ljava/util/List;)I
      70: istore_2
      71: getstatic     #239                // Field java/lang/System.out:Ljava/io/PrintStream;
      74: iload_2
      75: invokevirtual #244                // Method java/io/PrintStream.println:(I)V
      78: aload_1
      79: invokestatic  #231                // Method main$part2:(Ljava/util/List;)I
      82: istore_2
      83: getstatic     #239                // Field java/lang/System.out:Ljava/io/PrintStream;
      86: iload_2
      87: invokevirtual #244                // Method java/io/PrintStream.println:(I)V
      90: return

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

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #253                // Method heights:(Ljava/util/List;)Ljava/util/List;
       4: getstatic     #12                 // Field start:Lkotlin/Pair;
       7: invokestatic  #255                // Method dijkstra:(Ljava/util/List;Lkotlin/Pair;)Ljava/util/List;
      10: getstatic     #27                 // Field end:Lkotlin/Pair;
      13: invokestatic  #178                // Method UtilsKt.get:(Ljava/util/List;Lkotlin/Pair;)Ljava/lang/Object;
      16: checkcast     #164                // class java/lang/Number
      19: invokevirtual #167                // Method java/lang/Number.intValue:()I
      22: ireturn

  private static final boolean main$part2$lambda$10(int);
    Code:
       0: iload_0
       1: ifne          8
       4: iconst_1
       5: goto          9
       8: iconst_0
       9: ireturn

  private static final int main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #253                // Method heights:(Ljava/util/List;)Ljava/util/List;
       4: astore_1
       5: aload_1
       6: invokedynamic #275,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      11: invokestatic  #279                // Method UtilsKt.indexPairs:(Ljava/util/List;Lkotlin/jvm/functions/Function1;)Ljava/util/List;
      14: checkcast     #33                 // class java/lang/Iterable
      17: invokeinterface #51,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      22: astore_2
      23: aload_2
      24: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      29: ifne          40
      32: new           #281                // class java/util/NoSuchElementException
      35: dup
      36: invokespecial #282                // Method java/util/NoSuchElementException."<init>":()V
      39: athrow
      40: aload_2
      41: invokeinterface #61,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      46: checkcast     #159                // class kotlin/Pair
      49: astore_3
      50: iconst_0
      51: istore        4
      53: aload_1
      54: aload_3
      55: invokestatic  #255                // Method dijkstra:(Ljava/util/List;Lkotlin/Pair;)Ljava/util/List;
      58: getstatic     #27                 // Field end:Lkotlin/Pair;
      61: invokestatic  #178                // Method UtilsKt.get:(Ljava/util/List;Lkotlin/Pair;)Ljava/lang/Object;
      64: checkcast     #164                // class java/lang/Number
      67: invokevirtual #167                // Method java/lang/Number.intValue:()I
      70: istore_3
      71: aload_2
      72: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      77: ifeq          126
      80: aload_2
      81: invokeinterface #61,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      86: checkcast     #159                // class kotlin/Pair
      89: astore        4
      91: iconst_0
      92: istore        5
      94: aload_1
      95: aload         4
      97: invokestatic  #255                // Method dijkstra:(Ljava/util/List;Lkotlin/Pair;)Ljava/util/List;
     100: getstatic     #27                 // Field end:Lkotlin/Pair;
     103: invokestatic  #178                // Method UtilsKt.get:(Ljava/util/List;Lkotlin/Pair;)Ljava/lang/Object;
     106: checkcast     #164                // class java/lang/Number
     109: invokevirtual #167                // Method java/lang/Number.intValue:()I
     112: istore        4
     114: iload_3
     115: iload         4
     117: if_icmple     71
     120: iload         4
     122: istore_3
     123: goto          71
     126: iload_3
     127: ireturn

  static {};
    Code:
       0: iconst_0
       1: invokestatic  #83                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
       4: iconst_0
       5: invokestatic  #83                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
       8: invokestatic  #89                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      11: putstatic     #12                 // Field start:Lkotlin/Pair;
      14: iconst_0
      15: invokestatic  #83                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      18: iconst_0
      19: invokestatic  #83                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      22: invokestatic  #89                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      25: putstatic     #27                 // Field end:Lkotlin/Pair;
      28: return
}


private val template = """
Monkey (\d+):
  Starting items: (.*?)
  Operation: new = old (.) (.+)
  Test: divisible by (\d+)
    If true: throw to monkey (\d+)
    If false: throw to monkey (\d+)
    """.trim().toRegex()

private data class MonkeyBusiness(
    val items: MutableList<ULong>,
    val op: (ULong, ULong) -> ULong,
    val value: String,
    val divider: ULong,
    val onTrue: Int,
    val onFalse: Int,
    var inspected: ULong = 0U,
) {
    fun throwDecision(worryLevel: ULong) = if (worryLevel % divider == 0.toULong()) onTrue else onFalse

    fun roundEnd() {
        inspected += items.size.toUInt()
        items.clear()
    }
}

private fun parseMonkeys(input: List<String>) = input.map { monkey ->
    val (_, list, sign, value, divider, onTrue, onFalse) = template.matchEntire(monkey)!!.destructured
    val items = list.split(", ").map(String::toULong).toMutableList()
    val operation: (ULong, ULong) -> ULong = when (sign.first()) {
        '+' -> ULong::plus
        '*' -> ULong::times
        else -> error("Incorrect input")
    }

    MonkeyBusiness(items, operation, value, divider.toULong(), onTrue.toInt(), onFalse.toInt())
}

private fun throwRounds(monkeys: List<MonkeyBusiness>, times: Int, calming: (ULong) -> ULong): ULong {
    val greatDivider = monkeys.map { it.divider }.reduce(ULong::times)

    repeat(times) {
        for (monkey in monkeys) {
            for (item in monkey.items) {
                val numberValue = monkey.value.toULongOrNull() ?: item
                val worryLevel = calming(monkey.op(item, numberValue)) % greatDivider

                monkeys[monkey.throwDecision(worryLevel)].items.add(worryLevel)
            }

            monkey.roundEnd()
        }
    }

    return monkeys.map { it.inspected }.sorted().takeLast(2).reduce(ULong::times)
}

fun main() {
    fun part1(input: List<String>) = throwRounds(parseMonkeys(input), 20) { it / 3U }

    fun part2(input: List<String>) = throwRounds(parseMonkeys(input), 10_000) { it }

    // test if implementation meets criteria from the description, like:
    val testInput = readRawBlocks("Day11_test")
    check(part1(testInput) == 10_605.toULong())
    check(part2(testInput) == 2_713_310_158.toULong())

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

Compiled from "Day11.kt"
final class Day11Kt$parseMonkeys$1$operation$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<kotlin.ULong, kotlin.ULong, kotlin.ULong> {
  public static final Day11Kt$parseMonkeys$1$operation$2 INSTANCE;

  Day11Kt$parseMonkeys$1$operation$2();
    Code:
       0: aload_0
       1: iconst_2
       2: ldc           #11                 // class kotlin/ULong
       4: ldc           #13                 // String times
       6: ldc           #15                 // String times-VKZWuLQ(JJ)J
       8: iconst_0
       9: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final long invoke-oku0oEs(long, long);
    Code:
       0: lload_1
       1: lload_3
       2: lmul
       3: invokestatic  #26                 // Method kotlin/ULong."constructor-impl":(J)J
       6: lreturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #11                 // class kotlin/ULong
       5: invokevirtual #35                 // Method kotlin/ULong."unbox-impl":()J
       8: aload_2
       9: checkcast     #11                 // class kotlin/ULong
      12: invokevirtual #35                 // Method kotlin/ULong."unbox-impl":()J
      15: invokevirtual #37                 // Method "invoke-oku0oEs":(JJ)J
      18: invokestatic  #41                 // Method kotlin/ULong."box-impl":(J)Lkotlin/ULong;
      21: areturn

  static {};
    Code:
       0: new           #2                  // class Day11Kt$parseMonkeys$1$operation$2
       3: dup
       4: invokespecial #46                 // Method "<init>":()V
       7: putstatic     #49                 // Field INSTANCE:LDay11Kt$parseMonkeys$1$operation$2;
      10: return
}

Compiled from "Day11.kt"
final class Day11Kt$parseMonkeys$1$operation$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<kotlin.ULong, kotlin.ULong, kotlin.ULong> {
  public static final Day11Kt$parseMonkeys$1$operation$1 INSTANCE;

  Day11Kt$parseMonkeys$1$operation$1();
    Code:
       0: aload_0
       1: iconst_2
       2: ldc           #11                 // class kotlin/ULong
       4: ldc           #13                 // String plus
       6: ldc           #15                 // String plus-VKZWuLQ(JJ)J
       8: iconst_0
       9: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final long invoke-oku0oEs(long, long);
    Code:
       0: lload_1
       1: lload_3
       2: ladd
       3: invokestatic  #26                 // Method kotlin/ULong."constructor-impl":(J)J
       6: lreturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #11                 // class kotlin/ULong
       5: invokevirtual #35                 // Method kotlin/ULong."unbox-impl":()J
       8: aload_2
       9: checkcast     #11                 // class kotlin/ULong
      12: invokevirtual #35                 // Method kotlin/ULong."unbox-impl":()J
      15: invokevirtual #37                 // Method "invoke-oku0oEs":(JJ)J
      18: invokestatic  #41                 // Method kotlin/ULong."box-impl":(J)Lkotlin/ULong;
      21: areturn

  static {};
    Code:
       0: new           #2                  // class Day11Kt$parseMonkeys$1$operation$1
       3: dup
       4: invokespecial #46                 // Method "<init>":()V
       7: putstatic     #49                 // Field INSTANCE:LDay11Kt$parseMonkeys$1$operation$1;
      10: return
}

Compiled from "Day11.kt"
public final class Day11Kt {
  private static final kotlin.text.Regex template;

  private static final java.util.List<MonkeyBusiness> parseMonkeys(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #9                  // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: astore_3
       9: new           #11                 // class java/util/ArrayList
      12: dup
      13: aload_1
      14: bipush        10
      16: invokestatic  #17                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      19: invokespecial #21                 // Method java/util/ArrayList."<init>":(I)V
      22: checkcast     #23                 // class java/util/Collection
      25: astore        4
      27: iconst_0
      28: istore        5
      30: aload_3
      31: invokeinterface #27,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      36: astore        6
      38: aload         6
      40: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      45: ifeq          465
      48: aload         6
      50: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      55: astore        7
      57: aload         4
      59: aload         7
      61: checkcast     #39                 // class java/lang/String
      64: astore        8
      66: astore        28
      68: iconst_0
      69: istore        9
      71: getstatic     #43                 // Field template:Lkotlin/text/Regex;
      74: aload         8
      76: checkcast     #45                 // class java/lang/CharSequence
      79: invokevirtual #51                 // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;
      82: dup
      83: invokestatic  #57                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      86: invokeinterface #63,  1           // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;
      91: astore        10
      93: aload         10
      95: invokevirtual #69                 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
      98: invokeinterface #73,  1           // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     103: iconst_2
     104: invokeinterface #79,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     109: checkcast     #39                 // class java/lang/String
     112: astore        11
     114: aload         10
     116: invokevirtual #69                 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     119: invokeinterface #73,  1           // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     124: iconst_3
     125: invokeinterface #79,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     130: checkcast     #39                 // class java/lang/String
     133: astore        12
     135: aload         10
     137: invokevirtual #69                 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     140: invokeinterface #73,  1           // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     145: iconst_4
     146: invokeinterface #79,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     151: checkcast     #39                 // class java/lang/String
     154: astore        13
     156: aload         10
     158: invokevirtual #69                 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     161: invokeinterface #73,  1           // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     166: iconst_5
     167: invokeinterface #79,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     172: checkcast     #39                 // class java/lang/String
     175: astore        14
     177: aload         10
     179: invokevirtual #69                 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     182: invokeinterface #73,  1           // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     187: bipush        6
     189: invokeinterface #79,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     194: checkcast     #39                 // class java/lang/String
     197: astore        15
     199: aload         10
     201: invokevirtual #69                 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;
     204: invokeinterface #73,  1           // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;
     209: bipush        7
     211: invokeinterface #79,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     216: checkcast     #39                 // class java/lang/String
     219: astore        16
     221: aload         11
     223: checkcast     #45                 // class java/lang/CharSequence
     226: iconst_1
     227: anewarray     #39                 // class java/lang/String
     230: astore        17
     232: aload         17
     234: iconst_0
     235: ldc           #81                 // String ,
     237: aastore
     238: aload         17
     240: iconst_0
     241: iconst_0
     242: bipush        6
     244: aconst_null
     245: invokestatic  #87                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     248: checkcast     #9                  // class java/lang/Iterable
     251: astore        17
     253: iconst_0
     254: istore        18
     256: aload         17
     258: astore        19
     260: new           #11                 // class java/util/ArrayList
     263: dup
     264: aload         17
     266: bipush        10
     268: invokestatic  #17                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     271: invokespecial #21                 // Method java/util/ArrayList."<init>":(I)V
     274: checkcast     #23                 // class java/util/Collection
     277: astore        20
     279: iconst_0
     280: istore        21
     282: aload         19
     284: invokeinterface #27,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     289: astore        22
     291: aload         22
     293: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     298: ifeq          344
     301: aload         22
     303: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     308: astore        23
     310: aload         20
     312: aload         23
     314: checkcast     #39                 // class java/lang/String
     317: astore        24
     319: astore        25
     321: iconst_0
     322: istore        26
     324: aload         24
     326: invokestatic  #93                 // Method kotlin/text/UStringsKt.toULong:(Ljava/lang/String;)J
     329: invokestatic  #99                 // Method kotlin/ULong."box-impl":(J)Lkotlin/ULong;
     332: aload         25
     334: swap
     335: invokeinterface #103,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     340: pop
     341: goto          291
     344: aload         20
     346: checkcast     #75                 // class java/util/List
     349: nop
     350: checkcast     #23                 // class java/util/Collection
     353: invokestatic  #107                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     356: astore        27
     358: aload         12
     360: checkcast     #45                 // class java/lang/CharSequence
     363: invokestatic  #111                // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C
     366: tableswitch   { // 42 to 43
                    42: 397
                    43: 388
               default: 406
          }
     388: getstatic     #117                // Field Day11Kt$parseMonkeys$1$operation$1.INSTANCE:LDay11Kt$parseMonkeys$1$operation$1;
     391: checkcast     #119                // class kotlin/jvm/functions/Function2
     394: goto          419
     397: getstatic     #124                // Field Day11Kt$parseMonkeys$1$operation$2.INSTANCE:LDay11Kt$parseMonkeys$1$operation$2;
     400: checkcast     #119                // class kotlin/jvm/functions/Function2
     403: goto          419
     406: new           #126                // class java/lang/IllegalStateException
     409: dup
     410: ldc           #128                // String Incorrect input
     412: invokevirtual #132                // Method java/lang/Object.toString:()Ljava/lang/String;
     415: invokespecial #135                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     418: athrow
     419: astore        17
     421: new           #137                // class MonkeyBusiness
     424: dup
     425: aload         27
     427: aload         17
     429: aload         13
     431: aload         14
     433: invokestatic  #93                 // Method kotlin/text/UStringsKt.toULong:(Ljava/lang/String;)J
     436: aload         15
     438: invokestatic  #143                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     441: aload         16
     443: invokestatic  #143                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     446: lconst_0
     447: bipush        64
     449: aconst_null
     450: invokespecial #146                // Method MonkeyBusiness."<init>":(Ljava/util/List;Lkotlin/jvm/functions/Function2;Ljava/lang/String;JIIJILkotlin/jvm/internal/DefaultConstructorMarker;)V
     453: aload         28
     455: swap
     456: invokeinterface #103,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     461: pop
     462: goto          38
     465: aload         4
     467: checkcast     #75                 // class java/util/List
     470: nop
     471: areturn

  private static final long throwRounds(java.util.List<MonkeyBusiness>, int, kotlin.jvm.functions.Function1<? super kotlin.ULong, kotlin.ULong>);
    Code:
       0: aload_0
       1: checkcast     #9                  // class java/lang/Iterable
       4: astore        5
       6: iconst_0
       7: istore        6
       9: aload         5
      11: astore        7
      13: new           #11                 // class java/util/ArrayList
      16: dup
      17: aload         5
      19: bipush        10
      21: invokestatic  #17                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      24: invokespecial #21                 // Method java/util/ArrayList."<init>":(I)V
      27: checkcast     #23                 // class java/util/Collection
      30: astore        8
      32: iconst_0
      33: istore        9
      35: aload         7
      37: invokeinterface #27,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        10
      44: aload         10
      46: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          97
      54: aload         10
      56: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        11
      63: aload         8
      65: aload         11
      67: checkcast     #137                // class MonkeyBusiness
      70: astore        12
      72: astore        17
      74: iconst_0
      75: istore        13
      77: aload         12
      79: invokevirtual #179                // Method MonkeyBusiness."getDivider-s-VKNKU":()J
      82: invokestatic  #99                 // Method kotlin/ULong."box-impl":(J)Lkotlin/ULong;
      85: aload         17
      87: swap
      88: invokeinterface #103,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      93: pop
      94: goto          44
      97: aload         8
      99: checkcast     #75                 // class java/util/List
     102: nop
     103: checkcast     #9                  // class java/lang/Iterable
     106: astore        5
     108: nop
     109: iconst_0
     110: istore        6
     112: aload         5
     114: invokeinterface #27,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     119: astore        7
     121: aload         7
     123: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     128: ifne          141
     131: new           #181                // class java/lang/UnsupportedOperationException
     134: dup
     135: ldc           #183                // String Empty collection can\'t be reduced.
     137: invokespecial #184                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     140: athrow
     141: aload         7
     143: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     148: astore        8
     150: aload         7
     152: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     157: ifeq          205
     160: aload         8
     162: aload         7
     164: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     169: checkcast     #95                 // class kotlin/ULong
     172: invokevirtual #187                // Method kotlin/ULong."unbox-impl":()J
     175: lstore        9
     177: checkcast     #95                 // class kotlin/ULong
     180: invokevirtual #187                // Method kotlin/ULong."unbox-impl":()J
     183: lstore        11
     185: iconst_0
     186: istore        13
     188: lload         11
     190: lload         9
     192: lmul
     193: invokestatic  #191                // Method kotlin/ULong."constructor-impl":(J)J
     196: nop
     197: invokestatic  #99                 // Method kotlin/ULong."box-impl":(J)Lkotlin/ULong;
     200: astore        8
     202: goto          150
     205: aload         8
     207: checkcast     #95                 // class kotlin/ULong
     210: invokevirtual #187                // Method kotlin/ULong."unbox-impl":()J
     213: lstore_3
     214: iconst_0
     215: istore        5
     217: iload         5
     219: iload_1
     220: if_icmpge     406
     223: iload         5
     225: istore        6
     227: iconst_0
     228: istore        7
     230: aload_0
     231: invokeinterface #192,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     236: astore        8
     238: aload         8
     240: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     245: ifeq          399
     248: aload         8
     250: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     255: checkcast     #137                // class MonkeyBusiness
     258: astore        9
     260: aload         9
     262: invokevirtual #195                // Method MonkeyBusiness.getItems:()Ljava/util/List;
     265: invokeinterface #192,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     270: astore        10
     272: aload         10
     274: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     279: ifeq          391
     282: aload         10
     284: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     289: checkcast     #95                 // class kotlin/ULong
     292: invokevirtual #187                // Method kotlin/ULong."unbox-impl":()J
     295: lstore        11
     297: aload         9
     299: invokevirtual #198                // Method MonkeyBusiness.getValue:()Ljava/lang/String;
     302: invokestatic  #202                // Method kotlin/text/UStringsKt.toULongOrNull:(Ljava/lang/String;)Lkotlin/ULong;
     305: dup
     306: ifnull        315
     309: invokevirtual #187                // Method kotlin/ULong."unbox-impl":()J
     312: goto          318
     315: pop
     316: lload         11
     318: lstore        13
     320: aload_2
     321: aload         9
     323: invokevirtual #206                // Method MonkeyBusiness.getOp:()Lkotlin/jvm/functions/Function2;
     326: lload         11
     328: invokestatic  #99                 // Method kotlin/ULong."box-impl":(J)Lkotlin/ULong;
     331: lload         13
     333: invokestatic  #99                 // Method kotlin/ULong."box-impl":(J)Lkotlin/ULong;
     336: invokeinterface #210,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     341: invokeinterface #215,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
     346: checkcast     #95                 // class kotlin/ULong
     349: invokevirtual #187                // Method kotlin/ULong."unbox-impl":()J
     352: lload_3
     353: invokestatic  #221                // Method java/lang/Long.remainderUnsigned:(JJ)J
     356: lstore        15
     358: aload_0
     359: aload         9
     361: lload         15
     363: invokevirtual #225                // Method MonkeyBusiness."throwDecision-VKZWuLQ":(J)I
     366: invokeinterface #79,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     371: checkcast     #137                // class MonkeyBusiness
     374: invokevirtual #195                // Method MonkeyBusiness.getItems:()Ljava/util/List;
     377: lload         15
     379: invokestatic  #99                 // Method kotlin/ULong."box-impl":(J)Lkotlin/ULong;
     382: invokeinterface #226,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     387: pop
     388: goto          272
     391: aload         9
     393: invokevirtual #230                // Method MonkeyBusiness.roundEnd:()V
     396: goto          238
     399: nop
     400: iinc          5, 1
     403: goto          217
     406: aload_0
     407: checkcast     #9                  // class java/lang/Iterable
     410: astore        5
     412: iconst_0
     413: istore        6
     415: aload         5
     417: astore        7
     419: new           #11                 // class java/util/ArrayList
     422: dup
     423: aload         5
     425: bipush        10
     427: invokestatic  #17                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     430: invokespecial #21                 // Method java/util/ArrayList."<init>":(I)V
     433: checkcast     #23                 // class java/util/Collection
     436: astore        8
     438: iconst_0
     439: istore        9
     441: aload         7
     443: invokeinterface #27,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     448: astore        10
     450: aload         10
     452: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     457: ifeq          503
     460: aload         10
     462: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     467: astore        11
     469: aload         8
     471: aload         11
     473: checkcast     #137                // class MonkeyBusiness
     476: astore        12
     478: astore        17
     480: iconst_0
     481: istore        13
     483: aload         12
     485: invokevirtual #233                // Method MonkeyBusiness."getInspected-s-VKNKU":()J
     488: invokestatic  #99                 // Method kotlin/ULong."box-impl":(J)Lkotlin/ULong;
     491: aload         17
     493: swap
     494: invokeinterface #103,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     499: pop
     500: goto          450
     503: aload         8
     505: checkcast     #75                 // class java/util/List
     508: nop
     509: checkcast     #9                  // class java/lang/Iterable
     512: invokestatic  #237                // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
     515: iconst_2
     516: invokestatic  #241                // Method kotlin/collections/CollectionsKt.takeLast:(Ljava/util/List;I)Ljava/util/List;
     519: checkcast     #9                  // class java/lang/Iterable
     522: astore        5
     524: iconst_0
     525: istore        6
     527: aload         5
     529: invokeinterface #27,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     534: astore        7
     536: aload         7
     538: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     543: ifne          556
     546: new           #181                // class java/lang/UnsupportedOperationException
     549: dup
     550: ldc           #183                // String Empty collection can\'t be reduced.
     552: invokespecial #184                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     555: athrow
     556: aload         7
     558: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     563: astore        8
     565: aload         7
     567: invokeinterface #33,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     572: ifeq          620
     575: aload         8
     577: aload         7
     579: invokeinterface #37,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     584: checkcast     #95                 // class kotlin/ULong
     587: invokevirtual #187                // Method kotlin/ULong."unbox-impl":()J
     590: lstore        9
     592: checkcast     #95                 // class kotlin/ULong
     595: invokevirtual #187                // Method kotlin/ULong."unbox-impl":()J
     598: lstore        11
     600: iconst_0
     601: istore        13
     603: lload         11
     605: lload         9
     607: lmul
     608: invokestatic  #191                // Method kotlin/ULong."constructor-impl":(J)J
     611: nop
     612: invokestatic  #99                 // Method kotlin/ULong."box-impl":(J)Lkotlin/ULong;
     615: astore        8
     617: goto          565
     620: aload         8
     622: checkcast     #95                 // class kotlin/ULong
     625: invokevirtual #187                // Method kotlin/ULong."unbox-impl":()J
     628: lreturn

  public static final void main();
    Code:
       0: ldc_w         #266                // String Day11_test
       3: invokestatic  #272                // Method UtilsKt.readRawBlocks:(Ljava/lang/String;)Ljava/util/List;
       6: astore_0
       7: aload_0
       8: invokestatic  #276                // Method main$part1:(Ljava/util/List;)J
      11: sipush        10605
      14: i2l
      15: invokestatic  #191                // Method kotlin/ULong."constructor-impl":(J)J
      18: lcmp
      19: ifne          26
      22: iconst_1
      23: goto          27
      26: iconst_0
      27: ifne          41
      30: new           #126                // class java/lang/IllegalStateException
      33: dup
      34: ldc_w         #278                // String Check failed.
      37: invokespecial #135                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      40: athrow
      41: aload_0
      42: invokestatic  #281                // Method main$part2:(Ljava/util/List;)J
      45: ldc2_w        #282                // long 2713310158l
      48: invokestatic  #191                // Method kotlin/ULong."constructor-impl":(J)J
      51: lcmp
      52: ifne          59
      55: iconst_1
      56: goto          60
      59: iconst_0
      60: ifne          74
      63: new           #126                // class java/lang/IllegalStateException
      66: dup
      67: ldc_w         #278                // String Check failed.
      70: invokespecial #135                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      73: athrow
      74: ldc_w         #285                // String Day11
      77: invokestatic  #272                // Method UtilsKt.readRawBlocks:(Ljava/lang/String;)Ljava/util/List;
      80: astore_1
      81: aload_1
      82: invokestatic  #276                // Method main$part1:(Ljava/util/List;)J
      85: invokestatic  #99                 // Method kotlin/ULong."box-impl":(J)Lkotlin/ULong;
      88: getstatic     #291                // Field java/lang/System.out:Ljava/io/PrintStream;
      91: swap
      92: invokevirtual #296                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      95: aload_1
      96: invokestatic  #281                // Method main$part2:(Ljava/util/List;)J
      99: invokestatic  #99                 // Method kotlin/ULong."box-impl":(J)Lkotlin/ULong;
     102: getstatic     #291                // Field java/lang/System.out:Ljava/io/PrintStream;
     105: swap
     106: invokevirtual #296                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     109: return

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

  private static final kotlin.ULong main$part1$lambda$6(kotlin.ULong);
    Code:
       0: aload_0
       1: invokevirtual #187                // Method kotlin/ULong."unbox-impl":()J
       4: iconst_3
       5: i2l
       6: ldc2_w        #305                // long 4294967295l
       9: land
      10: invokestatic  #191                // Method kotlin/ULong."constructor-impl":(J)J
      13: invokestatic  #309                // Method java/lang/Long.divideUnsigned:(JJ)J
      16: invokestatic  #99                 // Method kotlin/ULong."box-impl":(J)Lkotlin/ULong;
      19: areturn

  private static final long main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #313                // Method parseMonkeys:(Ljava/util/List;)Ljava/util/List;
       4: bipush        20
       6: invokedynamic #328,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      11: invokestatic  #330                // Method throwRounds:(Ljava/util/List;ILkotlin/jvm/functions/Function1;)J
      14: lreturn

  private static final kotlin.ULong main$part2$lambda$7(kotlin.ULong);
    Code:
       0: aload_0
       1: areturn

  private static final long main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #313                // Method parseMonkeys:(Ljava/util/List;)Ljava/util/List;
       4: sipush        10000
       7: invokedynamic #335,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
      12: invokestatic  #330                // Method throwRounds:(Ljava/util/List;ILkotlin/jvm/functions/Function1;)J
      15: lreturn

  static {};
    Code:
       0: new           #47                 // class kotlin/text/Regex
       3: dup
       4: nop
       5: ldc_w         #338                // String \nMonkey (\\d+):\n  Starting items: (.*?)\n  Operation: new = old (.) (.+)\n  Test: divisible by (\\d+)\n    If true: throw to monkey (\\d+)\n    If false: throw to monkey (\\d+)\n
       8: checkcast     #45                 // class java/lang/CharSequence
      11: invokestatic  #342                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      14: invokevirtual #132                // Method java/lang/Object.toString:()Ljava/lang/String;
      17: invokespecial #343                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      20: putstatic     #43                 // Field template:Lkotlin/text/Regex;
      23: return
}


private const val SCREEN_WIDTH = 40
private const val SCREEN_SIZE = 6 * SCREEN_WIDTH
private const val SIGNAL_STRENGTH = SCREEN_WIDTH / 2

private fun cycleSignals(input: List<String>): List<Int> {
    val signals = MutableList(2 * input.size + 1) { 1 }

    var cycle = 0
    for (i in input.indices) {
        signals[cycle + 1] = signals[cycle]

        val instruction = input[i].split(" ")
        if (instruction.first() == "addx") {
            signals[++cycle + 1] = signals[cycle] + instruction.last().toInt()
        }

        cycle++
    }

    return signals
}

fun main() {
    fun part1(input: List<String>): Int {
        val signals = cycleSignals(input)

        return (SIGNAL_STRENGTH..SCREEN_SIZE - SIGNAL_STRENGTH step SCREEN_WIDTH).sumOf { it * signals[it - 1] }
    }

    fun part2(input: List<String>): String {
        val signals = cycleSignals(input).take(SCREEN_SIZE)

        return signals.chunked(SCREEN_WIDTH) { line ->
            line.mapIndexed { ind, signal -> if (signal in ind - 1..ind + 1) '#' else '.' }.joinToString("")
        }.joinToString("\n")
    }

    // test if implementation meets criteria from the description, like:
    val testInput = readInput("Day10_test")
    check(part1(testInput) == 13_140)
    println(part2(testInput))

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

Compiled from "Day10.kt"
public final class Day10Kt {
  private static final int SCREEN_WIDTH;

  private static final int SCREEN_SIZE;

  private static final int SIGNAL_STRENGTH;

  private static final java.util.List<java.lang.Integer> cycleSignals(java.util.List<java.lang.String>);
    Code:
       0: iconst_2
       1: aload_0
       2: invokeinterface #13,  1           // InterfaceMethod java/util/List.size:()I
       7: imul
       8: iconst_1
       9: iadd
      10: istore_2
      11: new           #15                 // class java/util/ArrayList
      14: dup
      15: iload_2
      16: invokespecial #19                 // Method java/util/ArrayList."<init>":(I)V
      19: astore_3
      20: iconst_0
      21: istore        4
      23: iload         4
      25: iload_2
      26: if_icmpge     60
      29: iload         4
      31: istore        5
      33: aload_3
      34: iload         5
      36: istore        6
      38: astore        8
      40: iconst_0
      41: istore        7
      43: iconst_1
      44: invokestatic  #25                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      47: aload         8
      49: swap
      50: invokevirtual #29                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      53: pop
      54: iinc          4, 1
      57: goto          23
      60: aload_3
      61: checkcast     #9                  // class java/util/List
      64: astore_1
      65: iconst_0
      66: istore_2
      67: iconst_0
      68: istore_3
      69: aload_0
      70: checkcast     #31                 // class java/util/Collection
      73: invokeinterface #32,  1           // InterfaceMethod java/util/Collection.size:()I
      78: istore        4
      80: iload_3
      81: iload         4
      83: if_icmpge     200
      86: aload_1
      87: iload_2
      88: iconst_1
      89: iadd
      90: aload_1
      91: iload_2
      92: invokeinterface #36,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      97: invokeinterface #40,  3           // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     102: pop
     103: aload_0
     104: iload_3
     105: invokeinterface #36,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     110: checkcast     #42                 // class java/lang/CharSequence
     113: iconst_1
     114: anewarray     #44                 // class java/lang/String
     117: astore        6
     119: aload         6
     121: iconst_0
     122: ldc           #46                 // String
     124: aastore
     125: aload         6
     127: iconst_0
     128: iconst_0
     129: bipush        6
     131: aconst_null
     132: invokestatic  #52                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     135: astore        5
     137: aload         5
     139: invokestatic  #58                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     142: ldc           #60                 // String addx
     144: invokestatic  #66                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     147: ifeq          191
     150: aload_1
     151: iinc          2, 1
     154: iload_2
     155: iconst_1
     156: iadd
     157: aload_1
     158: iload_2
     159: invokeinterface #36,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     164: checkcast     #68                 // class java/lang/Number
     167: invokevirtual #71                 // Method java/lang/Number.intValue:()I
     170: aload         5
     172: invokestatic  #74                 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     175: checkcast     #44                 // class java/lang/String
     178: invokestatic  #78                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     181: iadd
     182: invokestatic  #25                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     185: invokeinterface #40,  3           // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     190: pop
     191: iinc          2, 1
     194: iinc          3, 1
     197: goto          80
     200: aload_1
     201: areturn

  public static final void main();
    Code:
       0: ldc           #93                 // String Day10_test
       2: invokestatic  #99                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #103                // Method main$part1:(Ljava/util/List;)I
      10: sipush        13140
      13: if_icmpne     20
      16: iconst_1
      17: goto          21
      20: iconst_0
      21: ifne          34
      24: new           #105                // class java/lang/IllegalStateException
      27: dup
      28: ldc           #107                // String Check failed.
      30: invokespecial #110                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      33: athrow
      34: aload_0
      35: invokestatic  #114                // Method main$part2:(Ljava/util/List;)Ljava/lang/String;
      38: getstatic     #120                // Field java/lang/System.out:Ljava/io/PrintStream;
      41: swap
      42: invokevirtual #126                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      45: ldc           #128                // String Day10
      47: invokestatic  #99                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
      50: astore_1
      51: aload_1
      52: invokestatic  #103                // Method main$part1:(Ljava/util/List;)I
      55: istore_2
      56: getstatic     #120                // Field java/lang/System.out:Ljava/io/PrintStream;
      59: iload_2
      60: invokevirtual #130                // Method java/io/PrintStream.println:(I)V
      63: aload_1
      64: invokestatic  #114                // Method main$part2:(Ljava/util/List;)Ljava/lang/String;
      67: getstatic     #120                // Field java/lang/System.out:Ljava/io/PrintStream;
      70: swap
      71: invokevirtual #126                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      74: return

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

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #138                // Method cycleSignals:(Ljava/util/List;)Ljava/util/List;
       4: astore_1
       5: new           #140                // class kotlin/ranges/IntRange
       8: dup
       9: bipush        20
      11: sipush        220
      14: invokespecial #143                // Method kotlin/ranges/IntRange."<init>":(II)V
      17: checkcast     #145                // class kotlin/ranges/IntProgression
      20: bipush        40
      22: invokestatic  #151                // Method kotlin/ranges/RangesKt.step:(Lkotlin/ranges/IntProgression;I)Lkotlin/ranges/IntProgression;
      25: checkcast     #153                // class java/lang/Iterable
      28: astore_2
      29: iconst_0
      30: istore_3
      31: aload_2
      32: invokeinterface #157,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      37: astore        4
      39: aload         4
      41: invokeinterface #163,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          99
      49: aload         4
      51: checkcast     #165                // class kotlin/collections/IntIterator
      54: invokevirtual #168                // Method kotlin/collections/IntIterator.nextInt:()I
      57: istore        5
      59: iload_3
      60: iload         5
      62: istore        6
      64: istore        8
      66: iconst_0
      67: istore        7
      69: iload         6
      71: aload_1
      72: iload         6
      74: iconst_1
      75: isub
      76: invokeinterface #36,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      81: checkcast     #68                 // class java/lang/Number
      84: invokevirtual #71                 // Method java/lang/Number.intValue:()I
      87: imul
      88: istore        9
      90: iload         8
      92: iload         9
      94: iadd
      95: istore_3
      96: goto          39
      99: iload_3
     100: ireturn

  private static final java.lang.String main$part2$lambda$3(java.util.List);
    Code:
       0: aload_0
       1: ldc           #172                // String line
       3: invokestatic  #176                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #153                // class java/lang/Iterable
      10: astore_1
      11: iconst_0
      12: istore_2
      13: aload_1
      14: astore_3
      15: new           #15                 // class java/util/ArrayList
      18: dup
      19: aload_1
      20: bipush        10
      22: invokestatic  #180                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      25: invokespecial #19                 // Method java/util/ArrayList."<init>":(I)V
      28: checkcast     #31                 // class java/util/Collection
      31: astore        4
      33: iconst_0
      34: istore        5
      36: iconst_0
      37: istore        6
      39: aload_3
      40: invokeinterface #157,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      45: astore        7
      47: aload         7
      49: invokeinterface #163,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      54: ifeq          158
      57: aload         7
      59: invokeinterface #184,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      64: astore        8
      66: aload         4
      68: iload         6
      70: iinc          6, 1
      73: istore        9
      75: iload         9
      77: ifge          83
      80: invokestatic  #187                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      83: iload         9
      85: aload         8
      87: checkcast     #68                 // class java/lang/Number
      90: invokevirtual #71                 // Method java/lang/Number.intValue:()I
      93: istore        10
      95: istore        11
      97: astore        14
      99: iconst_0
     100: istore        12
     102: iload         11
     104: iconst_1
     105: isub
     106: istore        13
     108: iload         10
     110: iload         11
     112: iconst_1
     113: iadd
     114: if_icmpgt     132
     117: iload         13
     119: iload         10
     121: if_icmpgt     128
     124: iconst_1
     125: goto          133
     128: iconst_0
     129: goto          133
     132: iconst_0
     133: ifeq          141
     136: bipush        35
     138: goto          143
     141: bipush        46
     143: invokestatic  #192                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     146: aload         14
     148: swap
     149: invokeinterface #193,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     154: pop
     155: goto          47
     158: aload         4
     160: checkcast     #9                  // class java/util/List
     163: nop
     164: checkcast     #153                // class java/lang/Iterable
     167: ldc           #195                // String
     169: checkcast     #42                 // 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  #199                // 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: areturn

  private static final java.lang.String main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #138                // Method cycleSignals:(Ljava/util/List;)Ljava/util/List;
       4: checkcast     #153                // class java/lang/Iterable
       7: sipush        240
      10: invokestatic  #217                // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;
      13: astore_1
      14: aload_1
      15: checkcast     #153                // class java/lang/Iterable
      18: bipush        40
      20: invokedynamic #234,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      25: invokestatic  #238                // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;ILkotlin/jvm/functions/Function1;)Ljava/util/List;
      28: checkcast     #153                // class java/lang/Iterable
      31: ldc           #240                // String \n
      33: checkcast     #42                 // class java/lang/CharSequence
      36: aconst_null
      37: aconst_null
      38: iconst_0
      39: aconst_null
      40: aconst_null
      41: bipush        62
      43: aconst_null
      44: invokestatic  #199                // 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;
      47: areturn
}