import java.io.File
import java.math.BigInteger
import kotlin.math.abs
import kotlin.math.max

fun readInput(name: String) = File("aoc2022/src", "$name.txt")
    .readLines()

fun <T> assertEquals(value: T, target: T) {
    if (value != target)
        check(false) { "Expected $target got $value" }
}

fun String.destructured(regex: Regex): MatchResult.Destructured = regex.matchEntire(this)
    ?.destructured
    ?: throw IllegalArgumentException("Incorrect line $this")

val intLineRegex = """-?\d+""".toRegex()

fun String.ints() = intLineRegex.findAll(this).map { it.value.toInt() }.toList()

fun <T> test(
    day: Int,
    testTarget1: T,
    testTarget2: T,
    part1: (List<String>) -> T,
    part2: (List<String>) -> T,
) {
    // test if implementation meets criteria from the description, like:
    val dayNumber = day.toString().padStart(2, '0')
    val testInput = readInput("Day${dayNumber}_test")
    val input = readInput("Day${dayNumber}")

    println("[DAY $day]")

    println("Part 1")
    print("  test:   $testTarget1 ")
    var startTime = System.currentTimeMillis()
    assertEquals(part1(testInput), testTarget1)
    println("OK (${System.currentTimeMillis() - startTime} ms)")
    startTime = System.currentTimeMillis()
    println("  answer: ${part1(input)} (${System.currentTimeMillis() - startTime} ms)")

    println("Part 2")
    print("  test:   $testTarget2 ")
    startTime = System.currentTimeMillis()
    assertEquals(part2(testInput), testTarget2)
    println("OK (${System.currentTimeMillis() - startTime} ms)")
    startTime = System.currentTimeMillis()
    println("  answer: ${part2(input)} (${System.currentTimeMillis() - startTime} ms)")
}

class GridCell<T>(
    var value: T,
    val position: Vector2d,
)

class Grid<T>(data: List<List<T>>) {
    val data = data.mapIndexed { y, line ->
        line.mapIndexed { x, value -> GridCell(value, Vector2d(x, y)) }
    }

    val width = data.first().size
    val height = data.size

    fun get(x: Int, y: Int) = data[y][x]
    operator fun get(vector2d: Vector2d) = get(vector2d.x, vector2d.y)

    fun contains(x: Int, y: Int) = (x in 0 until width) && (y in 0 until height)

    operator fun contains(vector2d: Vector2d) = contains(vector2d.x, vector2d.y)

    fun crossNeighbours(vector2d: Vector2d) = Vector2d.DIRECTIONS.map { vector2d + it }.filter { contains(it) }.map { get(it) }

    fun path(
        start: GridCell<T>,
        end: GridCell<T>,
        heuristic: (GridCell<T>) -> Int = {
            (end.position - it.position).length()
        },
        neighbours: (GridCell<T>) -> Collection<GridCell<T>> = {
            crossNeighbours(it.position)
        },
    ) = aStar(start, isEndNode = { it == end }, heuristic, neighbours)
}

data class Vector2d(var x: Int = 0, var y: Int = 0) {
    companion object {
        val UP = Vector2d(0, -1)
        val DOWN = Vector2d(0, 1)
        val LEFT = Vector2d(-1, -0)
        val RIGHT = Vector2d(1, 0)
        val DIRECTIONS = arrayOf(UP, DOWN, LEFT, RIGHT)
    }

    operator fun plus(vector2d: Vector2d) = Vector2d(x + vector2d.x, y + vector2d.y)
    operator fun minus(vector2d: Vector2d) = Vector2d(x - vector2d.x, y - vector2d.y)

    fun increment(vector2d: Vector2d): Vector2d {
        this.x += vector2d.x
        this.y += vector2d.y

        return this
    }

    fun normalized() = Vector2d(if (x != 0) x / abs(x) else 0, if (y != 0) y / abs(y) else 0)

    fun negative() = Vector2d(-x, -y)

    fun length() = max(abs(x), abs(y))

    fun manhattan() = abs(x) + abs(y)

    fun neighbours8() = setOf(
        this + UP,
        this + UP + LEFT,
        this + UP + RIGHT,
        this + LEFT,
        this + RIGHT,
        this + DOWN,
        this + DOWN + LEFT,
        this + DOWN + RIGHT,
    )
}

data class Vector3d(var x: Int = 0, var y: Int = 0, var z: Int = 0) {
    companion object {
        val UP = Vector3d(0, -1, 0)
        val DOWN = Vector3d(0, 1, 0)
        val LEFT = Vector3d(-1, 0, 0)
        val RIGHT = Vector3d(1, 0, 0)
        val FORWARD = Vector3d(0, 0, -1)
        val FRONT = Vector3d(0, 0, -1)
        val BACKWARD = Vector3d(0, 0, 1)
        val BACK = Vector3d(0, 0, 1)
        val DIRECTIONS = arrayOf(UP, DOWN, LEFT, RIGHT, FORWARD, BACKWARD)
    }

    operator fun plus(vector3d: Vector3d) = Vector3d(x + vector3d.x, y + vector3d.y, z + vector3d.z)
    operator fun minus(vector3d: Vector3d) = Vector3d(x - vector3d.x, y - vector3d.y, z - vector3d.z)

    operator fun times(times: Int) = Vector3d(x * times, y * times, z * times)

    fun increment(vector3d: Vector3d): Vector3d {
        this.x += vector3d.x
        this.y += vector3d.y
        this.z += vector3d.z

        return this
    }
}

class VectorN(val components: MutableList<Int>) {
    constructor(vararg ints: Int) : this(ints.toMutableList())

    operator fun plus(vectorN: VectorN) = VectorN(components.mapIndexed { index, it -> it + vectorN.components[index] }.toMutableList())
    operator fun minus(vectorN: VectorN) = VectorN(components.mapIndexed { index, it -> it - vectorN.components[index] }.toMutableList())

    fun increment(vectorN: VectorN): VectorN {
        for (n in components.indices)
            components[n] += vectorN.components[n]

        return this
    }

    override fun toString(): String {
        return components.toString()
    }
}

fun <Node> aStar(
    start: Node,
    isEndNode: (Node) -> Boolean,
    heuristic: (Node) -> Int,
    neighbours: (Node) -> Collection<Node>,
): List<Node> {
    val openSet = mutableSetOf(start)
    val gScores = mutableMapOf(start to 0)
    val fScores = mutableMapOf(start to heuristic(start))
    val cameFrom = mutableMapOf<Node, Node>()

    fun reconstructPath(cameFrom: Map<Node, Node>, end: Node): List<Node> {
        val path = mutableListOf(end)
        var current = end

        while (current in cameFrom) {
            current = cameFrom[current]!!
            path.add(current)
        }

        return path
    }

    while (openSet.isNotEmpty()) {
        val current = openSet.minBy { fScores[it]!! }

        if (isEndNode(current))
            return reconstructPath(cameFrom, current)

        openSet.remove(current)

        for (neighbour in neighbours(current)) {
            val neighbourScore = gScores[current]!! + 1

            if (neighbourScore < gScores.getOrDefault(neighbour, 999999)) {
                cameFrom[neighbour] = current
                gScores[neighbour] = neighbourScore
                fScores[neighbour] = neighbourScore + heuristic(neighbour)

                if (neighbour !in openSet)
                    openSet += neighbour
            }
        }
    }

    return emptyList()
}

fun List<String>.separateByBlank(): List<List<String>> {
    val result = mutableListOf<List<String>>()
    var currentList = mutableListOf<String>()

    for (line in this)
        when {
            line.isBlank() && currentList.isEmpty() -> continue
            line.isBlank() -> {
                result.add(currentList)
                currentList = mutableListOf()
            }

            else -> currentList.add(line)
        }

    if (currentList.isNotEmpty())
        result.add(currentList)

    return result
}

fun Int.factorial() = (1L..this).reduce(Long::times)

fun <T> List<T>.findLongestSequence(): Pair<Int, Int> {
    val sequences = mutableListOf<Pair<Int, Int>>()

    for (startPos in indices) {
        for (sequenceLength in 1..(this.size - startPos) / 2) {
            var sequencesAreEqual = true

            for (i in 0 until sequenceLength)
                if (this[startPos + i] != this[startPos + sequenceLength + i]) {
                    sequencesAreEqual = false
                    break
                }

            if (sequencesAreEqual)
                sequences += Pair(startPos, sequenceLength)
        }
    }

    return sequences.maxBy { it.second }
}

fun gcd(a: Int, b: Int): Int {
    if (b == 0) return a
    return gcd(b, a % b)
}

fun Long.pow(exp: Int): Long {
    return BigInteger.valueOf(this).pow(exp).toLong()
}

fun Int.pow(exp: Int): Long {
    return BigInteger.valueOf(this.toLong()).pow(exp).toLong()
}

Compiled from "Utils.kt"
public final class UtilsKt {
  private static final kotlin.text.Regex intLineRegex;

  public static final java.util.List<java.lang.String> readInput(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #10                 // String name
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #18                 // class java/io/File
       9: dup
      10: ldc           #20                 // String aoc2022/src
      12: new           #22                 // class java/lang/StringBuilder
      15: dup
      16: invokespecial #26                 // Method java/lang/StringBuilder."<init>":()V
      19: aload_0
      20: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      23: ldc           #32                 // String .txt
      25: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      28: invokevirtual #36                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      31: invokespecial #39                 // Method java/io/File."<init>":(Ljava/lang/String;Ljava/lang/String;)V
      34: aconst_null
      35: iconst_1
      36: aconst_null
      37: invokestatic  #45                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
      40: areturn

  public static final <T> void assertEquals(T, T);
    Code:
       0: aload_0
       1: aload_1
       2: invokestatic  #53                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
       5: ifne          52
       8: nop
       9: iconst_0
      10: istore_2
      11: new           #22                 // class java/lang/StringBuilder
      14: dup
      15: invokespecial #26                 // Method java/lang/StringBuilder."<init>":()V
      18: ldc           #55                 // String Expected
      20: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      23: aload_1
      24: invokevirtual #58                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      27: ldc           #60                 // String  got
      29: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      32: aload_0
      33: invokevirtual #58                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      36: invokevirtual #36                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      39: astore_2
      40: new           #62                 // class java/lang/IllegalStateException
      43: dup
      44: aload_2
      45: invokevirtual #63                 // Method java/lang/Object.toString:()Ljava/lang/String;
      48: invokespecial #66                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      51: athrow
      52: return

  public static final kotlin.text.MatchResult$Destructured destructured(java.lang.String, kotlin.text.Regex);
    Code:
       0: aload_0
       1: ldc           #75                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #77                 // String regex
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: aload_0
      14: checkcast     #79                 // class java/lang/CharSequence
      17: invokevirtual #85                 // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;
      20: astore_2
      21: aload_2
      22: ifnull        40
      25: aload_2
      26: invokeinterface #91,  1           // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;
      31: astore_3
      32: aload_3
      33: ifnull        40
      36: aload_3
      37: goto          67
      40: new           #93                 // class java/lang/IllegalArgumentException
      43: dup
      44: new           #22                 // class java/lang/StringBuilder
      47: dup
      48: invokespecial #26                 // Method java/lang/StringBuilder."<init>":()V
      51: ldc           #95                 // String Incorrect line
      53: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      56: aload_0
      57: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      60: invokevirtual #36                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      63: invokespecial #96                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
      66: athrow
      67: areturn

  public static final kotlin.text.Regex getIntLineRegex();
    Code:
       0: getstatic     #107                // Field intLineRegex:Lkotlin/text/Regex;
       3: areturn

  public static final java.util.List<java.lang.Integer> ints(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #75                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: getstatic     #107                // Field intLineRegex:Lkotlin/text/Regex;
       9: aload_0
      10: checkcast     #79                 // class java/lang/CharSequence
      13: iconst_0
      14: iconst_2
      15: aconst_null
      16: invokestatic  #113                // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;
      19: invokedynamic #133,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      24: invokestatic  #139                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      27: invokestatic  #143                // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;
      30: areturn

  public static final <T> void test(int, T, T, kotlin.jvm.functions.Function1<? super java.util.List<java.lang.String>, ? extends T>, kotlin.jvm.functions.Function1<? super java.util.List<java.lang.String>, ? extends T>);
    Code:
       0: aload_3
       1: ldc           #149                // String part1
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload         4
       8: ldc           #151                // String part2
      10: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      13: iload_0
      14: invokestatic  #155                // Method java/lang/String.valueOf:(I)Ljava/lang/String;
      17: iconst_2
      18: bipush        48
      20: invokestatic  #161                // Method kotlin/text/StringsKt.padStart:(Ljava/lang/String;IC)Ljava/lang/String;
      23: astore        5
      25: new           #22                 // class java/lang/StringBuilder
      28: dup
      29: invokespecial #26                 // Method java/lang/StringBuilder."<init>":()V
      32: ldc           #163                // String Day
      34: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      37: aload         5
      39: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      42: ldc           #165                // String _test
      44: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      47: invokevirtual #36                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      50: invokestatic  #167                // Method readInput:(Ljava/lang/String;)Ljava/util/List;
      53: astore        6
      55: new           #22                 // class java/lang/StringBuilder
      58: dup
      59: invokespecial #26                 // Method java/lang/StringBuilder."<init>":()V
      62: ldc           #163                // String Day
      64: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      67: aload         5
      69: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      72: invokevirtual #36                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      75: invokestatic  #167                // Method readInput:(Ljava/lang/String;)Ljava/util/List;
      78: astore        7
      80: new           #22                 // class java/lang/StringBuilder
      83: dup
      84: invokespecial #26                 // Method java/lang/StringBuilder."<init>":()V
      87: ldc           #169                // String [DAY
      89: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      92: iload_0
      93: invokevirtual #172                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      96: bipush        93
      98: invokevirtual #175                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     101: invokevirtual #36                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     104: getstatic     #181                // Field java/lang/System.out:Ljava/io/PrintStream;
     107: swap
     108: invokevirtual #187                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     111: ldc           #189                // String Part 1
     113: getstatic     #181                // Field java/lang/System.out:Ljava/io/PrintStream;
     116: swap
     117: invokevirtual #187                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     120: new           #22                 // class java/lang/StringBuilder
     123: dup
     124: invokespecial #26                 // Method java/lang/StringBuilder."<init>":()V
     127: ldc           #191                // String   test:
     129: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     132: aload_1
     133: invokevirtual #58                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     136: bipush        32
     138: invokevirtual #175                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     141: invokevirtual #36                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     144: getstatic     #181                // Field java/lang/System.out:Ljava/io/PrintStream;
     147: swap
     148: invokevirtual #194                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     151: invokestatic  #198                // Method java/lang/System.currentTimeMillis:()J
     154: lstore        8
     156: aload_3
     157: aload         6
     159: invokeinterface #202,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
     164: aload_1
     165: invokestatic  #204                // Method assertEquals:(Ljava/lang/Object;Ljava/lang/Object;)V
     168: new           #22                 // class java/lang/StringBuilder
     171: dup
     172: invokespecial #26                 // Method java/lang/StringBuilder."<init>":()V
     175: ldc           #206                // String OK (
     177: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     180: invokestatic  #198                // Method java/lang/System.currentTimeMillis:()J
     183: lload         8
     185: lsub
     186: invokevirtual #209                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     189: ldc           #211                // String  ms)
     191: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     194: invokevirtual #36                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     197: getstatic     #181                // Field java/lang/System.out:Ljava/io/PrintStream;
     200: swap
     201: invokevirtual #187                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     204: invokestatic  #198                // Method java/lang/System.currentTimeMillis:()J
     207: lstore        8
     209: new           #22                 // class java/lang/StringBuilder
     212: dup
     213: invokespecial #26                 // Method java/lang/StringBuilder."<init>":()V
     216: ldc           #213                // String   answer:
     218: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     221: aload_3
     222: aload         7
     224: invokeinterface #202,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
     229: invokevirtual #58                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     232: ldc           #215                // String  (
     234: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     237: invokestatic  #198                // Method java/lang/System.currentTimeMillis:()J
     240: lload         8
     242: lsub
     243: invokevirtual #209                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     246: ldc           #211                // String  ms)
     248: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     251: invokevirtual #36                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     254: getstatic     #181                // Field java/lang/System.out:Ljava/io/PrintStream;
     257: swap
     258: invokevirtual #187                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     261: ldc           #217                // String Part 2
     263: getstatic     #181                // Field java/lang/System.out:Ljava/io/PrintStream;
     266: swap
     267: invokevirtual #187                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     270: new           #22                 // class java/lang/StringBuilder
     273: dup
     274: invokespecial #26                 // Method java/lang/StringBuilder."<init>":()V
     277: ldc           #191                // String   test:
     279: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     282: aload_2
     283: invokevirtual #58                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     286: bipush        32
     288: invokevirtual #175                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     291: invokevirtual #36                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     294: getstatic     #181                // Field java/lang/System.out:Ljava/io/PrintStream;
     297: swap
     298: invokevirtual #194                // Method java/io/PrintStream.print:(Ljava/lang/Object;)V
     301: invokestatic  #198                // Method java/lang/System.currentTimeMillis:()J
     304: lstore        8
     306: aload         4
     308: aload         6
     310: invokeinterface #202,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
     315: aload_2
     316: invokestatic  #204                // Method assertEquals:(Ljava/lang/Object;Ljava/lang/Object;)V
     319: new           #22                 // class java/lang/StringBuilder
     322: dup
     323: invokespecial #26                 // Method java/lang/StringBuilder."<init>":()V
     326: ldc           #206                // String OK (
     328: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     331: invokestatic  #198                // Method java/lang/System.currentTimeMillis:()J
     334: lload         8
     336: lsub
     337: invokevirtual #209                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     340: ldc           #211                // String  ms)
     342: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     345: invokevirtual #36                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     348: getstatic     #181                // Field java/lang/System.out:Ljava/io/PrintStream;
     351: swap
     352: invokevirtual #187                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     355: invokestatic  #198                // Method java/lang/System.currentTimeMillis:()J
     358: lstore        8
     360: new           #22                 // class java/lang/StringBuilder
     363: dup
     364: invokespecial #26                 // Method java/lang/StringBuilder."<init>":()V
     367: ldc           #213                // String   answer:
     369: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     372: aload         4
     374: aload         7
     376: invokeinterface #202,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
     381: invokevirtual #58                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
     384: ldc           #215                // String  (
     386: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     389: invokestatic  #198                // Method java/lang/System.currentTimeMillis:()J
     392: lload         8
     394: lsub
     395: invokevirtual #209                // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;
     398: ldc           #211                // String  ms)
     400: invokevirtual #30                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     403: invokevirtual #36                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     406: getstatic     #181                // Field java/lang/System.out:Ljava/io/PrintStream;
     409: swap
     410: invokevirtual #187                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     413: return

  public static final <Node> java.util.List<Node> aStar(Node, kotlin.jvm.functions.Function1<? super Node, java.lang.Boolean>, kotlin.jvm.functions.Function1<? super Node, java.lang.Integer>, kotlin.jvm.functions.Function1<? super Node, ? extends java.util.Collection<? extends Node>>);
    Code:
       0: aload_1
       1: ldc           #232                // String isEndNode
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #234                // String heuristic
       9: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_3
      13: ldc           #236                // String neighbours
      15: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      18: iconst_1
      19: anewarray     #4                  // class java/lang/Object
      22: astore        5
      24: aload         5
      26: iconst_0
      27: aload_0
      28: aastore
      29: aload         5
      31: invokestatic  #242                // Method kotlin/collections/SetsKt.mutableSetOf:([Ljava/lang/Object;)Ljava/util/Set;
      34: astore        4
      36: iconst_1
      37: anewarray     #244                // class kotlin/Pair
      40: astore        6
      42: aload         6
      44: iconst_0
      45: aload_0
      46: iconst_0
      47: invokestatic  #249                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      50: invokestatic  #255                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      53: aastore
      54: aload         6
      56: invokestatic  #261                // Method kotlin/collections/MapsKt.mutableMapOf:([Lkotlin/Pair;)Ljava/util/Map;
      59: astore        5
      61: iconst_1
      62: anewarray     #244                // class kotlin/Pair
      65: astore        7
      67: aload         7
      69: iconst_0
      70: aload_0
      71: aload_2
      72: aload_0
      73: invokeinterface #202,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
      78: invokestatic  #255                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      81: aastore
      82: aload         7
      84: invokestatic  #261                // Method kotlin/collections/MapsKt.mutableMapOf:([Lkotlin/Pair;)Ljava/util/Map;
      87: astore        6
      89: new           #263                // class java/util/LinkedHashMap
      92: dup
      93: invokespecial #264                // Method java/util/LinkedHashMap."<init>":()V
      96: checkcast     #266                // class java/util/Map
      99: astore        7
     101: aload         4
     103: checkcast     #268                // class java/util/Collection
     106: invokeinterface #272,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     111: ifne          118
     114: iconst_1
     115: goto          119
     118: iconst_0
     119: ifeq          504
     122: aload         4
     124: checkcast     #274                // class java/lang/Iterable
     127: astore        9
     129: iconst_0
     130: istore        10
     132: aload         9
     134: invokeinterface #278,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     139: astore        11
     141: aload         11
     143: invokeinterface #283,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     148: ifne          159
     151: new           #285                // class java/util/NoSuchElementException
     154: dup
     155: invokespecial #286                // Method java/util/NoSuchElementException."<init>":()V
     158: athrow
     159: aload         11
     161: invokeinterface #290,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     166: astore        12
     168: aload         11
     170: invokeinterface #283,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     175: ifne          183
     178: aload         12
     180: goto          292
     183: aload         12
     185: astore        13
     187: iconst_0
     188: istore        14
     190: aload         6
     192: aload         13
     194: invokeinterface #293,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     199: dup
     200: invokestatic  #296                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     203: checkcast     #298                // class java/lang/Number
     206: invokevirtual #302                // Method java/lang/Number.intValue:()I
     209: invokestatic  #249                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     212: checkcast     #304                // class java/lang/Comparable
     215: astore        13
     217: aload         11
     219: invokeinterface #290,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     224: astore        14
     226: aload         14
     228: astore        15
     230: iconst_0
     231: istore        16
     233: aload         6
     235: aload         15
     237: invokeinterface #293,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     242: dup
     243: invokestatic  #296                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     246: checkcast     #298                // class java/lang/Number
     249: invokevirtual #302                // Method java/lang/Number.intValue:()I
     252: invokestatic  #249                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     255: checkcast     #304                // class java/lang/Comparable
     258: astore        15
     260: aload         13
     262: aload         15
     264: invokeinterface #308,  2          // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I
     269: ifle          280
     272: aload         14
     274: astore        12
     276: aload         15
     278: astore        13
     280: aload         11
     282: invokeinterface #283,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     287: ifne          217
     290: aload         12
     292: astore        8
     294: aload_1
     295: aload         8
     297: invokeinterface #202,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
     302: checkcast     #310                // class java/lang/Boolean
     305: invokevirtual #313                // Method java/lang/Boolean.booleanValue:()Z
     308: ifeq          319
     311: aload         7
     313: aload         8
     315: invokestatic  #317                // Method aStar$reconstructPath:(Ljava/util/Map;Ljava/lang/Object;)Ljava/util/List;
     318: areturn
     319: aload         4
     321: aload         8
     323: invokeinterface #323,  2          // InterfaceMethod java/util/Set.remove:(Ljava/lang/Object;)Z
     328: pop
     329: aload_3
     330: aload         8
     332: invokeinterface #202,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
     337: checkcast     #268                // class java/util/Collection
     340: invokeinterface #324,  1          // InterfaceMethod java/util/Collection.iterator:()Ljava/util/Iterator;
     345: astore        9
     347: aload         9
     349: invokeinterface #283,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     354: ifeq          101
     357: aload         9
     359: invokeinterface #290,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     364: astore        10
     366: aload         5
     368: aload         8
     370: invokeinterface #293,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     375: dup
     376: invokestatic  #296                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     379: checkcast     #298                // class java/lang/Number
     382: invokevirtual #302                // Method java/lang/Number.intValue:()I
     385: iconst_1
     386: iadd
     387: istore        11
     389: iload         11
     391: aload         5
     393: aload         10
     395: ldc_w         #325                // int 999999
     398: invokestatic  #249                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     401: invokeinterface #329,  3          // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     406: checkcast     #298                // class java/lang/Number
     409: invokevirtual #302                // Method java/lang/Number.intValue:()I
     412: if_icmpge     347
     415: aload         7
     417: aload         10
     419: aload         8
     421: invokeinterface #332,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     426: pop
     427: iload         11
     429: invokestatic  #249                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     432: astore        13
     434: aload         5
     436: aload         10
     438: aload         13
     440: invokeinterface #332,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     445: pop
     446: aload         6
     448: aload         10
     450: iload         11
     452: aload_2
     453: aload         10
     455: invokeinterface #202,  2          // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;
     460: checkcast     #298                // class java/lang/Number
     463: invokevirtual #302                // Method java/lang/Number.intValue:()I
     466: iadd
     467: invokestatic  #249                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     470: invokeinterface #332,  3          // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     475: pop
     476: aload         4
     478: aload         10
     480: invokeinterface #335,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     485: ifne          347
     488: aload         4
     490: checkcast     #268                // class java/util/Collection
     493: aload         10
     495: invokeinterface #338,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     500: pop
     501: goto          347
     504: invokestatic  #344                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     507: areturn

  public static final java.util.List<java.util.List<java.lang.String>> separateByBlank(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #75                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #371                // class java/util/ArrayList
       9: dup
      10: invokespecial #372                // Method java/util/ArrayList."<init>":()V
      13: checkcast     #374                // class java/util/List
      16: astore_1
      17: new           #371                // class java/util/ArrayList
      20: dup
      21: invokespecial #372                // Method java/util/ArrayList."<init>":()V
      24: checkcast     #374                // class java/util/List
      27: astore_2
      28: aload_0
      29: invokeinterface #375,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      34: astore_3
      35: aload_3
      36: invokeinterface #283,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      41: ifeq          121
      44: aload_3
      45: invokeinterface #290,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      50: checkcast     #100                // class java/lang/String
      53: astore        4
      55: nop
      56: aload         4
      58: checkcast     #79                 // class java/lang/CharSequence
      61: invokestatic  #379                // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z
      64: ifeq          76
      67: aload_2
      68: invokeinterface #380,  1          // InterfaceMethod java/util/List.isEmpty:()Z
      73: ifne          35
      76: aload         4
      78: checkcast     #79                 // class java/lang/CharSequence
      81: invokestatic  #379                // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z
      84: ifeq          109
      87: aload_1
      88: aload_2
      89: invokeinterface #381,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      94: pop
      95: new           #371                // class java/util/ArrayList
      98: dup
      99: invokespecial #372                // Method java/util/ArrayList."<init>":()V
     102: checkcast     #374                // class java/util/List
     105: astore_2
     106: goto          35
     109: aload_2
     110: aload         4
     112: invokeinterface #381,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     117: pop
     118: goto          35
     121: aload_2
     122: checkcast     #268                // class java/util/Collection
     125: invokeinterface #272,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     130: ifne          137
     133: iconst_1
     134: goto          138
     137: iconst_0
     138: ifeq          149
     141: aload_1
     142: aload_2
     143: invokeinterface #381,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     148: pop
     149: aload_1
     150: areturn

  public static final long factorial(int);
    Code:
       0: new           #389                // class kotlin/ranges/LongRange
       3: dup
       4: lconst_1
       5: iload_0
       6: i2l
       7: invokespecial #392                // Method kotlin/ranges/LongRange."<init>":(JJ)V
      10: checkcast     #274                // class java/lang/Iterable
      13: astore_1
      14: iconst_0
      15: istore_2
      16: aload_1
      17: invokeinterface #278,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      22: astore_3
      23: aload_3
      24: invokeinterface #283,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      29: ifne          43
      32: new           #394                // class java/lang/UnsupportedOperationException
      35: dup
      36: ldc_w         #396                // String Empty collection can\'t be reduced.
      39: invokespecial #397                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
      42: athrow
      43: aload_3
      44: checkcast     #399                // class kotlin/collections/LongIterator
      47: invokevirtual #402                // Method kotlin/collections/LongIterator.nextLong:()J
      50: lstore        4
      52: aload_3
      53: invokeinterface #283,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      58: ifeq          87
      61: lload         4
      63: aload_3
      64: checkcast     #399                // class kotlin/collections/LongIterator
      67: invokevirtual #402                // Method kotlin/collections/LongIterator.nextLong:()J
      70: lstore        6
      72: lstore        8
      74: iconst_0
      75: istore        10
      77: lload         8
      79: lload         6
      81: lmul
      82: lstore        4
      84: goto          52
      87: lload         4
      89: lreturn

  public static final <T> kotlin.Pair<java.lang.Integer, java.lang.Integer> findLongestSequence(java.util.List<? extends T>);
    Code:
       0: aload_0
       1: ldc           #75                 // String <this>
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #371                // class java/util/ArrayList
       9: dup
      10: invokespecial #372                // Method java/util/ArrayList."<init>":()V
      13: checkcast     #374                // class java/util/List
      16: astore_1
      17: iconst_0
      18: istore_2
      19: aload_0
      20: checkcast     #268                // class java/util/Collection
      23: invokeinterface #415,  1          // InterfaceMethod java/util/Collection.size:()I
      28: istore_3
      29: iload_2
      30: iload_3
      31: if_icmpge     160
      34: iconst_1
      35: istore        4
      37: aload_0
      38: invokeinterface #416,  1          // InterfaceMethod java/util/List.size:()I
      43: iload_2
      44: isub
      45: iconst_2
      46: idiv
      47: istore        5
      49: iload         4
      51: iload         5
      53: if_icmpgt     154
      56: iconst_1
      57: istore        6
      59: iconst_0
      60: istore        7
      62: iload         7
      64: iload         4
      66: if_icmpge     110
      69: aload_0
      70: iload_2
      71: iload         7
      73: iadd
      74: invokeinterface #419,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      79: aload_0
      80: iload_2
      81: iload         4
      83: iadd
      84: iload         7
      86: iadd
      87: invokeinterface #419,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      92: invokestatic  #53                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      95: ifne          104
      98: iconst_0
      99: istore        6
     101: goto          110
     104: iinc          7, 1
     107: goto          62
     110: iload         6
     112: ifeq          141
     115: aload_1
     116: checkcast     #268                // class java/util/Collection
     119: new           #244                // class kotlin/Pair
     122: dup
     123: iload_2
     124: invokestatic  #249                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     127: iload         4
     129: invokestatic  #249                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     132: invokespecial #421                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     135: invokeinterface #338,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     140: pop
     141: iload         4
     143: iload         5
     145: if_icmpeq     154
     148: iinc          4, 1
     151: goto          56
     154: iinc          2, 1
     157: goto          29
     160: aload_1
     161: checkcast     #274                // class java/lang/Iterable
     164: astore_2
     165: iconst_0
     166: istore_3
     167: aload_2
     168: invokeinterface #278,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     173: astore        4
     175: aload         4
     177: invokeinterface #283,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     182: ifne          193
     185: new           #285                // class java/util/NoSuchElementException
     188: dup
     189: invokespecial #286                // Method java/util/NoSuchElementException."<init>":()V
     192: athrow
     193: aload         4
     195: invokeinterface #290,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     200: astore        5
     202: aload         4
     204: invokeinterface #283,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     209: ifne          217
     212: aload         5
     214: goto          299
     217: aload         5
     219: checkcast     #244                // class kotlin/Pair
     222: astore        6
     224: iconst_0
     225: istore        7
     227: aload         6
     229: invokevirtual #424                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     232: checkcast     #298                // class java/lang/Number
     235: invokevirtual #302                // Method java/lang/Number.intValue:()I
     238: istore        6
     240: aload         4
     242: invokeinterface #290,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     247: astore        7
     249: aload         7
     251: checkcast     #244                // class kotlin/Pair
     254: astore        8
     256: iconst_0
     257: istore        9
     259: aload         8
     261: invokevirtual #424                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     264: checkcast     #298                // class java/lang/Number
     267: invokevirtual #302                // Method java/lang/Number.intValue:()I
     270: istore        8
     272: iload         6
     274: iload         8
     276: if_icmpge     287
     279: aload         7
     281: astore        5
     283: iload         8
     285: istore        6
     287: aload         4
     289: invokeinterface #283,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     294: ifne          240
     297: aload         5
     299: checkcast     #244                // class kotlin/Pair
     302: areturn

  public static final int gcd(int, int);
    Code:
       0: iload_1
       1: ifne          6
       4: iload_0
       5: ireturn
       6: iload_1
       7: iload_0
       8: iload_1
       9: irem
      10: invokestatic  #441                // Method gcd:(II)I
      13: ireturn

  public static final long pow(long, int);
    Code:
       0: lload_0
       1: invokestatic  #450                // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;
       4: iload_2
       5: invokevirtual #453                // Method java/math/BigInteger.pow:(I)Ljava/math/BigInteger;
       8: invokevirtual #456                // Method java/math/BigInteger.longValue:()J
      11: lreturn

  public static final long pow(int, int);
    Code:
       0: iload_0
       1: i2l
       2: invokestatic  #450                // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;
       5: iload_1
       6: invokevirtual #453                // Method java/math/BigInteger.pow:(I)Ljava/math/BigInteger;
       9: invokevirtual #456                // Method java/math/BigInteger.longValue:()J
      12: lreturn

  private static final int ints$lambda$1(kotlin.text.MatchResult);
    Code:
       0: aload_0
       1: ldc_w         #460                // String it
       4: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokeinterface #463,  1          // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;
      13: invokestatic  #467                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      16: ireturn

  private static final <Node> java.util.List<Node> aStar$reconstructPath(java.util.Map<Node, ? extends Node>, Node);
    Code:
       0: iconst_1
       1: anewarray     #4                  // class java/lang/Object
       4: astore_3
       5: aload_3
       6: iconst_0
       7: aload_1
       8: aastore
       9: aload_3
      10: invokestatic  #473                // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
      13: astore_2
      14: aload_1
      15: astore_3
      16: aload_0
      17: aload_3
      18: invokeinterface #476,  2          // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z
      23: ifeq          49
      26: aload_0
      27: aload_3
      28: invokeinterface #293,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      33: dup
      34: invokestatic  #296                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      37: astore_3
      38: aload_2
      39: aload_3
      40: invokeinterface #381,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      45: pop
      46: goto          16
      49: aload_2
      50: areturn

  static {};
    Code:
       0: new           #81                 // class kotlin/text/Regex
       3: dup
       4: ldc_w         #481                // String -?\\d+
       7: invokespecial #482                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      10: putstatic     #107                // Field intLineRegex:Lkotlin/text/Regex;
      13: return
}


fun main() {
    fun fallingSand(input: List<String>, hardFloor: Boolean, stopOnOverflow: Boolean, startPoint: Vector2d = Vector2d(500, 0)): Int {
        val lines = input.map {
            it.ints().chunked(2).map { (x, y) ->
                Vector2d(x, y)
            }.toList()
        }

        val xMin = lines.flatten().toMutableList().also { it.add(startPoint) }.minOf { it.x }
        val yMin = lines.flatten().toMutableList().also { it.add(startPoint) }.minOf { it.y }
        val xMax = lines.flatten().toMutableList().also { it.add(startPoint) }.maxOf { it.x }
        val yMax = lines.flatten().toMutableList().also { it.add(startPoint) }.maxOf { it.y }

        val occupied = mutableSetOf<Vector2d>()

        for (line in lines)
            for (n in 0 until line.size - 1) {
                var current = line[n]
                val to = line[n + 1]
                val step = (to - current).normalized()

                while (current != to + step) {
                    occupied += current
                    current += step
                }
            }

        var unitsResting = 0

        unitLoop@ while (true) {
            var current = startPoint

            while (true) {
                when {
                    hardFloor && current.y == yMax + 1 -> {
                        occupied += current
                        unitsResting++

                        continue@unitLoop
                    }

                    !hardFloor && (current.x !in (xMin..xMax) || current.y !in (yMin..yMax)) -> return unitsResting
                    (current + Vector2d.DOWN) !in occupied -> current += Vector2d.DOWN
                    (current + Vector2d.DOWN + Vector2d.LEFT) !in occupied -> current += Vector2d.DOWN + Vector2d.LEFT
                    (current + Vector2d.DOWN + Vector2d.RIGHT) !in occupied -> current += Vector2d.DOWN + Vector2d.RIGHT
                    else -> {
                        occupied += current
                        unitsResting++

                        if (stopOnOverflow && current == startPoint)
                            return unitsResting

                        continue@unitLoop
                    }
                }
            }
        }
    }

    fun part1(input: List<String>) = fallingSand(input, hardFloor = false, stopOnOverflow = false)

    fun part2(input: List<String>) = fallingSand(input, hardFloor = true, stopOnOverflow = true)

    test(
        day = 14,
        testTarget1 = 24,
        testTarget2 = 93,
        part1 = ::part1,
        part2 = ::part2,
    )
}

Compiled from "Day14.kt"
public final class Day14Kt {
  public static final void main();
    Code:
       0: bipush        14
       2: bipush        24
       4: invokestatic  #12                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
       7: bipush        93
       9: invokestatic  #12                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      12: getstatic     #18                 // Field Day14Kt$main$1.INSTANCE:LDay14Kt$main$1;
      15: checkcast     #20                 // class kotlin/jvm/functions/Function1
      18: getstatic     #25                 // Field Day14Kt$main$2.INSTANCE:LDay14Kt$main$2;
      21: checkcast     #20                 // class kotlin/jvm/functions/Function1
      24: invokestatic  #31                 // Method UtilsKt.test:(ILjava/lang/Object;Ljava/lang/Object;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V
      27: return

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

  private static final int main$fallingSand(java.util.List<java.lang.String>, boolean, boolean, Vector2d);
    Code:
       0: aload_0
       1: checkcast     #41                 // class java/lang/Iterable
       4: astore        5
       6: iconst_0
       7: istore        6
       9: aload         5
      11: astore        7
      13: new           #43                 // class java/util/ArrayList
      16: dup
      17: aload         5
      19: bipush        10
      21: invokestatic  #49                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      24: invokespecial #53                 // Method java/util/ArrayList."<init>":(I)V
      27: checkcast     #55                 // class java/util/Collection
      30: astore        8
      32: iconst_0
      33: istore        9
      35: aload         7
      37: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        10
      44: aload         10
      46: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          244
      54: aload         10
      56: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        11
      63: aload         8
      65: aload         11
      67: checkcast     #71                 // class java/lang/String
      70: astore        12
      72: astore        26
      74: iconst_0
      75: istore        13
      77: aload         12
      79: invokestatic  #75                 // Method UtilsKt.ints:(Ljava/lang/String;)Ljava/util/List;
      82: checkcast     #41                 // class java/lang/Iterable
      85: iconst_2
      86: invokestatic  #79                 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;
      89: checkcast     #41                 // class java/lang/Iterable
      92: astore        14
      94: iconst_0
      95: istore        15
      97: aload         14
      99: astore        16
     101: new           #43                 // class java/util/ArrayList
     104: dup
     105: aload         14
     107: bipush        10
     109: invokestatic  #49                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     112: invokespecial #53                 // Method java/util/ArrayList."<init>":(I)V
     115: checkcast     #55                 // class java/util/Collection
     118: astore        17
     120: iconst_0
     121: istore        18
     123: aload         16
     125: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     130: astore        19
     132: aload         19
     134: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     139: ifeq          220
     142: aload         19
     144: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     149: astore        20
     151: aload         17
     153: aload         20
     155: checkcast     #81                 // class java/util/List
     158: astore        21
     160: astore        22
     162: iconst_0
     163: istore        23
     165: aload         21
     167: iconst_0
     168: invokeinterface #85,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     173: checkcast     #87                 // class java/lang/Number
     176: invokevirtual #91                 // Method java/lang/Number.intValue:()I
     179: istore        24
     181: aload         21
     183: iconst_1
     184: invokeinterface #85,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     189: checkcast     #87                 // class java/lang/Number
     192: invokevirtual #91                 // Method java/lang/Number.intValue:()I
     195: istore        25
     197: new           #93                 // class Vector2d
     200: dup
     201: iload         24
     203: iload         25
     205: invokespecial #96                 // Method Vector2d."<init>":(II)V
     208: aload         22
     210: swap
     211: invokeinterface #100,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     216: pop
     217: goto          132
     220: aload         17
     222: checkcast     #81                 // class java/util/List
     225: nop
     226: checkcast     #41                 // class java/lang/Iterable
     229: invokestatic  #104                // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     232: aload         26
     234: swap
     235: invokeinterface #100,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     240: pop
     241: goto          44
     244: aload         8
     246: checkcast     #81                 // class java/util/List
     249: nop
     250: astore        4
     252: aload         4
     254: checkcast     #41                 // class java/lang/Iterable
     257: invokestatic  #107                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
     260: checkcast     #55                 // class java/util/Collection
     263: invokestatic  #111                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     266: astore        6
     268: aload         6
     270: astore        7
     272: iconst_0
     273: istore        8
     275: aload         7
     277: aload_3
     278: invokeinterface #112,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     283: pop
     284: aload         6
     286: checkcast     #41                 // class java/lang/Iterable
     289: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     294: astore        7
     296: aload         7
     298: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     303: ifne          314
     306: new           #114                // class java/util/NoSuchElementException
     309: dup
     310: invokespecial #116                // Method java/util/NoSuchElementException."<init>":()V
     313: athrow
     314: aload         7
     316: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     321: checkcast     #93                 // class Vector2d
     324: astore        8
     326: iconst_0
     327: istore        9
     329: aload         8
     331: invokevirtual #119                // Method Vector2d.getX:()I
     334: istore        8
     336: aload         7
     338: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     343: ifeq          382
     346: aload         7
     348: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     353: checkcast     #93                 // class Vector2d
     356: astore        9
     358: iconst_0
     359: istore        10
     361: aload         9
     363: invokevirtual #119                // Method Vector2d.getX:()I
     366: istore        9
     368: iload         8
     370: iload         9
     372: if_icmple     336
     375: iload         9
     377: istore        8
     379: goto          336
     382: iload         8
     384: istore        5
     386: aload         4
     388: checkcast     #41                 // class java/lang/Iterable
     391: invokestatic  #107                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
     394: checkcast     #55                 // class java/util/Collection
     397: invokestatic  #111                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     400: astore        7
     402: aload         7
     404: astore        8
     406: iconst_0
     407: istore        9
     409: aload         8
     411: aload_3
     412: invokeinterface #112,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     417: pop
     418: aload         7
     420: checkcast     #41                 // class java/lang/Iterable
     423: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     428: astore        8
     430: aload         8
     432: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     437: ifne          448
     440: new           #114                // class java/util/NoSuchElementException
     443: dup
     444: invokespecial #116                // Method java/util/NoSuchElementException."<init>":()V
     447: athrow
     448: aload         8
     450: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     455: checkcast     #93                 // class Vector2d
     458: astore        9
     460: iconst_0
     461: istore        10
     463: aload         9
     465: invokevirtual #122                // Method Vector2d.getY:()I
     468: istore        9
     470: aload         8
     472: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     477: ifeq          516
     480: aload         8
     482: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     487: checkcast     #93                 // class Vector2d
     490: astore        10
     492: iconst_0
     493: istore        11
     495: aload         10
     497: invokevirtual #122                // Method Vector2d.getY:()I
     500: istore        10
     502: iload         9
     504: iload         10
     506: if_icmple     470
     509: iload         10
     511: istore        9
     513: goto          470
     516: iload         9
     518: istore        6
     520: aload         4
     522: checkcast     #41                 // class java/lang/Iterable
     525: invokestatic  #107                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
     528: checkcast     #55                 // class java/util/Collection
     531: invokestatic  #111                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     534: astore        8
     536: aload         8
     538: astore        9
     540: iconst_0
     541: istore        10
     543: aload         9
     545: aload_3
     546: invokeinterface #112,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     551: pop
     552: aload         8
     554: checkcast     #41                 // class java/lang/Iterable
     557: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     562: astore        9
     564: aload         9
     566: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     571: ifne          582
     574: new           #114                // class java/util/NoSuchElementException
     577: dup
     578: invokespecial #116                // Method java/util/NoSuchElementException."<init>":()V
     581: athrow
     582: aload         9
     584: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     589: checkcast     #93                 // class Vector2d
     592: astore        10
     594: iconst_0
     595: istore        11
     597: aload         10
     599: invokevirtual #119                // Method Vector2d.getX:()I
     602: istore        10
     604: aload         9
     606: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     611: ifeq          650
     614: aload         9
     616: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     621: checkcast     #93                 // class Vector2d
     624: astore        11
     626: iconst_0
     627: istore        12
     629: aload         11
     631: invokevirtual #119                // Method Vector2d.getX:()I
     634: istore        11
     636: iload         10
     638: iload         11
     640: if_icmpge     604
     643: iload         11
     645: istore        10
     647: goto          604
     650: iload         10
     652: istore        7
     654: aload         4
     656: checkcast     #41                 // class java/lang/Iterable
     659: invokestatic  #107                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
     662: checkcast     #55                 // class java/util/Collection
     665: invokestatic  #111                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     668: astore        9
     670: aload         9
     672: astore        10
     674: iconst_0
     675: istore        11
     677: aload         10
     679: aload_3
     680: invokeinterface #112,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     685: pop
     686: aload         9
     688: checkcast     #41                 // class java/lang/Iterable
     691: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     696: astore        10
     698: aload         10
     700: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     705: ifne          716
     708: new           #114                // class java/util/NoSuchElementException
     711: dup
     712: invokespecial #116                // Method java/util/NoSuchElementException."<init>":()V
     715: athrow
     716: aload         10
     718: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     723: checkcast     #93                 // class Vector2d
     726: astore        11
     728: iconst_0
     729: istore        12
     731: aload         11
     733: invokevirtual #122                // Method Vector2d.getY:()I
     736: istore        11
     738: aload         10
     740: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     745: ifeq          784
     748: aload         10
     750: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     755: checkcast     #93                 // class Vector2d
     758: astore        12
     760: iconst_0
     761: istore        13
     763: aload         12
     765: invokevirtual #122                // Method Vector2d.getY:()I
     768: istore        12
     770: iload         11
     772: iload         12
     774: if_icmpge     738
     777: iload         12
     779: istore        11
     781: goto          738
     784: iload         11
     786: istore        8
     788: new           #124                // class java/util/LinkedHashSet
     791: dup
     792: invokespecial #125                // Method java/util/LinkedHashSet."<init>":()V
     795: checkcast     #127                // class java/util/Set
     798: astore        9
     800: aload         4
     802: invokeinterface #128,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     807: astore        10
     809: aload         10
     811: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     816: ifeq          940
     819: aload         10
     821: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     826: checkcast     #81                 // class java/util/List
     829: astore        11
     831: iconst_0
     832: istore        12
     834: aload         11
     836: invokeinterface #131,  1          // InterfaceMethod java/util/List.size:()I
     841: iconst_1
     842: isub
     843: istore        13
     845: iload         12
     847: iload         13
     849: if_icmpge     809
     852: aload         11
     854: iload         12
     856: invokeinterface #85,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     861: checkcast     #93                 // class Vector2d
     864: astore        14
     866: aload         11
     868: iload         12
     870: iconst_1
     871: iadd
     872: invokeinterface #85,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     877: checkcast     #93                 // class Vector2d
     880: astore        15
     882: aload         15
     884: aload         14
     886: invokevirtual #135                // Method Vector2d.minus:(LVector2d;)LVector2d;
     889: invokevirtual #139                // Method Vector2d.normalized:()LVector2d;
     892: astore        16
     894: aload         14
     896: aload         15
     898: aload         16
     900: invokevirtual #142                // Method Vector2d.plus:(LVector2d;)LVector2d;
     903: invokestatic  #148                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     906: ifne          934
     909: aload         9
     911: checkcast     #55                 // class java/util/Collection
     914: aload         14
     916: invokeinterface #100,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     921: pop
     922: aload         14
     924: aload         16
     926: invokevirtual #142                // Method Vector2d.plus:(LVector2d;)LVector2d;
     929: astore        14
     931: goto          894
     934: iinc          12, 1
     937: goto          845
     940: iconst_0
     941: istore        10
     943: nop
     944: aload_3
     945: astore        11
     947: nop
     948: nop
     949: iload_1
     950: ifeq          984
     953: aload         11
     955: invokevirtual #122                // Method Vector2d.getY:()I
     958: iload         8
     960: iconst_1
     961: iadd
     962: if_icmpne     984
     965: aload         9
     967: checkcast     #55                 // class java/util/Collection
     970: aload         11
     972: invokeinterface #100,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     977: pop
     978: iinc          10, 1
     981: goto          943
     984: iload_1
     985: ifne          1057
     988: aload         11
     990: invokevirtual #119                // Method Vector2d.getX:()I
     993: istore        12
     995: iload         5
     997: iload         12
     999: if_icmpgt     1017
    1002: iload         12
    1004: iload         7
    1006: if_icmpgt     1013
    1009: iconst_1
    1010: goto          1018
    1013: iconst_0
    1014: goto          1018
    1017: iconst_0
    1018: ifeq          1054
    1021: aload         11
    1023: invokevirtual #122                // Method Vector2d.getY:()I
    1026: istore        12
    1028: iload         6
    1030: iload         12
    1032: if_icmpgt     1050
    1035: iload         12
    1037: iload         8
    1039: if_icmpgt     1046
    1042: iconst_1
    1043: goto          1051
    1046: iconst_0
    1047: goto          1051
    1050: iconst_0
    1051: ifne          1057
    1054: iload         10
    1056: ireturn
    1057: aload         9
    1059: aload         11
    1061: getstatic     #152                // Field Vector2d.Companion:LVector2d$Companion;
    1064: invokevirtual #157                // Method Vector2d$Companion.getDOWN:()LVector2d;
    1067: invokevirtual #142                // Method Vector2d.plus:(LVector2d;)LVector2d;
    1070: invokeinterface #160,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
    1075: ifne          1094
    1078: aload         11
    1080: getstatic     #152                // Field Vector2d.Companion:LVector2d$Companion;
    1083: invokevirtual #157                // Method Vector2d$Companion.getDOWN:()LVector2d;
    1086: invokevirtual #142                // Method Vector2d.plus:(LVector2d;)LVector2d;
    1089: astore        11
    1091: goto          947
    1094: aload         9
    1096: aload         11
    1098: getstatic     #152                // Field Vector2d.Companion:LVector2d$Companion;
    1101: invokevirtual #157                // Method Vector2d$Companion.getDOWN:()LVector2d;
    1104: invokevirtual #142                // Method Vector2d.plus:(LVector2d;)LVector2d;
    1107: getstatic     #152                // Field Vector2d.Companion:LVector2d$Companion;
    1110: invokevirtual #163                // Method Vector2d$Companion.getLEFT:()LVector2d;
    1113: invokevirtual #142                // Method Vector2d.plus:(LVector2d;)LVector2d;
    1116: invokeinterface #160,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
    1121: ifne          1149
    1124: aload         11
    1126: getstatic     #152                // Field Vector2d.Companion:LVector2d$Companion;
    1129: invokevirtual #157                // Method Vector2d$Companion.getDOWN:()LVector2d;
    1132: getstatic     #152                // Field Vector2d.Companion:LVector2d$Companion;
    1135: invokevirtual #163                // Method Vector2d$Companion.getLEFT:()LVector2d;
    1138: invokevirtual #142                // Method Vector2d.plus:(LVector2d;)LVector2d;
    1141: invokevirtual #142                // Method Vector2d.plus:(LVector2d;)LVector2d;
    1144: astore        11
    1146: goto          947
    1149: aload         9
    1151: aload         11
    1153: getstatic     #152                // Field Vector2d.Companion:LVector2d$Companion;
    1156: invokevirtual #157                // Method Vector2d$Companion.getDOWN:()LVector2d;
    1159: invokevirtual #142                // Method Vector2d.plus:(LVector2d;)LVector2d;
    1162: getstatic     #152                // Field Vector2d.Companion:LVector2d$Companion;
    1165: invokevirtual #166                // Method Vector2d$Companion.getRIGHT:()LVector2d;
    1168: invokevirtual #142                // Method Vector2d.plus:(LVector2d;)LVector2d;
    1171: invokeinterface #160,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
    1176: ifne          1204
    1179: aload         11
    1181: getstatic     #152                // Field Vector2d.Companion:LVector2d$Companion;
    1184: invokevirtual #157                // Method Vector2d$Companion.getDOWN:()LVector2d;
    1187: getstatic     #152                // Field Vector2d.Companion:LVector2d$Companion;
    1190: invokevirtual #166                // Method Vector2d$Companion.getRIGHT:()LVector2d;
    1193: invokevirtual #142                // Method Vector2d.plus:(LVector2d;)LVector2d;
    1196: invokevirtual #142                // Method Vector2d.plus:(LVector2d;)LVector2d;
    1199: astore        11
    1201: goto          947
    1204: aload         9
    1206: checkcast     #55                 // class java/util/Collection
    1209: aload         11
    1211: invokeinterface #100,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
    1216: pop
    1217: iinc          10, 1
    1220: iload_2
    1221: ifeq          1236
    1224: aload         11
    1226: aload_3
    1227: invokestatic  #148                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
    1230: ifeq          1236
    1233: iload         10
    1235: ireturn
    1236: goto          943

  static int main$fallingSand$default(java.util.List, boolean, boolean, Vector2d, int, java.lang.Object);
    Code:
       0: iload         4
       2: bipush        8
       4: iand
       5: ifeq          20
       8: new           #93                 // class Vector2d
      11: dup
      12: sipush        500
      15: iconst_0
      16: invokespecial #96                 // Method Vector2d."<init>":(II)V
      19: astore_3
      20: aload_0
      21: iload_1
      22: iload_2
      23: aload_3
      24: invokestatic  #214                // Method main$fallingSand:(Ljava/util/List;ZZLVector2d;)I
      27: ireturn

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: iconst_0
       2: iconst_0
       3: aconst_null
       4: bipush        8
       6: aconst_null
       7: invokestatic  #219                // Method main$fallingSand$default:(Ljava/util/List;ZZLVector2d;ILjava/lang/Object;)I
      10: ireturn

  private static final int main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: iconst_1
       2: iconst_1
       3: aconst_null
       4: bipush        8
       6: aconst_null
       7: invokestatic  #219                // Method main$fallingSand$default:(Ljava/util/List;ZZLVector2d;ILjava/lang/Object;)I
      10: ireturn

  public static final int access$main$part1(java.util.List);
    Code:
       0: aload_0
       1: invokestatic  #223                // Method main$part1:(Ljava/util/List;)I
       4: ireturn

  public static final int access$main$part2(java.util.List);
    Code:
       0: aload_0
       1: invokestatic  #226                // Method main$part2:(Ljava/util/List;)I
       4: ireturn
}

Compiled from "Day14.kt"
final class Day14Kt$main$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.util.List<? extends java.lang.String>, java.lang.Integer> {
  public static final Day14Kt$main$1 INSTANCE;

  Day14Kt$main$1();
    Code:
       0: aload_0
       1: iconst_1
       2: ldc           #11                 // class kotlin/jvm/internal/Intrinsics$Kotlin
       4: ldc           #13                 // String part1
       6: ldc           #15                 // String main$part1(Ljava/util/List;)I
       8: iconst_0
       9: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final java.lang.Integer invoke(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #25                 // String p0
       3: invokestatic  #31                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokestatic  #37                 // Method Day14Kt.access$main$part1:(Ljava/util/List;)I
      10: invokestatic  #43                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      13: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #47                 // class java/util/List
       5: invokevirtual #49                 // Method invoke:(Ljava/util/List;)Ljava/lang/Integer;
       8: areturn

  static {};
    Code:
       0: new           #2                  // class Day14Kt$main$1
       3: dup
       4: invokespecial #54                 // Method "<init>":()V
       7: putstatic     #57                 // Field INSTANCE:LDay14Kt$main$1;
      10: return
}

Compiled from "Day14.kt"
final class Day14Kt$main$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.util.List<? extends java.lang.String>, java.lang.Integer> {
  public static final Day14Kt$main$2 INSTANCE;

  Day14Kt$main$2();
    Code:
       0: aload_0
       1: iconst_1
       2: ldc           #11                 // class kotlin/jvm/internal/Intrinsics$Kotlin
       4: ldc           #13                 // String part2
       6: ldc           #15                 // String main$part2(Ljava/util/List;)I
       8: iconst_0
       9: invokespecial #18                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final java.lang.Integer invoke(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #25                 // String p0
       3: invokestatic  #31                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokestatic  #37                 // Method Day14Kt.access$main$part2:(Ljava/util/List;)I
      10: invokestatic  #43                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      13: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #47                 // class java/util/List
       5: invokevirtual #49                 // Method invoke:(Ljava/util/List;)Ljava/lang/Integer;
       8: areturn

  static {};
    Code:
       0: new           #2                  // class Day14Kt$main$2
       3: dup
       4: invokespecial #54                 // Method "<init>":()V
       7: putstatic     #57                 // Field INSTANCE:LDay14Kt$main$2;
      10: return
}