fun main() {
    val d = Day23(readInput("inputs/Day23"))
    println(d.part1())
    println(d.part2())
}

class Day23(input: List<String>) {

    private val startingPositions = parseInput(input)
    private val nextTurnOffsets: List<List<Point>> = createOffsets()

    fun part1(): Int {
        val locations = (0 until 10).fold(startingPositions) { carry, round -> carry.playRound(round) }
        val gridSize = ((locations.maxOf { it.x } - locations.minOf { it.x }) + 1) * ((locations.maxOf { it.y } - locations.minOf { it.y }) + 1)
        return gridSize - locations.size
    }

    fun part2(): Int {
        var thisTurn = startingPositions
        var roundId = 0
        do {
            val previousTurn = thisTurn
            thisTurn = previousTurn.playRound(roundId++)
        } while (previousTurn != thisTurn)
        return roundId
    }

    fun Point.neighbors(): Set<Point> =
        setOf(
            Point(x - 1, y - 1),
            Point(x, y - 1),
            Point(x + 1, y - 1),
            Point(x - 1, y),
            Point(x + 1, y),
            Point(x - 1, y + 1),
            Point(x, y + 1),
            Point(x + 1, y + 1)
        )

    private fun Set<Point>.playRound(roundNumber: Int): Set<Point> {
        val nextPositions = this.toMutableSet()
        val movers: Map<Point, Point> = this
            .filter { elf -> elf.neighbors().any { it in this } }
            .mapNotNull { elf ->
                nextTurnOffsets.indices.map { direction -> nextTurnOffsets[(roundNumber + direction) % 4] }
                    .firstNotNullOfOrNull { offsets ->
                        if (offsets.none { offset -> (elf + offset) in this }) elf to (elf + offsets.first())
                        else null
                    }
            }.toMap()

        val safeDestinations = movers.values.groupingBy { it }.eachCount().filter { it.value == 1 }.keys
        movers
            .filter { (_, target) -> target in safeDestinations }
            .forEach { (source, target) ->
                nextPositions.remove(source)
                nextPositions.add(target)
            }
        return nextPositions
    }

    private fun createOffsets(): List<List<Point>> =
        listOf(
            listOf(Point(0, -1), Point(-1, -1), Point(1, -1)), // N
            listOf(Point(0, 1), Point(-1, 1), Point(1, 1)), // S
            listOf(Point(-1, 0), Point(-1, -1), Point(-1, 1)), // W
            listOf(Point(1, 0), Point(1, -1), Point(1, 1)), // E
        )

    private fun parseInput(input: List<String>): Set<Point> =
        input.flatMapIndexed { y, row ->
            row.mapIndexedNotNull { x, char ->
                if (char == '#') Point(x, y) else null
            }
        }.toSet()
}

Compiled from "Day23.kt"
public final class Day23Kt {
  public static final void main();
    Code:
       0: new           #8                  // class Day23
       3: dup
       4: ldc           #10                 // String inputs/Day23
       6: invokestatic  #16                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       9: invokespecial #20                 // Method Day23."<init>":(Ljava/util/List;)V
      12: astore_0
      13: aload_0
      14: invokevirtual #24                 // Method Day23.part1:()I
      17: istore_1
      18: getstatic     #30                 // Field java/lang/System.out:Ljava/io/PrintStream;
      21: iload_1
      22: invokevirtual #36                 // Method java/io/PrintStream.println:(I)V
      25: aload_0
      26: invokevirtual #39                 // Method Day23.part2:()I
      29: istore_1
      30: getstatic     #30                 // Field java/lang/System.out:Ljava/io/PrintStream;
      33: iload_1
      34: invokevirtual #36                 // Method java/io/PrintStream.println:(I)V
      37: return

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

Compiled from "_Collections.kt"
public final class Day23$playRound$$inlined$groupingBy$1 implements kotlin.collections.Grouping<Point, Point> {
  final java.lang.Iterable $this_groupingBy;

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

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

  public Point keyOf(Point);
    Code:
       0: aload_1
       1: checkcast     #37                 // class Point
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: areturn
}

Compiled from "Day23.kt"
public final class Day23 {
  private final java.util.Set<Point> startingPositions;

  private final java.util.List<java.util.List<Point>> nextTurnOffsets;

  public Day23(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #10                 // String input
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #19                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: aload_0
      12: aload_1
      13: invokespecial #23                 // Method parseInput:(Ljava/util/List;)Ljava/util/Set;
      16: putfield      #27                 // Field startingPositions:Ljava/util/Set;
      19: aload_0
      20: aload_0
      21: invokespecial #31                 // Method createOffsets:()Ljava/util/List;
      24: putfield      #35                 // Field nextTurnOffsets:Ljava/util/List;
      27: return

  public final int part1();
    Code:
       0: iconst_0
       1: bipush        10
       3: invokestatic  #45                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
       6: checkcast     #47                 // class java/lang/Iterable
       9: astore_2
      10: aload_0
      11: getfield      #27                 // Field startingPositions:Ljava/util/Set;
      14: astore_3
      15: iconst_0
      16: istore        4
      18: aload_3
      19: astore        5
      21: aload_2
      22: invokeinterface #51,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      27: astore        6
      29: aload         6
      31: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      36: ifeq          73
      39: aload         6
      41: checkcast     #59                 // class kotlin/collections/IntIterator
      44: invokevirtual #62                 // Method kotlin/collections/IntIterator.nextInt:()I
      47: istore        7
      49: aload         5
      51: iload         7
      53: istore        8
      55: astore        9
      57: iconst_0
      58: istore        10
      60: aload_0
      61: aload         9
      63: iload         8
      65: invokespecial #66                 // Method playRound:(Ljava/util/Set;I)Ljava/util/Set;
      68: astore        5
      70: goto          29
      73: aload         5
      75: astore_1
      76: aload_1
      77: checkcast     #47                 // class java/lang/Iterable
      80: invokeinterface #51,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      85: astore        4
      87: aload         4
      89: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      94: ifne          105
      97: new           #68                 // class java/util/NoSuchElementException
     100: dup
     101: invokespecial #69                 // Method java/util/NoSuchElementException."<init>":()V
     104: athrow
     105: aload         4
     107: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     112: checkcast     #75                 // class Point
     115: astore        5
     117: iconst_0
     118: istore        6
     120: aload         5
     122: invokevirtual #78                 // Method Point.getX:()I
     125: istore        5
     127: aload         4
     129: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     134: ifeq          173
     137: aload         4
     139: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     144: checkcast     #75                 // class Point
     147: astore        6
     149: iconst_0
     150: istore        7
     152: aload         6
     154: invokevirtual #78                 // Method Point.getX:()I
     157: istore        6
     159: iload         5
     161: iload         6
     163: if_icmpge     127
     166: iload         6
     168: istore        5
     170: goto          127
     173: iload         5
     175: aload_1
     176: checkcast     #47                 // class java/lang/Iterable
     179: astore_3
     180: istore        11
     182: aload_3
     183: invokeinterface #51,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     188: astore        4
     190: aload         4
     192: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     197: ifne          208
     200: new           #68                 // class java/util/NoSuchElementException
     203: dup
     204: invokespecial #69                 // Method java/util/NoSuchElementException."<init>":()V
     207: athrow
     208: aload         4
     210: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     215: checkcast     #75                 // class Point
     218: astore        5
     220: iconst_0
     221: istore        6
     223: aload         5
     225: invokevirtual #78                 // Method Point.getX:()I
     228: istore        5
     230: aload         4
     232: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     237: ifeq          276
     240: aload         4
     242: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     247: checkcast     #75                 // class Point
     250: astore        6
     252: iconst_0
     253: istore        7
     255: aload         6
     257: invokevirtual #78                 // Method Point.getX:()I
     260: istore        6
     262: iload         5
     264: iload         6
     266: if_icmple     230
     269: iload         6
     271: istore        5
     273: goto          230
     276: iload         5
     278: istore        12
     280: iload         11
     282: iload         12
     284: isub
     285: iconst_1
     286: iadd
     287: aload_1
     288: checkcast     #47                 // class java/lang/Iterable
     291: astore_3
     292: istore        11
     294: aload_3
     295: invokeinterface #51,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     300: astore        4
     302: aload         4
     304: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     309: ifne          320
     312: new           #68                 // class java/util/NoSuchElementException
     315: dup
     316: invokespecial #69                 // Method java/util/NoSuchElementException."<init>":()V
     319: athrow
     320: aload         4
     322: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     327: checkcast     #75                 // class Point
     330: astore        5
     332: iconst_0
     333: istore        6
     335: aload         5
     337: invokevirtual #81                 // Method Point.getY:()I
     340: istore        5
     342: aload         4
     344: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     349: ifeq          388
     352: aload         4
     354: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     359: checkcast     #75                 // class Point
     362: astore        6
     364: iconst_0
     365: istore        7
     367: aload         6
     369: invokevirtual #81                 // Method Point.getY:()I
     372: istore        6
     374: iload         5
     376: iload         6
     378: if_icmpge     342
     381: iload         6
     383: istore        5
     385: goto          342
     388: iload         5
     390: istore        12
     392: iload         11
     394: iload         12
     396: aload_1
     397: checkcast     #47                 // class java/lang/Iterable
     400: astore_3
     401: istore        12
     403: istore        11
     405: aload_3
     406: invokeinterface #51,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     411: astore        4
     413: aload         4
     415: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     420: ifne          431
     423: new           #68                 // class java/util/NoSuchElementException
     426: dup
     427: invokespecial #69                 // Method java/util/NoSuchElementException."<init>":()V
     430: athrow
     431: aload         4
     433: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     438: checkcast     #75                 // class Point
     441: astore        5
     443: iconst_0
     444: istore        6
     446: aload         5
     448: invokevirtual #81                 // Method Point.getY:()I
     451: istore        5
     453: aload         4
     455: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     460: ifeq          499
     463: aload         4
     465: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     470: checkcast     #75                 // class Point
     473: astore        6
     475: iconst_0
     476: istore        7
     478: aload         6
     480: invokevirtual #81                 // Method Point.getY:()I
     483: istore        6
     485: iload         5
     487: iload         6
     489: if_icmple     453
     492: iload         6
     494: istore        5
     496: goto          453
     499: iload         5
     501: istore        13
     503: iload         11
     505: iload         12
     507: iload         13
     509: isub
     510: iconst_1
     511: iadd
     512: imul
     513: istore_2
     514: iload_2
     515: aload_1
     516: invokeinterface #86,  1           // InterfaceMethod java/util/Set.size:()I
     521: isub
     522: ireturn

  public final int part2();
    Code:
       0: aload_0
       1: getfield      #27                 // Field startingPositions:Ljava/util/Set;
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: astore_3
       9: aload_0
      10: aload_3
      11: iload_2
      12: iinc          2, 1
      15: invokespecial #66                 // Method playRound:(Ljava/util/Set;I)Ljava/util/Set;
      18: astore_1
      19: aload_3
      20: aload_1
      21: invokestatic  #110                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      24: ifeq          7
      27: iload_2
      28: ireturn

  public final java.util.Set<Point> neighbors(Point);
    Code:
       0: aload_1
       1: ldc           #118                // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: bipush        8
       8: anewarray     #75                 // class Point
      11: astore_2
      12: aload_2
      13: iconst_0
      14: new           #75                 // class Point
      17: dup
      18: aload_1
      19: invokevirtual #78                 // Method Point.getX:()I
      22: iconst_1
      23: isub
      24: aload_1
      25: invokevirtual #81                 // Method Point.getY:()I
      28: iconst_1
      29: isub
      30: invokespecial #121                // Method Point."<init>":(II)V
      33: aastore
      34: aload_2
      35: iconst_1
      36: new           #75                 // class Point
      39: dup
      40: aload_1
      41: invokevirtual #78                 // Method Point.getX:()I
      44: aload_1
      45: invokevirtual #81                 // Method Point.getY:()I
      48: iconst_1
      49: isub
      50: invokespecial #121                // Method Point."<init>":(II)V
      53: aastore
      54: aload_2
      55: iconst_2
      56: new           #75                 // class Point
      59: dup
      60: aload_1
      61: invokevirtual #78                 // Method Point.getX:()I
      64: iconst_1
      65: iadd
      66: aload_1
      67: invokevirtual #81                 // Method Point.getY:()I
      70: iconst_1
      71: isub
      72: invokespecial #121                // Method Point."<init>":(II)V
      75: aastore
      76: aload_2
      77: iconst_3
      78: new           #75                 // class Point
      81: dup
      82: aload_1
      83: invokevirtual #78                 // Method Point.getX:()I
      86: iconst_1
      87: isub
      88: aload_1
      89: invokevirtual #81                 // Method Point.getY:()I
      92: invokespecial #121                // Method Point."<init>":(II)V
      95: aastore
      96: aload_2
      97: iconst_4
      98: new           #75                 // class Point
     101: dup
     102: aload_1
     103: invokevirtual #78                 // Method Point.getX:()I
     106: iconst_1
     107: iadd
     108: aload_1
     109: invokevirtual #81                 // Method Point.getY:()I
     112: invokespecial #121                // Method Point."<init>":(II)V
     115: aastore
     116: aload_2
     117: iconst_5
     118: new           #75                 // class Point
     121: dup
     122: aload_1
     123: invokevirtual #78                 // Method Point.getX:()I
     126: iconst_1
     127: isub
     128: aload_1
     129: invokevirtual #81                 // Method Point.getY:()I
     132: iconst_1
     133: iadd
     134: invokespecial #121                // Method Point."<init>":(II)V
     137: aastore
     138: aload_2
     139: bipush        6
     141: new           #75                 // class Point
     144: dup
     145: aload_1
     146: invokevirtual #78                 // Method Point.getX:()I
     149: aload_1
     150: invokevirtual #81                 // Method Point.getY:()I
     153: iconst_1
     154: iadd
     155: invokespecial #121                // Method Point."<init>":(II)V
     158: aastore
     159: aload_2
     160: bipush        7
     162: new           #75                 // class Point
     165: dup
     166: aload_1
     167: invokevirtual #78                 // Method Point.getX:()I
     170: iconst_1
     171: iadd
     172: aload_1
     173: invokevirtual #81                 // Method Point.getY:()I
     176: iconst_1
     177: iadd
     178: invokespecial #121                // Method Point."<init>":(II)V
     181: aastore
     182: aload_2
     183: invokestatic  #127                // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;
     186: areturn

  private final java.util.Set<Point> playRound(java.util.Set<Point>, int);
    Code:
       0: aload_1
       1: checkcast     #47                 // class java/lang/Iterable
       4: invokestatic  #135                // Method kotlin/collections/CollectionsKt.toMutableSet:(Ljava/lang/Iterable;)Ljava/util/Set;
       7: astore_3
       8: aload_1
       9: checkcast     #47                 // class java/lang/Iterable
      12: astore        5
      14: nop
      15: iconst_0
      16: istore        6
      18: aload         5
      20: astore        7
      22: new           #137                // class java/util/ArrayList
      25: dup
      26: invokespecial #138                // Method java/util/ArrayList."<init>":()V
      29: checkcast     #140                // class java/util/Collection
      32: astore        8
      34: iconst_0
      35: istore        9
      37: aload         7
      39: invokeinterface #51,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      44: astore        10
      46: aload         10
      48: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      53: ifeq          185
      56: aload         10
      58: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: astore        11
      65: aload         11
      67: checkcast     #75                 // class Point
      70: astore        12
      72: iconst_0
      73: istore        13
      75: aload_0
      76: aload         12
      78: invokevirtual #142                // Method neighbors:(LPoint;)Ljava/util/Set;
      81: checkcast     #47                 // class java/lang/Iterable
      84: astore        14
      86: iconst_0
      87: istore        15
      89: aload         14
      91: instanceof    #140                // class java/util/Collection
      94: ifeq          114
      97: aload         14
      99: checkcast     #140                // class java/util/Collection
     102: invokeinterface #145,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     107: ifeq          114
     110: iconst_0
     111: goto          168
     114: aload         14
     116: invokeinterface #51,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     121: astore        16
     123: aload         16
     125: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     130: ifeq          167
     133: aload         16
     135: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     140: astore        17
     142: aload         17
     144: checkcast     #75                 // class Point
     147: astore        18
     149: iconst_0
     150: istore        19
     152: aload_1
     153: aload         18
     155: invokeinterface #149,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     160: ifeq          123
     163: iconst_1
     164: goto          168
     167: iconst_0
     168: nop
     169: ifeq          46
     172: aload         8
     174: aload         11
     176: invokeinterface #152,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     181: pop
     182: goto          46
     185: aload         8
     187: checkcast     #154                // class java/util/List
     190: nop
     191: checkcast     #47                 // class java/lang/Iterable
     194: astore        5
     196: nop
     197: iconst_0
     198: istore        6
     200: aload         5
     202: astore        7
     204: new           #137                // class java/util/ArrayList
     207: dup
     208: invokespecial #138                // Method java/util/ArrayList."<init>":()V
     211: checkcast     #140                // class java/util/Collection
     214: astore        8
     216: iconst_0
     217: istore        9
     219: aload         7
     221: astore        10
     223: iconst_0
     224: istore        11
     226: aload         10
     228: invokeinterface #51,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     233: astore        12
     235: aload         12
     237: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     242: ifeq          586
     245: aload         12
     247: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     252: astore        13
     254: aload         13
     256: astore        14
     258: iconst_0
     259: istore        15
     261: aload         14
     263: checkcast     #75                 // class Point
     266: astore        16
     268: iconst_0
     269: istore        17
     271: aload_0
     272: getfield      #35                 // Field nextTurnOffsets:Ljava/util/List;
     275: checkcast     #140                // class java/util/Collection
     278: invokestatic  #158                // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;
     281: checkcast     #47                 // class java/lang/Iterable
     284: astore        18
     286: iconst_0
     287: istore        19
     289: aload         18
     291: astore        20
     293: new           #137                // class java/util/ArrayList
     296: dup
     297: aload         18
     299: bipush        10
     301: invokestatic  #162                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     304: invokespecial #165                // Method java/util/ArrayList."<init>":(I)V
     307: checkcast     #140                // class java/util/Collection
     310: astore        21
     312: iconst_0
     313: istore        22
     315: aload         20
     317: invokeinterface #51,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     322: astore        23
     324: aload         23
     326: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     331: ifeq          385
     334: aload         23
     336: checkcast     #59                 // class kotlin/collections/IntIterator
     339: invokevirtual #62                 // Method kotlin/collections/IntIterator.nextInt:()I
     342: istore        24
     344: aload         21
     346: iload         24
     348: istore        25
     350: astore        26
     352: iconst_0
     353: istore        27
     355: aload_0
     356: getfield      #35                 // Field nextTurnOffsets:Ljava/util/List;
     359: iload_2
     360: iload         25
     362: iadd
     363: iconst_4
     364: irem
     365: invokeinterface #169,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     370: checkcast     #154                // class java/util/List
     373: aload         26
     375: swap
     376: invokeinterface #152,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     381: pop
     382: goto          324
     385: aload         21
     387: checkcast     #154                // class java/util/List
     390: nop
     391: checkcast     #47                 // class java/lang/Iterable
     394: invokeinterface #51,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     399: astore        19
     401: aload         19
     403: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     408: ifeq          557
     411: aload         19
     413: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     418: checkcast     #154                // class java/util/List
     421: astore        20
     423: iconst_0
     424: istore        21
     426: aload         20
     428: checkcast     #47                 // class java/lang/Iterable
     431: astore        22
     433: iconst_0
     434: istore        23
     436: aload         22
     438: instanceof    #140                // class java/util/Collection
     441: ifeq          461
     444: aload         22
     446: checkcast     #140                // class java/util/Collection
     449: invokeinterface #145,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     454: ifeq          461
     457: iconst_1
     458: goto          520
     461: aload         22
     463: invokeinterface #51,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     468: astore        24
     470: aload         24
     472: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     477: ifeq          519
     480: aload         24
     482: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     487: astore        25
     489: aload         25
     491: checkcast     #75                 // class Point
     494: astore        27
     496: iconst_0
     497: istore        28
     499: aload_1
     500: aload         16
     502: aload         27
     504: invokevirtual #173                // Method Point.plus:(LPoint;)LPoint;
     507: invokeinterface #149,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     512: ifeq          470
     515: iconst_0
     516: goto          520
     519: iconst_1
     520: ifeq          544
     523: aload         16
     525: aload         16
     527: aload         20
     529: invokestatic  #177                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     532: checkcast     #75                 // class Point
     535: invokevirtual #173                // Method Point.plus:(LPoint;)LPoint;
     538: invokestatic  #183                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     541: goto          545
     544: aconst_null
     545: astore        20
     547: aload         20
     549: ifnull        401
     552: aload         20
     554: goto          558
     557: aconst_null
     558: nop
     559: dup
     560: ifnull        581
     563: astore        29
     565: iconst_0
     566: istore        30
     568: aload         8
     570: aload         29
     572: invokeinterface #152,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     577: pop
     578: goto          582
     581: pop
     582: nop
     583: goto          235
     586: nop
     587: aload         8
     589: checkcast     #154                // class java/util/List
     592: nop
     593: checkcast     #47                 // class java/lang/Iterable
     596: invokestatic  #189                // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;
     599: astore        4
     601: aload         4
     603: invokeinterface #195,  1          // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;
     608: checkcast     #47                 // class java/lang/Iterable
     611: astore        6
     613: iconst_0
     614: istore        7
     616: new           #197                // class Day23$playRound$$inlined$groupingBy$1
     619: dup
     620: aload         6
     622: invokespecial #200                // Method Day23$playRound$$inlined$groupingBy$1."<init>":(Ljava/lang/Iterable;)V
     625: checkcast     #202                // class kotlin/collections/Grouping
     628: invokestatic  #208                // Method kotlin/collections/GroupingKt.eachCount:(Lkotlin/collections/Grouping;)Ljava/util/Map;
     631: astore        6
     633: iconst_0
     634: istore        7
     636: aload         6
     638: astore        8
     640: new           #210                // class java/util/LinkedHashMap
     643: dup
     644: invokespecial #211                // Method java/util/LinkedHashMap."<init>":()V
     647: checkcast     #191                // class java/util/Map
     650: astore        9
     652: iconst_0
     653: istore        10
     655: aload         8
     657: invokeinterface #215,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     662: invokeinterface #216,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     667: astore        11
     669: aload         11
     671: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     676: ifeq          748
     679: aload         11
     681: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     686: checkcast     #218                // class java/util/Map$Entry
     689: astore        12
     691: aload         12
     693: astore        13
     695: iconst_0
     696: istore        14
     698: aload         13
     700: invokeinterface #221,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     705: checkcast     #223                // class java/lang/Number
     708: invokevirtual #226                // Method java/lang/Number.intValue:()I
     711: iconst_1
     712: if_icmpne     719
     715: iconst_1
     716: goto          720
     719: iconst_0
     720: ifeq          669
     723: aload         9
     725: aload         12
     727: invokeinterface #229,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     732: aload         12
     734: invokeinterface #221,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     739: invokeinterface #233,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     744: pop
     745: goto          669
     748: aload         9
     750: nop
     751: invokeinterface #236,  1          // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;
     756: astore        5
     758: aload         4
     760: astore        6
     762: nop
     763: iconst_0
     764: istore        7
     766: aload         6
     768: astore        8
     770: new           #210                // class java/util/LinkedHashMap
     773: dup
     774: invokespecial #211                // Method java/util/LinkedHashMap."<init>":()V
     777: checkcast     #191                // class java/util/Map
     780: astore        9
     782: iconst_0
     783: istore        10
     785: aload         8
     787: invokeinterface #215,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     792: invokeinterface #216,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     797: astore        11
     799: aload         11
     801: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     806: ifeq          877
     809: aload         11
     811: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     816: checkcast     #218                // class java/util/Map$Entry
     819: astore        12
     821: aload         12
     823: astore        13
     825: iconst_0
     826: istore        14
     828: aload         13
     830: invokeinterface #221,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     835: checkcast     #75                 // class Point
     838: astore        15
     840: aload         5
     842: aload         15
     844: invokeinterface #149,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     849: ifeq          799
     852: aload         9
     854: aload         12
     856: invokeinterface #229,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     861: aload         12
     863: invokeinterface #221,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     868: invokeinterface #233,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     873: pop
     874: goto          799
     877: aload         9
     879: nop
     880: astore        6
     882: nop
     883: iconst_0
     884: istore        7
     886: aload         6
     888: invokeinterface #215,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     893: invokeinterface #216,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     898: astore        8
     900: aload         8
     902: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     907: ifeq          976
     910: aload         8
     912: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     917: checkcast     #218                // class java/util/Map$Entry
     920: astore        9
     922: aload         9
     924: astore        10
     926: iconst_0
     927: istore        11
     929: aload         10
     931: invokeinterface #229,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     936: checkcast     #75                 // class Point
     939: astore        12
     941: aload         10
     943: invokeinterface #221,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     948: checkcast     #75                 // class Point
     951: astore        13
     953: aload_3
     954: aload         12
     956: invokeinterface #239,  2          // InterfaceMethod java/util/Set.remove:(Ljava/lang/Object;)Z
     961: pop
     962: aload_3
     963: aload         13
     965: invokeinterface #240,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     970: pop
     971: nop
     972: nop
     973: goto          900
     976: nop
     977: aload_3
     978: areturn

  private final java.util.List<java.util.List<Point>> createOffsets();
    Code:
       0: iconst_4
       1: anewarray     #154                // class java/util/List
       4: astore_1
       5: aload_1
       6: iconst_0
       7: iconst_3
       8: anewarray     #75                 // class Point
      11: astore_2
      12: aload_2
      13: iconst_0
      14: new           #75                 // class Point
      17: dup
      18: iconst_0
      19: iconst_m1
      20: invokespecial #121                // Method Point."<init>":(II)V
      23: aastore
      24: aload_2
      25: iconst_1
      26: new           #75                 // class Point
      29: dup
      30: iconst_m1
      31: iconst_m1
      32: invokespecial #121                // Method Point."<init>":(II)V
      35: aastore
      36: aload_2
      37: iconst_2
      38: new           #75                 // class Point
      41: dup
      42: iconst_1
      43: iconst_m1
      44: invokespecial #121                // Method Point."<init>":(II)V
      47: aastore
      48: aload_2
      49: invokestatic  #298                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      52: aastore
      53: aload_1
      54: iconst_1
      55: iconst_3
      56: anewarray     #75                 // class Point
      59: astore_2
      60: aload_2
      61: iconst_0
      62: new           #75                 // class Point
      65: dup
      66: iconst_0
      67: iconst_1
      68: invokespecial #121                // Method Point."<init>":(II)V
      71: aastore
      72: aload_2
      73: iconst_1
      74: new           #75                 // class Point
      77: dup
      78: iconst_m1
      79: iconst_1
      80: invokespecial #121                // Method Point."<init>":(II)V
      83: aastore
      84: aload_2
      85: iconst_2
      86: new           #75                 // class Point
      89: dup
      90: iconst_1
      91: iconst_1
      92: invokespecial #121                // Method Point."<init>":(II)V
      95: aastore
      96: aload_2
      97: invokestatic  #298                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     100: aastore
     101: aload_1
     102: iconst_2
     103: iconst_3
     104: anewarray     #75                 // class Point
     107: astore_2
     108: aload_2
     109: iconst_0
     110: new           #75                 // class Point
     113: dup
     114: iconst_m1
     115: iconst_0
     116: invokespecial #121                // Method Point."<init>":(II)V
     119: aastore
     120: aload_2
     121: iconst_1
     122: new           #75                 // class Point
     125: dup
     126: iconst_m1
     127: iconst_m1
     128: invokespecial #121                // Method Point."<init>":(II)V
     131: aastore
     132: aload_2
     133: iconst_2
     134: new           #75                 // class Point
     137: dup
     138: iconst_m1
     139: iconst_1
     140: invokespecial #121                // Method Point."<init>":(II)V
     143: aastore
     144: aload_2
     145: invokestatic  #298                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     148: aastore
     149: aload_1
     150: iconst_3
     151: iconst_3
     152: anewarray     #75                 // class Point
     155: astore_2
     156: aload_2
     157: iconst_0
     158: new           #75                 // class Point
     161: dup
     162: iconst_1
     163: iconst_0
     164: invokespecial #121                // Method Point."<init>":(II)V
     167: aastore
     168: aload_2
     169: iconst_1
     170: new           #75                 // class Point
     173: dup
     174: iconst_1
     175: iconst_m1
     176: invokespecial #121                // Method Point."<init>":(II)V
     179: aastore
     180: aload_2
     181: iconst_2
     182: new           #75                 // class Point
     185: dup
     186: iconst_1
     187: iconst_1
     188: invokespecial #121                // Method Point."<init>":(II)V
     191: aastore
     192: aload_2
     193: invokestatic  #298                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     196: aastore
     197: aload_1
     198: invokestatic  #298                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     201: areturn

  private final java.util.Set<Point> parseInput(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: checkcast     #47                 // class java/lang/Iterable
       4: astore_2
       5: new           #137                // class java/util/ArrayList
       8: dup
       9: invokespecial #138                // Method java/util/ArrayList."<init>":()V
      12: checkcast     #140                // class java/util/Collection
      15: astore_3
      16: iconst_0
      17: istore        4
      19: aload_2
      20: invokeinterface #51,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      25: astore        5
      27: aload         5
      29: invokeinterface #57,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      34: ifeq          237
      37: aload         5
      39: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      44: astore        6
      46: iload         4
      48: iinc          4, 1
      51: istore        7
      53: iload         7
      55: ifge          61
      58: invokestatic  #302                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      61: iload         7
      63: aload         6
      65: checkcast     #304                // class java/lang/String
      68: astore        8
      70: istore        9
      72: iconst_0
      73: istore        10
      75: aload         8
      77: checkcast     #306                // class java/lang/CharSequence
      80: astore        11
      82: iconst_0
      83: istore        12
      85: aload         11
      87: astore        13
      89: new           #137                // class java/util/ArrayList
      92: dup
      93: invokespecial #138                // Method java/util/ArrayList."<init>":()V
      96: checkcast     #140                // class java/util/Collection
      99: astore        14
     101: iconst_0
     102: istore        15
     104: aload         13
     106: astore        16
     108: iconst_0
     109: istore        17
     111: iconst_0
     112: istore        18
     114: iconst_0
     115: istore        19
     117: iload         19
     119: aload         16
     121: invokeinterface #309,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     126: if_icmpge     217
     129: aload         16
     131: iload         19
     133: invokeinterface #313,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     138: istore        20
     140: iload         18
     142: iinc          18, 1
     145: iload         20
     147: istore        21
     149: istore        22
     151: iconst_0
     152: istore        23
     154: iload         22
     156: iload         21
     158: istore        24
     160: istore        25
     162: iconst_0
     163: istore        26
     165: iload         24
     167: bipush        35
     169: if_icmpne     186
     172: new           #75                 // class Point
     175: dup
     176: iload         25
     178: iload         9
     180: invokespecial #121                // Method Point."<init>":(II)V
     183: goto          187
     186: aconst_null
     187: dup
     188: ifnull        209
     191: astore        27
     193: iconst_0
     194: istore        28
     196: aload         14
     198: aload         27
     200: invokeinterface #152,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     205: pop
     206: goto          210
     209: pop
     210: nop
     211: iinc          19, 1
     214: goto          117
     217: nop
     218: aload         14
     220: checkcast     #154                // class java/util/List
     223: nop
     224: checkcast     #47                 // class java/lang/Iterable
     227: nop
     228: aload_3
     229: swap
     230: invokestatic  #317                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     233: pop
     234: goto          27
     237: aload_3
     238: checkcast     #154                // class java/util/List
     241: checkcast     #47                 // class java/lang/Iterable
     244: invokestatic  #320                // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;
     247: areturn
}


import kotlin.math.abs
import kotlin.math.sign

fun main() {

    fun List<IntRange>.union(): List<IntRange> {
        val sorted = sortedBy { it.first }
        val init = mutableListOf(sorted.first())

        return sortedBy { it.first }.fold(init) { acc, r ->
            val last = acc.last()

            if (r.first <= last.last) {
                acc[acc.lastIndex] = (last.first..maxOf(last.last, r.last))
            } else {
                acc += r
            }

            acc
        }
    }

    fun Point.frequency() = (x * 4_000_000L) + y

    infix fun Point.distanceTo(other: Point): Int {
        return abs(x - other.x) + abs(y - other.y)
    }

    infix fun Point.lineTo(other: Point): List<Point> {
        val xDelta = (other.x - x).sign
        val yDelta = (other.y - y).sign
        val steps = maxOf(abs(x - other.x), abs(y - other.y))
        return (1..steps).scan(this) { prev, _ -> Point(prev.x + xDelta, prev.y + yDelta) }
    }

    fun Point.findRange(y: Int, distance: Int): IntRange? {
        val width = distance - abs(this.y - y)
        return (this.x - width..this.x + width).takeIf { it.first <= it.last }
    }

    fun parse(input: List<String>): MutableList<Pair<Point, Point>> {
        return input.map {
            val sensorX = it.substringAfter("Sensor at x=").substringBefore(",").toInt()
            val sensorY = it.substringBefore(":").substringAfter("y=").toInt()

            val beaconX = it.substringAfter("closest beacon is at x=").substringBefore(",").toInt()
            val beaconY = it.substringAfterLast("y=").toInt()

            Pair(Point(sensorX, sensorY), Point(beaconX, beaconY))
        }
        .toMutableList()
    }

    fun part1(input: List<String>): Int {
        val pairs = parse(input)
        val y = 2_000_000

        return pairs
            .mapNotNull { (sensor, beacon) ->
                val distance = sensor distanceTo beacon
                sensor.findRange(y, distance)
            }
            .union()
            .sumOf { it.last - it.first }
    }

    fun part2(input: List<String>): Long {
        val pairs = parse(input)
        val cave = 0..4_000_000L

        return pairs.firstNotNullOf { (sensor, beacon) ->
            val distance = sensor distanceTo beacon

            val up = Point(sensor.x, sensor.y - distance - 1)
            val down = Point(sensor.x, sensor.y + distance + 1)
            val left = Point(sensor.x - distance - 1, sensor.y)
            val right = Point(sensor.x + distance + 1, sensor.y)

            (up.lineTo(right) + right.lineTo(down) + down.lineTo(left) + left.lineTo(up))
                .filter { it.x in cave && it.y in cave }
                .firstOrNull { point ->
                    pairs.all { (sensor, beacon) ->
                        sensor distanceTo point > sensor distanceTo beacon
                    }
                }
        }.frequency()
    }

    val input = readInput("inputs/Day15")
    println(part1(input))
    println(part2(input))
}

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

  public final int compare(T, T);
    Code:
       0: aload_1
       1: checkcast     #23                 // class kotlin/ranges/IntRange
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokevirtual #27                 // Method kotlin/ranges/IntRange.getFirst:()I
      12: invokestatic  #33                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      15: checkcast     #35                 // class java/lang/Comparable
      18: aload_2
      19: checkcast     #23                 // class kotlin/ranges/IntRange
      22: astore_3
      23: astore        5
      25: iconst_0
      26: istore        4
      28: aload_3
      29: invokevirtual #27                 // Method kotlin/ranges/IntRange.getFirst:()I
      32: invokestatic  #33                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      35: aload         5
      37: swap
      38: checkcast     #35                 // class java/lang/Comparable
      41: invokestatic  #41                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      44: ireturn
}

Compiled from "Day15.kt"
public final class Day15Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String inputs/Day15
       2: invokestatic  #14                 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;
       5: astore_0
       6: aload_0
       7: invokestatic  #18                 // Method main$part1:(Ljava/util/List;)I
      10: istore_1
      11: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
      14: iload_1
      15: invokevirtual #30                 // Method java/io/PrintStream.println:(I)V
      18: aload_0
      19: invokestatic  #34                 // Method main$part2:(Ljava/util/List;)J
      22: lstore_1
      23: getstatic     #24                 // Field java/lang/System.out:Ljava/io/PrintStream;
      26: lload_1
      27: invokevirtual #37                 // Method java/io/PrintStream.println:(J)V
      30: return

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

  private static final java.util.List<kotlin.ranges.IntRange> main$union(java.util.List<kotlin.ranges.IntRange>);
    Code:
       0: aload_0
       1: checkcast     #49                 // class java/lang/Iterable
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: new           #51                 // class Day15Kt$main$union$$inlined$sortedBy$1
      11: dup
      12: invokespecial #54                 // Method Day15Kt$main$union$$inlined$sortedBy$1."<init>":()V
      15: checkcast     #56                 // class java/util/Comparator
      18: invokestatic  #62                 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
      21: astore_1
      22: iconst_1
      23: anewarray     #64                 // class kotlin/ranges/IntRange
      26: astore_3
      27: aload_3
      28: iconst_0
      29: aload_1
      30: invokestatic  #68                 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
      33: aastore
      34: aload_3
      35: invokestatic  #72                 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
      38: astore_2
      39: aload_0
      40: checkcast     #49                 // class java/lang/Iterable
      43: astore_3
      44: iconst_0
      45: istore        4
      47: aload_3
      48: new           #74                 // class Day15Kt$main$union$$inlined$sortedBy$2
      51: dup
      52: invokespecial #75                 // Method Day15Kt$main$union$$inlined$sortedBy$2."<init>":()V
      55: checkcast     #56                 // class java/util/Comparator
      58: invokestatic  #62                 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
      61: checkcast     #49                 // class java/lang/Iterable
      64: astore_3
      65: nop
      66: iconst_0
      67: istore        4
      69: aload_2
      70: astore        5
      72: aload_3
      73: invokeinterface #79,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      78: astore        6
      80: aload         6
      82: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      87: ifeq          197
      90: aload         6
      92: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      97: astore        7
      99: aload         5
     101: aload         7
     103: checkcast     #64                 // class kotlin/ranges/IntRange
     106: astore        8
     108: astore        9
     110: iconst_0
     111: istore        10
     113: aload         9
     115: invokestatic  #92                 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     118: checkcast     #64                 // class kotlin/ranges/IntRange
     121: astore        11
     123: aload         8
     125: invokevirtual #96                 // Method kotlin/ranges/IntRange.getFirst:()I
     128: aload         11
     130: invokevirtual #99                 // Method kotlin/ranges/IntRange.getLast:()I
     133: if_icmpgt     177
     136: aload         9
     138: aload         9
     140: invokestatic  #102                // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I
     143: new           #64                 // class kotlin/ranges/IntRange
     146: dup
     147: aload         11
     149: invokevirtual #96                 // Method kotlin/ranges/IntRange.getFirst:()I
     152: aload         11
     154: invokevirtual #99                 // Method kotlin/ranges/IntRange.getLast:()I
     157: aload         8
     159: invokevirtual #99                 // Method kotlin/ranges/IntRange.getLast:()I
     162: invokestatic  #108                // Method java/lang/Math.max:(II)I
     165: invokespecial #111                // Method kotlin/ranges/IntRange."<init>":(II)V
     168: invokeinterface #117,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     173: pop
     174: goto          190
     177: aload         9
     179: checkcast     #119                // class java/util/Collection
     182: aload         8
     184: invokeinterface #123,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     189: pop
     190: aload         9
     192: astore        5
     194: goto          80
     197: aload         5
     199: areturn

  private static final long main$frequency(Point);
    Code:
       0: aload_0
       1: invokevirtual #146                // Method Point.getX:()I
       4: i2l
       5: ldc2_w        #147                // long 4000000l
       8: lmul
       9: aload_0
      10: invokevirtual #151                // Method Point.getY:()I
      13: i2l
      14: ladd
      15: lreturn

  private static final int main$distanceTo(Point, Point);
    Code:
       0: aload_0
       1: invokevirtual #146                // Method Point.getX:()I
       4: aload_1
       5: invokevirtual #146                // Method Point.getX:()I
       8: isub
       9: invokestatic  #159                // Method java/lang/Math.abs:(I)I
      12: aload_0
      13: invokevirtual #151                // Method Point.getY:()I
      16: aload_1
      17: invokevirtual #151                // Method Point.getY:()I
      20: isub
      21: invokestatic  #159                // Method java/lang/Math.abs:(I)I
      24: iadd
      25: ireturn

  private static final java.util.List<Point> main$lineTo(Point, Point);
    Code:
       0: aload_1
       1: invokevirtual #146                // Method Point.getX:()I
       4: aload_0
       5: invokevirtual #146                // Method Point.getX:()I
       8: isub
       9: invokestatic  #169                // Method kotlin/math/MathKt.getSign:(I)I
      12: istore_2
      13: aload_1
      14: invokevirtual #151                // Method Point.getY:()I
      17: aload_0
      18: invokevirtual #151                // Method Point.getY:()I
      21: isub
      22: invokestatic  #169                // Method kotlin/math/MathKt.getSign:(I)I
      25: istore_3
      26: nop
      27: aload_0
      28: invokevirtual #146                // Method Point.getX:()I
      31: aload_1
      32: invokevirtual #146                // Method Point.getX:()I
      35: isub
      36: invokestatic  #159                // Method java/lang/Math.abs:(I)I
      39: aload_0
      40: invokevirtual #151                // Method Point.getY:()I
      43: aload_1
      44: invokevirtual #151                // Method Point.getY:()I
      47: isub
      48: invokestatic  #159                // Method java/lang/Math.abs:(I)I
      51: invokestatic  #108                // Method java/lang/Math.max:(II)I
      54: istore        4
      56: new           #64                 // class kotlin/ranges/IntRange
      59: dup
      60: iconst_1
      61: iload         4
      63: invokespecial #111                // Method kotlin/ranges/IntRange."<init>":(II)V
      66: checkcast     #49                 // class java/lang/Iterable
      69: astore        5
      71: iconst_0
      72: istore        6
      74: aload         5
      76: astore        7
      78: iconst_0
      79: istore        8
      81: aload         7
      83: bipush        9
      85: invokestatic  #173                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      88: istore        9
      90: iload         9
      92: ifne          102
      95: aload_0
      96: invokestatic  #177                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      99: goto          211
     102: new           #179                // class java/util/ArrayList
     105: dup
     106: iload         9
     108: iconst_1
     109: iadd
     110: invokespecial #181                // Method java/util/ArrayList."<init>":(I)V
     113: astore        10
     115: aload         10
     117: astore        11
     119: iconst_0
     120: istore        12
     122: aload         11
     124: aload_0
     125: invokevirtual #182                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     128: pop
     129: aload         10
     131: astore        13
     133: aload_0
     134: astore        10
     136: aload         7
     138: invokeinterface #79,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     143: astore        11
     145: aload         11
     147: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     152: ifeq          206
     155: aload         11
     157: checkcast     #184                // class kotlin/collections/IntIterator
     160: invokevirtual #187                // Method kotlin/collections/IntIterator.nextInt:()I
     163: istore        12
     165: aload         10
     167: astore        14
     169: iconst_0
     170: istore        15
     172: new           #143                // class Point
     175: dup
     176: aload         14
     178: invokevirtual #146                // Method Point.getX:()I
     181: iload_2
     182: iadd
     183: aload         14
     185: invokevirtual #151                // Method Point.getY:()I
     188: iload_3
     189: iadd
     190: invokespecial #188                // Method Point."<init>":(II)V
     193: astore        10
     195: aload         13
     197: aload         10
     199: invokevirtual #182                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     202: pop
     203: goto          145
     206: aload         13
     208: checkcast     #113                // class java/util/List
     211: nop
     212: areturn

  private static final kotlin.ranges.IntRange main$findRange(Point, int, int);
    Code:
       0: iload_2
       1: aload_0
       2: invokevirtual #151                // Method Point.getY:()I
       5: iload_1
       6: isub
       7: invokestatic  #159                // Method java/lang/Math.abs:(I)I
      10: isub
      11: istore_3
      12: new           #64                 // class kotlin/ranges/IntRange
      15: dup
      16: aload_0
      17: invokevirtual #146                // Method Point.getX:()I
      20: iload_3
      21: isub
      22: aload_0
      23: invokevirtual #146                // Method Point.getX:()I
      26: iload_3
      27: iadd
      28: invokespecial #111                // Method kotlin/ranges/IntRange."<init>":(II)V
      31: astore        4
      33: aload         4
      35: astore        5
      37: iconst_0
      38: istore        6
      40: aload         5
      42: invokevirtual #96                 // Method kotlin/ranges/IntRange.getFirst:()I
      45: aload         5
      47: invokevirtual #99                 // Method kotlin/ranges/IntRange.getLast:()I
      50: if_icmpgt     57
      53: iconst_1
      54: goto          58
      57: iconst_0
      58: ifeq          66
      61: aload         4
      63: goto          67
      66: aconst_null
      67: areturn

  private static final java.util.List<kotlin.Pair<Point, Point>> main$parse(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #49                 // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: astore_3
       9: new           #179                // class java/util/ArrayList
      12: dup
      13: aload_1
      14: bipush        10
      16: invokestatic  #173                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      19: invokespecial #181                // Method java/util/ArrayList."<init>":(I)V
      22: checkcast     #119                // class java/util/Collection
      25: astore        4
      27: iconst_0
      28: istore        5
      30: aload_3
      31: invokeinterface #79,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      36: astore        6
      38: aload         6
      40: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      45: ifeq          196
      48: aload         6
      50: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      55: astore        7
      57: aload         4
      59: aload         7
      61: checkcast     #217                // class java/lang/String
      64: astore        8
      66: astore        14
      68: iconst_0
      69: istore        9
      71: aload         8
      73: ldc           #219                // String Sensor at x=
      75: aconst_null
      76: iconst_2
      77: aconst_null
      78: invokestatic  #225                // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
      81: ldc           #227                // String ,
      83: aconst_null
      84: iconst_2
      85: aconst_null
      86: invokestatic  #230                // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
      89: invokestatic  #236                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      92: istore        10
      94: aload         8
      96: ldc           #238                // String :
      98: aconst_null
      99: iconst_2
     100: aconst_null
     101: invokestatic  #230                // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     104: ldc           #240                // String y=
     106: aconst_null
     107: iconst_2
     108: aconst_null
     109: invokestatic  #225                // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     112: invokestatic  #236                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     115: istore        11
     117: aload         8
     119: ldc           #242                // String closest beacon is at x=
     121: aconst_null
     122: iconst_2
     123: aconst_null
     124: invokestatic  #225                // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     127: ldc           #227                // String ,
     129: aconst_null
     130: iconst_2
     131: aconst_null
     132: invokestatic  #230                // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     135: invokestatic  #236                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     138: istore        12
     140: aload         8
     142: ldc           #240                // String y=
     144: aconst_null
     145: iconst_2
     146: aconst_null
     147: invokestatic  #245                // Method kotlin/text/StringsKt.substringAfterLast$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;
     150: invokestatic  #236                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     153: istore        13
     155: new           #247                // class kotlin/Pair
     158: dup
     159: new           #143                // class Point
     162: dup
     163: iload         10
     165: iload         11
     167: invokespecial #188                // Method Point."<init>":(II)V
     170: new           #143                // class Point
     173: dup
     174: iload         12
     176: iload         13
     178: invokespecial #188                // Method Point."<init>":(II)V
     181: invokespecial #250                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     184: aload         14
     186: swap
     187: invokeinterface #123,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     192: pop
     193: goto          38
     196: aload         4
     198: checkcast     #113                // class java/util/List
     201: nop
     202: checkcast     #119                // class java/util/Collection
     205: invokestatic  #254                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     208: areturn

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #270                // Method main$parse:(Ljava/util/List;)Ljava/util/List;
       4: astore_1
       5: ldc_w         #271                // int 2000000
       8: istore_2
       9: aload_1
      10: checkcast     #49                 // class java/lang/Iterable
      13: astore_3
      14: nop
      15: iconst_0
      16: istore        4
      18: aload_3
      19: astore        5
      21: new           #179                // class java/util/ArrayList
      24: dup
      25: invokespecial #272                // Method java/util/ArrayList."<init>":()V
      28: checkcast     #119                // class java/util/Collection
      31: astore        6
      33: iconst_0
      34: istore        7
      36: aload         5
      38: astore        8
      40: iconst_0
      41: istore        9
      43: aload         8
      45: invokeinterface #79,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      50: astore        10
      52: aload         10
      54: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      59: ifeq          152
      62: aload         10
      64: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      69: astore        11
      71: aload         11
      73: astore        12
      75: iconst_0
      76: istore        13
      78: aload         12
      80: checkcast     #247                // class kotlin/Pair
      83: astore        14
      85: iconst_0
      86: istore        15
      88: aload         14
      90: invokevirtual #275                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      93: checkcast     #143                // class Point
      96: astore        16
      98: aload         14
     100: invokevirtual #278                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     103: checkcast     #143                // class Point
     106: astore        17
     108: aload         16
     110: aload         17
     112: invokestatic  #280                // Method main$distanceTo:(LPoint;LPoint;)I
     115: istore        18
     117: aload         16
     119: iload_2
     120: iload         18
     122: invokestatic  #282                // Method main$findRange:(LPoint;II)Lkotlin/ranges/IntRange;
     125: dup
     126: ifnull        147
     129: astore        19
     131: iconst_0
     132: istore        20
     134: aload         6
     136: aload         19
     138: invokeinterface #123,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     143: pop
     144: goto          148
     147: pop
     148: nop
     149: goto          52
     152: nop
     153: aload         6
     155: checkcast     #113                // class java/util/List
     158: nop
     159: invokestatic  #284                // Method main$union:(Ljava/util/List;)Ljava/util/List;
     162: checkcast     #49                 // class java/lang/Iterable
     165: astore_3
     166: iconst_0
     167: istore        4
     169: aload_3
     170: invokeinterface #79,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     175: astore        5
     177: aload         5
     179: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     184: ifeq          233
     187: aload         5
     189: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     194: astore        6
     196: iload         4
     198: aload         6
     200: checkcast     #64                 // class kotlin/ranges/IntRange
     203: astore        7
     205: istore        21
     207: iconst_0
     208: istore        8
     210: aload         7
     212: invokevirtual #99                 // Method kotlin/ranges/IntRange.getLast:()I
     215: aload         7
     217: invokevirtual #96                 // Method kotlin/ranges/IntRange.getFirst:()I
     220: isub
     221: istore        22
     223: iload         21
     225: iload         22
     227: iadd
     228: istore        4
     230: goto          177
     233: iload         4
     235: ireturn

  private static final long main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #270                // Method main$parse:(Ljava/util/List;)Ljava/util/List;
       4: astore_1
       5: new           #302                // class kotlin/ranges/LongRange
       8: dup
       9: lconst_0
      10: ldc2_w        #147                // long 4000000l
      13: invokespecial #305                // Method kotlin/ranges/LongRange."<init>":(JJ)V
      16: astore_2
      17: aload_1
      18: checkcast     #49                 // class java/lang/Iterable
      21: invokeinterface #79,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      26: astore_3
      27: aload_3
      28: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      33: ifeq          610
      36: aload_3
      37: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      42: checkcast     #247                // class kotlin/Pair
      45: astore        4
      47: iconst_0
      48: istore        5
      50: aload         4
      52: invokevirtual #275                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      55: checkcast     #143                // class Point
      58: astore        6
      60: aload         4
      62: invokevirtual #278                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      65: checkcast     #143                // class Point
      68: astore        7
      70: aload         6
      72: aload         7
      74: invokestatic  #280                // Method main$distanceTo:(LPoint;LPoint;)I
      77: istore        8
      79: new           #143                // class Point
      82: dup
      83: aload         6
      85: invokevirtual #146                // Method Point.getX:()I
      88: aload         6
      90: invokevirtual #151                // Method Point.getY:()I
      93: iload         8
      95: isub
      96: iconst_1
      97: isub
      98: invokespecial #188                // Method Point."<init>":(II)V
     101: astore        9
     103: new           #143                // class Point
     106: dup
     107: aload         6
     109: invokevirtual #146                // Method Point.getX:()I
     112: aload         6
     114: invokevirtual #151                // Method Point.getY:()I
     117: iload         8
     119: iadd
     120: iconst_1
     121: iadd
     122: invokespecial #188                // Method Point."<init>":(II)V
     125: astore        10
     127: new           #143                // class Point
     130: dup
     131: aload         6
     133: invokevirtual #146                // Method Point.getX:()I
     136: iload         8
     138: isub
     139: iconst_1
     140: isub
     141: aload         6
     143: invokevirtual #151                // Method Point.getY:()I
     146: invokespecial #188                // Method Point."<init>":(II)V
     149: astore        11
     151: new           #143                // class Point
     154: dup
     155: aload         6
     157: invokevirtual #146                // Method Point.getX:()I
     160: iload         8
     162: iadd
     163: iconst_1
     164: iadd
     165: aload         6
     167: invokevirtual #151                // Method Point.getY:()I
     170: invokespecial #188                // Method Point."<init>":(II)V
     173: astore        12
     175: aload         9
     177: aload         12
     179: invokestatic  #307                // Method main$lineTo:(LPoint;LPoint;)Ljava/util/List;
     182: checkcast     #119                // class java/util/Collection
     185: aload         12
     187: aload         10
     189: invokestatic  #307                // Method main$lineTo:(LPoint;LPoint;)Ljava/util/List;
     192: checkcast     #49                 // class java/lang/Iterable
     195: invokestatic  #311                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     198: checkcast     #119                // class java/util/Collection
     201: aload         10
     203: aload         11
     205: invokestatic  #307                // Method main$lineTo:(LPoint;LPoint;)Ljava/util/List;
     208: checkcast     #49                 // class java/lang/Iterable
     211: invokestatic  #311                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     214: checkcast     #119                // class java/util/Collection
     217: aload         11
     219: aload         9
     221: invokestatic  #307                // Method main$lineTo:(LPoint;LPoint;)Ljava/util/List;
     224: checkcast     #49                 // class java/lang/Iterable
     227: invokestatic  #311                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     230: checkcast     #49                 // class java/lang/Iterable
     233: astore        13
     235: nop
     236: iconst_0
     237: istore        14
     239: aload         13
     241: astore        15
     243: new           #179                // class java/util/ArrayList
     246: dup
     247: invokespecial #272                // Method java/util/ArrayList."<init>":()V
     250: checkcast     #119                // class java/util/Collection
     253: astore        16
     255: iconst_0
     256: istore        17
     258: aload         15
     260: invokeinterface #79,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     265: astore        18
     267: aload         18
     269: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     274: ifeq          413
     277: aload         18
     279: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     284: astore        19
     286: aload         19
     288: checkcast     #143                // class Point
     291: astore        20
     293: iconst_0
     294: istore        21
     296: aload_2
     297: invokevirtual #314                // Method kotlin/ranges/LongRange.getFirst:()J
     300: lstore        22
     302: aload_2
     303: invokevirtual #316                // Method kotlin/ranges/LongRange.getLast:()J
     306: lstore        24
     308: aload         20
     310: invokevirtual #146                // Method Point.getX:()I
     313: i2l
     314: lstore        26
     316: lload         22
     318: lload         26
     320: lcmp
     321: ifgt          340
     324: lload         26
     326: lload         24
     328: lcmp
     329: ifgt          336
     332: iconst_1
     333: goto          341
     336: iconst_0
     337: goto          341
     340: iconst_0
     341: ifeq          396
     344: aload_2
     345: invokevirtual #314                // Method kotlin/ranges/LongRange.getFirst:()J
     348: lstore        22
     350: aload_2
     351: invokevirtual #316                // Method kotlin/ranges/LongRange.getLast:()J
     354: lstore        24
     356: aload         20
     358: invokevirtual #151                // Method Point.getY:()I
     361: i2l
     362: lstore        26
     364: lload         22
     366: lload         26
     368: lcmp
     369: ifgt          388
     372: lload         26
     374: lload         24
     376: lcmp
     377: ifgt          384
     380: iconst_1
     381: goto          389
     384: iconst_0
     385: goto          389
     388: iconst_0
     389: ifeq          396
     392: iconst_1
     393: goto          397
     396: iconst_0
     397: ifeq          267
     400: aload         16
     402: aload         19
     404: invokeinterface #123,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     409: pop
     410: goto          267
     413: aload         16
     415: checkcast     #113                // class java/util/List
     418: nop
     419: checkcast     #49                 // class java/lang/Iterable
     422: astore        13
     424: nop
     425: iconst_0
     426: istore        14
     428: aload         13
     430: invokeinterface #79,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     435: astore        15
     437: aload         15
     439: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     444: ifeq          597
     447: aload         15
     449: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     454: astore        16
     456: aload         16
     458: checkcast     #143                // class Point
     461: astore        17
     463: iconst_0
     464: istore        18
     466: aload_1
     467: checkcast     #49                 // class java/lang/Iterable
     470: astore        19
     472: iconst_0
     473: istore        20
     475: aload         19
     477: instanceof    #119                // class java/util/Collection
     480: ifeq          500
     483: aload         19
     485: checkcast     #119                // class java/util/Collection
     488: invokeinterface #319,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     493: ifeq          500
     496: iconst_1
     497: goto          588
     500: aload         19
     502: invokeinterface #79,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     507: astore        21
     509: aload         21
     511: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     516: ifeq          587
     519: aload         21
     521: invokeinterface #89,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     526: astore        28
     528: aload         28
     530: checkcast     #247                // class kotlin/Pair
     533: astore        29
     535: iconst_0
     536: istore        30
     538: aload         29
     540: invokevirtual #275                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     543: checkcast     #143                // class Point
     546: astore        31
     548: aload         29
     550: invokevirtual #278                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     553: checkcast     #143                // class Point
     556: astore        32
     558: aload         31
     560: aload         17
     562: invokestatic  #280                // Method main$distanceTo:(LPoint;LPoint;)I
     565: aload         31
     567: aload         32
     569: invokestatic  #280                // Method main$distanceTo:(LPoint;LPoint;)I
     572: if_icmple     579
     575: iconst_1
     576: goto          580
     579: iconst_0
     580: ifne          509
     583: iconst_0
     584: goto          588
     587: iconst_1
     588: nop
     589: ifeq          437
     592: aload         16
     594: goto          598
     597: aconst_null
     598: checkcast     #143                // class Point
     601: nop
     602: dup
     603: ifnonnull     611
     606: pop
     607: goto          27
     610: aconst_null
     611: dup
     612: ifnonnull     627
     615: pop
     616: new           #321                // class java/util/NoSuchElementException
     619: dup
     620: ldc_w         #323                // String No element of the collection was transformed to a non-null value.
     623: invokespecial #326                // Method java/util/NoSuchElementException."<init>":(Ljava/lang/String;)V
     626: athrow
     627: invokestatic  #328                // Method main$frequency:(LPoint;)J
     630: lreturn
}

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

  public final int compare(T, T);
    Code:
       0: aload_1
       1: checkcast     #23                 // class kotlin/ranges/IntRange
       4: astore_3
       5: iconst_0
       6: istore        4
       8: aload_3
       9: invokevirtual #27                 // Method kotlin/ranges/IntRange.getFirst:()I
      12: invokestatic  #33                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      15: checkcast     #35                 // class java/lang/Comparable
      18: aload_2
      19: checkcast     #23                 // class kotlin/ranges/IntRange
      22: astore_3
      23: astore        5
      25: iconst_0
      26: istore        4
      28: aload_3
      29: invokevirtual #27                 // Method kotlin/ranges/IntRange.getFirst:()I
      32: invokestatic  #33                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      35: aload         5
      37: swap
      38: checkcast     #35                 // class java/lang/Comparable
      41: invokestatic  #41                 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I
      44: ireturn
}