import java.io.File
import java.nio.charset.StandardCharsets.UTF_8
import kotlin.collections.Map.Entry

object Day14 {

    object Part1 {

        private fun toRule(s: String): Pair<List<Char>, Char> {
            val (pair, value) = s.split(" -> ")
            return pair.toCharArray().let { listOf(it[0], it[1]) } to value[0]
        }

        private fun step(
            input: List<Char>,
            rules: Map<List<Char>, Char>
        ) = input.windowed(2, 1)
            .flatMap { p ->
                rules[p]?.let { listOf(p[0], it) } ?: listOf(p[0])
            } + input.last()

        fun run() {
            val lines = File("day14/input-real.txt").readLines(UTF_8)

            val input = lines.first().toCharArray().toList()
            val rules = lines.drop(2).associate(::toRule)

            val result = generateSequence(input) { step(it, rules) }.drop(10).first()

            val freqs = result.groupingBy { it }.eachCount().entries
            val max = freqs.maxOf { it.value }
            val min = freqs.minOf { it.value }

            println(max - min)
        }
    }

    object Part2 {

        private fun toRule(s: String): Pair<List<Char>, Char> {
            val (pair, value) = s.split(" -> ")
            return pair.toCharArray().let { listOf(it[0], it[1]) } to value[0]
        }

        private fun toTransitions() = { (k, v): Entry<List<Char>, Char> ->
            (k[0] to k[1]) to listOf(k[0] to v, v to k[1]) }

        private fun step(
            values: MutableMap<Pair<Char, Char>, Long>,
            transitions: Map<Pair<Char, Char>, List<Pair<Char, Char>>>
        ): MutableMap<Pair<Char, Char>, Long> {
            val newValues = values.flatMap { (k, v) ->
                val new = transitions[k]!!
                new.map { it to v }
            }.groupBy({ it.first }, { it.second }).mapValues { it.value.sum() }

            return newValues.toMutableMap();
        }

        fun run() {
            val lines = File("day14/input-real.txt").readLines(UTF_8)

            val input = lines.first().toCharArray().toList()

            val rules = lines.drop(2).associate(::toRule)
            val transitions = rules.map(toTransitions()).toMap()

            val initialFreqs = input
                .windowed(2, 1)
                .map { it[0] to it[1] }
                .groupingBy { it }
                .eachCount()
                .mapValues { it.value.toLong() }
                .toMutableMap()

            val result = generateSequence(initialFreqs) { step(it, transitions) }.drop(40).first()

            val freqs = result.entries
                .groupBy({ it.key.first }, { it.value })
                .mapValues { it.value.sum() }
                .toMutableMap().also {
                    // Add single last character in
                    it[input.last()] = 1L + it[input.last()]!!
                }

            val max = freqs.maxOf { it.value }
            val min = freqs.minOf { it.value }

            println(max - min)
        }
    }
}

fun main() {
    Day14.Part1.run()
    Day14.Part2.run()
}

Compiled from "Day14.kt"
public final class Day14Kt {
  public static final void main();
    Code:
       0: getstatic     #12                 // Field Day14$Part1.INSTANCE:LDay14$Part1;
       3: invokevirtual #15                 // Method Day14$Part1.run:()V
       6: getstatic     #20                 // Field Day14$Part2.INSTANCE:LDay14$Part2;
       9: invokevirtual #21                 // Method Day14$Part2.run:()V
      12: return

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

Compiled from "Day14.kt"
public final class Day14$Part1 {
  public static final Day14$Part1 INSTANCE;

  private Day14$Part1();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  private final kotlin.Pair<java.util.List<java.lang.Character>, java.lang.Character> toRule(java.lang.String);
    Code:
       0: aload_1
       1: checkcast     #15                 // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #17                 // class java/lang/String
       8: astore_3
       9: aload_3
      10: iconst_0
      11: ldc           #19                 // String  ->
      13: aastore
      14: aload_3
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #25                 // 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 #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      31: checkcast     #17                 // class java/lang/String
      34: astore_3
      35: aload_2
      36: iconst_1
      37: invokeinterface #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      42: checkcast     #17                 // class java/lang/String
      45: astore        4
      47: aload_3
      48: invokevirtual #35                 // Method java/lang/String.toCharArray:()[C
      51: dup
      52: ldc           #37                 // String toCharArray(...)
      54: invokestatic  #43                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      57: astore        5
      59: iconst_0
      60: istore        6
      62: iconst_2
      63: anewarray     #45                 // class java/lang/Character
      66: astore        7
      68: aload         7
      70: iconst_0
      71: aload         5
      73: iconst_0
      74: caload
      75: invokestatic  #49                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      78: aastore
      79: aload         7
      81: iconst_1
      82: aload         5
      84: iconst_1
      85: caload
      86: invokestatic  #49                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      89: aastore
      90: aload         7
      92: invokestatic  #55                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      95: nop
      96: aload         4
      98: iconst_0
      99: invokevirtual #59                 // Method java/lang/String.charAt:(I)C
     102: invokestatic  #49                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     105: invokestatic  #65                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     108: areturn

  private final java.util.List<java.lang.Character> step(java.util.List<java.lang.Character>, java.util.Map<java.util.List<java.lang.Character>, java.lang.Character>);
    Code:
       0: aload_1
       1: checkcast     #78                 // class java/lang/Iterable
       4: iconst_2
       5: iconst_1
       6: iconst_0
       7: iconst_4
       8: aconst_null
       9: invokestatic  #82                 // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;
      12: checkcast     #78                 // class java/lang/Iterable
      15: astore_3
      16: nop
      17: iconst_0
      18: istore        4
      20: aload_3
      21: astore        5
      23: new           #84                 // class java/util/ArrayList
      26: dup
      27: invokespecial #85                 // Method java/util/ArrayList."<init>":()V
      30: checkcast     #87                 // class java/util/Collection
      33: astore        6
      35: iconst_0
      36: istore        7
      38: aload         5
      40: invokeinterface #91,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      45: astore        8
      47: aload         8
      49: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      54: ifeq          164
      57: aload         8
      59: invokeinterface #101,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      64: astore        9
      66: aload         9
      68: checkcast     #27                 // class java/util/List
      71: astore        10
      73: iconst_0
      74: istore        11
      76: aload_2
      77: aload         10
      79: invokeinterface #106,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      84: checkcast     #45                 // class java/lang/Character
      87: dup
      88: ifnull        136
      91: invokevirtual #110                // Method java/lang/Character.charValue:()C
      94: istore        12
      96: iconst_0
      97: istore        13
      99: iconst_2
     100: anewarray     #45                 // class java/lang/Character
     103: astore        14
     105: aload         14
     107: iconst_0
     108: aload         10
     110: iconst_0
     111: invokeinterface #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     116: aastore
     117: aload         14
     119: iconst_1
     120: iload         12
     122: invokestatic  #49                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     125: aastore
     126: aload         14
     128: invokestatic  #55                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     131: nop
     132: dup
     133: ifnonnull     148
     136: pop
     137: aload         10
     139: iconst_0
     140: invokeinterface #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     145: invokestatic  #113                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     148: checkcast     #78                 // class java/lang/Iterable
     151: astore        10
     153: aload         6
     155: aload         10
     157: invokestatic  #117                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     160: pop
     161: goto          47
     164: aload         6
     166: checkcast     #27                 // class java/util/List
     169: nop
     170: checkcast     #87                 // class java/util/Collection
     173: aload_1
     174: invokestatic  #121                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     177: invokestatic  #125                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;
     180: areturn

  public final void run();
    Code:
       0: new           #146                // class java/io/File
       3: dup
       4: ldc           #148                // String day14/input-real.txt
       6: invokespecial #151                // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: getstatic     #157                // Field java/nio/charset/StandardCharsets.UTF_8:Ljava/nio/charset/Charset;
      12: dup
      13: ldc           #158                // String UTF_8
      15: invokestatic  #43                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      18: invokestatic  #164                // Method kotlin/io/FilesKt.readLines:(Ljava/io/File;Ljava/nio/charset/Charset;)Ljava/util/List;
      21: astore_1
      22: aload_1
      23: invokestatic  #167                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      26: checkcast     #17                 // class java/lang/String
      29: invokevirtual #35                 // Method java/lang/String.toCharArray:()[C
      32: dup
      33: ldc           #37                 // String toCharArray(...)
      35: invokestatic  #43                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      38: invokestatic  #173                // Method kotlin/collections/ArraysKt.toList:([C)Ljava/util/List;
      41: astore_2
      42: aload_1
      43: checkcast     #78                 // class java/lang/Iterable
      46: iconst_2
      47: invokestatic  #177                // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
      50: checkcast     #78                 // class java/lang/Iterable
      53: astore        4
      55: iconst_0
      56: istore        5
      58: aload         4
      60: bipush        10
      62: invokestatic  #181                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      65: invokestatic  #187                // Method kotlin/collections/MapsKt.mapCapacity:(I)I
      68: bipush        16
      70: invokestatic  #193                // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I
      73: istore        6
      75: aload         4
      77: astore        7
      79: new           #195                // class java/util/LinkedHashMap
      82: dup
      83: iload         6
      85: invokespecial #198                // Method java/util/LinkedHashMap."<init>":(I)V
      88: checkcast     #103                // class java/util/Map
      91: astore        8
      93: iconst_0
      94: istore        9
      96: aload         7
      98: invokeinterface #91,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     103: astore        10
     105: aload         10
     107: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     112: ifeq          167
     115: aload         10
     117: invokeinterface #101,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     122: astore        11
     124: aload         8
     126: astore        12
     128: aload         11
     130: checkcast     #17                 // class java/lang/String
     133: astore        13
     135: iconst_0
     136: istore        14
     138: aload_0
     139: aload         13
     141: invokespecial #200                // Method toRule:(Ljava/lang/String;)Lkotlin/Pair;
     144: astore        13
     146: aload         12
     148: aload         13
     150: invokevirtual #205                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     153: aload         13
     155: invokevirtual #208                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     158: invokeinterface #212,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     163: pop
     164: goto          105
     167: aload         8
     169: nop
     170: astore_3
     171: aload_2
     172: aload_3
     173: invokedynamic #231,  0            // InvokeDynamic #0:invoke:(Ljava/util/Map;)Lkotlin/jvm/functions/Function1;
     178: invokestatic  #237                // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     181: bipush        10
     183: invokestatic  #240                // Method kotlin/sequences/SequencesKt.drop:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;
     186: invokestatic  #243                // Method kotlin/sequences/SequencesKt.first:(Lkotlin/sequences/Sequence;)Ljava/lang/Object;
     189: checkcast     #27                 // class java/util/List
     192: astore        4
     194: aload         4
     196: checkcast     #78                 // class java/lang/Iterable
     199: astore        6
     201: iconst_0
     202: istore        7
     204: new           #245                // class Day14$Part1$run$$inlined$groupingBy$1
     207: dup
     208: aload         6
     210: invokespecial #248                // Method Day14$Part1$run$$inlined$groupingBy$1."<init>":(Ljava/lang/Iterable;)V
     213: checkcast     #250                // class kotlin/collections/Grouping
     216: invokestatic  #256                // Method kotlin/collections/GroupingKt.eachCount:(Lkotlin/collections/Grouping;)Ljava/util/Map;
     219: invokeinterface #260,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     224: astore        5
     226: aload         5
     228: checkcast     #78                 // class java/lang/Iterable
     231: invokeinterface #91,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     236: astore        8
     238: aload         8
     240: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     245: ifne          256
     248: new           #262                // class java/util/NoSuchElementException
     251: dup
     252: invokespecial #263                // Method java/util/NoSuchElementException."<init>":()V
     255: athrow
     256: aload         8
     258: invokeinterface #101,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     263: checkcast     #265                // class java/util/Map$Entry
     266: astore        9
     268: iconst_0
     269: istore        10
     271: aload         9
     273: invokeinterface #268,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     278: checkcast     #270                // class java/lang/Number
     281: invokevirtual #274                // Method java/lang/Number.intValue:()I
     284: istore        9
     286: aload         8
     288: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     293: ifeq          340
     296: aload         8
     298: invokeinterface #101,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     303: checkcast     #265                // class java/util/Map$Entry
     306: astore        10
     308: iconst_0
     309: istore        11
     311: aload         10
     313: invokeinterface #268,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     318: checkcast     #270                // class java/lang/Number
     321: invokevirtual #274                // Method java/lang/Number.intValue:()I
     324: istore        10
     326: iload         9
     328: iload         10
     330: if_icmpge     286
     333: iload         10
     335: istore        9
     337: goto          286
     340: iload         9
     342: istore        6
     344: aload         5
     346: checkcast     #78                 // class java/lang/Iterable
     349: invokeinterface #91,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     354: astore        9
     356: aload         9
     358: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     363: ifne          374
     366: new           #262                // class java/util/NoSuchElementException
     369: dup
     370: invokespecial #263                // Method java/util/NoSuchElementException."<init>":()V
     373: athrow
     374: aload         9
     376: invokeinterface #101,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     381: checkcast     #265                // class java/util/Map$Entry
     384: astore        10
     386: iconst_0
     387: istore        11
     389: aload         10
     391: invokeinterface #268,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     396: checkcast     #270                // class java/lang/Number
     399: invokevirtual #274                // Method java/lang/Number.intValue:()I
     402: istore        10
     404: aload         9
     406: invokeinterface #97,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     411: ifeq          458
     414: aload         9
     416: invokeinterface #101,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     421: checkcast     #265                // class java/util/Map$Entry
     424: astore        11
     426: iconst_0
     427: istore        12
     429: aload         11
     431: invokeinterface #268,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     436: checkcast     #270                // class java/lang/Number
     439: invokevirtual #274                // Method java/lang/Number.intValue:()I
     442: istore        11
     444: iload         10
     446: iload         11
     448: if_icmple     404
     451: iload         11
     453: istore        10
     455: goto          404
     458: iload         10
     460: istore        7
     462: iload         6
     464: iload         7
     466: isub
     467: istore        8
     469: getstatic     #280                // Field java/lang/System.out:Ljava/io/PrintStream;
     472: iload         8
     474: invokevirtual #285                // Method java/io/PrintStream.println:(I)V
     477: return

  private static final java.util.List run$lambda$3(java.util.Map, java.util.List);
    Code:
       0: aload_1
       1: ldc_w         #306                // String it
       4: invokestatic  #309                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: getstatic     #312                // Field INSTANCE:LDay14$Part1;
      10: aload_1
      11: aload_0
      12: invokespecial #314                // Method step:(Ljava/util/List;Ljava/util/Map;)Ljava/util/List;
      15: areturn

  static {};
    Code:
       0: new           #2                  // class Day14$Part1
       3: dup
       4: invokespecial #317                // Method "<init>":()V
       7: putstatic     #312                // Field INSTANCE:LDay14$Part1;
      10: return
}

Compiled from "Day14.kt"
public final class Day14 {
  public static final Day14 INSTANCE;

  private Day14();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  static {};
    Code:
       0: new           #2                  // class Day14
       3: dup
       4: invokespecial #12                 // Method "<init>":()V
       7: putstatic     #15                 // Field INSTANCE:LDay14;
      10: return
}

Compiled from "Day14.kt"
public final class Day14$Part2 {
  public static final Day14$Part2 INSTANCE;

  private Day14$Part2();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  private final kotlin.Pair<java.util.List<java.lang.Character>, java.lang.Character> toRule(java.lang.String);
    Code:
       0: aload_1
       1: checkcast     #15                 // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #17                 // class java/lang/String
       8: astore_3
       9: aload_3
      10: iconst_0
      11: ldc           #19                 // String  ->
      13: aastore
      14: aload_3
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #25                 // 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 #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      31: checkcast     #17                 // class java/lang/String
      34: astore_3
      35: aload_2
      36: iconst_1
      37: invokeinterface #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      42: checkcast     #17                 // class java/lang/String
      45: astore        4
      47: aload_3
      48: invokevirtual #35                 // Method java/lang/String.toCharArray:()[C
      51: dup
      52: ldc           #37                 // String toCharArray(...)
      54: invokestatic  #43                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      57: astore        5
      59: iconst_0
      60: istore        6
      62: iconst_2
      63: anewarray     #45                 // class java/lang/Character
      66: astore        7
      68: aload         7
      70: iconst_0
      71: aload         5
      73: iconst_0
      74: caload
      75: invokestatic  #49                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      78: aastore
      79: aload         7
      81: iconst_1
      82: aload         5
      84: iconst_1
      85: caload
      86: invokestatic  #49                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      89: aastore
      90: aload         7
      92: invokestatic  #55                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      95: nop
      96: aload         4
      98: iconst_0
      99: invokevirtual #59                 // Method java/lang/String.charAt:(I)C
     102: invokestatic  #49                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     105: invokestatic  #65                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     108: areturn

  private final kotlin.jvm.functions.Function1<java.util.Map$Entry<? extends java.util.List<java.lang.Character>, java.lang.Character>, kotlin.Pair<kotlin.Pair<java.lang.Character, java.lang.Character>, java.util.List<kotlin.Pair<java.lang.Character, java.lang.Character>>>> toTransitions();
    Code:
       0: invokedynamic #94,  0             // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
       5: areturn

  private final java.util.Map<kotlin.Pair<java.lang.Character, java.lang.Character>, java.lang.Long> step(java.util.Map<kotlin.Pair<java.lang.Character, java.lang.Character>, java.lang.Long>, java.util.Map<kotlin.Pair<java.lang.Character, java.lang.Character>, ? extends java.util.List<kotlin.Pair<java.lang.Character, java.lang.Character>>>);
    Code:
       0: aload_1
       1: astore        4
       3: iconst_0
       4: istore        5
       6: aload         4
       8: astore        6
      10: new           #99                 // class java/util/ArrayList
      13: dup
      14: invokespecial #100                // Method java/util/ArrayList."<init>":()V
      17: checkcast     #102                // class java/util/Collection
      20: astore        7
      22: iconst_0
      23: istore        8
      25: aload         6
      27: invokeinterface #108,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
      32: invokeinterface #114,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
      37: astore        9
      39: aload         9
      41: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      46: ifeq          235
      49: aload         9
      51: invokeinterface #124,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      56: checkcast     #126                // class java/util/Map$Entry
      59: astore        10
      61: aload         10
      63: astore        11
      65: iconst_0
      66: istore        12
      68: aload         11
      70: invokeinterface #129,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
      75: checkcast     #131                // class kotlin/Pair
      78: astore        13
      80: aload         11
      82: invokeinterface #134,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
      87: checkcast     #136                // class java/lang/Number
      90: invokevirtual #140                // Method java/lang/Number.longValue:()J
      93: lstore        14
      95: aload_2
      96: aload         13
      98: invokeinterface #142,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     103: dup
     104: invokestatic  #146                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     107: checkcast     #27                 // class java/util/List
     110: astore        16
     112: aload         16
     114: checkcast     #148                // class java/lang/Iterable
     117: astore        17
     119: iconst_0
     120: istore        18
     122: aload         17
     124: astore        19
     126: new           #99                 // class java/util/ArrayList
     129: dup
     130: aload         17
     132: bipush        10
     134: invokestatic  #152                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     137: invokespecial #155                // Method java/util/ArrayList."<init>":(I)V
     140: checkcast     #102                // class java/util/Collection
     143: astore        20
     145: iconst_0
     146: istore        21
     148: aload         19
     150: invokeinterface #156,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     155: astore        22
     157: aload         22
     159: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     164: ifeq          212
     167: aload         22
     169: invokeinterface #124,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     174: astore        23
     176: aload         20
     178: aload         23
     180: checkcast     #131                // class kotlin/Pair
     183: astore        24
     185: astore        25
     187: iconst_0
     188: istore        26
     190: aload         24
     192: lload         14
     194: invokestatic  #161                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     197: invokestatic  #65                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     200: aload         25
     202: swap
     203: invokeinterface #165,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     208: pop
     209: goto          157
     212: aload         20
     214: checkcast     #27                 // class java/util/List
     217: nop
     218: checkcast     #148                // class java/lang/Iterable
     221: nop
     222: astore        11
     224: aload         7
     226: aload         11
     228: invokestatic  #169                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     231: pop
     232: goto          39
     235: aload         7
     237: checkcast     #27                 // class java/util/List
     240: nop
     241: checkcast     #148                // class java/lang/Iterable
     244: astore        4
     246: nop
     247: iconst_0
     248: istore        5
     250: aload         4
     252: astore        6
     254: new           #171                // class java/util/LinkedHashMap
     257: dup
     258: invokespecial #172                // Method java/util/LinkedHashMap."<init>":()V
     261: checkcast     #104                // class java/util/Map
     264: astore        7
     266: iconst_0
     267: istore        8
     269: aload         6
     271: invokeinterface #156,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     276: astore        9
     278: aload         9
     280: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     285: ifeq          420
     288: aload         9
     290: invokeinterface #124,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     295: astore        10
     297: aload         10
     299: checkcast     #131                // class kotlin/Pair
     302: astore        11
     304: iconst_0
     305: istore        12
     307: aload         11
     309: invokevirtual #175                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     312: checkcast     #131                // class kotlin/Pair
     315: astore        13
     317: aload         7
     319: astore        14
     321: iconst_0
     322: istore        15
     324: aload         14
     326: aload         13
     328: invokeinterface #142,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     333: astore        16
     335: aload         16
     337: ifnonnull     372
     340: iconst_0
     341: istore        17
     343: new           #99                 // class java/util/ArrayList
     346: dup
     347: invokespecial #100                // Method java/util/ArrayList."<init>":()V
     350: checkcast     #27                 // class java/util/List
     353: astore        17
     355: aload         14
     357: aload         13
     359: aload         17
     361: invokeinterface #179,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     366: pop
     367: aload         17
     369: goto          374
     372: aload         16
     374: nop
     375: checkcast     #27                 // class java/util/List
     378: astore        11
     380: aload         11
     382: aload         10
     384: checkcast     #131                // class kotlin/Pair
     387: astore        12
     389: astore        27
     391: iconst_0
     392: istore        18
     394: aload         12
     396: invokevirtual #182                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     399: checkcast     #136                // class java/lang/Number
     402: invokevirtual #140                // Method java/lang/Number.longValue:()J
     405: invokestatic  #161                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     408: aload         27
     410: swap
     411: invokeinterface #183,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     416: pop
     417: goto          278
     420: aload         7
     422: nop
     423: astore        4
     425: nop
     426: iconst_0
     427: istore        5
     429: aload         4
     431: astore        6
     433: new           #171                // class java/util/LinkedHashMap
     436: dup
     437: aload         4
     439: invokeinterface #187,  1          // InterfaceMethod java/util/Map.size:()I
     444: invokestatic  #193                // Method kotlin/collections/MapsKt.mapCapacity:(I)I
     447: invokespecial #194                // Method java/util/LinkedHashMap."<init>":(I)V
     450: checkcast     #104                // class java/util/Map
     453: astore        7
     455: iconst_0
     456: istore        8
     458: aload         6
     460: invokeinterface #108,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     465: checkcast     #148                // class java/lang/Iterable
     468: astore        9
     470: iconst_0
     471: istore        10
     473: aload         9
     475: invokeinterface #156,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     480: astore        11
     482: aload         11
     484: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     489: ifeq          572
     492: aload         11
     494: invokeinterface #124,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     499: astore        12
     501: aload         7
     503: aload         12
     505: checkcast     #126                // class java/util/Map$Entry
     508: astore        13
     510: astore        14
     512: iconst_0
     513: istore        15
     515: aload         13
     517: invokeinterface #129,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     522: aload         14
     524: swap
     525: aload         12
     527: checkcast     #126                // class java/util/Map$Entry
     530: astore        16
     532: astore        28
     534: astore        27
     536: iconst_0
     537: istore        17
     539: aload         16
     541: invokeinterface #134,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     546: checkcast     #148                // class java/lang/Iterable
     549: invokestatic  #198                // Method kotlin/collections/CollectionsKt.sumOfLong:(Ljava/lang/Iterable;)J
     552: invokestatic  #161                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     555: astore        29
     557: aload         27
     559: aload         28
     561: aload         29
     563: invokeinterface #179,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     568: pop
     569: goto          482
     572: aload         7
     574: nop
     575: nop
     576: astore_3
     577: aload_3
     578: invokestatic  #202                // Method kotlin/collections/MapsKt.toMutableMap:(Ljava/util/Map;)Ljava/util/Map;
     581: areturn

  public final void run();
    Code:
       0: new           #255                // class java/io/File
       3: dup
       4: ldc_w         #257                // String day14/input-real.txt
       7: invokespecial #260                // Method java/io/File."<init>":(Ljava/lang/String;)V
      10: getstatic     #266                // Field java/nio/charset/StandardCharsets.UTF_8:Ljava/nio/charset/Charset;
      13: dup
      14: ldc_w         #267                // String UTF_8
      17: invokestatic  #43                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      20: invokestatic  #273                // Method kotlin/io/FilesKt.readLines:(Ljava/io/File;Ljava/nio/charset/Charset;)Ljava/util/List;
      23: astore_1
      24: aload_1
      25: invokestatic  #277                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      28: checkcast     #17                 // class java/lang/String
      31: invokevirtual #35                 // Method java/lang/String.toCharArray:()[C
      34: dup
      35: ldc           #37                 // String toCharArray(...)
      37: invokestatic  #43                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      40: invokestatic  #283                // Method kotlin/collections/ArraysKt.toList:([C)Ljava/util/List;
      43: astore_2
      44: aload_1
      45: checkcast     #148                // class java/lang/Iterable
      48: iconst_2
      49: invokestatic  #287                // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
      52: checkcast     #148                // class java/lang/Iterable
      55: astore        4
      57: iconst_0
      58: istore        5
      60: aload         4
      62: bipush        10
      64: invokestatic  #152                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      67: invokestatic  #193                // Method kotlin/collections/MapsKt.mapCapacity:(I)I
      70: bipush        16
      72: invokestatic  #293                // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I
      75: istore        6
      77: aload         4
      79: astore        7
      81: new           #171                // class java/util/LinkedHashMap
      84: dup
      85: iload         6
      87: invokespecial #194                // Method java/util/LinkedHashMap."<init>":(I)V
      90: checkcast     #104                // class java/util/Map
      93: astore        8
      95: iconst_0
      96: istore        9
      98: aload         7
     100: invokeinterface #156,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     105: astore        10
     107: aload         10
     109: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     114: ifeq          169
     117: aload         10
     119: invokeinterface #124,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     124: astore        11
     126: aload         8
     128: astore        12
     130: aload         11
     132: checkcast     #17                 // class java/lang/String
     135: astore        14
     137: iconst_0
     138: istore        16
     140: aload_0
     141: aload         14
     143: invokespecial #295                // Method toRule:(Ljava/lang/String;)Lkotlin/Pair;
     146: astore        14
     148: aload         12
     150: aload         14
     152: invokevirtual #175                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     155: aload         14
     157: invokevirtual #182                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     160: invokeinterface #179,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     165: pop
     166: goto          107
     169: aload         8
     171: nop
     172: astore_3
     173: aload_3
     174: astore        5
     176: aload_0
     177: invokespecial #297                // Method toTransitions:()Lkotlin/jvm/functions/Function1;
     180: astore        6
     182: iconst_0
     183: istore        7
     185: aload         5
     187: astore        8
     189: new           #99                 // class java/util/ArrayList
     192: dup
     193: aload         5
     195: invokeinterface #187,  1          // InterfaceMethod java/util/Map.size:()I
     200: invokespecial #155                // Method java/util/ArrayList."<init>":(I)V
     203: checkcast     #102                // class java/util/Collection
     206: astore        9
     208: iconst_0
     209: istore        10
     211: aload         8
     213: invokeinterface #108,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     218: invokeinterface #114,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     223: astore        11
     225: aload         11
     227: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     232: ifeq          267
     235: aload         11
     237: invokeinterface #124,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     242: checkcast     #126                // class java/util/Map$Entry
     245: astore        12
     247: aload         9
     249: aload         6
     251: aload         12
     253: invokeinterface #301,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
     258: invokeinterface #165,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     263: pop
     264: goto          225
     267: aload         9
     269: checkcast     #27                 // class java/util/List
     272: nop
     273: checkcast     #148                // class java/lang/Iterable
     276: invokestatic  #305                // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;
     279: astore        4
     281: aload_2
     282: checkcast     #148                // class java/lang/Iterable
     285: iconst_2
     286: iconst_1
     287: iconst_0
     288: iconst_4
     289: aconst_null
     290: invokestatic  #309                // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;
     293: checkcast     #148                // class java/lang/Iterable
     296: astore        6
     298: nop
     299: iconst_0
     300: istore        7
     302: aload         6
     304: astore        8
     306: new           #99                 // class java/util/ArrayList
     309: dup
     310: aload         6
     312: bipush        10
     314: invokestatic  #152                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     317: invokespecial #155                // Method java/util/ArrayList."<init>":(I)V
     320: checkcast     #102                // class java/util/Collection
     323: astore        9
     325: iconst_0
     326: istore        10
     328: aload         8
     330: invokeinterface #156,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     335: astore        11
     337: aload         11
     339: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     344: ifeq          401
     347: aload         11
     349: invokeinterface #124,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     354: astore        12
     356: aload         9
     358: aload         12
     360: checkcast     #27                 // class java/util/List
     363: astore        14
     365: astore        27
     367: iconst_0
     368: istore        16
     370: aload         14
     372: iconst_0
     373: invokeinterface #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     378: aload         14
     380: iconst_1
     381: invokeinterface #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     386: invokestatic  #65                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     389: aload         27
     391: swap
     392: invokeinterface #165,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     397: pop
     398: goto          337
     401: aload         9
     403: checkcast     #27                 // class java/util/List
     406: nop
     407: checkcast     #148                // class java/lang/Iterable
     410: astore        6
     412: nop
     413: iconst_0
     414: istore        7
     416: new           #311                // class Day14$Part2$run$$inlined$groupingBy$1
     419: dup
     420: aload         6
     422: invokespecial #314                // Method Day14$Part2$run$$inlined$groupingBy$1."<init>":(Ljava/lang/Iterable;)V
     425: checkcast     #316                // class kotlin/collections/Grouping
     428: invokestatic  #322                // Method kotlin/collections/GroupingKt.eachCount:(Lkotlin/collections/Grouping;)Ljava/util/Map;
     431: astore        6
     433: nop
     434: iconst_0
     435: istore        7
     437: aload         6
     439: astore        8
     441: new           #171                // class java/util/LinkedHashMap
     444: dup
     445: aload         6
     447: invokeinterface #187,  1          // InterfaceMethod java/util/Map.size:()I
     452: invokestatic  #193                // Method kotlin/collections/MapsKt.mapCapacity:(I)I
     455: invokespecial #194                // Method java/util/LinkedHashMap."<init>":(I)V
     458: checkcast     #104                // class java/util/Map
     461: astore        9
     463: iconst_0
     464: istore        10
     466: aload         8
     468: invokeinterface #108,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     473: checkcast     #148                // class java/lang/Iterable
     476: astore        11
     478: iconst_0
     479: istore        12
     481: aload         11
     483: invokeinterface #156,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     488: astore        14
     490: aload         14
     492: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     497: ifeq          581
     500: aload         14
     502: invokeinterface #124,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     507: astore        16
     509: aload         9
     511: aload         16
     513: checkcast     #126                // class java/util/Map$Entry
     516: astore        18
     518: astore        20
     520: iconst_0
     521: istore        21
     523: aload         18
     525: invokeinterface #129,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     530: aload         20
     532: swap
     533: aload         16
     535: checkcast     #126                // class java/util/Map$Entry
     538: astore        22
     540: astore        28
     542: astore        27
     544: iconst_0
     545: istore        23
     547: aload         22
     549: invokeinterface #134,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     554: checkcast     #136                // class java/lang/Number
     557: invokevirtual #325                // Method java/lang/Number.intValue:()I
     560: i2l
     561: invokestatic  #161                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     564: astore        29
     566: aload         27
     568: aload         28
     570: aload         29
     572: invokeinterface #179,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     577: pop
     578: goto          490
     581: aload         9
     583: nop
     584: nop
     585: invokestatic  #202                // Method kotlin/collections/MapsKt.toMutableMap:(Ljava/util/Map;)Ljava/util/Map;
     588: astore        5
     590: aload         5
     592: aload         4
     594: invokedynamic #333,  0            // InvokeDynamic #1:invoke:(Ljava/util/Map;)Lkotlin/jvm/functions/Function1;
     599: invokestatic  #339                // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     602: bipush        40
     604: invokestatic  #342                // Method kotlin/sequences/SequencesKt.drop:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;
     607: invokestatic  #345                // Method kotlin/sequences/SequencesKt.first:(Lkotlin/sequences/Sequence;)Ljava/lang/Object;
     610: checkcast     #104                // class java/util/Map
     613: astore        6
     615: aload         6
     617: invokeinterface #108,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     622: checkcast     #148                // class java/lang/Iterable
     625: astore        8
     627: nop
     628: iconst_0
     629: istore        9
     631: aload         8
     633: astore        10
     635: new           #171                // class java/util/LinkedHashMap
     638: dup
     639: invokespecial #172                // Method java/util/LinkedHashMap."<init>":()V
     642: checkcast     #104                // class java/util/Map
     645: astore        11
     647: iconst_0
     648: istore        12
     650: aload         10
     652: invokeinterface #156,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     657: astore        14
     659: aload         14
     661: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     666: ifeq          817
     669: aload         14
     671: invokeinterface #124,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     676: astore        16
     678: aload         16
     680: checkcast     #126                // class java/util/Map$Entry
     683: astore        18
     685: iconst_0
     686: istore        20
     688: aload         18
     690: invokeinterface #129,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     695: checkcast     #131                // class kotlin/Pair
     698: invokevirtual #175                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     701: checkcast     #45                 // class java/lang/Character
     704: invokevirtual #349                // Method java/lang/Character.charValue:()C
     707: invokestatic  #49                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     710: astore        21
     712: aload         11
     714: astore        22
     716: iconst_0
     717: istore        23
     719: aload         22
     721: aload         21
     723: invokeinterface #142,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     728: astore        24
     730: aload         24
     732: ifnonnull     767
     735: iconst_0
     736: istore        25
     738: new           #99                 // class java/util/ArrayList
     741: dup
     742: invokespecial #100                // Method java/util/ArrayList."<init>":()V
     745: checkcast     #27                 // class java/util/List
     748: astore        25
     750: aload         22
     752: aload         21
     754: aload         25
     756: invokeinterface #179,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     761: pop
     762: aload         25
     764: goto          769
     767: aload         24
     769: nop
     770: checkcast     #27                 // class java/util/List
     773: astore        18
     775: aload         18
     777: aload         16
     779: checkcast     #126                // class java/util/Map$Entry
     782: astore        20
     784: astore        27
     786: iconst_0
     787: istore        26
     789: aload         20
     791: invokeinterface #134,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     796: checkcast     #136                // class java/lang/Number
     799: invokevirtual #140                // Method java/lang/Number.longValue:()J
     802: invokestatic  #161                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     805: aload         27
     807: swap
     808: invokeinterface #183,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     813: pop
     814: goto          659
     817: aload         11
     819: nop
     820: astore        8
     822: nop
     823: iconst_0
     824: istore        9
     826: aload         8
     828: astore        10
     830: new           #171                // class java/util/LinkedHashMap
     833: dup
     834: aload         8
     836: invokeinterface #187,  1          // InterfaceMethod java/util/Map.size:()I
     841: invokestatic  #193                // Method kotlin/collections/MapsKt.mapCapacity:(I)I
     844: invokespecial #194                // Method java/util/LinkedHashMap."<init>":(I)V
     847: checkcast     #104                // class java/util/Map
     850: astore        11
     852: iconst_0
     853: istore        12
     855: aload         10
     857: invokeinterface #108,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     862: checkcast     #148                // class java/lang/Iterable
     865: astore        14
     867: iconst_0
     868: istore        16
     870: aload         14
     872: invokeinterface #156,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     877: astore        18
     879: aload         18
     881: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     886: ifeq          969
     889: aload         18
     891: invokeinterface #124,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     896: astore        20
     898: aload         11
     900: aload         20
     902: checkcast     #126                // class java/util/Map$Entry
     905: astore        21
     907: astore        22
     909: iconst_0
     910: istore        23
     912: aload         21
     914: invokeinterface #129,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     919: aload         22
     921: swap
     922: aload         20
     924: checkcast     #126                // class java/util/Map$Entry
     927: astore        24
     929: astore        28
     931: astore        27
     933: iconst_0
     934: istore        25
     936: aload         24
     938: invokeinterface #134,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     943: checkcast     #148                // class java/lang/Iterable
     946: invokestatic  #198                // Method kotlin/collections/CollectionsKt.sumOfLong:(Ljava/lang/Iterable;)J
     949: invokestatic  #161                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     952: astore        29
     954: aload         27
     956: aload         28
     958: aload         29
     960: invokeinterface #179,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     965: pop
     966: goto          879
     969: aload         11
     971: nop
     972: nop
     973: invokestatic  #202                // Method kotlin/collections/MapsKt.toMutableMap:(Ljava/util/Map;)Ljava/util/Map;
     976: astore        8
     978: aload         8
     980: astore        9
     982: iconst_0
     983: istore        10
     985: aload         9
     987: aload_2
     988: invokestatic  #352                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     991: lconst_1
     992: aload         9
     994: aload_2
     995: invokestatic  #352                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     998: invokeinterface #142,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
    1003: dup
    1004: invokestatic  #146                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
    1007: checkcast     #136                // class java/lang/Number
    1010: invokevirtual #140                // Method java/lang/Number.longValue:()J
    1013: ladd
    1014: invokestatic  #161                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
    1017: invokeinterface #179,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    1022: pop
    1023: nop
    1024: aload         8
    1026: astore        7
    1028: aload         7
    1030: invokeinterface #108,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
    1035: checkcast     #148                // class java/lang/Iterable
    1038: invokeinterface #156,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
    1043: astore        11
    1045: aload         11
    1047: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
    1052: ifne          1063
    1055: new           #354                // class java/util/NoSuchElementException
    1058: dup
    1059: invokespecial #355                // Method java/util/NoSuchElementException."<init>":()V
    1062: athrow
    1063: aload         11
    1065: invokeinterface #124,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1070: checkcast     #126                // class java/util/Map$Entry
    1073: astore        12
    1075: iconst_0
    1076: istore        14
    1078: aload         12
    1080: invokeinterface #134,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
    1085: checkcast     #136                // class java/lang/Number
    1088: invokevirtual #140                // Method java/lang/Number.longValue:()J
    1091: lstore        12
    1093: aload         11
    1095: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
    1100: ifeq          1148
    1103: aload         11
    1105: invokeinterface #124,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1110: checkcast     #126                // class java/util/Map$Entry
    1113: astore        14
    1115: iconst_0
    1116: istore        16
    1118: aload         14
    1120: invokeinterface #134,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
    1125: checkcast     #136                // class java/lang/Number
    1128: invokevirtual #140                // Method java/lang/Number.longValue:()J
    1131: lstore        14
    1133: lload         12
    1135: lload         14
    1137: lcmp
    1138: ifge          1093
    1141: lload         14
    1143: lstore        12
    1145: goto          1093
    1148: lload         12
    1150: lstore        8
    1152: aload         7
    1154: invokeinterface #108,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
    1159: checkcast     #148                // class java/lang/Iterable
    1162: invokeinterface #156,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
    1167: astore        14
    1169: aload         14
    1171: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
    1176: ifne          1187
    1179: new           #354                // class java/util/NoSuchElementException
    1182: dup
    1183: invokespecial #355                // Method java/util/NoSuchElementException."<init>":()V
    1186: athrow
    1187: aload         14
    1189: invokeinterface #124,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1194: checkcast     #126                // class java/util/Map$Entry
    1197: astore        16
    1199: iconst_0
    1200: istore        18
    1202: aload         16
    1204: invokeinterface #134,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
    1209: checkcast     #136                // class java/lang/Number
    1212: invokevirtual #140                // Method java/lang/Number.longValue:()J
    1215: lstore        16
    1217: aload         14
    1219: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
    1224: ifeq          1272
    1227: aload         14
    1229: invokeinterface #124,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1234: checkcast     #126                // class java/util/Map$Entry
    1237: astore        18
    1239: iconst_0
    1240: istore        20
    1242: aload         18
    1244: invokeinterface #134,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
    1249: checkcast     #136                // class java/lang/Number
    1252: invokevirtual #140                // Method java/lang/Number.longValue:()J
    1255: lstore        18
    1257: lload         16
    1259: lload         18
    1261: lcmp
    1262: ifle          1217
    1265: lload         18
    1267: lstore        16
    1269: goto          1217
    1272: lload         16
    1274: lstore        10
    1276: lload         8
    1278: lload         10
    1280: lsub
    1281: lstore        12
    1283: getstatic     #361                // Field java/lang/System.out:Ljava/io/PrintStream;
    1286: lload         12
    1288: invokevirtual #367                // Method java/io/PrintStream.println:(J)V
    1291: return

  private static final kotlin.Pair toTransitions$lambda$1(java.util.Map$Entry);
    Code:
       0: aload_0
       1: ldc_w         #396                // String <destruct>
       4: invokestatic  #399                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokeinterface #129,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
      13: checkcast     #27                 // class java/util/List
      16: astore_1
      17: aload_0
      18: invokeinterface #134,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
      23: checkcast     #45                 // class java/lang/Character
      26: invokevirtual #349                // Method java/lang/Character.charValue:()C
      29: istore_2
      30: aload_1
      31: iconst_0
      32: invokeinterface #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      37: aload_1
      38: iconst_1
      39: invokeinterface #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      44: invokestatic  #65                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      47: iconst_2
      48: anewarray     #131                // class kotlin/Pair
      51: astore_3
      52: aload_3
      53: iconst_0
      54: aload_1
      55: iconst_0
      56: invokeinterface #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      61: iload_2
      62: invokestatic  #49                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      65: invokestatic  #65                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      68: aastore
      69: aload_3
      70: iconst_1
      71: iload_2
      72: invokestatic  #49                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      75: aload_1
      76: iconst_1
      77: invokeinterface #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      82: invokestatic  #65                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      85: aastore
      86: aload_3
      87: invokestatic  #55                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      90: invokestatic  #65                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      93: areturn

  private static final java.util.Map run$lambda$10(java.util.Map, java.util.Map);
    Code:
       0: aload_1
       1: ldc_w         #401                // String it
       4: invokestatic  #399                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: getstatic     #404                // Field INSTANCE:LDay14$Part2;
      10: aload_1
      11: aload_0
      12: invokespecial #406                // Method step:(Ljava/util/Map;Ljava/util/Map;)Ljava/util/Map;
      15: areturn

  static {};
    Code:
       0: new           #2                  // class Day14$Part2
       3: dup
       4: invokespecial #409                // Method "<init>":()V
       7: putstatic     #404                // Field INSTANCE:LDay14$Part2;
      10: return
}

Compiled from "_Collections.kt"
public final class Day14$Part2$run$$inlined$groupingBy$1 implements kotlin.collections.Grouping<kotlin.Pair<? extends java.lang.Character, ? extends java.lang.Character>, kotlin.Pair<? extends java.lang.Character, ? extends java.lang.Character>> {
  final java.lang.Iterable $this_groupingBy;

  public Day14$Part2$run$$inlined$groupingBy$1(java.lang.Iterable);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #18                 // Field $this_groupingBy:Ljava/lang/Iterable;
       5: aload_0
       6: invokespecial #21                 // Method java/lang/Object."<init>":()V
       9: return

  public java.util.Iterator<kotlin.Pair<? extends java.lang.Character, ? extends java.lang.Character>> sourceIterator();
    Code:
       0: aload_0
       1: getfield      #18                 // Field $this_groupingBy:Ljava/lang/Iterable;
       4: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
       9: areturn

  public kotlin.Pair<? extends java.lang.Character, ? extends java.lang.Character> keyOf(kotlin.Pair<? extends java.lang.Character, ? extends java.lang.Character>);
    Code:
       0: aload_1
       1: checkcast     #37                 // class kotlin/Pair
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: areturn
}

Compiled from "_Collections.kt"
public final class Day14$Part1$run$$inlined$groupingBy$1 implements kotlin.collections.Grouping<java.lang.Character, java.lang.Character> {
  final java.lang.Iterable $this_groupingBy;

  public Day14$Part1$run$$inlined$groupingBy$1(java.lang.Iterable);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #18                 // Field $this_groupingBy:Ljava/lang/Iterable;
       5: aload_0
       6: invokespecial #21                 // Method java/lang/Object."<init>":()V
       9: return

  public java.util.Iterator<java.lang.Character> sourceIterator();
    Code:
       0: aload_0
       1: getfield      #18                 // Field $this_groupingBy:Ljava/lang/Iterable;
       4: invokeinterface #32,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
       9: areturn

  public java.lang.Character keyOf(java.lang.Character);
    Code:
       0: aload_1
       1: checkcast     #37                 // class java/lang/Character
       4: invokevirtual #41                 // Method java/lang/Character.charValue:()C
       7: istore_2
       8: iconst_0
       9: istore_3
      10: iload_2
      11: invokestatic  #45                 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      14: areturn
}