package dev.kosmx.aoc23.graphs

import java.io.File
import java.util.PriorityQueue

operator fun List<String>.get(x: Int, y: Int): Char = this.getOrNull(y)?.getOrNull(x) ?: '.'

operator fun List<String>.get(xy: Pair<Int, Int>): Char = this[xy.first, xy.second]

operator fun List<String>.contains(xy: Pair<Int, Int>): Boolean = xy.second in indices && xy.first in this[0].indices

val deltas = listOf(-1 to 0, 0 to -1, 1 to 0, 0 to 1)

val neighbours: Map<Char, Collection<Pair<Int, Int>>> = mapOf(
    '.' to listOf(),
    'S' to deltas,
    'L' to listOf(0 to -1, 1 to 0),
    'F' to listOf(1 to 0, 0 to 1),
    'J' to listOf(0 to -1, -1 to 0),
    '7' to listOf(-1 to 0, 0 to 1),
    '-' to listOf(-1 to 0, 1 to 0),
    '|' to listOf(0 to -1, 0 to 1)
)

fun main() {
    val map = File("pipes.txt").readLines()
    val start = map.indexOfFirst { 'S' in it }.let { y -> map[y].indexOf('S') to y }

    println("Start at $start")

    val lengths = mutableMapOf(start to 0)

    val seen = PriorityQueue<Pair<Int, Int>> { a, b -> lengths[a]!!.compareTo(lengths[b]!!) }.apply {
        this += start
    }

    // coordinate to vector
    val directions: MutableMap<Pair<Int, Int>, Pair<Int, Int>> = mutableMapOf(start to (0 to 0))

    // Let's BFS
    piece@while (seen.any()) {
        val head: Pair<Int, Int> = seen.remove()
        for (delta in neighbours[map[head]]!!) {
            val newPos = head + delta
            if (newPos !in lengths && neighbours[map[newPos]]!!.contains(-delta)) {
                lengths[newPos] = lengths[head]!! + 1
                // update direction vectors for part2
                directions[head] = directions.getOrDefault(head, 0 to 0) + delta
                directions[newPos] = directions.getOrDefault(newPos, 0 to 0) + delta

                seen += newPos
                continue@piece
            }
        }
    }

    println("Part1: ${lengths.maxBy { (it.value+1)/2 }}")

    // part 2, false for negative true for positive area
    val areas = mutableMapOf<Pair<Int, Int>, Boolean>()

    // last created list
    var lastUpdate = listOf<Pair<Pair<Int, Int>, Boolean>>()

    run { // Round 0
        val new = mutableListOf<Pair<Pair<Int, Int>, Boolean>>()
        for (y in map.indices) {
            for (x in map[y].indices) {
                if ((x to y) !in directions) {
                    deltas.asSequence().map { d -> d to (x to y) + d }
                        .mapNotNull { directions[it.second]?.let { (dx, dy) -> it.first * (dy to -dx) } }
                        .firstOrNull()?.let { side ->
                            if (side != 0) {
                                new += (x to y) to (side > 0)
                            }
                        }
                }
            }

        }
        lastUpdate = new
        areas += lastUpdate
    }

    //*
    while (lastUpdate.isNotEmpty()) {
        val new = mutableListOf<Pair<Pair<Int, Int>, Boolean>>()
        lastUpdate.forEach { (pos, side) ->
            deltas.forEach { delta ->
                val p = pos + delta
                if (p !in directions && p !in areas && p in map) {
                    areas += p to side
                    new += p to side
                }
            }
        }

        lastUpdate = new
    }// */

    //*
    for (y in map.indices) {
        for (x in map[y].indices) {
            val area = areas[x to y]
            val areaCode = if (area != null) if(area) "I" else "O" else "X"

            val direction = directions[x to y]?.let {
                when(it) {
                    (1 to 0), (2 to 0) -> '→'
                    -1 to 0, -2 to 0 -> '←'
                    0 to 1, 0 to 2 -> '↓'
                    0 to -1, 0 to -2 -> '↑'
                    1 to 1, -> '↘'
                    1 to -1 -> '↗'
                    -1 to -1 -> '↖'
                    -1 to 1 -> '↙'
                    else -> '↻'
                }
            }

            print((direction ?: areaCode).toString().padEnd(1, ' '))
        }
        println()
    }// */

    val groups = areas.asSequence().groupingBy { it.value }.eachCount()
    println(groups)
}

// Math!
operator fun Pair<Int, Int>.plus(other: Pair<Int, Int>): Pair<Int, Int> = first + other.first to second + other.second
operator fun Pair<Int, Int>.minus(other: Pair<Int, Int>): Pair<Int, Int> = first - other.first to second - other.second
operator fun Pair<Int, Int>.unaryMinus(): Pair<Int, Int> = -first to -second

// Mathematical dot product
operator fun Pair<Int, Int>.times(other: Pair<Int, Int>): Int = this.first * other.first + this.second * other.second

Compiled from "BFS.kt"
public final class dev.kosmx.aoc23.graphs.BFSKt {
  private static final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> deltas;

  private static final java.util.Map<java.lang.Character, java.util.Collection<kotlin.Pair<java.lang.Integer, java.lang.Integer>>> neighbours;

  public static final char get(java.util.List<java.lang.String>, int, int);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: iload_2
       8: invokestatic  #22                 // Method kotlin/collections/CollectionsKt.getOrNull:(Ljava/util/List;I)Ljava/lang/Object;
      11: checkcast     #24                 // class java/lang/String
      14: dup
      15: ifnull        35
      18: checkcast     #26                 // class java/lang/CharSequence
      21: iload_1
      22: invokestatic  #31                 // Method kotlin/text/StringsKt.getOrNull:(Ljava/lang/CharSequence;I)Ljava/lang/Character;
      25: dup
      26: ifnull        35
      29: invokevirtual #37                 // Method java/lang/Character.charValue:()C
      32: goto          38
      35: pop
      36: bipush        46
      38: ireturn

  public static final char get(java.util.List<java.lang.String>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #46                 // String xy
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: aload_1
      14: invokevirtual #52                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      17: checkcast     #54                 // class java/lang/Number
      20: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      23: aload_1
      24: invokevirtual #61                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      27: checkcast     #54                 // class java/lang/Number
      30: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      33: invokestatic  #63                 // Method get:(Ljava/util/List;II)C
      36: ireturn

  public static final boolean contains(java.util.List<java.lang.String>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #46                 // String xy
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: checkcast     #69                 // class java/util/Collection
      16: invokeinterface #72,  1           // InterfaceMethod java/util/Collection.size:()I
      21: istore_2
      22: aload_1
      23: invokevirtual #61                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      26: checkcast     #54                 // class java/lang/Number
      29: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      32: istore_3
      33: iconst_0
      34: iload_3
      35: if_icmpgt     51
      38: iload_3
      39: iload_2
      40: if_icmpge     47
      43: iconst_1
      44: goto          52
      47: iconst_0
      48: goto          52
      51: iconst_0
      52: ifeq          108
      55: aload_0
      56: iconst_0
      57: invokeinterface #77,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      62: checkcast     #26                 // class java/lang/CharSequence
      65: invokeinterface #80,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      70: istore_2
      71: aload_1
      72: invokevirtual #52                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      75: checkcast     #54                 // class java/lang/Number
      78: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      81: istore_3
      82: iconst_0
      83: iload_3
      84: if_icmpgt     100
      87: iload_3
      88: iload_2
      89: if_icmpge     96
      92: iconst_1
      93: goto          101
      96: iconst_0
      97: goto          101
     100: iconst_0
     101: ifeq          108
     104: iconst_1
     105: goto          109
     108: iconst_0
     109: ireturn

  public static final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> getDeltas();
    Code:
       0: getstatic     #87                 // Field deltas:Ljava/util/List;
       3: areturn

  public static final java.util.Map<java.lang.Character, java.util.Collection<kotlin.Pair<java.lang.Integer, java.lang.Integer>>> getNeighbours();
    Code:
       0: getstatic     #94                 // Field neighbours:Ljava/util/Map;
       3: areturn

  public static final void main();
    Code:
       0: new           #98                 // class java/io/File
       3: dup
       4: ldc           #100                // String pipes.txt
       6: invokespecial #104                // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #110                // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      15: astore_0
      16: aload_0
      17: astore_2
      18: iconst_0
      19: istore_3
      20: iconst_0
      21: istore        4
      23: aload_2
      24: invokeinterface #114,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      29: astore        5
      31: aload         5
      33: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      38: ifeq          87
      41: aload         5
      43: invokeinterface #123,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      48: astore        6
      50: aload         6
      52: checkcast     #24                 // class java/lang/String
      55: astore        7
      57: iconst_0
      58: istore        8
      60: aload         7
      62: checkcast     #26                 // class java/lang/CharSequence
      65: bipush        83
      67: iconst_0
      68: iconst_2
      69: aconst_null
      70: invokestatic  #127                // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;CZILjava/lang/Object;)Z
      73: ifeq          81
      76: iload         4
      78: goto          88
      81: iinc          4, 1
      84: goto          31
      87: iconst_m1
      88: istore_3
      89: iconst_0
      90: istore        4
      92: aload_0
      93: iload_3
      94: invokeinterface #77,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      99: checkcast     #26                 // class java/lang/CharSequence
     102: bipush        83
     104: iconst_0
     105: iconst_0
     106: bipush        6
     108: aconst_null
     109: invokestatic  #131                // Method kotlin/text/StringsKt.indexOf$default:(Ljava/lang/CharSequence;CIZILjava/lang/Object;)I
     112: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     115: iload_3
     116: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     119: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     122: nop
     123: astore_1
     124: new           #145                // class java/lang/StringBuilder
     127: dup
     128: invokespecial #147                // Method java/lang/StringBuilder."<init>":()V
     131: ldc           #149                // String Start at
     133: invokevirtual #153                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     136: aload_1
     137: invokevirtual #156                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     140: invokevirtual #160                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     143: getstatic     #166                // Field java/lang/System.out:Ljava/io/PrintStream;
     146: swap
     147: invokevirtual #172                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     150: iconst_1
     151: anewarray     #48                 // class kotlin/Pair
     154: astore_3
     155: aload_3
     156: iconst_0
     157: aload_1
     158: iconst_0
     159: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     162: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     165: aastore
     166: aload_3
     167: invokestatic  #178                // Method kotlin/collections/MapsKt.mutableMapOf:([Lkotlin/Pair;)Ljava/util/Map;
     170: astore_2
     171: new           #180                // class java/util/PriorityQueue
     174: dup
     175: aload_2
     176: invokedynamic #200,  0            // InvokeDynamic #0:invoke:(Ljava/util/Map;)Lkotlin/jvm/functions/Function2;
     181: invokedynamic #211,  0            // InvokeDynamic #1:compare:(Lkotlin/jvm/functions/Function2;)Ljava/util/Comparator;
     186: invokespecial #214                // Method java/util/PriorityQueue."<init>":(Ljava/util/Comparator;)V
     189: astore        4
     191: aload         4
     193: astore        5
     195: iconst_0
     196: istore        6
     198: aload         5
     200: checkcast     #69                 // class java/util/Collection
     203: aload_1
     204: invokeinterface #218,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     209: pop
     210: nop
     211: aload         4
     213: astore_3
     214: iconst_1
     215: anewarray     #48                 // class kotlin/Pair
     218: astore        5
     220: aload         5
     222: iconst_0
     223: aload_1
     224: iconst_0
     225: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     228: iconst_0
     229: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     232: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     235: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     238: aastore
     239: aload         5
     241: invokestatic  #178                // Method kotlin/collections/MapsKt.mutableMapOf:([Lkotlin/Pair;)Ljava/util/Map;
     244: astore        4
     246: aload_3
     247: checkcast     #220                // class java/lang/Iterable
     250: invokestatic  #224                // Method kotlin/collections/CollectionsKt.any:(Ljava/lang/Iterable;)Z
     253: ifeq          504
     256: aload_3
     257: invokevirtual #227                // Method java/util/PriorityQueue.remove:()Ljava/lang/Object;
     260: dup
     261: ldc           #229                // String remove(...)
     263: invokestatic  #232                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     266: checkcast     #48                 // class kotlin/Pair
     269: astore        5
     271: getstatic     #94                 // Field neighbours:Ljava/util/Map;
     274: aload_0
     275: aload         5
     277: invokestatic  #234                // Method get:(Ljava/util/List;Lkotlin/Pair;)C
     280: invokestatic  #237                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     283: invokeinterface #242,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     288: dup
     289: invokestatic  #245                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     292: checkcast     #69                 // class java/util/Collection
     295: invokeinterface #246,  1          // InterfaceMethod java/util/Collection.iterator:()Ljava/util/Iterator;
     300: astore        6
     302: aload         6
     304: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     309: ifeq          246
     312: aload         6
     314: invokeinterface #123,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     319: checkcast     #48                 // class kotlin/Pair
     322: astore        7
     324: aload         5
     326: aload         7
     328: invokestatic  #250                // Method plus:(Lkotlin/Pair;Lkotlin/Pair;)Lkotlin/Pair;
     331: astore        8
     333: aload_2
     334: aload         8
     336: invokeinterface #253,  2          // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
     341: ifne          302
     344: getstatic     #94                 // Field neighbours:Ljava/util/Map;
     347: aload_0
     348: aload         8
     350: invokestatic  #234                // Method get:(Ljava/util/List;Lkotlin/Pair;)C
     353: invokestatic  #237                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     356: invokeinterface #242,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     361: dup
     362: invokestatic  #245                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     365: checkcast     #69                 // class java/util/Collection
     368: aload         7
     370: invokestatic  #257                // Method unaryMinus:(Lkotlin/Pair;)Lkotlin/Pair;
     373: invokeinterface #259,  2          // InterfaceMethod java/util/Collection.contains:(Ljava/lang/Object;)Z
     378: ifeq          302
     381: aload_2
     382: aload         8
     384: aload_2
     385: aload         5
     387: invokeinterface #242,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     392: dup
     393: invokestatic  #245                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     396: checkcast     #54                 // class java/lang/Number
     399: invokevirtual #58                 // Method java/lang/Number.intValue:()I
     402: iconst_1
     403: iadd
     404: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     407: invokeinterface #262,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     412: pop
     413: aload         4
     415: aload         5
     417: aload         4
     419: aload         5
     421: iconst_0
     422: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     425: iconst_0
     426: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     429: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     432: invokeinterface #265,  3          // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     437: checkcast     #48                 // class kotlin/Pair
     440: aload         7
     442: invokestatic  #250                // Method plus:(Lkotlin/Pair;Lkotlin/Pair;)Lkotlin/Pair;
     445: invokeinterface #262,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     450: pop
     451: aload         4
     453: aload         8
     455: aload         4
     457: aload         8
     459: iconst_0
     460: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     463: iconst_0
     464: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     467: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     470: invokeinterface #265,  3          // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     475: checkcast     #48                 // class kotlin/Pair
     478: aload         7
     480: invokestatic  #250                // Method plus:(Lkotlin/Pair;Lkotlin/Pair;)Lkotlin/Pair;
     483: invokeinterface #262,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     488: pop
     489: aload_3
     490: checkcast     #69                 // class java/util/Collection
     493: aload         8
     495: invokeinterface #218,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     500: pop
     501: goto          246
     504: new           #145                // class java/lang/StringBuilder
     507: dup
     508: invokespecial #147                // Method java/lang/StringBuilder."<init>":()V
     511: ldc_w         #267                // String Part1:
     514: invokevirtual #153                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     517: aload_2
     518: astore        5
     520: astore        25
     522: aload         5
     524: invokeinterface #271,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     529: checkcast     #220                // class java/lang/Iterable
     532: astore        6
     534: aload         6
     536: invokeinterface #272,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     541: astore        7
     543: aload         7
     545: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     550: ifne          561
     553: new           #274                // class java/util/NoSuchElementException
     556: dup
     557: invokespecial #275                // Method java/util/NoSuchElementException."<init>":()V
     560: athrow
     561: aload         7
     563: invokeinterface #123,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     568: astore        8
     570: aload         7
     572: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     577: ifne          585
     580: aload         8
     582: goto          679
     585: aload         8
     587: checkcast     #277                // class java/util/Map$Entry
     590: astore        9
     592: iconst_0
     593: istore        10
     595: aload         9
     597: invokeinterface #280,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     602: checkcast     #54                 // class java/lang/Number
     605: invokevirtual #58                 // Method java/lang/Number.intValue:()I
     608: iconst_1
     609: iadd
     610: iconst_2
     611: idiv
     612: istore        9
     614: aload         7
     616: invokeinterface #123,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     621: astore        10
     623: aload         10
     625: checkcast     #277                // class java/util/Map$Entry
     628: astore        11
     630: iconst_0
     631: istore        12
     633: aload         11
     635: invokeinterface #280,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     640: checkcast     #54                 // class java/lang/Number
     643: invokevirtual #58                 // Method java/lang/Number.intValue:()I
     646: iconst_1
     647: iadd
     648: iconst_2
     649: idiv
     650: istore        11
     652: iload         9
     654: iload         11
     656: if_icmpge     667
     659: aload         10
     661: astore        8
     663: iload         11
     665: istore        9
     667: aload         7
     669: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     674: ifne          614
     677: aload         8
     679: checkcast     #277                // class java/util/Map$Entry
     682: aload         25
     684: swap
     685: invokevirtual #156                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     688: invokevirtual #160                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     691: getstatic     #166                // Field java/lang/System.out:Ljava/io/PrintStream;
     694: swap
     695: invokevirtual #172                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     698: new           #282                // class java/util/LinkedHashMap
     701: dup
     702: invokespecial #283                // Method java/util/LinkedHashMap."<init>":()V
     705: checkcast     #239                // class java/util/Map
     708: astore        5
     710: aconst_null
     711: astore        6
     713: invokestatic  #286                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     716: astore        6
     718: iconst_0
     719: istore        7
     721: new           #288                // class java/util/ArrayList
     724: dup
     725: invokespecial #289                // Method java/util/ArrayList."<init>":()V
     728: checkcast     #74                 // class java/util/List
     731: astore        8
     733: iconst_0
     734: istore        9
     736: aload_0
     737: checkcast     #69                 // class java/util/Collection
     740: invokeinterface #72,  1           // InterfaceMethod java/util/Collection.size:()I
     745: istore        10
     747: iload         9
     749: iload         10
     751: if_icmpge     924
     754: iconst_0
     755: istore        11
     757: aload_0
     758: iload         9
     760: invokeinterface #77,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     765: checkcast     #26                 // class java/lang/CharSequence
     768: invokeinterface #80,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     773: istore        12
     775: iload         11
     777: iload         12
     779: if_icmpge     918
     782: aload         4
     784: iload         11
     786: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     789: iload         9
     791: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     794: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     797: invokeinterface #253,  2          // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
     802: ifne          912
     805: getstatic     #87                 // Field deltas:Ljava/util/List;
     808: checkcast     #220                // class java/lang/Iterable
     811: invokestatic  #293                // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;
     814: iload         11
     816: iload         9
     818: invokedynamic #303,  0            // InvokeDynamic #2:invoke:(II)Lkotlin/jvm/functions/Function1;
     823: invokestatic  #309                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     826: aload         4
     828: invokedynamic #319,  0            // InvokeDynamic #3:invoke:(Ljava/util/Map;)Lkotlin/jvm/functions/Function1;
     833: invokestatic  #322                // Method kotlin/sequences/SequencesKt.mapNotNull:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
     836: invokestatic  #326                // Method kotlin/sequences/SequencesKt.firstOrNull:(Lkotlin/sequences/Sequence;)Ljava/lang/Object;
     839: checkcast     #133                // class java/lang/Integer
     842: astore        13
     844: aload         13
     846: ifnull        911
     849: aload         13
     851: checkcast     #54                 // class java/lang/Number
     854: invokevirtual #58                 // Method java/lang/Number.intValue:()I
     857: istore        14
     859: iconst_0
     860: istore        15
     862: iload         14
     864: ifeq          907
     867: aload         8
     869: checkcast     #69                 // class java/util/Collection
     872: iload         11
     874: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     877: iload         9
     879: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     882: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     885: iload         14
     887: ifle          894
     890: iconst_1
     891: goto          895
     894: iconst_0
     895: invokestatic  #331                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     898: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     901: invokeinterface #218,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     906: pop
     907: nop
     908: goto          912
     911: nop
     912: iinc          11, 1
     915: goto          775
     918: iinc          9, 1
     921: goto          747
     924: aload         8
     926: astore        6
     928: aload         5
     930: aload         6
     932: checkcast     #220                // class java/lang/Iterable
     935: invokestatic  #335                // Method kotlin/collections/MapsKt.putAll:(Ljava/util/Map;Ljava/lang/Iterable;)V
     938: nop
     939: nop
     940: aload         6
     942: checkcast     #69                 // class java/util/Collection
     945: invokeinterface #338,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     950: ifne          957
     953: iconst_1
     954: goto          958
     957: iconst_0
     958: ifeq          1209
     961: new           #288                // class java/util/ArrayList
     964: dup
     965: invokespecial #289                // Method java/util/ArrayList."<init>":()V
     968: checkcast     #74                 // class java/util/List
     971: astore        7
     973: aload         6
     975: checkcast     #220                // class java/lang/Iterable
     978: astore        8
     980: iconst_0
     981: istore        9
     983: aload         8
     985: invokeinterface #272,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     990: astore        10
     992: aload         10
     994: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     999: ifeq          1201
    1002: aload         10
    1004: invokeinterface #123,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1009: astore        11
    1011: aload         11
    1013: checkcast     #48                 // class kotlin/Pair
    1016: astore        12
    1018: iconst_0
    1019: istore        13
    1021: aload         12
    1023: invokevirtual #341                // Method kotlin/Pair.component1:()Ljava/lang/Object;
    1026: checkcast     #48                 // class kotlin/Pair
    1029: astore        14
    1031: aload         12
    1033: invokevirtual #344                // Method kotlin/Pair.component2:()Ljava/lang/Object;
    1036: checkcast     #328                // class java/lang/Boolean
    1039: invokevirtual #347                // Method java/lang/Boolean.booleanValue:()Z
    1042: istore        15
    1044: getstatic     #87                 // Field deltas:Ljava/util/List;
    1047: checkcast     #220                // class java/lang/Iterable
    1050: astore        16
    1052: iconst_0
    1053: istore        17
    1055: aload         16
    1057: invokeinterface #272,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
    1062: astore        18
    1064: aload         18
    1066: invokeinterface #120,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
    1071: ifeq          1195
    1074: aload         18
    1076: invokeinterface #123,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1081: astore        19
    1083: aload         19
    1085: checkcast     #48                 // class kotlin/Pair
    1088: astore        20
    1090: iconst_0
    1091: istore        21
    1093: aload         14
    1095: aload         20
    1097: invokestatic  #250                // Method plus:(Lkotlin/Pair;Lkotlin/Pair;)Lkotlin/Pair;
    1100: astore        22
    1102: aload         4
    1104: aload         22
    1106: invokeinterface #253,  2          // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
    1111: ifne          1190
    1114: aload         5
    1116: aload         22
    1118: invokeinterface #253,  2          // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
    1123: ifne          1190
    1126: aload_0
    1127: aload         22
    1129: invokestatic  #349                // Method contains:(Ljava/util/List;Lkotlin/Pair;)Z
    1132: ifeq          1190
    1135: aload         5
    1137: astore        23
    1139: aload         22
    1141: iload         15
    1143: invokestatic  #331                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
    1146: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
    1149: astore        24
    1151: aload         23
    1153: aload         24
    1155: invokevirtual #52                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
    1158: aload         24
    1160: invokevirtual #61                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
    1163: invokeinterface #262,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
    1168: pop
    1169: aload         7
    1171: checkcast     #69                 // class java/util/Collection
    1174: aload         22
    1176: iload         15
    1178: invokestatic  #331                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
    1181: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
    1184: invokeinterface #218,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
    1189: pop
    1190: nop
    1191: nop
    1192: goto          1064
    1195: nop
    1196: nop
    1197: nop
    1198: goto          992
    1201: nop
    1202: aload         7
    1204: astore        6
    1206: goto          940
    1209: iconst_0
    1210: istore        7
    1212: aload_0
    1213: checkcast     #69                 // class java/util/Collection
    1216: invokeinterface #72,  1           // InterfaceMethod java/util/Collection.size:()I
    1221: istore        8
    1223: iload         7
    1225: iload         8
    1227: if_icmpge     1684
    1230: iconst_0
    1231: istore        9
    1233: aload_0
    1234: iload         7
    1236: invokeinterface #77,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
    1241: checkcast     #26                 // class java/lang/CharSequence
    1244: invokeinterface #80,  1           // InterfaceMethod java/lang/CharSequence.length:()I
    1249: istore        10
    1251: iload         9
    1253: iload         10
    1255: if_icmpge     1672
    1258: aload         5
    1260: iload         9
    1262: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1265: iload         7
    1267: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1270: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
    1273: invokeinterface #242,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
    1278: checkcast     #328                // class java/lang/Boolean
    1281: astore        11
    1283: aload         11
    1285: dup
    1286: ifnull        1307
    1289: invokevirtual #347                // Method java/lang/Boolean.booleanValue:()Z
    1292: ifeq          1301
    1295: ldc_w         #350                // String I
    1298: goto          1311
    1301: ldc_w         #352                // String O
    1304: goto          1311
    1307: pop
    1308: ldc_w         #354                // String X
    1311: astore        12
    1313: aload         4
    1315: iload         9
    1317: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1320: iload         7
    1322: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1325: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
    1328: invokeinterface #242,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
    1333: checkcast     #48                 // class kotlin/Pair
    1336: dup
    1337: ifnull        1637
    1340: astore        16
    1342: iconst_0
    1343: istore        17
    1345: aload         16
    1347: astore        18
    1349: aload         18
    1351: iconst_1
    1352: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1355: iconst_0
    1356: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1359: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
    1362: invokestatic  #358                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
    1365: ifne          1387
    1368: aload         18
    1370: iconst_2
    1371: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1374: iconst_0
    1375: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1378: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
    1381: invokestatic  #358                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
    1384: ifeq          1393
    1387: sipush        8594
    1390: goto          1630
    1393: aload         18
    1395: iconst_m1
    1396: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1399: iconst_0
    1400: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1403: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
    1406: invokestatic  #358                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
    1409: ifne          1432
    1412: aload         18
    1414: bipush        -2
    1416: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1419: iconst_0
    1420: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1423: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
    1426: invokestatic  #358                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
    1429: ifeq          1438
    1432: sipush        8592
    1435: goto          1630
    1438: aload         18
    1440: iconst_0
    1441: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1444: iconst_1
    1445: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1448: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
    1451: invokestatic  #358                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
    1454: ifne          1476
    1457: aload         18
    1459: iconst_0
    1460: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1463: iconst_2
    1464: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1467: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
    1470: invokestatic  #358                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
    1473: ifeq          1482
    1476: sipush        8595
    1479: goto          1630
    1482: aload         18
    1484: iconst_0
    1485: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1488: iconst_m1
    1489: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1492: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
    1495: invokestatic  #358                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
    1498: ifne          1521
    1501: aload         18
    1503: iconst_0
    1504: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1507: bipush        -2
    1509: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1512: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
    1515: invokestatic  #358                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
    1518: ifeq          1527
    1521: sipush        8593
    1524: goto          1630
    1527: aload         18
    1529: iconst_1
    1530: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1533: iconst_1
    1534: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1537: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
    1540: invokestatic  #358                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
    1543: ifeq          1552
    1546: sipush        8600
    1549: goto          1630
    1552: aload         18
    1554: iconst_1
    1555: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1558: iconst_m1
    1559: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1562: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
    1565: invokestatic  #358                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
    1568: ifeq          1577
    1571: sipush        8599
    1574: goto          1630
    1577: aload         18
    1579: iconst_m1
    1580: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1583: iconst_m1
    1584: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1587: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
    1590: invokestatic  #358                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
    1593: ifeq          1602
    1596: sipush        8598
    1599: goto          1630
    1602: aload         18
    1604: iconst_m1
    1605: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1608: iconst_1
    1609: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
    1612: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
    1615: invokestatic  #358                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
    1618: ifeq          1627
    1621: sipush        8601
    1624: goto          1630
    1627: sipush        8635
    1630: nop
    1631: invokestatic  #237                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
    1634: goto          1639
    1637: pop
    1638: aconst_null
    1639: astore        13
    1641: aload         13
    1643: dup
    1644: ifnonnull     1650
    1647: pop
    1648: aload         12
    1650: invokevirtual #359                // Method java/lang/Object.toString:()Ljava/lang/String;
    1653: iconst_1
    1654: bipush        32
    1656: invokestatic  #363                // Method kotlin/text/StringsKt.padEnd:(Ljava/lang/String;IC)Ljava/lang/String;
    1659: getstatic     #166                // Field java/lang/System.out:Ljava/io/PrintStream;
    1662: swap
    1663: invokevirtual #366                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
    1666: iinc          9, 1
    1669: goto          1251
    1672: getstatic     #166                // Field java/lang/System.out:Ljava/io/PrintStream;
    1675: invokevirtual #368                // Method java/io/PrintStream.println:()V
    1678: iinc          7, 1
    1681: goto          1223
    1684: aload         5
    1686: invokestatic  #371                // Method kotlin/collections/MapsKt.asSequence:(Ljava/util/Map;)Lkotlin/sequences/Sequence;
    1689: astore        8
    1691: iconst_0
    1692: istore        9
    1694: new           #373                // class dev/kosmx/aoc23/graphs/BFSKt$main$$inlined$groupingBy$1
    1697: dup
    1698: aload         8
    1700: invokespecial #376                // Method dev/kosmx/aoc23/graphs/BFSKt$main$$inlined$groupingBy$1."<init>":(Lkotlin/sequences/Sequence;)V
    1703: checkcast     #378                // class kotlin/collections/Grouping
    1706: invokestatic  #384                // Method kotlin/collections/GroupingKt.eachCount:(Lkotlin/collections/Grouping;)Ljava/util/Map;
    1709: astore        7
    1711: getstatic     #166                // Field java/lang/System.out:Ljava/io/PrintStream;
    1714: aload         7
    1716: invokevirtual #172                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
    1719: return

  public static final kotlin.Pair<java.lang.Integer, java.lang.Integer> plus(kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc_w         #433                // String other
      10: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      13: aload_0
      14: invokevirtual #52                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      17: checkcast     #54                 // class java/lang/Number
      20: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      23: aload_1
      24: invokevirtual #52                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      27: checkcast     #54                 // class java/lang/Number
      30: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      33: iadd
      34: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      37: aload_0
      38: invokevirtual #61                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      41: checkcast     #54                 // class java/lang/Number
      44: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      47: aload_1
      48: invokevirtual #61                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      51: checkcast     #54                 // class java/lang/Number
      54: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      57: iadd
      58: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      61: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      64: areturn

  public static final kotlin.Pair<java.lang.Integer, java.lang.Integer> minus(kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc_w         #433                // String other
      10: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      13: aload_0
      14: invokevirtual #52                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      17: checkcast     #54                 // class java/lang/Number
      20: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      23: aload_1
      24: invokevirtual #52                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      27: checkcast     #54                 // class java/lang/Number
      30: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      33: isub
      34: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      37: aload_0
      38: invokevirtual #61                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      41: checkcast     #54                 // class java/lang/Number
      44: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      47: aload_1
      48: invokevirtual #61                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      51: checkcast     #54                 // class java/lang/Number
      54: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      57: isub
      58: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      61: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      64: areturn

  public static final kotlin.Pair<java.lang.Integer, java.lang.Integer> unaryMinus(kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #52                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      10: checkcast     #54                 // class java/lang/Number
      13: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      16: ineg
      17: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      20: aload_0
      21: invokevirtual #61                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      24: checkcast     #54                 // class java/lang/Number
      27: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      30: ineg
      31: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      34: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      37: areturn

  public static final int times(kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #10                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc_w         #433                // String other
      10: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      13: aload_0
      14: invokevirtual #52                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      17: checkcast     #54                 // class java/lang/Number
      20: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      23: aload_1
      24: invokevirtual #52                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      27: checkcast     #54                 // class java/lang/Number
      30: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      33: imul
      34: aload_0
      35: invokevirtual #61                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      38: checkcast     #54                 // class java/lang/Number
      41: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      44: aload_1
      45: invokevirtual #61                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      48: checkcast     #54                 // class java/lang/Number
      51: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      54: imul
      55: iadd
      56: ireturn

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

  private static final int main$lambda$2(java.util.Map, kotlin.Pair, kotlin.Pair);
    Code:
       0: aload_0
       1: aload_1
       2: invokeinterface #242,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
       7: dup
       8: invokestatic  #245                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      11: checkcast     #54                 // class java/lang/Number
      14: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      17: aload_0
      18: aload_2
      19: invokeinterface #242,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      24: dup
      25: invokestatic  #245                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      28: checkcast     #54                 // class java/lang/Number
      31: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      34: invokestatic  #450                // Method kotlin/jvm/internal/Intrinsics.compare:(II)I
      37: ireturn

  private static final int main$lambda$3(kotlin.jvm.functions.Function2, java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: invokeinterface #457,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
       8: checkcast     #54                 // class java/lang/Number
      11: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      14: ireturn

  private static final kotlin.Pair main$lambda$10$lambda$6(int, int, kotlin.Pair);
    Code:
       0: aload_2
       1: ldc_w         #463                // String d
       4: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_2
       8: iload_0
       9: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      12: iload_1
      13: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      16: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      19: aload_2
      20: invokestatic  #250                // Method plus:(Lkotlin/Pair;Lkotlin/Pair;)Lkotlin/Pair;
      23: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      26: areturn

  private static final java.lang.Integer main$lambda$10$lambda$8(java.util.Map, kotlin.Pair);
    Code:
       0: aload_1
       1: ldc_w         #466                // String it
       4: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: aload_1
       9: invokevirtual #61                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      12: invokeinterface #242,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      17: checkcast     #48                 // class kotlin/Pair
      20: dup
      21: ifnull        81
      24: astore_2
      25: iconst_0
      26: istore_3
      27: aload_2
      28: invokevirtual #341                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      31: checkcast     #54                 // class java/lang/Number
      34: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      37: istore        4
      39: aload_2
      40: invokevirtual #344                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      43: checkcast     #54                 // class java/lang/Number
      46: invokevirtual #58                 // Method java/lang/Number.intValue:()I
      49: istore        5
      51: aload_1
      52: invokevirtual #52                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      55: checkcast     #48                 // class kotlin/Pair
      58: iload         5
      60: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      63: iload         4
      65: ineg
      66: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      69: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      72: invokestatic  #468                // Method times:(Lkotlin/Pair;Lkotlin/Pair;)I
      75: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      78: goto          83
      81: pop
      82: aconst_null
      83: areturn

  static {};
    Code:
       0: iconst_4
       1: anewarray     #48                 // class kotlin/Pair
       4: astore_0
       5: aload_0
       6: iconst_0
       7: iconst_m1
       8: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      11: iconst_0
      12: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      15: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      18: aastore
      19: aload_0
      20: iconst_1
      21: iconst_0
      22: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      25: iconst_m1
      26: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      29: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      32: aastore
      33: aload_0
      34: iconst_2
      35: iconst_1
      36: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      39: iconst_0
      40: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      43: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      46: aastore
      47: aload_0
      48: iconst_3
      49: iconst_0
      50: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      53: iconst_1
      54: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      57: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      60: aastore
      61: aload_0
      62: invokestatic  #477                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      65: putstatic     #87                 // Field deltas:Ljava/util/List;
      68: bipush        8
      70: anewarray     #48                 // class kotlin/Pair
      73: astore_0
      74: aload_0
      75: iconst_0
      76: bipush        46
      78: invokestatic  #237                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      81: invokestatic  #286                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      84: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      87: aastore
      88: aload_0
      89: iconst_1
      90: bipush        83
      92: invokestatic  #237                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
      95: getstatic     #87                 // Field deltas:Ljava/util/List;
      98: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     101: aastore
     102: aload_0
     103: iconst_2
     104: bipush        76
     106: invokestatic  #237                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     109: iconst_2
     110: anewarray     #48                 // class kotlin/Pair
     113: astore_1
     114: aload_1
     115: iconst_0
     116: iconst_0
     117: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     120: iconst_m1
     121: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     124: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     127: aastore
     128: aload_1
     129: iconst_1
     130: iconst_1
     131: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     134: iconst_0
     135: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     138: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     141: aastore
     142: aload_1
     143: invokestatic  #477                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     146: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     149: aastore
     150: aload_0
     151: iconst_3
     152: bipush        70
     154: invokestatic  #237                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     157: iconst_2
     158: anewarray     #48                 // class kotlin/Pair
     161: astore_1
     162: aload_1
     163: iconst_0
     164: iconst_1
     165: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     168: iconst_0
     169: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     172: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     175: aastore
     176: aload_1
     177: iconst_1
     178: iconst_0
     179: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     182: iconst_1
     183: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     186: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     189: aastore
     190: aload_1
     191: invokestatic  #477                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     194: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     197: aastore
     198: aload_0
     199: iconst_4
     200: bipush        74
     202: invokestatic  #237                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     205: iconst_2
     206: anewarray     #48                 // class kotlin/Pair
     209: astore_1
     210: aload_1
     211: iconst_0
     212: iconst_0
     213: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     216: iconst_m1
     217: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     220: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     223: aastore
     224: aload_1
     225: iconst_1
     226: iconst_m1
     227: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     230: iconst_0
     231: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     234: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     237: aastore
     238: aload_1
     239: invokestatic  #477                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     242: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     245: aastore
     246: aload_0
     247: iconst_5
     248: bipush        55
     250: invokestatic  #237                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     253: iconst_2
     254: anewarray     #48                 // class kotlin/Pair
     257: astore_1
     258: aload_1
     259: iconst_0
     260: iconst_m1
     261: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     264: iconst_0
     265: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     268: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     271: aastore
     272: aload_1
     273: iconst_1
     274: iconst_0
     275: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     278: iconst_1
     279: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     282: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     285: aastore
     286: aload_1
     287: invokestatic  #477                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     290: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     293: aastore
     294: aload_0
     295: bipush        6
     297: bipush        45
     299: invokestatic  #237                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     302: iconst_2
     303: anewarray     #48                 // class kotlin/Pair
     306: astore_1
     307: aload_1
     308: iconst_0
     309: iconst_m1
     310: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     313: iconst_0
     314: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     317: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     320: aastore
     321: aload_1
     322: iconst_1
     323: iconst_1
     324: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     327: iconst_0
     328: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     331: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     334: aastore
     335: aload_1
     336: invokestatic  #477                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     339: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     342: aastore
     343: aload_0
     344: bipush        7
     346: bipush        124
     348: invokestatic  #237                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     351: iconst_2
     352: anewarray     #48                 // class kotlin/Pair
     355: astore_1
     356: aload_1
     357: iconst_0
     358: iconst_0
     359: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     362: iconst_m1
     363: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     366: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     369: aastore
     370: aload_1
     371: iconst_1
     372: iconst_0
     373: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     376: iconst_1
     377: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     380: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     383: aastore
     384: aload_1
     385: invokestatic  #477                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     388: invokestatic  #143                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     391: aastore
     392: aload_0
     393: invokestatic  #480                // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;
     396: putstatic     #94                 // Field neighbours:Ljava/util/Map;
     399: return
}

Compiled from "_Sequences.kt"
public final class dev.kosmx.aoc23.graphs.BFSKt$main$$inlined$groupingBy$1 implements kotlin.collections.Grouping<java.util.Map$Entry<? extends kotlin.Pair<? extends java.lang.Integer, ? extends java.lang.Integer>, ? extends java.lang.Boolean>, java.lang.Boolean> {
  final kotlin.sequences.Sequence $this_groupingBy;

  public dev.kosmx.aoc23.graphs.BFSKt$main$$inlined$groupingBy$1(kotlin.sequences.Sequence);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #18                 // Field $this_groupingBy:Lkotlin/sequences/Sequence;
       5: aload_0
       6: invokespecial #21                 // Method java/lang/Object."<init>":()V
       9: return

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

  public java.lang.Boolean keyOf(java.util.Map$Entry<? extends kotlin.Pair<? extends java.lang.Integer, ? extends java.lang.Integer>, ? extends java.lang.Boolean>);
    Code:
       0: aload_1
       1: checkcast     #37                 // class java/util/Map$Entry
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: invokeinterface #41,  1           // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
      13: checkcast     #43                 // class java/lang/Boolean
      16: invokevirtual #47                 // Method java/lang/Boolean.booleanValue:()Z
      19: invokestatic  #51                 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
      22: areturn
}


package urbanistic.transform

import kotlin.math.sqrt

class Point3(var x: Double = 0.0, var y: Double = 0.0, var z: Double = 0.0) {
    fun set(x: Double, y: Double, z: Double) {
        this.x = x
        this.y = y
        this.z = z
    }

    operator fun minus(v2: Point3): Point3 {
        return Point3(x - v2.x, y - v2.y, z - v2.z)
    }

    operator fun plus(v2: Point3): Point3 {
        return Point3(v2.x + x, v2.y + y, v2.z + z)
    }

    operator fun times(sc: Double): Point3 {
        return Point3(x * sc, y * sc, z * sc)
    }

    operator fun div(sc: Double): Point3 {
        return Point3(x / sc, y / sc, z / sc)
    }

    fun normalize() {
        val d = sqrt(x * x + y * y + z * z)
        if (d != 0.0) {
            x /= d
            y /= d
            z /= d
        }
    }

    fun cross(b: Point3): Point3 {
        return Point3(
            y * b.z - b.y * z,
            z * b.x - b.z * x,
            x * b.y - b.x * y
        )
    }
}

fun normal(vertices: DoubleArray): DoubleArray {
    val ccw = true // counterclockwise normal direction

    val points = arrayListOf<Point3>()
    for (i in 0 until (vertices.size / 3)) {
        points.add(Point3(vertices[i * 3], vertices[i * 3 + 1], vertices[i * 3 + 2]))
    }

    var m3: Point3 = points[points.size - 2]
    var m2 = points[points.size - 1]

    var c123 = Point3()
    var v32: Point3
    var v12: Point3

    for (i in points.indices) {
        val m1 = points[i]

        v32 = m3 - m2
        v12 = m1 - m2

        c123 = if (!ccw) {
            c123 + v32.cross(v12)
        } else {
            c123 + v12.cross(v32)
        }

        m3 = m2
        m2 = m1
    }

    c123.normalize()

    return doubleArrayOf(c123.x, c123.y, c123.z)
}

class AnyToXYTransform(nx: Double, ny: Double, nz: Double) {

    protected var m00 = 0.0
    protected var m01 = 0.0
    protected var m02 = 0.0
    protected var m10 = 0.0
    protected var m11 = 0.0
    protected var m12 = 0.0
    protected var m20 = 0.0
    protected var m21 = 0.0
    protected var m22 = 0.0

    /**
     * normal must be normalized
     *
     * @param nx
     * @param ny
     * @param nz
     */
    fun setSourceNormal(nx: Double, ny: Double, nz: Double) {
        val h: Double
        val f: Double
        val hvx: Double
        val vx: Double = -ny
        val vy: Double = nx
        val c: Double = nz
        h = (1 - c) / (1 - c * c)
        hvx = h * vx
        f = if (c < 0) -c else c
        if (f < 1.0 - 1.0E-4) {
            m00 = c + hvx * vx
            m01 = hvx * vy
            m02 = -vy
            m10 = hvx * vy
            m11 = c + h * vy * vy
            m12 = vx
            m20 = vy
            m21 = -vx
            m22 = c
        } else {
            // if "from" and "to" vectors are nearly parallel
            m00 = 1.0
            m01 = 0.0
            m02 = 0.0
            m10 = 0.0
            m11 = 1.0
            m12 = 0.0
            m20 = 0.0
            m21 = 0.0
            m22 = if (c > 0) {
                1.0
            } else {
                -1.0
            }
        }
    }

    /**
     * Assumes source normal is normalized
     */
    init {
        setSourceNormal(nx, ny, nz)
    }

    fun transform(p: Point3) {
        val px: Double = p.x
        val py: Double = p.y
        val pz: Double = p.z
        p.set(
            m00 * px + m01 * py + m02 * pz,
            m10 * px + m11 * py + m12 * pz,
            m20 * px + m21 * py + m22 * pz
        )
    }

    fun transform(data: DoubleArray) {
        for (i in 0 until (data.size / 3)) {
            val point = Point3(data[i * 3], data[i * 3 + 1], data[i * 3 + 2])
            transform(point)
            data[i * 3] = point.x
            data[i * 3 + 1] = point.y
            data[i * 3 + 2] = point.z
        }
    }
}

Compiled from "AnyToXY.kt"
public final class urbanistic.transform.AnyToXYKt {
  public static final double[] normal(double[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String vertices
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_1
       7: istore_1
       8: new           #17                 // class java/util/ArrayList
      11: dup
      12: invokespecial #21                 // Method java/util/ArrayList."<init>":()V
      15: astore_2
      16: iconst_0
      17: istore_3
      18: aload_0
      19: arraylength
      20: iconst_3
      21: idiv
      22: istore        4
      24: iload_3
      25: iload         4
      27: if_icmpge     67
      30: aload_2
      31: new           #23                 // class urbanistic/transform/Point3
      34: dup
      35: aload_0
      36: iload_3
      37: iconst_3
      38: imul
      39: daload
      40: aload_0
      41: iload_3
      42: iconst_3
      43: imul
      44: iconst_1
      45: iadd
      46: daload
      47: aload_0
      48: iload_3
      49: iconst_3
      50: imul
      51: iconst_2
      52: iadd
      53: daload
      54: invokespecial #26                 // Method urbanistic/transform/Point3."<init>":(DDD)V
      57: invokevirtual #30                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      60: pop
      61: iinc          3, 1
      64: goto          24
      67: aload_2
      68: aload_2
      69: invokevirtual #34                 // Method java/util/ArrayList.size:()I
      72: iconst_2
      73: isub
      74: invokevirtual #38                 // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
      77: dup
      78: ldc           #40                 // String get(...)
      80: invokestatic  #43                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      83: checkcast     #23                 // class urbanistic/transform/Point3
      86: astore_3
      87: aload_2
      88: aload_2
      89: invokevirtual #34                 // Method java/util/ArrayList.size:()I
      92: iconst_1
      93: isub
      94: invokevirtual #38                 // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
      97: dup
      98: ldc           #40                 // String get(...)
     100: invokestatic  #43                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     103: checkcast     #23                 // class urbanistic/transform/Point3
     106: astore        4
     108: new           #23                 // class urbanistic/transform/Point3
     111: dup
     112: dconst_0
     113: dconst_0
     114: dconst_0
     115: bipush        7
     117: aconst_null
     118: invokespecial #46                 // Method urbanistic/transform/Point3."<init>":(DDDILkotlin/jvm/internal/DefaultConstructorMarker;)V
     121: astore        5
     123: aconst_null
     124: astore        6
     126: aconst_null
     127: astore        7
     129: iconst_0
     130: istore        8
     132: aload_2
     133: checkcast     #48                 // class java/util/Collection
     136: invokeinterface #49,  1           // InterfaceMethod java/util/Collection.size:()I
     141: istore        9
     143: iload         8
     145: iload         9
     147: if_icmpge     212
     150: aload_2
     151: iload         8
     153: invokevirtual #38                 // Method java/util/ArrayList.get:(I)Ljava/lang/Object;
     156: dup
     157: ldc           #40                 // String get(...)
     159: invokestatic  #43                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     162: checkcast     #23                 // class urbanistic/transform/Point3
     165: astore        10
     167: aload_3
     168: aload         4
     170: invokevirtual #53                 // Method urbanistic/transform/Point3.minus:(Lurbanistic/transform/Point3;)Lurbanistic/transform/Point3;
     173: astore        6
     175: aload         10
     177: aload         4
     179: invokevirtual #53                 // Method urbanistic/transform/Point3.minus:(Lurbanistic/transform/Point3;)Lurbanistic/transform/Point3;
     182: astore        7
     184: nop
     185: aload         5
     187: aload         7
     189: aload         6
     191: invokevirtual #56                 // Method urbanistic/transform/Point3.cross:(Lurbanistic/transform/Point3;)Lurbanistic/transform/Point3;
     194: invokevirtual #59                 // Method urbanistic/transform/Point3.plus:(Lurbanistic/transform/Point3;)Lurbanistic/transform/Point3;
     197: astore        5
     199: aload         4
     201: astore_3
     202: aload         10
     204: astore        4
     206: iinc          8, 1
     209: goto          143
     212: aload         5
     214: invokevirtual #62                 // Method urbanistic/transform/Point3.normalize:()V
     217: iconst_3
     218: newarray       double
     220: astore        8
     222: aload         8
     224: iconst_0
     225: aload         5
     227: invokevirtual #66                 // Method urbanistic/transform/Point3.getX:()D
     230: dastore
     231: aload         8
     233: iconst_1
     234: aload         5
     236: invokevirtual #69                 // Method urbanistic/transform/Point3.getY:()D
     239: dastore
     240: aload         8
     242: iconst_2
     243: aload         5
     245: invokevirtual #72                 // Method urbanistic/transform/Point3.getZ:()D
     248: dastore
     249: aload         8
     251: areturn
}


package shortestpath

import java.util.*
import kotlin.math.*

private const val INF = 1e9.toInt()

fun main(){
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val start = sc.nextInt()

    //최단거리 테이블 초기화
    val distances = IntArray(n + 1) { INF }
    //그래프 초기화
    val graph = mutableListOf<MutableList<City>>()
    for(i in 0..n){
        graph.add(mutableListOf())
    }
    //그래프 입력받기
    for(i in 0 until m){
        val x = sc.nextInt()
        val y = sc.nextInt()
        val z = sc.nextInt()

        graph[x].add(City(y, z))
    }

    fun dijkstra(start: Int){
        val pq = PriorityQueue<City>()
        //시작 노드 삽입 및 거리 0으로 초기화
        pq.offer(City(start, 0))
        distances[start] = 0
        //큐가 빌 때까지 반복
        while(!pq.isEmpty()){
            val city = pq.poll()
            val now = city.index
            val distance = city.distance
            //이미 처리된 도시라면 무시
            if(distances[now] < distance) continue
            //아니라면 연결되어있는 도시들 탐색
            for(i in 0 until graph[now].size){
                val cost = distances[now] + graph[now][i].distance
                //더 거리가 짧다면 업데이트
                if(cost < distances[graph[now][i].index]){
                    distances[graph[now][i].index] = cost
                    pq.offer(City(graph[now][i].index, cost))
                }
            }
        }
    }

    dijkstra(start)

    val cityCount = distances.count { it != INF && it != 0 }
    val time = distances.maxBy { it != INF && it != 0 }

    println("$cityCount $time")
}

data class City(val index: Int, val distance: Int): Comparable<City> {
    override fun compareTo(other: City): Int  = this.distance - other.distance
}

Compiled from "전보.kt"
public final class shortestpath.전보Kt {
  private static final int INF;

  public static final void main();
    Code:
       0: new           #8                  // class java/util/Scanner
       3: dup
       4: getstatic     #14                 // Field java/lang/System.in:Ljava/io/InputStream;
       7: invokespecial #18                 // Method java/util/Scanner."<init>":(Ljava/io/InputStream;)V
      10: astore_0
      11: aload_0
      12: invokevirtual #22                 // Method java/util/Scanner.nextInt:()I
      15: istore_1
      16: aload_0
      17: invokevirtual #22                 // Method java/util/Scanner.nextInt:()I
      20: istore_2
      21: aload_0
      22: invokevirtual #22                 // Method java/util/Scanner.nextInt:()I
      25: istore_3
      26: iconst_0
      27: istore        5
      29: iload_1
      30: iconst_1
      31: iadd
      32: istore        6
      34: iload         6
      36: newarray       int
      38: astore        7
      40: iload         5
      42: iload         6
      44: if_icmpge     64
      47: iload         5
      49: istore        8
      51: aload         7
      53: iload         8
      55: ldc           #23                 // int 1000000000
      57: iastore
      58: iinc          5, 1
      61: goto          40
      64: aload         7
      66: astore        4
      68: new           #25                 // class java/util/ArrayList
      71: dup
      72: invokespecial #27                 // Method java/util/ArrayList."<init>":()V
      75: checkcast     #29                 // class java/util/List
      78: astore        5
      80: iconst_0
      81: istore        6
      83: iload         6
      85: iload_1
      86: if_icmpgt     119
      89: aload         5
      91: new           #25                 // class java/util/ArrayList
      94: dup
      95: invokespecial #27                 // Method java/util/ArrayList."<init>":()V
      98: checkcast     #29                 // class java/util/List
     101: invokeinterface #33,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     106: pop
     107: iload         6
     109: iload_1
     110: if_icmpeq     119
     113: iinc          6, 1
     116: goto          89
     119: iconst_0
     120: istore        6
     122: iload         6
     124: iload_2
     125: if_icmpge     181
     128: aload_0
     129: invokevirtual #22                 // Method java/util/Scanner.nextInt:()I
     132: istore        7
     134: aload_0
     135: invokevirtual #22                 // Method java/util/Scanner.nextInt:()I
     138: istore        8
     140: aload_0
     141: invokevirtual #22                 // Method java/util/Scanner.nextInt:()I
     144: istore        9
     146: aload         5
     148: iload         7
     150: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     155: checkcast     #29                 // class java/util/List
     158: new           #39                 // class shortestpath/City
     161: dup
     162: iload         8
     164: iload         9
     166: invokespecial #42                 // Method shortestpath/City."<init>":(II)V
     169: invokeinterface #33,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     174: pop
     175: iinc          6, 1
     178: goto          122
     181: aload         4
     183: aload         5
     185: iload_3
     186: invokestatic  #46                 // Method main$dijkstra:([ILjava/util/List;I)V
     189: aload         4
     191: astore        7
     193: iconst_0
     194: istore        8
     196: iconst_0
     197: istore        9
     199: iconst_0
     200: istore        10
     202: aload         7
     204: arraylength
     205: istore        11
     207: iload         10
     209: iload         11
     211: if_icmpge     257
     214: aload         7
     216: iload         10
     218: iaload
     219: istore        12
     221: iload         12
     223: istore        13
     225: iconst_0
     226: istore        14
     228: iload         13
     230: ldc           #23                 // int 1000000000
     232: if_icmpeq     244
     235: iload         13
     237: ifeq          244
     240: iconst_1
     241: goto          245
     244: iconst_0
     245: ifeq          251
     248: iinc          9, 1
     251: iinc          10, 1
     254: goto          207
     257: iload         9
     259: istore        6
     261: aload         4
     263: astore        8
     265: iconst_0
     266: istore        9
     268: aload         8
     270: arraylength
     271: ifne          278
     274: iconst_1
     275: goto          279
     278: iconst_0
     279: ifeq          290
     282: new           #48                 // class java/util/NoSuchElementException
     285: dup
     286: invokespecial #49                 // Method java/util/NoSuchElementException."<init>":()V
     289: athrow
     290: aload         8
     292: iconst_0
     293: iaload
     294: istore        10
     296: aload         8
     298: invokestatic  #55                 // Method kotlin/collections/ArraysKt.getLastIndex:([I)I
     301: istore        11
     303: iload         11
     305: ifne          313
     308: iload         10
     310: goto          412
     313: iload         10
     315: istore        12
     317: iconst_0
     318: istore        13
     320: iload         12
     322: ldc           #23                 // int 1000000000
     324: if_icmpeq     336
     327: iload         12
     329: ifeq          336
     332: iconst_1
     333: goto          337
     336: iconst_0
     337: istore        12
     339: iconst_1
     340: istore        13
     342: iload         13
     344: iload         11
     346: if_icmpgt     410
     349: aload         8
     351: iload         13
     353: iaload
     354: istore        14
     356: iload         14
     358: istore        15
     360: iconst_0
     361: istore        16
     363: iload         15
     365: ldc           #23                 // int 1000000000
     367: if_icmpeq     379
     370: iload         15
     372: ifeq          379
     375: iconst_1
     376: goto          380
     379: iconst_0
     380: istore        15
     382: iload         12
     384: iload         15
     386: if_icmpge     397
     389: iload         14
     391: istore        10
     393: iload         15
     395: istore        12
     397: iload         13
     399: iload         11
     401: if_icmpeq     410
     404: iinc          13, 1
     407: goto          349
     410: iload         10
     412: istore        7
     414: new           #57                 // class java/lang/StringBuilder
     417: dup
     418: invokespecial #58                 // Method java/lang/StringBuilder."<init>":()V
     421: iload         6
     423: invokevirtual #62                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     426: bipush        32
     428: invokevirtual #65                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     431: iload         7
     433: invokevirtual #62                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     436: invokevirtual #69                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     439: getstatic     #73                 // Field java/lang/System.out:Ljava/io/PrintStream;
     442: swap
     443: invokevirtual #79                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     446: return

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

  private static final void main$dijkstra(int[], java.util.List<java.util.List<shortestpath.City>>, int);
    Code:
       0: new           #120                // class java/util/PriorityQueue
       3: dup
       4: invokespecial #121                // Method java/util/PriorityQueue."<init>":()V
       7: astore_3
       8: aload_3
       9: new           #39                 // class shortestpath/City
      12: dup
      13: iload_2
      14: iconst_0
      15: invokespecial #42                 // Method shortestpath/City."<init>":(II)V
      18: invokevirtual #124                // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z
      21: pop
      22: aload_0
      23: iload_2
      24: iconst_0
      25: iastore
      26: aload_3
      27: invokevirtual #128                // Method java/util/PriorityQueue.isEmpty:()Z
      30: ifne          227
      33: aload_3
      34: invokevirtual #132                // Method java/util/PriorityQueue.poll:()Ljava/lang/Object;
      37: checkcast     #39                 // class shortestpath/City
      40: astore        4
      42: aload         4
      44: invokevirtual #135                // Method shortestpath/City.getIndex:()I
      47: istore        5
      49: aload         4
      51: invokevirtual #138                // Method shortestpath/City.getDistance:()I
      54: istore        6
      56: aload_0
      57: iload         5
      59: iaload
      60: iload         6
      62: if_icmplt     26
      65: iconst_0
      66: istore        7
      68: aload_1
      69: iload         5
      71: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      76: checkcast     #29                 // class java/util/List
      79: invokeinterface #141,  1          // InterfaceMethod java/util/List.size:()I
      84: istore        8
      86: iload         7
      88: iload         8
      90: if_icmpge     26
      93: aload_0
      94: iload         5
      96: iaload
      97: aload_1
      98: iload         5
     100: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     105: checkcast     #29                 // class java/util/List
     108: iload         7
     110: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     115: checkcast     #39                 // class shortestpath/City
     118: invokevirtual #138                // Method shortestpath/City.getDistance:()I
     121: iadd
     122: istore        9
     124: iload         9
     126: aload_0
     127: aload_1
     128: iload         5
     130: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     135: checkcast     #29                 // class java/util/List
     138: iload         7
     140: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     145: checkcast     #39                 // class shortestpath/City
     148: invokevirtual #135                // Method shortestpath/City.getIndex:()I
     151: iaload
     152: if_icmpge     221
     155: aload_0
     156: aload_1
     157: iload         5
     159: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     164: checkcast     #29                 // class java/util/List
     167: iload         7
     169: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     174: checkcast     #39                 // class shortestpath/City
     177: invokevirtual #135                // Method shortestpath/City.getIndex:()I
     180: iload         9
     182: iastore
     183: aload_3
     184: new           #39                 // class shortestpath/City
     187: dup
     188: aload_1
     189: iload         5
     191: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     196: checkcast     #29                 // class java/util/List
     199: iload         7
     201: invokeinterface #37,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     206: checkcast     #39                 // class shortestpath/City
     209: invokevirtual #135                // Method shortestpath/City.getIndex:()I
     212: iload         9
     214: invokespecial #42                 // Method shortestpath/City."<init>":(II)V
     217: invokevirtual #124                // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z
     220: pop
     221: iinc          7, 1
     224: goto          86
     227: return
}