class Day11 {

    fun part1(input: String): Long {
        val monkeys = input.split("\n\n").map { it.toMonkey() }.toTypedArray()
        val rounds = 20
        val stressReducerFormula: (Long) -> Long = { it / 3 }
        repeat(rounds) { round ->
            monkeys.forEach {
                it.handleItems(stressReducerFormula).forEach {
                        (item, monkey) -> monkeys[monkey].passItem(item)
                }
            }
        }
        return monkeys.map { it.handledItemsCount }.sortedDescending().take(2).reduce { acc, i -> acc * i }
    }

    fun part2(input: String): Long {
        val monkeys = input.split("\n\n").map { it.toMonkey() }.toTypedArray()
        val rounds = 10000
        val lcm = monkeys.map { it.divisor.toLong() }.reduce(Long::times)
        val stressReducerFormula: (Long) -> Long = { it % lcm }
        repeat(rounds) {
            monkeys.forEach {
                it.handleItems(stressReducerFormula).forEach { (itemToPass, monkeyNumber) ->
                    monkeys[monkeyNumber].passItem(itemToPass)
                }
            }
        }
        val map = monkeys.map { it.handledItemsCount }
        return map.sortedDescending().take(2).reduce { acc, i -> acc * i }
    }

    data class Monkey(
        private val items: MutableList<Long>,
        private val newStressLevelFormula: (Long) -> Long,
        val divisor: Int,
        private val passToOnSuccess: Int,
        private val passToOnFailure: Int,
        var handledItemsCount: Long = 0L
    ) {
        fun handleItems(stressReducerFormula: (Long) -> Long): List<Pair<Long, Int>> {
            val handledItems = items.map {
                handledItemsCount++
                handleItem(it, stressReducerFormula)
            }
            items.clear()
            return handledItems
        }

        private fun handleItem(item: Long, stressReducerFormula: (Long) -> Long): Pair<Long, Int> {
            val newStressLevel = newStressLevelFormula(item)
            val levelAfterBoredMonkey = stressReducerFormula(newStressLevel)
            return levelAfterBoredMonkey to if (levelAfterBoredMonkey % divisor == 0L) passToOnSuccess else passToOnFailure
        }

        fun passItem(item: Long) {
            items.add(item)
        }
    }

    private fun String.toMonkey(): Monkey {
        val lines = split("\n")
        val monkeyNumber = lines[0].toMonkeyNumber()
        val items = lines[1].toItems()
        val operation = lines[2].mapToOperation()
        val divisor = lines[3].toDivisor()
        val passToOnSuccess = lines[4].toSuccessMonkey()
        val passToOnFailure = lines[5].toFailureMonkey()
        return Monkey(items, operation, divisor, passToOnSuccess, passToOnFailure)
    }

    private fun String.toMonkeyNumber() = substringAfter("Monkey ").dropLast(1).toInt()
    private fun String.toItems() = trim()
        .substringAfter("Starting items: ")
        .split(", ")
        .map { it.toLong() }
        .toMutableList()

    private fun String.toDivisor() = trim().substringAfter("Test: divisible by ").toInt()
    private fun String.toSuccessMonkey() = trim().substringAfter("If true: throw to monkey ").toInt()
    private fun String.toFailureMonkey() = trim().substringAfter("If false: throw to monkey ").toInt()

    private fun String.mapToOperation(): (Long) -> Long {
        val (sign, value) = trim().substringAfter("Operation: new = old ").split(" ")
        return when (sign) {
            "*" -> { old -> old * if (value == "old") old else value.toLong() }
            "+" -> { old -> old + if (value == "old") old else value.toLong() }
            else -> error("wrong operation $this")
        }
    }
}

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

  public final long part1(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #15                 // String input
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #23                 // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #25                 // class java/lang/String
      14: astore_3
      15: aload_3
      16: iconst_0
      17: ldc           #27                 // String \n\n
      19: aastore
      20: aload_3
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #33                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: checkcast     #35                 // class java/lang/Iterable
      32: astore_3
      33: iconst_0
      34: istore        4
      36: aload_3
      37: astore        5
      39: new           #37                 // class java/util/ArrayList
      42: dup
      43: aload_3
      44: bipush        10
      46: invokestatic  #43                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      49: invokespecial #46                 // Method java/util/ArrayList."<init>":(I)V
      52: checkcast     #48                 // class java/util/Collection
      55: astore        6
      57: iconst_0
      58: istore        7
      60: aload         5
      62: invokeinterface #52,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      67: astore        8
      69: aload         8
      71: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      76: ifeq          120
      79: aload         8
      81: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      86: astore        9
      88: aload         6
      90: aload         9
      92: checkcast     #25                 // class java/lang/String
      95: astore        10
      97: astore        24
      99: iconst_0
     100: istore        11
     102: aload_0
     103: aload         10
     105: invokespecial #66                 // Method toMonkey:(Ljava/lang/String;)LDay11$Monkey;
     108: aload         24
     110: swap
     111: invokeinterface #70,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     116: pop
     117: goto          69
     120: aload         6
     122: checkcast     #72                 // class java/util/List
     125: nop
     126: checkcast     #48                 // class java/util/Collection
     129: astore_3
     130: nop
     131: iconst_0
     132: istore        4
     134: aload_3
     135: astore        5
     137: aload         5
     139: iconst_0
     140: anewarray     #74                 // class Day11$Monkey
     143: invokeinterface #78,  2           // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;
     148: checkcast     #80                 // class "[LDay11$Monkey;"
     151: astore_2
     152: bipush        20
     154: istore_3
     155: invokedynamic #100,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
     160: astore        4
     162: iconst_0
     163: istore        5
     165: iload         5
     167: iload_3
     168: if_icmpge     323
     171: iload         5
     173: istore        6
     175: iconst_0
     176: istore        7
     178: aload_2
     179: astore        8
     181: iconst_0
     182: istore        9
     184: iconst_0
     185: istore        10
     187: aload         8
     189: arraylength
     190: istore        11
     192: iload         10
     194: iload         11
     196: if_icmpge     315
     199: aload         8
     201: iload         10
     203: aaload
     204: astore        12
     206: aload         12
     208: astore        13
     210: iconst_0
     211: istore        14
     213: aload         13
     215: aload         4
     217: invokevirtual #104                // Method Day11$Monkey.handleItems:(Lkotlin/jvm/functions/Function1;)Ljava/util/List;
     220: checkcast     #35                 // class java/lang/Iterable
     223: astore        15
     225: iconst_0
     226: istore        16
     228: aload         15
     230: invokeinterface #52,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     235: astore        17
     237: aload         17
     239: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     244: ifeq          306
     247: aload         17
     249: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     254: astore        18
     256: aload         18
     258: checkcast     #106                // class kotlin/Pair
     261: astore        19
     263: iconst_0
     264: istore        20
     266: aload         19
     268: invokevirtual #109                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     271: checkcast     #111                // class java/lang/Number
     274: invokevirtual #115                // Method java/lang/Number.longValue:()J
     277: lstore        21
     279: aload         19
     281: invokevirtual #118                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     284: checkcast     #111                // class java/lang/Number
     287: invokevirtual #122                // Method java/lang/Number.intValue:()I
     290: istore        23
     292: aload_2
     293: iload         23
     295: aaload
     296: lload         21
     298: invokevirtual #126                // Method Day11$Monkey.passItem:(J)V
     301: nop
     302: nop
     303: goto          237
     306: nop
     307: nop
     308: nop
     309: iinc          10, 1
     312: goto          192
     315: nop
     316: nop
     317: iinc          5, 1
     320: goto          165
     323: aload_2
     324: astore        5
     326: iconst_0
     327: istore        6
     329: aload         5
     331: astore        7
     333: new           #37                 // class java/util/ArrayList
     336: dup
     337: aload         5
     339: arraylength
     340: invokespecial #46                 // Method java/util/ArrayList."<init>":(I)V
     343: checkcast     #48                 // class java/util/Collection
     346: astore        8
     348: iconst_0
     349: istore        9
     351: iconst_0
     352: istore        10
     354: aload         7
     356: arraylength
     357: istore        11
     359: iload         10
     361: iload         11
     363: if_icmpge     407
     366: aload         7
     368: iload         10
     370: aaload
     371: astore        12
     373: aload         8
     375: aload         12
     377: astore        13
     379: astore        24
     381: iconst_0
     382: istore        14
     384: aload         13
     386: invokevirtual #129                // Method Day11$Monkey.getHandledItemsCount:()J
     389: invokestatic  #135                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     392: aload         24
     394: swap
     395: invokeinterface #70,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     400: pop
     401: iinc          10, 1
     404: goto          359
     407: aload         8
     409: checkcast     #72                 // class java/util/List
     412: nop
     413: checkcast     #35                 // class java/lang/Iterable
     416: invokestatic  #139                // Method kotlin/collections/CollectionsKt.sortedDescending:(Ljava/lang/Iterable;)Ljava/util/List;
     419: checkcast     #35                 // class java/lang/Iterable
     422: iconst_2
     423: invokestatic  #143                // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;
     426: checkcast     #35                 // class java/lang/Iterable
     429: astore        5
     431: iconst_0
     432: istore        6
     434: aload         5
     436: invokeinterface #52,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     441: astore        7
     443: aload         7
     445: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     450: ifne          463
     453: new           #145                // class java/lang/UnsupportedOperationException
     456: dup
     457: ldc           #147                // String Empty collection can\'t be reduced.
     459: invokespecial #150                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     462: athrow
     463: aload         7
     465: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     470: astore        8
     472: aload         7
     474: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     479: ifeq          523
     482: aload         8
     484: aload         7
     486: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     491: checkcast     #111                // class java/lang/Number
     494: invokevirtual #115                // Method java/lang/Number.longValue:()J
     497: lstore        9
     499: checkcast     #111                // class java/lang/Number
     502: invokevirtual #115                // Method java/lang/Number.longValue:()J
     505: lstore        11
     507: iconst_0
     508: istore        13
     510: lload         11
     512: lload         9
     514: lmul
     515: invokestatic  #135                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     518: astore        8
     520: goto          472
     523: aload         8
     525: checkcast     #111                // class java/lang/Number
     528: invokevirtual #115                // Method java/lang/Number.longValue:()J
     531: lreturn

  public final long part2(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #15                 // String input
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #23                 // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #25                 // class java/lang/String
      14: astore_3
      15: aload_3
      16: iconst_0
      17: ldc           #27                 // String \n\n
      19: aastore
      20: aload_3
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #33                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: checkcast     #35                 // class java/lang/Iterable
      32: astore_3
      33: iconst_0
      34: istore        4
      36: aload_3
      37: astore        5
      39: new           #37                 // class java/util/ArrayList
      42: dup
      43: aload_3
      44: bipush        10
      46: invokestatic  #43                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      49: invokespecial #46                 // Method java/util/ArrayList."<init>":(I)V
      52: checkcast     #48                 // class java/util/Collection
      55: astore        6
      57: iconst_0
      58: istore        7
      60: aload         5
      62: invokeinterface #52,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      67: astore        8
      69: aload         8
      71: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      76: ifeq          120
      79: aload         8
      81: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      86: astore        9
      88: aload         6
      90: aload         9
      92: checkcast     #25                 // class java/lang/String
      95: astore        10
      97: astore        26
      99: iconst_0
     100: istore        11
     102: aload_0
     103: aload         10
     105: invokespecial #66                 // Method toMonkey:(Ljava/lang/String;)LDay11$Monkey;
     108: aload         26
     110: swap
     111: invokeinterface #70,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     116: pop
     117: goto          69
     120: aload         6
     122: checkcast     #72                 // class java/util/List
     125: nop
     126: checkcast     #48                 // class java/util/Collection
     129: astore_3
     130: nop
     131: iconst_0
     132: istore        4
     134: aload_3
     135: astore        5
     137: aload         5
     139: iconst_0
     140: anewarray     #74                 // class Day11$Monkey
     143: invokeinterface #78,  2           // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;
     148: checkcast     #80                 // class "[LDay11$Monkey;"
     151: astore_2
     152: sipush        10000
     155: istore_3
     156: aload_2
     157: astore        6
     159: iconst_0
     160: istore        7
     162: aload         6
     164: astore        8
     166: new           #37                 // class java/util/ArrayList
     169: dup
     170: aload         6
     172: arraylength
     173: invokespecial #46                 // Method java/util/ArrayList."<init>":(I)V
     176: checkcast     #48                 // class java/util/Collection
     179: astore        9
     181: iconst_0
     182: istore        10
     184: iconst_0
     185: istore        11
     187: aload         8
     189: arraylength
     190: istore        12
     192: iload         11
     194: iload         12
     196: if_icmpge     241
     199: aload         8
     201: iload         11
     203: aaload
     204: astore        13
     206: aload         9
     208: aload         13
     210: astore        14
     212: astore        26
     214: iconst_0
     215: istore        15
     217: aload         14
     219: invokevirtual #197                // Method Day11$Monkey.getDivisor:()I
     222: i2l
     223: invokestatic  #135                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     226: aload         26
     228: swap
     229: invokeinterface #70,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     234: pop
     235: iinc          11, 1
     238: goto          192
     241: aload         9
     243: checkcast     #72                 // class java/util/List
     246: nop
     247: checkcast     #35                 // class java/lang/Iterable
     250: astore        6
     252: nop
     253: iconst_0
     254: istore        7
     256: aload         6
     258: invokeinterface #52,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     263: astore        8
     265: aload         8
     267: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     272: ifne          285
     275: new           #145                // class java/lang/UnsupportedOperationException
     278: dup
     279: ldc           #147                // String Empty collection can\'t be reduced.
     281: invokespecial #150                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     284: athrow
     285: aload         8
     287: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     292: astore        9
     294: aload         8
     296: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     301: ifeq          345
     304: aload         9
     306: aload         8
     308: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     313: checkcast     #111                // class java/lang/Number
     316: invokevirtual #115                // Method java/lang/Number.longValue:()J
     319: lstore        10
     321: checkcast     #111                // class java/lang/Number
     324: invokevirtual #115                // Method java/lang/Number.longValue:()J
     327: lstore        12
     329: iconst_0
     330: istore        14
     332: lload         12
     334: lload         10
     336: lmul
     337: invokestatic  #135                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     340: astore        9
     342: goto          294
     345: aload         9
     347: checkcast     #111                // class java/lang/Number
     350: invokevirtual #115                // Method java/lang/Number.longValue:()J
     353: lstore        4
     355: lload         4
     357: invokedynamic #205,  0            // InvokeDynamic #1:invoke:(J)Lkotlin/jvm/functions/Function1;
     362: astore        6
     364: iconst_0
     365: istore        7
     367: iload         7
     369: iload_3
     370: if_icmpge     525
     373: iload         7
     375: istore        8
     377: iconst_0
     378: istore        9
     380: aload_2
     381: astore        10
     383: iconst_0
     384: istore        11
     386: iconst_0
     387: istore        12
     389: aload         10
     391: arraylength
     392: istore        13
     394: iload         12
     396: iload         13
     398: if_icmpge     517
     401: aload         10
     403: iload         12
     405: aaload
     406: astore        14
     408: aload         14
     410: astore        15
     412: iconst_0
     413: istore        16
     415: aload         15
     417: aload         6
     419: invokevirtual #104                // Method Day11$Monkey.handleItems:(Lkotlin/jvm/functions/Function1;)Ljava/util/List;
     422: checkcast     #35                 // class java/lang/Iterable
     425: astore        17
     427: iconst_0
     428: istore        18
     430: aload         17
     432: invokeinterface #52,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     437: astore        19
     439: aload         19
     441: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     446: ifeq          508
     449: aload         19
     451: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     456: astore        20
     458: aload         20
     460: checkcast     #106                // class kotlin/Pair
     463: astore        21
     465: iconst_0
     466: istore        22
     468: aload         21
     470: invokevirtual #109                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     473: checkcast     #111                // class java/lang/Number
     476: invokevirtual #115                // Method java/lang/Number.longValue:()J
     479: lstore        23
     481: aload         21
     483: invokevirtual #118                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     486: checkcast     #111                // class java/lang/Number
     489: invokevirtual #122                // Method java/lang/Number.intValue:()I
     492: istore        25
     494: aload_2
     495: iload         25
     497: aaload
     498: lload         23
     500: invokevirtual #126                // Method Day11$Monkey.passItem:(J)V
     503: nop
     504: nop
     505: goto          439
     508: nop
     509: nop
     510: nop
     511: iinc          12, 1
     514: goto          394
     517: nop
     518: nop
     519: iinc          7, 1
     522: goto          367
     525: aload_2
     526: astore        8
     528: iconst_0
     529: istore        9
     531: aload         8
     533: astore        10
     535: new           #37                 // class java/util/ArrayList
     538: dup
     539: aload         8
     541: arraylength
     542: invokespecial #46                 // Method java/util/ArrayList."<init>":(I)V
     545: checkcast     #48                 // class java/util/Collection
     548: astore        11
     550: iconst_0
     551: istore        12
     553: iconst_0
     554: istore        13
     556: aload         10
     558: arraylength
     559: istore        14
     561: iload         13
     563: iload         14
     565: if_icmpge     609
     568: aload         10
     570: iload         13
     572: aaload
     573: astore        15
     575: aload         11
     577: aload         15
     579: astore        16
     581: astore        26
     583: iconst_0
     584: istore        17
     586: aload         16
     588: invokevirtual #129                // Method Day11$Monkey.getHandledItemsCount:()J
     591: invokestatic  #135                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     594: aload         26
     596: swap
     597: invokeinterface #70,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     602: pop
     603: iinc          13, 1
     606: goto          561
     609: aload         11
     611: checkcast     #72                 // class java/util/List
     614: nop
     615: astore        7
     617: aload         7
     619: checkcast     #35                 // class java/lang/Iterable
     622: invokestatic  #139                // Method kotlin/collections/CollectionsKt.sortedDescending:(Ljava/lang/Iterable;)Ljava/util/List;
     625: checkcast     #35                 // class java/lang/Iterable
     628: iconst_2
     629: invokestatic  #143                // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;
     632: checkcast     #35                 // class java/lang/Iterable
     635: astore        8
     637: iconst_0
     638: istore        9
     640: aload         8
     642: invokeinterface #52,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     647: astore        10
     649: aload         10
     651: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     656: ifne          669
     659: new           #145                // class java/lang/UnsupportedOperationException
     662: dup
     663: ldc           #147                // String Empty collection can\'t be reduced.
     665: invokespecial #150                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     668: athrow
     669: aload         10
     671: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     676: astore        11
     678: aload         10
     680: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     685: ifeq          729
     688: aload         11
     690: aload         10
     692: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     697: checkcast     #111                // class java/lang/Number
     700: invokevirtual #115                // Method java/lang/Number.longValue:()J
     703: lstore        12
     705: checkcast     #111                // class java/lang/Number
     708: invokevirtual #115                // Method java/lang/Number.longValue:()J
     711: lstore        14
     713: iconst_0
     714: istore        16
     716: lload         14
     718: lload         12
     720: lmul
     721: invokestatic  #135                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     724: astore        11
     726: goto          678
     729: aload         11
     731: checkcast     #111                // class java/lang/Number
     734: invokevirtual #115                // Method java/lang/Number.longValue:()J
     737: lreturn

  private final Day11$Monkey toMonkey(java.lang.String);
    Code:
       0: aload_1
       1: checkcast     #23                 // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #25                 // class java/lang/String
       8: astore_3
       9: aload_3
      10: iconst_0
      11: ldc           #222                // String \n
      13: aastore
      14: aload_3
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #33                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: astore_2
      24: aload_0
      25: aload_2
      26: iconst_0
      27: invokeinterface #226,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      32: checkcast     #25                 // class java/lang/String
      35: invokespecial #230                // Method toMonkeyNumber:(Ljava/lang/String;)I
      38: istore_3
      39: aload_0
      40: aload_2
      41: iconst_1
      42: invokeinterface #226,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      47: checkcast     #25                 // class java/lang/String
      50: invokespecial #234                // Method toItems:(Ljava/lang/String;)Ljava/util/List;
      53: astore        4
      55: aload_0
      56: aload_2
      57: iconst_2
      58: invokeinterface #226,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      63: checkcast     #25                 // class java/lang/String
      66: invokespecial #238                // Method mapToOperation:(Ljava/lang/String;)Lkotlin/jvm/functions/Function1;
      69: astore        5
      71: aload_0
      72: aload_2
      73: iconst_3
      74: invokeinterface #226,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      79: checkcast     #25                 // class java/lang/String
      82: invokespecial #241                // Method toDivisor:(Ljava/lang/String;)I
      85: istore        6
      87: aload_0
      88: aload_2
      89: iconst_4
      90: invokeinterface #226,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      95: checkcast     #25                 // class java/lang/String
      98: invokespecial #244                // Method toSuccessMonkey:(Ljava/lang/String;)I
     101: istore        7
     103: aload_0
     104: aload_2
     105: iconst_5
     106: invokeinterface #226,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     111: checkcast     #25                 // class java/lang/String
     114: invokespecial #247                // Method toFailureMonkey:(Ljava/lang/String;)I
     117: istore        8
     119: new           #74                 // class Day11$Monkey
     122: dup
     123: aload         4
     125: aload         5
     127: iload         6
     129: iload         7
     131: iload         8
     133: lconst_0
     134: bipush        32
     136: aconst_null
     137: invokespecial #250                // Method Day11$Monkey."<init>":(Ljava/util/List;Lkotlin/jvm/functions/Function1;IIIJILkotlin/jvm/internal/DefaultConstructorMarker;)V
     140: areturn

  private final int toMonkeyNumber(java.lang.String);
    Code:
       0: aload_1
       1: ldc_w         #259                // String Monkey
       4: aconst_null
       5: iconst_2
       6: aconst_null
       7: invokestatic  #263                // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
      10: iconst_1
      11: invokestatic  #267                // Method kotlin/text/StringsKt.dropLast:(Ljava/lang/String;I)Ljava/lang/String;
      14: invokestatic  #272                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      17: ireturn

  private final java.util.List<java.lang.Long> toItems(java.lang.String);
    Code:
       0: aload_1
       1: checkcast     #23                 // class java/lang/CharSequence
       4: invokestatic  #278                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
       7: invokevirtual #282                // Method java/lang/Object.toString:()Ljava/lang/String;
      10: ldc_w         #284                // String Starting items:
      13: aconst_null
      14: iconst_2
      15: aconst_null
      16: invokestatic  #263                // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
      19: checkcast     #23                 // class java/lang/CharSequence
      22: iconst_1
      23: anewarray     #25                 // class java/lang/String
      26: astore_2
      27: aload_2
      28: iconst_0
      29: ldc_w         #286                // String ,
      32: aastore
      33: aload_2
      34: iconst_0
      35: iconst_0
      36: bipush        6
      38: aconst_null
      39: invokestatic  #33                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      42: checkcast     #35                 // class java/lang/Iterable
      45: astore_2
      46: nop
      47: iconst_0
      48: istore_3
      49: aload_2
      50: astore        4
      52: new           #37                 // class java/util/ArrayList
      55: dup
      56: aload_2
      57: bipush        10
      59: invokestatic  #43                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      62: invokespecial #46                 // Method java/util/ArrayList."<init>":(I)V
      65: checkcast     #48                 // class java/util/Collection
      68: astore        5
      70: iconst_0
      71: istore        6
      73: aload         4
      75: invokeinterface #52,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      80: astore        7
      82: aload         7
      84: invokeinterface #58,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      89: ifeq          136
      92: aload         7
      94: invokeinterface #62,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      99: astore        8
     101: aload         5
     103: aload         8
     105: checkcast     #25                 // class java/lang/String
     108: astore        9
     110: astore        11
     112: iconst_0
     113: istore        10
     115: aload         9
     117: invokestatic  #289                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
     120: nop
     121: invokestatic  #135                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     124: aload         11
     126: swap
     127: invokeinterface #70,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     132: pop
     133: goto          82
     136: aload         5
     138: checkcast     #72                 // class java/util/List
     141: nop
     142: checkcast     #48                 // class java/util/Collection
     145: invokestatic  #293                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     148: areturn

  private final int toDivisor(java.lang.String);
    Code:
       0: aload_1
       1: checkcast     #23                 // class java/lang/CharSequence
       4: invokestatic  #278                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
       7: invokevirtual #282                // Method java/lang/Object.toString:()Ljava/lang/String;
      10: ldc_w         #297                // String Test: divisible by
      13: aconst_null
      14: iconst_2
      15: aconst_null
      16: invokestatic  #263                // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
      19: invokestatic  #272                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      22: ireturn

  private final int toSuccessMonkey(java.lang.String);
    Code:
       0: aload_1
       1: checkcast     #23                 // class java/lang/CharSequence
       4: invokestatic  #278                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
       7: invokevirtual #282                // Method java/lang/Object.toString:()Ljava/lang/String;
      10: ldc_w         #300                // String If true: throw to monkey
      13: aconst_null
      14: iconst_2
      15: aconst_null
      16: invokestatic  #263                // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
      19: invokestatic  #272                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      22: ireturn

  private final int toFailureMonkey(java.lang.String);
    Code:
       0: aload_1
       1: checkcast     #23                 // class java/lang/CharSequence
       4: invokestatic  #278                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
       7: invokevirtual #282                // Method java/lang/Object.toString:()Ljava/lang/String;
      10: ldc_w         #303                // String If false: throw to monkey
      13: aconst_null
      14: iconst_2
      15: aconst_null
      16: invokestatic  #263                // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
      19: invokestatic  #272                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      22: ireturn

  private final kotlin.jvm.functions.Function1<java.lang.Long, java.lang.Long> mapToOperation(java.lang.String);
    Code:
       0: aload_1
       1: checkcast     #23                 // class java/lang/CharSequence
       4: invokestatic  #278                // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
       7: invokevirtual #282                // Method java/lang/Object.toString:()Ljava/lang/String;
      10: ldc_w         #307                // String Operation: new = old
      13: aconst_null
      14: iconst_2
      15: aconst_null
      16: invokestatic  #263                // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
      19: checkcast     #23                 // class java/lang/CharSequence
      22: iconst_1
      23: anewarray     #25                 // class java/lang/String
      26: astore_3
      27: aload_3
      28: iconst_0
      29: ldc_w         #309                // String
      32: aastore
      33: aload_3
      34: iconst_0
      35: iconst_0
      36: bipush        6
      38: aconst_null
      39: invokestatic  #33                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      42: astore_2
      43: aload_2
      44: iconst_0
      45: invokeinterface #226,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      50: checkcast     #25                 // class java/lang/String
      53: astore_3
      54: aload_2
      55: iconst_1
      56: invokeinterface #226,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      61: checkcast     #25                 // class java/lang/String
      64: astore        4
      66: aload_3
      67: astore        5
      69: aload         5
      71: ldc_w         #311                // String *
      74: invokestatic  #315                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      77: ifeq          90
      80: aload         4
      82: invokedynamic #322,  0            // InvokeDynamic #2:invoke:(Ljava/lang/String;)Lkotlin/jvm/functions/Function1;
      87: goto          142
      90: aload         5
      92: ldc_w         #324                // String +
      95: invokestatic  #315                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      98: ifeq          111
     101: aload         4
     103: invokedynamic #329,  0            // InvokeDynamic #3:invoke:(Ljava/lang/String;)Lkotlin/jvm/functions/Function1;
     108: goto          142
     111: new           #331                // class java/lang/IllegalStateException
     114: dup
     115: new           #333                // class java/lang/StringBuilder
     118: dup
     119: invokespecial #334                // Method java/lang/StringBuilder."<init>":()V
     122: ldc_w         #336                // String wrong operation
     125: invokevirtual #340                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     128: aload_1
     129: invokevirtual #340                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     132: invokevirtual #341                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     135: invokevirtual #282                // Method java/lang/Object.toString:()Ljava/lang/String;
     138: invokespecial #342                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     141: athrow
     142: areturn

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

  private static final long part2$lambda$9(long, long);
    Code:
       0: lload_2
       1: lload_0
       2: lrem
       3: lreturn

  private static final long mapToOperation$lambda$16(java.lang.String, long);
    Code:
       0: lload_1
       1: aload_0
       2: ldc_w         #348                // String old
       5: invokestatic  #315                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
       8: ifeq          15
      11: lload_1
      12: goto          19
      15: aload_0
      16: invokestatic  #289                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
      19: lmul
      20: lreturn

  private static final long mapToOperation$lambda$17(java.lang.String, long);
    Code:
       0: lload_1
       1: aload_0
       2: ldc_w         #348                // String old
       5: invokestatic  #315                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
       8: ifeq          15
      11: lload_1
      12: goto          19
      15: aload_0
      16: invokestatic  #289                // Method java/lang/Long.parseLong:(Ljava/lang/String;)J
      19: ladd
      20: lreturn
}

Compiled from "Day11.kt"
public final class Day11$Monkey {
  private final java.util.List<java.lang.Long> items;

  private final kotlin.jvm.functions.Function1<java.lang.Long, java.lang.Long> newStressLevelFormula;

  private final int divisor;

  private final int passToOnSuccess;

  private final int passToOnFailure;

  private long handledItemsCount;

  public Day11$Monkey(java.util.List<java.lang.Long>, kotlin.jvm.functions.Function1<? super java.lang.Long, java.lang.Long>, int, int, int, long);
    Code:
       0: aload_1
       1: ldc           #10                 // String items
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #18                 // String newStressLevelFormula
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: invokespecial #21                 // Method java/lang/Object."<init>":()V
      16: aload_0
      17: aload_1
      18: putfield      #24                 // Field items:Ljava/util/List;
      21: aload_0
      22: aload_2
      23: putfield      #27                 // Field newStressLevelFormula:Lkotlin/jvm/functions/Function1;
      26: aload_0
      27: iload_3
      28: putfield      #31                 // Field divisor:I
      31: aload_0
      32: iload         4
      34: putfield      #34                 // Field passToOnSuccess:I
      37: aload_0
      38: iload         5
      40: putfield      #37                 // Field passToOnFailure:I
      43: aload_0
      44: lload         6
      46: putfield      #41                 // Field handledItemsCount:J
      49: return

  public Day11$Monkey(java.util.List, kotlin.jvm.functions.Function1, int, int, int, long, int, kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: iload         8
       2: bipush        32
       4: iand
       5: ifeq          11
       8: lconst_0
       9: lstore        6
      11: aload_0
      12: aload_1
      13: aload_2
      14: iload_3
      15: iload         4
      17: iload         5
      19: lload         6
      21: invokespecial #46                 // Method "<init>":(Ljava/util/List;Lkotlin/jvm/functions/Function1;IIIJ)V
      24: return

  public final int getDivisor();
    Code:
       0: aload_0
       1: getfield      #31                 // Field divisor:I
       4: ireturn

  public final long getHandledItemsCount();
    Code:
       0: aload_0
       1: getfield      #41                 // Field handledItemsCount:J
       4: lreturn

  public final void setHandledItemsCount(long);
    Code:
       0: aload_0
       1: lload_1
       2: putfield      #41                 // Field handledItemsCount:J
       5: return

  public final java.util.List<kotlin.Pair<java.lang.Long, java.lang.Integer>> handleItems(kotlin.jvm.functions.Function1<? super java.lang.Long, java.lang.Long>);
    Code:
       0: aload_1
       1: ldc           #58                 // String stressReducerFormula
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: getfield      #24                 // Field items:Ljava/util/List;
      10: checkcast     #60                 // class java/lang/Iterable
      13: astore_3
      14: iconst_0
      15: istore        4
      17: aload_3
      18: astore        5
      20: new           #62                 // class java/util/ArrayList
      23: dup
      24: aload_3
      25: bipush        10
      27: invokestatic  #68                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      30: invokespecial #71                 // Method java/util/ArrayList."<init>":(I)V
      33: checkcast     #73                 // class java/util/Collection
      36: astore        6
      38: iconst_0
      39: istore        7
      41: aload         5
      43: invokeinterface #77,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      48: astore        8
      50: aload         8
      52: invokeinterface #83,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      57: ifeq          119
      60: aload         8
      62: invokeinterface #87,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      67: astore        9
      69: aload         6
      71: aload         9
      73: checkcast     #89                 // class java/lang/Number
      76: invokevirtual #92                 // Method java/lang/Number.longValue:()J
      79: lstore        10
      81: astore        15
      83: iconst_0
      84: istore        12
      86: aload_0
      87: getfield      #41                 // Field handledItemsCount:J
      90: lstore        13
      92: aload_0
      93: lload         13
      95: lconst_1
      96: ladd
      97: putfield      #41                 // Field handledItemsCount:J
     100: aload_0
     101: lload         10
     103: aload_1
     104: invokespecial #96                 // Method handleItem:(JLkotlin/jvm/functions/Function1;)Lkotlin/Pair;
     107: aload         15
     109: swap
     110: invokeinterface #100,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     115: pop
     116: goto          50
     119: aload         6
     121: checkcast     #102                // class java/util/List
     124: nop
     125: astore_2
     126: aload_0
     127: getfield      #24                 // Field items:Ljava/util/List;
     130: invokeinterface #105,  1          // InterfaceMethod java/util/List.clear:()V
     135: aload_2
     136: areturn

  private final kotlin.Pair<java.lang.Long, java.lang.Integer> handleItem(long, kotlin.jvm.functions.Function1<? super java.lang.Long, java.lang.Long>);
    Code:
       0: aload_0
       1: getfield      #27                 // Field newStressLevelFormula:Lkotlin/jvm/functions/Function1;
       4: lload_1
       5: invokestatic  #126                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
       8: invokeinterface #130,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      13: checkcast     #89                 // class java/lang/Number
      16: invokevirtual #92                 // Method java/lang/Number.longValue:()J
      19: lstore        4
      21: aload_3
      22: lload         4
      24: invokestatic  #126                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      27: invokeinterface #130,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      32: checkcast     #89                 // class java/lang/Number
      35: invokevirtual #92                 // Method java/lang/Number.longValue:()J
      38: lstore        6
      40: lload         6
      42: invokestatic  #126                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      45: lload         6
      47: aload_0
      48: getfield      #31                 // Field divisor:I
      51: i2l
      52: lrem
      53: lconst_0
      54: lcmp
      55: ifne          65
      58: aload_0
      59: getfield      #34                 // Field passToOnSuccess:I
      62: goto          69
      65: aload_0
      66: getfield      #37                 // Field passToOnFailure:I
      69: invokestatic  #135                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      72: invokestatic  #141                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      75: areturn

  public final void passItem(long);
    Code:
       0: aload_0
       1: getfield      #24                 // Field items:Ljava/util/List;
       4: lload_1
       5: invokestatic  #126                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
       8: invokeinterface #146,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      13: pop
      14: return

  private final java.util.List<java.lang.Long> component1();
    Code:
       0: aload_0
       1: getfield      #24                 // Field items:Ljava/util/List;
       4: areturn

  private final kotlin.jvm.functions.Function1<java.lang.Long, java.lang.Long> component2();
    Code:
       0: aload_0
       1: getfield      #27                 // Field newStressLevelFormula:Lkotlin/jvm/functions/Function1;
       4: areturn

  public final int component3();
    Code:
       0: aload_0
       1: getfield      #31                 // Field divisor:I
       4: ireturn

  private final int component4();
    Code:
       0: aload_0
       1: getfield      #34                 // Field passToOnSuccess:I
       4: ireturn

  private final int component5();
    Code:
       0: aload_0
       1: getfield      #37                 // Field passToOnFailure:I
       4: ireturn

  public final long component6();
    Code:
       0: aload_0
       1: getfield      #41                 // Field handledItemsCount:J
       4: lreturn

  public final Day11$Monkey copy(java.util.List<java.lang.Long>, kotlin.jvm.functions.Function1<? super java.lang.Long, java.lang.Long>, int, int, int, long);
    Code:
       0: aload_1
       1: ldc           #10                 // String items
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #18                 // String newStressLevelFormula
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: new           #2                  // class Day11$Monkey
      15: dup
      16: aload_1
      17: aload_2
      18: iload_3
      19: iload         4
      21: iload         5
      23: lload         6
      25: invokespecial #46                 // Method "<init>":(Ljava/util/List;Lkotlin/jvm/functions/Function1;IIIJ)V
      28: areturn

  public static Day11$Monkey copy$default(Day11$Monkey, java.util.List, kotlin.jvm.functions.Function1, int, int, int, long, int, java.lang.Object);
    Code:
       0: iload         8
       2: iconst_1
       3: iand
       4: ifeq          12
       7: aload_0
       8: getfield      #24                 // Field items:Ljava/util/List;
      11: astore_1
      12: iload         8
      14: iconst_2
      15: iand
      16: ifeq          24
      19: aload_0
      20: getfield      #27                 // Field newStressLevelFormula:Lkotlin/jvm/functions/Function1;
      23: astore_2
      24: iload         8
      26: iconst_4
      27: iand
      28: ifeq          36
      31: aload_0
      32: getfield      #31                 // Field divisor:I
      35: istore_3
      36: iload         8
      38: bipush        8
      40: iand
      41: ifeq          50
      44: aload_0
      45: getfield      #34                 // Field passToOnSuccess:I
      48: istore        4
      50: iload         8
      52: bipush        16
      54: iand
      55: ifeq          64
      58: aload_0
      59: getfield      #37                 // Field passToOnFailure:I
      62: istore        5
      64: iload         8
      66: bipush        32
      68: iand
      69: ifeq          78
      72: aload_0
      73: getfield      #41                 // Field handledItemsCount:J
      76: lstore        6
      78: aload_0
      79: aload_1
      80: aload_2
      81: iload_3
      82: iload         4
      84: iload         5
      86: lload         6
      88: invokevirtual #163                // Method copy:(Ljava/util/List;Lkotlin/jvm/functions/Function1;IIIJ)LDay11$Monkey;
      91: areturn

  public java.lang.String toString();
    Code:
       0: new           #167                // class java/lang/StringBuilder
       3: dup
       4: invokespecial #168                // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #170                // String Monkey(items=
       9: invokevirtual #174                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #24                 // Field items:Ljava/util/List;
      16: invokevirtual #177                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      19: ldc           #179                // String , newStressLevelFormula=
      21: invokevirtual #174                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #27                 // Field newStressLevelFormula:Lkotlin/jvm/functions/Function1;
      28: invokevirtual #177                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      31: ldc           #181                // String , divisor=
      33: invokevirtual #174                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      36: aload_0
      37: getfield      #31                 // Field divisor:I
      40: invokevirtual #184                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      43: ldc           #186                // String , passToOnSuccess=
      45: invokevirtual #174                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      48: aload_0
      49: getfield      #34                 // Field passToOnSuccess:I
      52: invokevirtual #184                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      55: ldc           #188                // String , passToOnFailure=
      57: invokevirtual #174                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      60: aload_0
      61: getfield      #37                 // Field passToOnFailure:I
      64: invokevirtual #184                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      67: ldc           #190                // String , handledItemsCount=
      69: invokevirtual #174                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      72: aload_0
      73: getfield      #41                 // Field handledItemsCount:J
      76: invokevirtual #193                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
      79: bipush        41
      81: invokevirtual #196                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      84: invokevirtual #198                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      87: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #24                 // Field items:Ljava/util/List;
       4: invokevirtual #201                // Method java/lang/Object.hashCode:()I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #27                 // Field newStressLevelFormula:Lkotlin/jvm/functions/Function1;
      16: invokevirtual #201                // Method java/lang/Object.hashCode:()I
      19: iadd
      20: istore_1
      21: iload_1
      22: bipush        31
      24: imul
      25: aload_0
      26: getfield      #31                 // Field divisor:I
      29: invokestatic  #204                // Method java/lang/Integer.hashCode:(I)I
      32: iadd
      33: istore_1
      34: iload_1
      35: bipush        31
      37: imul
      38: aload_0
      39: getfield      #34                 // Field passToOnSuccess:I
      42: invokestatic  #204                // Method java/lang/Integer.hashCode:(I)I
      45: iadd
      46: istore_1
      47: iload_1
      48: bipush        31
      50: imul
      51: aload_0
      52: getfield      #37                 // Field passToOnFailure:I
      55: invokestatic  #204                // Method java/lang/Integer.hashCode:(I)I
      58: iadd
      59: istore_1
      60: iload_1
      61: bipush        31
      63: imul
      64: aload_0
      65: getfield      #41                 // Field handledItemsCount:J
      68: invokestatic  #207                // Method java/lang/Long.hashCode:(J)I
      71: iadd
      72: istore_1
      73: iload_1
      74: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class Day11$Monkey
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class Day11$Monkey
      20: astore_2
      21: aload_0
      22: getfield      #24                 // Field items:Ljava/util/List;
      25: aload_2
      26: getfield      #24                 // Field items:Ljava/util/List;
      29: invokestatic  #214                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      32: ifne          37
      35: iconst_0
      36: ireturn
      37: aload_0
      38: getfield      #27                 // Field newStressLevelFormula:Lkotlin/jvm/functions/Function1;
      41: aload_2
      42: getfield      #27                 // Field newStressLevelFormula:Lkotlin/jvm/functions/Function1;
      45: invokestatic  #214                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      48: ifne          53
      51: iconst_0
      52: ireturn
      53: aload_0
      54: getfield      #31                 // Field divisor:I
      57: aload_2
      58: getfield      #31                 // Field divisor:I
      61: if_icmpeq     66
      64: iconst_0
      65: ireturn
      66: aload_0
      67: getfield      #34                 // Field passToOnSuccess:I
      70: aload_2
      71: getfield      #34                 // Field passToOnSuccess:I
      74: if_icmpeq     79
      77: iconst_0
      78: ireturn
      79: aload_0
      80: getfield      #37                 // Field passToOnFailure:I
      83: aload_2
      84: getfield      #37                 // Field passToOnFailure:I
      87: if_icmpeq     92
      90: iconst_0
      91: ireturn
      92: aload_0
      93: getfield      #41                 // Field handledItemsCount:J
      96: aload_2
      97: getfield      #41                 // Field handledItemsCount:J
     100: lcmp
     101: ifeq          106
     104: iconst_0
     105: ireturn
     106: iconst_1
     107: ireturn
}


import java.lang.StringBuilder

class Day10 {

    fun part1(input: List<String>): Int {
        val cyclesToCheck = (20..220 step 40).toList()
        var result = 0
        val instructions = listOf(1) + input.flatMap { it.toOperation() }
        instructions.reduceIndexed { cycle, acc, instruction ->
            if (cycle in cyclesToCheck) {
                result += cycle * acc
            }
            acc + instruction
        }
        return result
    }

    fun part2(input: List<String>): String {
        val crtCyclesToCheck = (40..220 step 40).toList()
        var spritePosition = 0
        val instructions = listOf(1) + input.flatMap { it.toOperation() }
        val crtScreen = StringBuilder()

        instructions.reduceIndexed { cycle, acc, instruction ->
            crtScreen.append(if ((cycle - 1) % 40 in spritePosition - 1 .. spritePosition + 1) '#' else '.')
            if (cycle in crtCyclesToCheck) {
                crtScreen.appendLine()
            }
            spritePosition = acc + instruction
            acc + instruction
        }

        val screen = crtScreen.toString()
        println("====== Result ======")
        println(screen)
        println("====================")
        return screen
    }

    private fun String.toOperation(): List<Int> {
        return when {
            this == "noop" -> listOf(0)
            this.startsWith("addx") -> listOf(0, this.substringAfter("addx ").toInt())
            else -> error("wrong operation $this")
        }
    }

}

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

  public final int part1(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #16                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #24                 // class kotlin/ranges/IntRange
       9: dup
      10: bipush        20
      12: sipush        220
      15: invokespecial #27                 // Method kotlin/ranges/IntRange."<init>":(II)V
      18: checkcast     #29                 // class kotlin/ranges/IntProgression
      21: bipush        40
      23: invokestatic  #35                 // Method kotlin/ranges/RangesKt.step:(Lkotlin/ranges/IntProgression;I)Lkotlin/ranges/IntProgression;
      26: checkcast     #37                 // class java/lang/Iterable
      29: invokestatic  #43                 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
      32: astore_2
      33: iconst_0
      34: istore_3
      35: iconst_1
      36: invokestatic  #49                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      39: invokestatic  #53                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      42: checkcast     #55                 // class java/util/Collection
      45: aload_1
      46: checkcast     #37                 // class java/lang/Iterable
      49: astore        5
      51: astore        15
      53: iconst_0
      54: istore        6
      56: aload         5
      58: astore        7
      60: new           #57                 // class java/util/ArrayList
      63: dup
      64: invokespecial #58                 // Method java/util/ArrayList."<init>":()V
      67: checkcast     #55                 // class java/util/Collection
      70: astore        8
      72: iconst_0
      73: istore        9
      75: aload         7
      77: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      82: astore        10
      84: aload         10
      86: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      91: ifeq          135
      94: aload         10
      96: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     101: astore        11
     103: aload         11
     105: checkcast     #74                 // class java/lang/String
     108: astore        12
     110: iconst_0
     111: istore        13
     113: aload_0
     114: aload         12
     116: invokespecial #78                 // Method toOperation:(Ljava/lang/String;)Ljava/util/List;
     119: checkcast     #37                 // class java/lang/Iterable
     122: astore        12
     124: aload         8
     126: aload         12
     128: invokestatic  #82                 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     131: pop
     132: goto          84
     135: aload         8
     137: checkcast     #84                 // class java/util/List
     140: nop
     141: aload         15
     143: swap
     144: checkcast     #37                 // class java/lang/Iterable
     147: invokestatic  #88                 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     150: astore        4
     152: aload         4
     154: checkcast     #37                 // class java/lang/Iterable
     157: astore        5
     159: iconst_0
     160: istore        6
     162: aload         5
     164: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     169: astore        7
     171: aload         7
     173: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     178: ifne          191
     181: new           #90                 // class java/lang/UnsupportedOperationException
     184: dup
     185: ldc           #92                 // String Empty collection can\'t be reduced.
     187: invokespecial #95                 // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     190: athrow
     191: iconst_1
     192: istore        8
     194: aload         7
     196: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     201: astore        9
     203: aload         7
     205: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     210: ifeq          295
     213: iload         8
     215: iinc          8, 1
     218: istore        10
     220: iload         10
     222: ifge          228
     225: invokestatic  #98                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     228: iload         10
     230: aload         9
     232: aload         7
     234: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     239: checkcast     #100                // class java/lang/Number
     242: invokevirtual #104                // Method java/lang/Number.intValue:()I
     245: istore        11
     247: checkcast     #100                // class java/lang/Number
     250: invokevirtual #104                // Method java/lang/Number.intValue:()I
     253: istore        12
     255: istore        13
     257: iconst_0
     258: istore        14
     260: aload_2
     261: iload         13
     263: invokestatic  #49                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     266: invokeinterface #108,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     271: ifeq          282
     274: iload_3
     275: iload         13
     277: iload         12
     279: imul
     280: iadd
     281: istore_3
     282: iload         12
     284: iload         11
     286: iadd
     287: invokestatic  #49                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     290: astore        9
     292: goto          203
     295: nop
     296: iload_3
     297: ireturn

  public final java.lang.String part2(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #16                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #24                 // class kotlin/ranges/IntRange
       9: dup
      10: bipush        40
      12: sipush        220
      15: invokespecial #27                 // Method kotlin/ranges/IntRange."<init>":(II)V
      18: checkcast     #29                 // class kotlin/ranges/IntProgression
      21: bipush        40
      23: invokestatic  #35                 // Method kotlin/ranges/RangesKt.step:(Lkotlin/ranges/IntProgression;I)Lkotlin/ranges/IntProgression;
      26: checkcast     #37                 // class java/lang/Iterable
      29: invokestatic  #43                 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
      32: astore_2
      33: iconst_0
      34: istore_3
      35: iconst_1
      36: invokestatic  #49                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      39: invokestatic  #53                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      42: checkcast     #55                 // class java/util/Collection
      45: aload_1
      46: checkcast     #37                 // class java/lang/Iterable
      49: astore        5
      51: astore        19
      53: iconst_0
      54: istore        6
      56: aload         5
      58: astore        7
      60: new           #57                 // class java/util/ArrayList
      63: dup
      64: invokespecial #58                 // Method java/util/ArrayList."<init>":()V
      67: checkcast     #55                 // class java/util/Collection
      70: astore        8
      72: iconst_0
      73: istore        9
      75: aload         7
      77: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      82: astore        10
      84: aload         10
      86: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      91: ifeq          135
      94: aload         10
      96: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     101: astore        11
     103: aload         11
     105: checkcast     #74                 // class java/lang/String
     108: astore        12
     110: iconst_0
     111: istore        13
     113: aload_0
     114: aload         12
     116: invokespecial #78                 // Method toOperation:(Ljava/lang/String;)Ljava/util/List;
     119: checkcast     #37                 // class java/lang/Iterable
     122: astore        12
     124: aload         8
     126: aload         12
     128: invokestatic  #82                 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     131: pop
     132: goto          84
     135: aload         8
     137: checkcast     #84                 // class java/util/List
     140: nop
     141: aload         19
     143: swap
     144: checkcast     #37                 // class java/lang/Iterable
     147: invokestatic  #88                 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     150: astore        4
     152: new           #141                // class java/lang/StringBuilder
     155: dup
     156: invokespecial #142                // Method java/lang/StringBuilder."<init>":()V
     159: astore        5
     161: aload         4
     163: checkcast     #37                 // class java/lang/Iterable
     166: astore        6
     168: iconst_0
     169: istore        7
     171: aload         6
     173: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     178: astore        8
     180: aload         8
     182: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     187: ifne          200
     190: new           #90                 // class java/lang/UnsupportedOperationException
     193: dup
     194: ldc           #92                 // String Empty collection can\'t be reduced.
     196: invokespecial #95                 // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     199: athrow
     200: iconst_1
     201: istore        9
     203: aload         8
     205: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     210: astore        10
     212: aload         8
     214: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     219: ifeq          368
     222: iload         9
     224: iinc          9, 1
     227: istore        11
     229: iload         11
     231: ifge          237
     234: invokestatic  #98                 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     237: iload         11
     239: aload         10
     241: aload         8
     243: invokeinterface #72,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     248: checkcast     #100                // class java/lang/Number
     251: invokevirtual #104                // Method java/lang/Number.intValue:()I
     254: istore        12
     256: checkcast     #100                // class java/lang/Number
     259: invokevirtual #104                // Method java/lang/Number.intValue:()I
     262: istore        13
     264: istore        14
     266: iconst_0
     267: istore        15
     269: aload         5
     271: iload_3
     272: iconst_1
     273: isub
     274: istore        16
     276: iload_3
     277: iconst_1
     278: iadd
     279: istore        17
     281: iload         14
     283: iconst_1
     284: isub
     285: bipush        40
     287: irem
     288: istore        18
     290: iload         16
     292: iload         18
     294: if_icmpgt     312
     297: iload         18
     299: iload         17
     301: if_icmpgt     308
     304: iconst_1
     305: goto          313
     308: iconst_0
     309: goto          313
     312: iconst_0
     313: ifeq          321
     316: bipush        35
     318: goto          323
     321: bipush        46
     323: invokevirtual #146                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     326: pop
     327: aload_2
     328: iload         14
     330: invokestatic  #49                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     333: invokeinterface #108,  2          // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     338: ifeq          349
     341: aload         5
     343: bipush        10
     345: invokevirtual #146                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     348: pop
     349: iload         13
     351: iload         12
     353: iadd
     354: istore_3
     355: iload         13
     357: iload         12
     359: iadd
     360: invokestatic  #49                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     363: astore        10
     365: goto          212
     368: nop
     369: aload         5
     371: invokevirtual #150                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     374: dup
     375: ldc           #152                // String toString(...)
     377: invokestatic  #155                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     380: astore        6
     382: ldc           #157                // String ====== Result ======
     384: getstatic     #163                // Field java/lang/System.out:Ljava/io/PrintStream;
     387: swap
     388: invokevirtual #169                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     391: getstatic     #163                // Field java/lang/System.out:Ljava/io/PrintStream;
     394: aload         6
     396: invokevirtual #169                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     399: ldc           #171                // String ====================
     401: getstatic     #163                // Field java/lang/System.out:Ljava/io/PrintStream;
     404: swap
     405: invokevirtual #169                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     408: aload         6
     410: areturn

  private final java.util.List<java.lang.Integer> toOperation(java.lang.String);
    Code:
       0: nop
       1: aload_1
       2: ldc           #181                // String noop
       4: invokestatic  #185                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
       7: ifeq          20
      10: iconst_0
      11: invokestatic  #49                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      14: invokestatic  #53                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      17: goto          99
      20: aload_1
      21: ldc           #187                // String addx
      23: iconst_0
      24: iconst_2
      25: aconst_null
      26: invokestatic  #193                // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
      29: ifeq          69
      32: iconst_2
      33: anewarray     #45                 // class java/lang/Integer
      36: astore_2
      37: aload_2
      38: iconst_0
      39: iconst_0
      40: invokestatic  #49                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      43: aastore
      44: aload_2
      45: iconst_1
      46: aload_1
      47: ldc           #195                // String addx
      49: aconst_null
      50: iconst_2
      51: aconst_null
      52: invokestatic  #199                // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
      55: invokestatic  #203                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      58: invokestatic  #49                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      61: aastore
      62: aload_2
      63: invokestatic  #206                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      66: goto          99
      69: new           #208                // class java/lang/IllegalStateException
      72: dup
      73: new           #141                // class java/lang/StringBuilder
      76: dup
      77: invokespecial #142                // Method java/lang/StringBuilder."<init>":()V
      80: ldc           #210                // String wrong operation
      82: invokevirtual #213                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      85: aload_1
      86: invokevirtual #213                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      89: invokevirtual #150                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      92: invokevirtual #214                // Method java/lang/Object.toString:()Ljava/lang/String;
      95: invokespecial #215                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      98: athrow
      99: areturn
}


class Day04 {

    fun part1(input: List<String>): Int {
        return input
            .map { it.toRanges() }
            .count { (range1, range2) -> range1 includeRange range2 }
    }

    fun part2(input: List<String>): Int {
        return input
            .map { it.toRanges() }
            .count { (range1, range2) -> range1 overlapRange range2 }
    }

    private fun String.toRanges(): Pair<IntRange, IntRange> {
        val (range1, range2) = split(",")
        return Pair(range1.toRange(), range2.toRange())
    }

    private infix fun IntRange.includeRange(other: IntRange): Boolean {
        return (first <= other.first && last >= other.last)
                || (other.first <= first && other.last >= last)
    }

    private infix fun IntRange.overlapRange(other: IntRange): Boolean {
        return (first <= other.last && other.first <= last)
                || (first <= other.last && other.first <= last)
    }

    private fun String.toRange(): IntRange {
        val (from, to) = split("-")
        return from.toInt()..to.toInt()
    }
}

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

  public final int part1(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #16                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #24                 // class java/lang/Iterable
      10: astore_2
      11: nop
      12: iconst_0
      13: istore_3
      14: aload_2
      15: astore        4
      17: new           #26                 // class java/util/ArrayList
      20: dup
      21: aload_2
      22: bipush        10
      24: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      27: invokespecial #35                 // Method java/util/ArrayList."<init>":(I)V
      30: checkcast     #37                 // class java/util/Collection
      33: astore        5
      35: iconst_0
      36: istore        6
      38: aload         4
      40: invokeinterface #41,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      45: astore        7
      47: aload         7
      49: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      54: ifeq          98
      57: aload         7
      59: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      64: astore        8
      66: aload         5
      68: aload         8
      70: checkcast     #53                 // class java/lang/String
      73: astore        9
      75: astore        11
      77: iconst_0
      78: istore        10
      80: aload_0
      81: aload         9
      83: invokespecial #57                 // Method toRanges:(Ljava/lang/String;)Lkotlin/Pair;
      86: aload         11
      88: swap
      89: invokeinterface #61,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      94: pop
      95: goto          47
      98: aload         5
     100: checkcast     #63                 // class java/util/List
     103: nop
     104: checkcast     #24                 // class java/lang/Iterable
     107: astore_2
     108: nop
     109: iconst_0
     110: istore_3
     111: aload_2
     112: instanceof    #37                 // class java/util/Collection
     115: ifeq          134
     118: aload_2
     119: checkcast     #37                 // class java/util/Collection
     122: invokeinterface #66,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
     127: ifeq          134
     130: iconst_0
     131: goto          221
     134: iconst_0
     135: istore        4
     137: aload_2
     138: invokeinterface #41,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     143: astore        5
     145: aload         5
     147: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     152: ifeq          219
     155: aload         5
     157: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     162: astore        6
     164: aload         6
     166: checkcast     #68                 // class kotlin/Pair
     169: astore        7
     171: iconst_0
     172: istore        8
     174: aload         7
     176: invokevirtual #71                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     179: checkcast     #73                 // class kotlin/ranges/IntRange
     182: astore        9
     184: aload         7
     186: invokevirtual #76                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     189: checkcast     #73                 // class kotlin/ranges/IntRange
     192: astore        10
     194: aload_0
     195: aload         9
     197: aload         10
     199: invokespecial #80                 // Method includeRange:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z
     202: ifeq          145
     205: iinc          4, 1
     208: iload         4
     210: ifge          145
     213: invokestatic  #83                 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     216: goto          145
     219: iload         4
     221: ireturn

  public final int part2(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #16                 // String input
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #24                 // class java/lang/Iterable
      10: astore_2
      11: nop
      12: iconst_0
      13: istore_3
      14: aload_2
      15: astore        4
      17: new           #26                 // class java/util/ArrayList
      20: dup
      21: aload_2
      22: bipush        10
      24: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      27: invokespecial #35                 // Method java/util/ArrayList."<init>":(I)V
      30: checkcast     #37                 // class java/util/Collection
      33: astore        5
      35: iconst_0
      36: istore        6
      38: aload         4
      40: invokeinterface #41,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      45: astore        7
      47: aload         7
      49: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      54: ifeq          98
      57: aload         7
      59: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      64: astore        8
      66: aload         5
      68: aload         8
      70: checkcast     #53                 // class java/lang/String
      73: astore        9
      75: astore        11
      77: iconst_0
      78: istore        10
      80: aload_0
      81: aload         9
      83: invokespecial #57                 // Method toRanges:(Ljava/lang/String;)Lkotlin/Pair;
      86: aload         11
      88: swap
      89: invokeinterface #61,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      94: pop
      95: goto          47
      98: aload         5
     100: checkcast     #63                 // class java/util/List
     103: nop
     104: checkcast     #24                 // class java/lang/Iterable
     107: astore_2
     108: nop
     109: iconst_0
     110: istore_3
     111: aload_2
     112: instanceof    #37                 // class java/util/Collection
     115: ifeq          134
     118: aload_2
     119: checkcast     #37                 // class java/util/Collection
     122: invokeinterface #66,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
     127: ifeq          134
     130: iconst_0
     131: goto          221
     134: iconst_0
     135: istore        4
     137: aload_2
     138: invokeinterface #41,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     143: astore        5
     145: aload         5
     147: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     152: ifeq          219
     155: aload         5
     157: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     162: astore        6
     164: aload         6
     166: checkcast     #68                 // class kotlin/Pair
     169: astore        7
     171: iconst_0
     172: istore        8
     174: aload         7
     176: invokevirtual #71                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     179: checkcast     #73                 // class kotlin/ranges/IntRange
     182: astore        9
     184: aload         7
     186: invokevirtual #76                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     189: checkcast     #73                 // class kotlin/ranges/IntRange
     192: astore        10
     194: aload_0
     195: aload         9
     197: aload         10
     199: invokespecial #109                // Method overlapRange:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z
     202: ifeq          145
     205: iinc          4, 1
     208: iload         4
     210: ifge          145
     213: invokestatic  #83                 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     216: goto          145
     219: iload         4
     221: ireturn

  private final kotlin.Pair<kotlin.ranges.IntRange, kotlin.ranges.IntRange> toRanges(java.lang.String);
    Code:
       0: aload_1
       1: checkcast     #114                // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #53                 // class java/lang/String
       8: astore_3
       9: aload_3
      10: iconst_0
      11: ldc           #116                // String ,
      13: aastore
      14: aload_3
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #122                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: astore_2
      24: aload_2
      25: iconst_0
      26: invokeinterface #126,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      31: checkcast     #53                 // class java/lang/String
      34: astore_3
      35: aload_2
      36: iconst_1
      37: invokeinterface #126,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      42: checkcast     #53                 // class java/lang/String
      45: astore        4
      47: new           #68                 // class kotlin/Pair
      50: dup
      51: aload_0
      52: aload_3
      53: invokespecial #130                // Method toRange:(Ljava/lang/String;)Lkotlin/ranges/IntRange;
      56: aload_0
      57: aload         4
      59: invokespecial #130                // Method toRange:(Ljava/lang/String;)Lkotlin/ranges/IntRange;
      62: invokespecial #133                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      65: areturn

  private final boolean includeRange(kotlin.ranges.IntRange, kotlin.ranges.IntRange);
    Code:
       0: aload_1
       1: invokevirtual #138                // Method kotlin/ranges/IntRange.getFirst:()I
       4: aload_2
       5: invokevirtual #138                // Method kotlin/ranges/IntRange.getFirst:()I
       8: if_icmpgt     22
      11: aload_1
      12: invokevirtual #141                // Method kotlin/ranges/IntRange.getLast:()I
      15: aload_2
      16: invokevirtual #141                // Method kotlin/ranges/IntRange.getLast:()I
      19: if_icmpge     44
      22: aload_2
      23: invokevirtual #138                // Method kotlin/ranges/IntRange.getFirst:()I
      26: aload_1
      27: invokevirtual #138                // Method kotlin/ranges/IntRange.getFirst:()I
      30: if_icmpgt     48
      33: aload_2
      34: invokevirtual #141                // Method kotlin/ranges/IntRange.getLast:()I
      37: aload_1
      38: invokevirtual #141                // Method kotlin/ranges/IntRange.getLast:()I
      41: if_icmplt     48
      44: iconst_1
      45: goto          49
      48: iconst_0
      49: ireturn

  private final boolean overlapRange(kotlin.ranges.IntRange, kotlin.ranges.IntRange);
    Code:
       0: aload_1
       1: invokevirtual #138                // Method kotlin/ranges/IntRange.getFirst:()I
       4: aload_2
       5: invokevirtual #141                // Method kotlin/ranges/IntRange.getLast:()I
       8: if_icmpgt     22
      11: aload_2
      12: invokevirtual #138                // Method kotlin/ranges/IntRange.getFirst:()I
      15: aload_1
      16: invokevirtual #141                // Method kotlin/ranges/IntRange.getLast:()I
      19: if_icmple     44
      22: aload_1
      23: invokevirtual #138                // Method kotlin/ranges/IntRange.getFirst:()I
      26: aload_2
      27: invokevirtual #141                // Method kotlin/ranges/IntRange.getLast:()I
      30: if_icmpgt     48
      33: aload_2
      34: invokevirtual #138                // Method kotlin/ranges/IntRange.getFirst:()I
      37: aload_1
      38: invokevirtual #141                // Method kotlin/ranges/IntRange.getLast:()I
      41: if_icmpgt     48
      44: iconst_1
      45: goto          49
      48: iconst_0
      49: ireturn

  private final kotlin.ranges.IntRange toRange(java.lang.String);
    Code:
       0: aload_1
       1: checkcast     #114                // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #53                 // class java/lang/String
       8: astore_3
       9: aload_3
      10: iconst_0
      11: ldc           #146                // String -
      13: aastore
      14: aload_3
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #122                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: astore_2
      24: aload_2
      25: iconst_0
      26: invokeinterface #126,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      31: checkcast     #53                 // class java/lang/String
      34: astore_3
      35: aload_2
      36: iconst_1
      37: invokeinterface #126,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      42: checkcast     #53                 // class java/lang/String
      45: astore        4
      47: new           #73                 // class kotlin/ranges/IntRange
      50: dup
      51: aload_3
      52: invokestatic  #152                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      55: aload         4
      57: invokestatic  #152                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      60: invokespecial #155                // Method kotlin/ranges/IntRange."<init>":(II)V
      63: areturn
}