package day7

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

fun parseInput(input: String) = input.split(",").groupingBy(String::toInt).eachCount()

private fun minFuelSpentToAlignedPosition(data: Map<Int, Int>, costFn: (Int, Int) -> Int): Int {
  val min = data.keys.minOf { it }
  val max = data.keys.maxOf { it }

  return (min..max)
    .map { destination -> data.map { (currentPosition, crabs) -> costFn(destination, currentPosition) * crabs } }
    .minOf { it.sum() }
}

fun minFuelSpentToAlignedPosition(data: Map<Int, Int>): Int =
  minFuelSpentToAlignedPosition(data){ destination, currentPosition -> abs(destination - currentPosition)}

fun minFuelSpentToAlignedPositionPart2(data: Map<Int, Int>): Int =
  minFuelSpentToAlignedPosition(data){ destination: Int, currentPosition: Int ->
    val steps = abs(currentPosition - destination)
    ((steps * (steps + 1)) / 2)
  }

fun main() {
  File("./input/day7.txt").useLines { lines ->
    val crabsMap = parseInput(lines.first())
    println("First part: ${minFuelSpentToAlignedPosition(crabsMap)}")
    println("Second part: ${minFuelSpentToAlignedPositionPart2(crabsMap)}")
  }
}

Compiled from "_Collections.kt"
public final class day7.Day7Kt$parseInput$$inlined$groupingBy$1 implements kotlin.collections.Grouping<java.lang.String, java.lang.Integer> {
  final java.lang.Iterable $this_groupingBy;

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

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

  public java.lang.Integer keyOf(java.lang.String);
    Code:
       0: aload_1
       1: checkcast     #37                 // class java/lang/String
       4: astore_2
       5: iconst_0
       6: istore_3
       7: aload_2
       8: invokestatic  #43                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      11: nop
      12: invokestatic  #47                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      15: areturn
}

Compiled from "Day7.kt"
public final class day7.Day7Kt {
  public static final java.util.Map<java.lang.Integer, java.lang.Integer> parseInput(java.lang.String);
    Code:
       0: aload_0
       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: checkcast     #18                 // class java/lang/CharSequence
      10: iconst_1
      11: anewarray     #20                 // class java/lang/String
      14: astore_1
      15: aload_1
      16: iconst_0
      17: ldc           #22                 // String ,
      19: aastore
      20: aload_1
      21: iconst_0
      22: iconst_0
      23: bipush        6
      25: aconst_null
      26: invokestatic  #28                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      29: checkcast     #30                 // class java/lang/Iterable
      32: astore_1
      33: iconst_0
      34: istore_2
      35: new           #32                 // class day7/Day7Kt$parseInput$$inlined$groupingBy$1
      38: dup
      39: aload_1
      40: invokespecial #36                 // Method day7/Day7Kt$parseInput$$inlined$groupingBy$1."<init>":(Ljava/lang/Iterable;)V
      43: checkcast     #38                 // class kotlin/collections/Grouping
      46: invokestatic  #44                 // Method kotlin/collections/GroupingKt.eachCount:(Lkotlin/collections/Grouping;)Ljava/util/Map;
      49: areturn

  private static final int minFuelSpentToAlignedPosition(java.util.Map<java.lang.Integer, java.lang.Integer>, kotlin.jvm.functions.Function2<? super java.lang.Integer, ? super java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: invokeinterface #58,  1           // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;
       6: checkcast     #30                 // class java/lang/Iterable
       9: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      14: astore        4
      16: aload         4
      18: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      23: ifne          34
      26: new           #70                 // class java/util/NoSuchElementException
      29: dup
      30: invokespecial #73                 // Method java/util/NoSuchElementException."<init>":()V
      33: athrow
      34: aload         4
      36: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      41: checkcast     #79                 // class java/lang/Number
      44: invokevirtual #83                 // Method java/lang/Number.intValue:()I
      47: istore        5
      49: iconst_0
      50: istore        6
      52: iload         5
      54: istore        5
      56: aload         4
      58: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      63: ifeq          102
      66: aload         4
      68: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      73: checkcast     #79                 // class java/lang/Number
      76: invokevirtual #83                 // Method java/lang/Number.intValue:()I
      79: istore        6
      81: iconst_0
      82: istore        7
      84: iload         6
      86: istore        6
      88: iload         5
      90: iload         6
      92: if_icmple     56
      95: iload         6
      97: istore        5
      99: goto          56
     102: iload         5
     104: istore_2
     105: aload_0
     106: invokeinterface #58,  1           // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;
     111: checkcast     #30                 // class java/lang/Iterable
     114: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     119: astore        5
     121: aload         5
     123: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     128: ifne          139
     131: new           #70                 // class java/util/NoSuchElementException
     134: dup
     135: invokespecial #73                 // Method java/util/NoSuchElementException."<init>":()V
     138: athrow
     139: aload         5
     141: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     146: checkcast     #79                 // class java/lang/Number
     149: invokevirtual #83                 // Method java/lang/Number.intValue:()I
     152: istore        6
     154: iconst_0
     155: istore        7
     157: iload         6
     159: istore        6
     161: aload         5
     163: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     168: ifeq          207
     171: aload         5
     173: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     178: checkcast     #79                 // class java/lang/Number
     181: invokevirtual #83                 // Method java/lang/Number.intValue:()I
     184: istore        7
     186: iconst_0
     187: istore        8
     189: iload         7
     191: istore        7
     193: iload         6
     195: iload         7
     197: if_icmpge     161
     200: iload         7
     202: istore        6
     204: goto          161
     207: iload         6
     209: istore_3
     210: new           #85                 // class kotlin/ranges/IntRange
     213: dup
     214: iload_2
     215: iload_3
     216: invokespecial #88                 // Method kotlin/ranges/IntRange."<init>":(II)V
     219: checkcast     #30                 // class java/lang/Iterable
     222: astore        4
     224: nop
     225: iconst_0
     226: istore        5
     228: aload         4
     230: astore        6
     232: new           #90                 // class java/util/ArrayList
     235: dup
     236: aload         4
     238: bipush        10
     240: invokestatic  #96                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     243: invokespecial #99                 // Method java/util/ArrayList."<init>":(I)V
     246: checkcast     #101                // class java/util/Collection
     249: astore        7
     251: iconst_0
     252: istore        8
     254: aload         6
     256: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     261: astore        9
     263: aload         9
     265: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     270: ifeq          462
     273: aload         9
     275: checkcast     #103                // class kotlin/collections/IntIterator
     278: invokevirtual #106                // Method kotlin/collections/IntIterator.nextInt:()I
     281: istore        10
     283: aload         7
     285: iload         10
     287: istore        11
     289: astore        25
     291: iconst_0
     292: istore        12
     294: aload_0
     295: astore        13
     297: iconst_0
     298: istore        14
     300: aload         13
     302: astore        15
     304: new           #90                 // class java/util/ArrayList
     307: dup
     308: aload         13
     310: invokeinterface #109,  1          // InterfaceMethod java/util/Map.size:()I
     315: invokespecial #99                 // Method java/util/ArrayList."<init>":(I)V
     318: checkcast     #101                // class java/util/Collection
     321: astore        16
     323: iconst_0
     324: istore        17
     326: aload         15
     328: invokeinterface #112,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     333: invokeinterface #115,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     338: astore        18
     340: aload         18
     342: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     347: ifeq          443
     350: aload         18
     352: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     357: checkcast     #117                // class java/util/Map$Entry
     360: astore        19
     362: aload         16
     364: aload         19
     366: astore        20
     368: astore        21
     370: iconst_0
     371: istore        22
     373: aload         20
     375: invokeinterface #120,  1          // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;
     380: checkcast     #79                 // class java/lang/Number
     383: invokevirtual #83                 // Method java/lang/Number.intValue:()I
     386: istore        23
     388: aload         20
     390: invokeinterface #123,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     395: checkcast     #79                 // class java/lang/Number
     398: invokevirtual #83                 // Method java/lang/Number.intValue:()I
     401: istore        24
     403: aload_1
     404: iload         11
     406: invokestatic  #129                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     409: iload         23
     411: invokestatic  #129                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     414: invokeinterface #135,  3          // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
     419: checkcast     #79                 // class java/lang/Number
     422: invokevirtual #83                 // Method java/lang/Number.intValue:()I
     425: iload         24
     427: imul
     428: invokestatic  #129                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     431: aload         21
     433: swap
     434: invokeinterface #139,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     439: pop
     440: goto          340
     443: aload         16
     445: checkcast     #141                // class java/util/List
     448: nop
     449: nop
     450: aload         25
     452: swap
     453: invokeinterface #139,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     458: pop
     459: goto          263
     462: aload         7
     464: checkcast     #141                // class java/util/List
     467: nop
     468: checkcast     #30                 // class java/lang/Iterable
     471: invokeinterface #62,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     476: astore        5
     478: aload         5
     480: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     485: ifne          496
     488: new           #70                 // class java/util/NoSuchElementException
     491: dup
     492: invokespecial #73                 // Method java/util/NoSuchElementException."<init>":()V
     495: athrow
     496: aload         5
     498: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     503: checkcast     #141                // class java/util/List
     506: astore        6
     508: iconst_0
     509: istore        7
     511: aload         6
     513: checkcast     #30                 // class java/lang/Iterable
     516: invokestatic  #145                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     519: istore        6
     521: aload         5
     523: invokeinterface #68,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     528: ifeq          570
     531: aload         5
     533: invokeinterface #77,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     538: checkcast     #141                // class java/util/List
     541: astore        7
     543: iconst_0
     544: istore        8
     546: aload         7
     548: checkcast     #30                 // class java/lang/Iterable
     551: invokestatic  #145                // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I
     554: istore        7
     556: iload         6
     558: iload         7
     560: if_icmple     521
     563: iload         7
     565: istore        6
     567: goto          521
     570: iload         6
     572: ireturn

  public static final int minFuelSpentToAlignedPosition(java.util.Map<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #172                // String data
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokedynamic #190,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;
      12: invokestatic  #192                // Method minFuelSpentToAlignedPosition:(Ljava/util/Map;Lkotlin/jvm/functions/Function2;)I
      15: ireturn

  public static final int minFuelSpentToAlignedPositionPart2(java.util.Map<java.lang.Integer, java.lang.Integer>);
    Code:
       0: aload_0
       1: ldc           #172                // String data
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokedynamic #198,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function2;
      12: invokestatic  #192                // Method minFuelSpentToAlignedPosition:(Ljava/util/Map;Lkotlin/jvm/functions/Function2;)I
      15: ireturn

  public static final void main();
    Code:
       0: new           #203                // class java/io/File
       3: dup
       4: ldc           #205                // String ./input/day7.txt
       6: invokespecial #208                // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: astore_0
      10: getstatic     #214                // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      13: astore_1
      14: iconst_0
      15: istore_2
      16: aload_0
      17: astore_3
      18: sipush        8192
      21: istore        4
      23: aload_3
      24: astore        5
      26: new           #216                // class java/io/InputStreamReader
      29: dup
      30: new           #218                // class java/io/FileInputStream
      33: dup
      34: aload         5
      36: invokespecial #221                // Method java/io/FileInputStream."<init>":(Ljava/io/File;)V
      39: checkcast     #223                // class java/io/InputStream
      42: aload_1
      43: invokespecial #226                // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V
      46: checkcast     #228                // class java/io/Reader
      49: astore        5
      51: aload         5
      53: instanceof    #230                // class java/io/BufferedReader
      56: ifeq          67
      59: aload         5
      61: checkcast     #230                // class java/io/BufferedReader
      64: goto          78
      67: new           #230                // class java/io/BufferedReader
      70: dup
      71: aload         5
      73: iload         4
      75: invokespecial #233                // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
      78: checkcast     #235                // class java/io/Closeable
      81: astore_3
      82: aconst_null
      83: astore        4
      85: nop
      86: aload_3
      87: checkcast     #230                // class java/io/BufferedReader
      90: astore        5
      92: iconst_0
      93: istore        6
      95: aload         5
      97: invokestatic  #241                // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;
     100: astore        7
     102: iconst_0
     103: istore        8
     105: aload         7
     107: invokestatic  #247                // Method kotlin/sequences/SequencesKt.first:(Lkotlin/sequences/Sequence;)Ljava/lang/Object;
     110: checkcast     #20                 // class java/lang/String
     113: invokestatic  #249                // Method parseInput:(Ljava/lang/String;)Ljava/util/Map;
     116: astore        9
     118: new           #251                // class java/lang/StringBuilder
     121: dup
     122: invokespecial #252                // Method java/lang/StringBuilder."<init>":()V
     125: ldc           #254                // String First part:
     127: invokevirtual #258                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     130: aload         9
     132: invokestatic  #260                // Method minFuelSpentToAlignedPosition:(Ljava/util/Map;)I
     135: invokevirtual #263                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     138: invokevirtual #267                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     141: getstatic     #273                // Field java/lang/System.out:Ljava/io/PrintStream;
     144: swap
     145: invokevirtual #279                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     148: new           #251                // class java/lang/StringBuilder
     151: dup
     152: invokespecial #252                // Method java/lang/StringBuilder."<init>":()V
     155: ldc_w         #281                // String Second part:
     158: invokevirtual #258                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     161: aload         9
     163: invokestatic  #283                // Method minFuelSpentToAlignedPositionPart2:(Ljava/util/Map;)I
     166: invokevirtual #263                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     169: invokevirtual #267                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     172: getstatic     #273                // Field java/lang/System.out:Ljava/io/PrintStream;
     175: swap
     176: invokevirtual #279                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     179: nop
     180: getstatic     #289                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     183: astore        5
     185: aload_3
     186: aload         4
     188: invokestatic  #295                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     191: goto          214
     194: astore        6
     196: aload         6
     198: astore        4
     200: aload         6
     202: athrow
     203: astore        6
     205: aload_3
     206: aload         4
     208: invokestatic  #295                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     211: aload         6
     213: athrow
     214: nop
     215: return
    Exception table:
       from    to  target type
          85   185   194   Class java/lang/Throwable
          85   185   203   any
         194   203   203   any
         203   205   203   any

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

  private static final int minFuelSpentToAlignedPosition$lambda$5(int, int);
    Code:
       0: iload_0
       1: iload_1
       2: isub
       3: invokestatic  #321                // Method java/lang/Math.abs:(I)I
       6: ireturn

  private static final int minFuelSpentToAlignedPositionPart2$lambda$6(int, int);
    Code:
       0: iload_1
       1: iload_0
       2: isub
       3: invokestatic  #321                // Method java/lang/Math.abs:(I)I
       6: istore_2
       7: iload_2
       8: iload_2
       9: iconst_1
      10: iadd
      11: imul
      12: iconst_2
      13: idiv
      14: ireturn
}


package day9

import java.io.File

fun parseMap(rows: List<String>): Array<IntArray> =
  rows.map { row -> row.trim().map { it - '0' }.toIntArray() }.toTypedArray()

fun expandAdjacent(row: Int, column: Int, map: Array<IntArray>): List<Pair<Int, Int>> =
  listOf(0 to -1, -1 to 0, 0 to 1, 1 to 0)
    .map { (r, c) -> (r + row) to (c + column) }
    .filterNot { (r, c) -> r < 0 || c < 0 || r >= map.size || c >= map[0].size }

fun findLocalMinimums(map: Array<IntArray>): List<Pair<Int, Int>> {
  fun isLocalMinimum(row: Int, column: Int): Boolean {
    val adjacent = expandAdjacent(row, column, map)
    val current = map[row][column]
    return adjacent.all { (r, c) -> map[r][c] > current }
  }

  val rows = map.indices
  val columns = map[0].indices

  val traverseMapIndices = rows.flatMap { r -> columns.map { c -> r to c } }
  return traverseMapIndices.filter { (r, c) -> isLocalMinimum(r, c) }
}

fun sumOfLocalMinimums(map: Array<IntArray>): Int =
  findLocalMinimums(map).sumOf { (r, c) -> map[r][c] + 1 }

fun computeBasinSize(row: Int, column: Int, map: Array<IntArray>): Int {
  val visited = mutableSetOf<Pair<Int, Int>>()
  val remaining = ArrayDeque(listOf(row to column))
  var size = 0
  do {
    val current = remaining.removeFirst()
    val currentValue = map[current.first][current.second]
    if (currentValue == 9 || visited.contains(current)) continue

    val nonVisitedAdjacent = expandAdjacent(current.first, current.second, map).filterNot { visited.contains(it) }
    val belongsToBasin = nonVisitedAdjacent.all { (r, c) -> map[r][c] >= currentValue }
    if (belongsToBasin) {
      size += 1
      visited.add(current)
      remaining.addAll(nonVisitedAdjacent)
    }
  } while (!remaining.isEmpty())
  return size
}

fun productOfSizeThreeLargestBasins(map: Array<IntArray>): Int =
  findLocalMinimums(map)
    .map { (r, c) -> computeBasinSize(r, c, map) }
    .sorted()
    .takeLast(3)
    .reduce(Int::times)

fun main() {
  File("./input/day9.txt").useLines { lines ->
    val map = parseMap(lines.toList())
    println(findLocalMinimums(map))
    println(productOfSizeThreeLargestBasins(map))
  }
}

Compiled from "Day9.kt"
public final class day9.Day9Kt {
  public static final int[][] parseMap(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #10                 // String rows
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #18                 // class java/lang/Iterable
      10: astore_1
      11: iconst_0
      12: istore_2
      13: aload_1
      14: astore_3
      15: new           #20                 // class java/util/ArrayList
      18: dup
      19: aload_1
      20: bipush        10
      22: invokestatic  #26                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      25: invokespecial #30                 // Method java/util/ArrayList."<init>":(I)V
      28: checkcast     #32                 // class java/util/Collection
      31: astore        4
      33: iconst_0
      34: istore        5
      36: aload_3
      37: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        6
      44: aload         6
      46: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          207
      54: aload         6
      56: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        7
      63: aload         4
      65: aload         7
      67: checkcast     #48                 // class java/lang/String
      70: astore        8
      72: astore        20
      74: iconst_0
      75: istore        9
      77: aload         8
      79: checkcast     #50                 // class java/lang/CharSequence
      82: invokestatic  #56                 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;
      85: invokevirtual #60                 // Method java/lang/Object.toString:()Ljava/lang/String;
      88: checkcast     #50                 // class java/lang/CharSequence
      91: astore        10
      93: nop
      94: iconst_0
      95: istore        11
      97: aload         10
      99: astore        12
     101: new           #20                 // class java/util/ArrayList
     104: dup
     105: aload         10
     107: invokeinterface #64,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     112: invokespecial #30                 // Method java/util/ArrayList."<init>":(I)V
     115: checkcast     #32                 // class java/util/Collection
     118: astore        13
     120: iconst_0
     121: istore        14
     123: iconst_0
     124: istore        15
     126: iload         15
     128: aload         12
     130: invokeinterface #64,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     135: if_icmpge     183
     138: aload         12
     140: iload         15
     142: invokeinterface #68,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     147: istore        16
     149: aload         13
     151: iload         16
     153: istore        17
     155: astore        18
     157: iconst_0
     158: istore        19
     160: iload         17
     162: bipush        48
     164: isub
     165: invokestatic  #74                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     168: aload         18
     170: swap
     171: invokeinterface #78,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     176: pop
     177: iinc          15, 1
     180: goto          126
     183: aload         13
     185: checkcast     #80                 // class java/util/List
     188: nop
     189: checkcast     #32                 // class java/util/Collection
     192: invokestatic  #84                 // Method kotlin/collections/CollectionsKt.toIntArray:(Ljava/util/Collection;)[I
     195: aload         20
     197: swap
     198: invokeinterface #78,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     203: pop
     204: goto          44
     207: aload         4
     209: checkcast     #80                 // class java/util/List
     212: nop
     213: checkcast     #32                 // class java/util/Collection
     216: astore_1
     217: nop
     218: iconst_0
     219: istore_2
     220: aload_1
     221: astore_3
     222: aload_3
     223: iconst_0
     224: anewarray     #86                 // class "[I"
     227: invokeinterface #90,  2           // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;
     232: checkcast     #92                 // class "[[I"
     235: areturn

  public static final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> expandAdjacent(int, int, int[][]);
    Code:
       0: aload_2
       1: ldc           #118                // String map
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_4
       7: anewarray     #120                // class kotlin/Pair
      10: astore_3
      11: aload_3
      12: iconst_0
      13: iconst_0
      14: invokestatic  #74                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      17: iconst_m1
      18: invokestatic  #74                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      21: invokestatic  #126                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      24: aastore
      25: aload_3
      26: iconst_1
      27: iconst_m1
      28: invokestatic  #74                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      31: iconst_0
      32: invokestatic  #74                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      35: invokestatic  #126                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      38: aastore
      39: aload_3
      40: iconst_2
      41: iconst_0
      42: invokestatic  #74                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      45: iconst_1
      46: invokestatic  #74                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      49: invokestatic  #126                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      52: aastore
      53: aload_3
      54: iconst_3
      55: iconst_1
      56: invokestatic  #74                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      59: iconst_0
      60: invokestatic  #74                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      63: invokestatic  #126                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      66: aastore
      67: aload_3
      68: invokestatic  #130                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      71: checkcast     #18                 // class java/lang/Iterable
      74: astore_3
      75: nop
      76: iconst_0
      77: istore        4
      79: aload_3
      80: astore        5
      82: new           #20                 // class java/util/ArrayList
      85: dup
      86: aload_3
      87: bipush        10
      89: invokestatic  #26                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      92: invokespecial #30                 // Method java/util/ArrayList."<init>":(I)V
      95: checkcast     #32                 // class java/util/Collection
      98: astore        6
     100: iconst_0
     101: istore        7
     103: aload         5
     105: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     110: astore        8
     112: aload         8
     114: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     119: ifeq          200
     122: aload         8
     124: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     129: astore        9
     131: aload         6
     133: aload         9
     135: checkcast     #120                // class kotlin/Pair
     138: astore        10
     140: astore        14
     142: iconst_0
     143: istore        11
     145: aload         10
     147: invokevirtual #133                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     150: checkcast     #135                // class java/lang/Number
     153: invokevirtual #138                // Method java/lang/Number.intValue:()I
     156: istore        12
     158: aload         10
     160: invokevirtual #141                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     163: checkcast     #135                // class java/lang/Number
     166: invokevirtual #138                // Method java/lang/Number.intValue:()I
     169: istore        13
     171: iload         12
     173: iload_0
     174: iadd
     175: invokestatic  #74                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     178: iload         13
     180: iload_1
     181: iadd
     182: invokestatic  #74                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     185: invokestatic  #126                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     188: aload         14
     190: swap
     191: invokeinterface #78,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     196: pop
     197: goto          112
     200: aload         6
     202: checkcast     #80                 // class java/util/List
     205: nop
     206: checkcast     #18                 // class java/lang/Iterable
     209: astore_3
     210: nop
     211: iconst_0
     212: istore        4
     214: aload_3
     215: astore        5
     217: new           #20                 // class java/util/ArrayList
     220: dup
     221: invokespecial #144                // Method java/util/ArrayList."<init>":()V
     224: checkcast     #32                 // class java/util/Collection
     227: astore        6
     229: iconst_0
     230: istore        7
     232: aload         5
     234: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     239: astore        8
     241: aload         8
     243: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     248: ifeq          346
     251: aload         8
     253: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     258: astore        9
     260: aload         9
     262: checkcast     #120                // class kotlin/Pair
     265: astore        10
     267: iconst_0
     268: istore        11
     270: aload         10
     272: invokevirtual #133                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     275: checkcast     #135                // class java/lang/Number
     278: invokevirtual #138                // Method java/lang/Number.intValue:()I
     281: istore        12
     283: aload         10
     285: invokevirtual #141                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     288: checkcast     #135                // class java/lang/Number
     291: invokevirtual #138                // Method java/lang/Number.intValue:()I
     294: istore        13
     296: iload         12
     298: iflt          325
     301: iload         13
     303: iflt          325
     306: iload         12
     308: aload_2
     309: checkcast     #146                // class "[Ljava/lang/Object;"
     312: arraylength
     313: if_icmpge     325
     316: iload         13
     318: aload_2
     319: iconst_0
     320: aaload
     321: arraylength
     322: if_icmplt     329
     325: iconst_1
     326: goto          330
     329: iconst_0
     330: ifne          241
     333: aload         6
     335: aload         9
     337: invokeinterface #78,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     342: pop
     343: goto          241
     346: aload         6
     348: checkcast     #80                 // class java/util/List
     351: nop
     352: areturn

  public static final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> findLocalMinimums(int[][]);
    Code:
       0: aload_0
       1: ldc           #118                // String map
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: checkcast     #146                // class "[Ljava/lang/Object;"
      10: invokestatic  #165                // Method kotlin/collections/ArraysKt.getIndices:([Ljava/lang/Object;)Lkotlin/ranges/IntRange;
      13: astore_1
      14: aload_0
      15: iconst_0
      16: aaload
      17: invokestatic  #168                // Method kotlin/collections/ArraysKt.getIndices:([I)Lkotlin/ranges/IntRange;
      20: astore_2
      21: aload_1
      22: checkcast     #18                 // class java/lang/Iterable
      25: astore        4
      27: iconst_0
      28: istore        5
      30: aload         4
      32: astore        6
      34: new           #20                 // class java/util/ArrayList
      37: dup
      38: invokespecial #144                // Method java/util/ArrayList."<init>":()V
      41: checkcast     #32                 // class java/util/Collection
      44: astore        7
      46: iconst_0
      47: istore        8
      49: aload         6
      51: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      56: astore        9
      58: aload         9
      60: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      65: ifeq          208
      68: aload         9
      70: checkcast     #170                // class kotlin/collections/IntIterator
      73: invokevirtual #173                // Method kotlin/collections/IntIterator.nextInt:()I
      76: istore        10
      78: iload         10
      80: istore        11
      82: iconst_0
      83: istore        12
      85: aload_2
      86: checkcast     #18                 // class java/lang/Iterable
      89: astore        13
      91: iconst_0
      92: istore        14
      94: aload         13
      96: astore        15
      98: new           #20                 // class java/util/ArrayList
     101: dup
     102: aload         13
     104: bipush        10
     106: invokestatic  #26                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     109: invokespecial #30                 // Method java/util/ArrayList."<init>":(I)V
     112: checkcast     #32                 // class java/util/Collection
     115: astore        16
     117: iconst_0
     118: istore        17
     120: aload         15
     122: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     127: astore        18
     129: aload         18
     131: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     136: ifeq          185
     139: aload         18
     141: checkcast     #170                // class kotlin/collections/IntIterator
     144: invokevirtual #173                // Method kotlin/collections/IntIterator.nextInt:()I
     147: istore        19
     149: aload         16
     151: iload         19
     153: istore        20
     155: astore        21
     157: iconst_0
     158: istore        22
     160: iload         11
     162: invokestatic  #74                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     165: iload         20
     167: invokestatic  #74                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     170: invokestatic  #126                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     173: aload         21
     175: swap
     176: invokeinterface #78,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     181: pop
     182: goto          129
     185: aload         16
     187: checkcast     #80                 // class java/util/List
     190: nop
     191: checkcast     #18                 // class java/lang/Iterable
     194: nop
     195: astore        11
     197: aload         7
     199: aload         11
     201: invokestatic  #177                // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z
     204: pop
     205: goto          58
     208: aload         7
     210: checkcast     #80                 // class java/util/List
     213: nop
     214: astore_3
     215: aload_3
     216: checkcast     #18                 // class java/lang/Iterable
     219: astore        4
     221: iconst_0
     222: istore        5
     224: aload         4
     226: astore        6
     228: new           #20                 // class java/util/ArrayList
     231: dup
     232: invokespecial #144                // Method java/util/ArrayList."<init>":()V
     235: checkcast     #32                 // class java/util/Collection
     238: astore        7
     240: iconst_0
     241: istore        8
     243: aload         6
     245: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     250: astore        9
     252: aload         9
     254: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     259: ifeq          331
     262: aload         9
     264: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     269: astore        10
     271: aload         10
     273: checkcast     #120                // class kotlin/Pair
     276: astore        11
     278: iconst_0
     279: istore        12
     281: aload         11
     283: invokevirtual #133                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     286: checkcast     #135                // class java/lang/Number
     289: invokevirtual #138                // Method java/lang/Number.intValue:()I
     292: istore        13
     294: aload         11
     296: invokevirtual #141                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     299: checkcast     #135                // class java/lang/Number
     302: invokevirtual #138                // Method java/lang/Number.intValue:()I
     305: istore        14
     307: aload_0
     308: iload         13
     310: iload         14
     312: invokestatic  #181                // Method findLocalMinimums$isLocalMinimum:([[III)Z
     315: ifeq          252
     318: aload         7
     320: aload         10
     322: invokeinterface #78,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     327: pop
     328: goto          252
     331: aload         7
     333: checkcast     #80                 // class java/util/List
     336: nop
     337: areturn

  public static final int sumOfLocalMinimums(int[][]);
    Code:
       0: aload_0
       1: ldc           #118                // String map
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #202                // Method findLocalMinimums:([[I)Ljava/util/List;
      10: checkcast     #18                 // class java/lang/Iterable
      13: astore_1
      14: iconst_0
      15: istore_2
      16: aload_1
      17: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      22: astore_3
      23: aload_3
      24: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      29: ifeq          99
      32: aload_3
      33: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      38: astore        4
      40: iload_2
      41: aload         4
      43: checkcast     #120                // class kotlin/Pair
      46: astore        5
      48: istore        9
      50: iconst_0
      51: istore        6
      53: aload         5
      55: invokevirtual #133                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      58: checkcast     #135                // class java/lang/Number
      61: invokevirtual #138                // Method java/lang/Number.intValue:()I
      64: istore        7
      66: aload         5
      68: invokevirtual #141                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      71: checkcast     #135                // class java/lang/Number
      74: invokevirtual #138                // Method java/lang/Number.intValue:()I
      77: istore        8
      79: aload_0
      80: iload         7
      82: aaload
      83: iload         8
      85: iaload
      86: iconst_1
      87: iadd
      88: istore        10
      90: iload         9
      92: iload         10
      94: iadd
      95: istore_2
      96: goto          23
      99: iload_2
     100: ireturn

  public static final int computeBasinSize(int, int, int[][]);
    Code:
       0: aload_2
       1: ldc           #118                // String map
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #207                // class java/util/LinkedHashSet
       9: dup
      10: invokespecial #208                // Method java/util/LinkedHashSet."<init>":()V
      13: checkcast     #210                // class java/util/Set
      16: astore_3
      17: new           #212                // class kotlin/collections/ArrayDeque
      20: dup
      21: iload_0
      22: invokestatic  #74                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      25: iload_1
      26: invokestatic  #74                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      29: invokestatic  #126                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      32: invokestatic  #215                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      35: checkcast     #32                 // class java/util/Collection
      38: invokespecial #218                // Method kotlin/collections/ArrayDeque."<init>":(Ljava/util/Collection;)V
      41: astore        4
      43: iconst_0
      44: istore        5
      46: aload         4
      48: invokevirtual #221                // Method kotlin/collections/ArrayDeque.removeFirst:()Ljava/lang/Object;
      51: checkcast     #120                // class kotlin/Pair
      54: astore        6
      56: aload_2
      57: aload         6
      59: invokevirtual #224                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      62: checkcast     #135                // class java/lang/Number
      65: invokevirtual #138                // Method java/lang/Number.intValue:()I
      68: aaload
      69: aload         6
      71: invokevirtual #227                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      74: checkcast     #135                // class java/lang/Number
      77: invokevirtual #138                // Method java/lang/Number.intValue:()I
      80: iaload
      81: istore        7
      83: iload         7
      85: bipush        9
      87: if_icmpeq     381
      90: aload_3
      91: aload         6
      93: invokeinterface #230,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
      98: ifeq          104
     101: goto          381
     104: aload         6
     106: invokevirtual #224                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     109: checkcast     #135                // class java/lang/Number
     112: invokevirtual #138                // Method java/lang/Number.intValue:()I
     115: aload         6
     117: invokevirtual #227                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     120: checkcast     #135                // class java/lang/Number
     123: invokevirtual #138                // Method java/lang/Number.intValue:()I
     126: aload_2
     127: invokestatic  #232                // Method expandAdjacent:(II[[I)Ljava/util/List;
     130: checkcast     #18                 // class java/lang/Iterable
     133: astore        9
     135: iconst_0
     136: istore        10
     138: aload         9
     140: astore        11
     142: new           #20                 // class java/util/ArrayList
     145: dup
     146: invokespecial #144                // Method java/util/ArrayList."<init>":()V
     149: checkcast     #32                 // class java/util/Collection
     152: astore        12
     154: iconst_0
     155: istore        13
     157: aload         11
     159: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     164: astore        14
     166: aload         14
     168: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     173: ifeq          219
     176: aload         14
     178: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     183: astore        15
     185: aload         15
     187: checkcast     #120                // class kotlin/Pair
     190: astore        16
     192: iconst_0
     193: istore        17
     195: aload_3
     196: aload         16
     198: invokeinterface #230,  2          // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
     203: ifne          166
     206: aload         12
     208: aload         15
     210: invokeinterface #78,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     215: pop
     216: goto          166
     219: aload         12
     221: checkcast     #80                 // class java/util/List
     224: nop
     225: astore        8
     227: aload         8
     229: checkcast     #18                 // class java/lang/Iterable
     232: astore        10
     234: iconst_0
     235: istore        11
     237: aload         10
     239: instanceof    #32                 // class java/util/Collection
     242: ifeq          262
     245: aload         10
     247: checkcast     #32                 // class java/util/Collection
     250: invokeinterface #235,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     255: ifeq          262
     258: iconst_1
     259: goto          351
     262: aload         10
     264: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     269: astore        12
     271: aload         12
     273: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     278: ifeq          350
     281: aload         12
     283: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     288: astore        13
     290: aload         13
     292: checkcast     #120                // class kotlin/Pair
     295: astore        14
     297: iconst_0
     298: istore        15
     300: aload         14
     302: invokevirtual #133                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     305: checkcast     #135                // class java/lang/Number
     308: invokevirtual #138                // Method java/lang/Number.intValue:()I
     311: istore        16
     313: aload         14
     315: invokevirtual #141                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     318: checkcast     #135                // class java/lang/Number
     321: invokevirtual #138                // Method java/lang/Number.intValue:()I
     324: istore        17
     326: aload_2
     327: iload         16
     329: aaload
     330: iload         17
     332: iaload
     333: iload         7
     335: if_icmplt     342
     338: iconst_1
     339: goto          343
     342: iconst_0
     343: ifne          271
     346: iconst_0
     347: goto          351
     350: iconst_1
     351: istore        9
     353: iload         9
     355: ifeq          381
     358: iinc          5, 1
     361: aload_3
     362: aload         6
     364: invokeinterface #236,  2          // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     369: pop
     370: aload         4
     372: aload         8
     374: checkcast     #32                 // class java/util/Collection
     377: invokevirtual #239                // Method kotlin/collections/ArrayDeque.addAll:(Ljava/util/Collection;)Z
     380: pop
     381: aload         4
     383: invokevirtual #240                // Method kotlin/collections/ArrayDeque.isEmpty:()Z
     386: ifeq          46
     389: iload         5
     391: ireturn

  public static final int productOfSizeThreeLargestBasins(int[][]);
    Code:
       0: aload_0
       1: ldc           #118                // String map
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #202                // Method findLocalMinimums:([[I)Ljava/util/List;
      10: checkcast     #18                 // class java/lang/Iterable
      13: astore_1
      14: nop
      15: iconst_0
      16: istore_2
      17: aload_1
      18: astore_3
      19: new           #20                 // class java/util/ArrayList
      22: dup
      23: aload_1
      24: bipush        10
      26: invokestatic  #26                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      29: invokespecial #30                 // Method java/util/ArrayList."<init>":(I)V
      32: checkcast     #32                 // class java/util/Collection
      35: astore        4
      37: iconst_0
      38: istore        5
      40: aload_3
      41: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      46: astore        6
      48: aload         6
      50: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      55: ifeq          130
      58: aload         6
      60: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      65: astore        7
      67: aload         4
      69: aload         7
      71: checkcast     #120                // class kotlin/Pair
      74: astore        8
      76: astore        12
      78: iconst_0
      79: istore        9
      81: aload         8
      83: invokevirtual #133                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      86: checkcast     #135                // class java/lang/Number
      89: invokevirtual #138                // Method java/lang/Number.intValue:()I
      92: istore        10
      94: aload         8
      96: invokevirtual #141                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      99: checkcast     #135                // class java/lang/Number
     102: invokevirtual #138                // Method java/lang/Number.intValue:()I
     105: istore        11
     107: iload         10
     109: iload         11
     111: aload_0
     112: invokestatic  #259                // Method computeBasinSize:(II[[I)I
     115: invokestatic  #74                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     118: aload         12
     120: swap
     121: invokeinterface #78,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     126: pop
     127: goto          48
     130: aload         4
     132: checkcast     #80                 // class java/util/List
     135: nop
     136: checkcast     #18                 // class java/lang/Iterable
     139: invokestatic  #263                // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;
     142: iconst_3
     143: invokestatic  #267                // Method kotlin/collections/CollectionsKt.takeLast:(Ljava/util/List;I)Ljava/util/List;
     146: checkcast     #18                 // class java/lang/Iterable
     149: astore_1
     150: nop
     151: iconst_0
     152: istore_2
     153: aload_1
     154: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     159: astore_3
     160: aload_3
     161: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     166: ifne          180
     169: new           #269                // class java/lang/UnsupportedOperationException
     172: dup
     173: ldc_w         #271                // String Empty collection can\'t be reduced.
     176: invokespecial #274                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     179: athrow
     180: aload_3
     181: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     186: astore        4
     188: aload_3
     189: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     194: ifeq          237
     197: aload         4
     199: aload_3
     200: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     205: checkcast     #135                // class java/lang/Number
     208: invokevirtual #138                // Method java/lang/Number.intValue:()I
     211: istore        5
     213: checkcast     #135                // class java/lang/Number
     216: invokevirtual #138                // Method java/lang/Number.intValue:()I
     219: istore        6
     221: iconst_0
     222: istore        7
     224: iload         6
     226: iload         5
     228: imul
     229: invokestatic  #74                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     232: astore        4
     234: goto          188
     237: aload         4
     239: checkcast     #135                // class java/lang/Number
     242: invokevirtual #138                // Method java/lang/Number.intValue:()I
     245: ireturn

  public static final void main();
    Code:
       0: new           #288                // class java/io/File
       3: dup
       4: ldc_w         #290                // String ./input/day9.txt
       7: invokespecial #291                // Method java/io/File."<init>":(Ljava/lang/String;)V
      10: astore_0
      11: getstatic     #297                // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;
      14: astore_1
      15: iconst_0
      16: istore_2
      17: aload_0
      18: astore_3
      19: sipush        8192
      22: istore        4
      24: aload_3
      25: astore        5
      27: new           #299                // class java/io/InputStreamReader
      30: dup
      31: new           #301                // class java/io/FileInputStream
      34: dup
      35: aload         5
      37: invokespecial #304                // Method java/io/FileInputStream."<init>":(Ljava/io/File;)V
      40: checkcast     #306                // class java/io/InputStream
      43: aload_1
      44: invokespecial #309                // Method java/io/InputStreamReader."<init>":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V
      47: checkcast     #311                // class java/io/Reader
      50: astore        5
      52: aload         5
      54: instanceof    #313                // class java/io/BufferedReader
      57: ifeq          68
      60: aload         5
      62: checkcast     #313                // class java/io/BufferedReader
      65: goto          79
      68: new           #313                // class java/io/BufferedReader
      71: dup
      72: aload         5
      74: iload         4
      76: invokespecial #316                // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;I)V
      79: checkcast     #318                // class java/io/Closeable
      82: astore_3
      83: aconst_null
      84: astore        4
      86: nop
      87: aload_3
      88: checkcast     #313                // class java/io/BufferedReader
      91: astore        5
      93: iconst_0
      94: istore        6
      96: aload         5
      98: invokestatic  #324                // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;
     101: astore        7
     103: iconst_0
     104: istore        8
     106: aload         7
     108: invokestatic  #330                // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;
     111: invokestatic  #332                // Method parseMap:(Ljava/util/List;)[[I
     114: astore        9
     116: aload         9
     118: invokestatic  #202                // Method findLocalMinimums:([[I)Ljava/util/List;
     121: getstatic     #338                // Field java/lang/System.out:Ljava/io/PrintStream;
     124: swap
     125: invokevirtual #344                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     128: aload         9
     130: invokestatic  #346                // Method productOfSizeThreeLargestBasins:([[I)I
     133: istore        10
     135: getstatic     #338                // Field java/lang/System.out:Ljava/io/PrintStream;
     138: iload         10
     140: invokevirtual #348                // Method java/io/PrintStream.println:(I)V
     143: nop
     144: getstatic     #354                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     147: astore        5
     149: aload_3
     150: aload         4
     152: invokestatic  #360                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     155: goto          178
     158: astore        6
     160: aload         6
     162: astore        4
     164: aload         6
     166: athrow
     167: astore        6
     169: aload_3
     170: aload         4
     172: invokestatic  #360                // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V
     175: aload         6
     177: athrow
     178: nop
     179: return
    Exception table:
       from    to  target type
          86   149   158   Class java/lang/Throwable
          86   149   167   any
         158   167   167   any
         167   169   167   any

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

  private static final boolean findLocalMinimums$isLocalMinimum(int[][], int, int);
    Code:
       0: iload_1
       1: iload_2
       2: aload_0
       3: invokestatic  #232                // Method expandAdjacent:(II[[I)Ljava/util/List;
       6: astore_3
       7: aload_0
       8: iload_1
       9: aaload
      10: iload_2
      11: iaload
      12: istore        4
      14: aload_3
      15: checkcast     #18                 // class java/lang/Iterable
      18: astore        5
      20: iconst_0
      21: istore        6
      23: aload         5
      25: instanceof    #32                 // class java/util/Collection
      28: ifeq          48
      31: aload         5
      33: checkcast     #32                 // class java/util/Collection
      36: invokeinterface #235,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
      41: ifeq          48
      44: iconst_1
      45: goto          137
      48: aload         5
      50: invokeinterface #36,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      55: astore        7
      57: aload         7
      59: invokeinterface #42,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      64: ifeq          136
      67: aload         7
      69: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      74: astore        8
      76: aload         8
      78: checkcast     #120                // class kotlin/Pair
      81: astore        9
      83: iconst_0
      84: istore        10
      86: aload         9
      88: invokevirtual #133                // Method kotlin/Pair.component1:()Ljava/lang/Object;
      91: checkcast     #135                // class java/lang/Number
      94: invokevirtual #138                // Method java/lang/Number.intValue:()I
      97: istore        11
      99: aload         9
     101: invokevirtual #141                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     104: checkcast     #135                // class java/lang/Number
     107: invokevirtual #138                // Method java/lang/Number.intValue:()I
     110: istore        12
     112: aload_0
     113: iload         11
     115: aaload
     116: iload         12
     118: iaload
     119: iload         4
     121: if_icmple     128
     124: iconst_1
     125: goto          129
     128: iconst_0
     129: ifne          57
     132: iconst_0
     133: goto          137
     136: iconst_1
     137: ireturn
}