fun main() = Sand.solve()

private object Sand {
    fun solve() {
        val input = readInput()
        val (grid, start) = inputToGrid(input)
        drawGrid(grid)
        println("Start: $start")
        drawGrid(addSand(grid, start))
    }

    private fun addSand(grid: List<MutableList<Cell>>, start: Pos): List<List<Cell>> {
        val result = grid.map { it.toMutableList() }

        fun nextPos(pos: Pos): Pos? {
            val variants = listOf(
                Pos(pos.x, pos.y + 1),
                Pos(pos.x - 1, pos.y + 1),
                Pos(pos.x + 1, pos.y + 1)
            )
            for (variant in variants) {
                if (variant.y >= result.size) {
                    return null
                }
                if (variant.x < 0 || variant.x >= result.first().size) {
                    return null
                }
                if (result[variant.y][variant.x] == Cell.Empty) {
                    return variant
                }
            }
            return pos
        }

        fun percolate(): Boolean {
            var pos = start
            while (true) {
                val next = nextPos(pos) ?: return false
                if (next == pos) {
                    result[pos.y][pos.x] = Cell.Sand
                    return pos != start
                }
                pos = next
            }
        }

        var iterations = 1
        while (percolate()) {
            iterations += 1
        }
        println("Iterations: $iterations")

        return result
    }

    private fun readInput(): List<List<Pos>> {
        return generateSequence(::readLine).map {
            it.splitToSequence(" -> ").map {
                val parts = it.split(",")
                Pos(parts[0].toInt(10), parts[1].toInt(10))
            }.toList()
        }.toList()
    }

    private fun inputToGrid(input: List<List<Pos>>): Pair<List<MutableList<Cell>>, Pos> {
        val start = Pos(500, 0)
        val positions = input.flatten()
        val minX = minOf(start.x, positions.map { it.x }.min()) - 200
        val maxX = maxOf(start.x, positions.map { it.x }.max()) + 200
        val minY = minOf(start.y, positions.map { it.y }.min())
        val maxY = maxOf(start.y, positions.map { it.y }.max()) + 2
        println("$minX $maxX $minY $maxY")
        val result = mutableListOf<MutableList<Cell>>()
        for (y in minY..maxY) {
            val line = mutableListOf<Cell>()
            for (x in minX..maxX) {
                line.add(Cell.Empty)
            }
            result.add(line)
        }

        fun fillWithRock(grid: List<MutableList<Cell>>, from: Pos, to: Pos) {
//            println("$from $to")

            if (from.x != to.x) {
                val src = Pos(minOf(from.x, to.x), from.y)
                val dst = Pos(maxOf(from.x, to.x), from.y)
                for (x in src.x..dst.x) {
                    grid[src.y - minY][x - minX] = Cell.Rock
                }
            } else {
                val src = Pos(from.x, minOf(from.y, to.y))
                val dst = Pos(from.x, maxOf(from.y, to.y))
                for (y in src.y..dst.y) {
                    grid[y - minY][src.x - minX] = Cell.Rock
                }
            }
        }

        for (rock in input) {
            val points = rock.toMutableList()
            var from = points.removeFirst()
            while (!points.isEmpty()) {
                val to = points.removeFirst()
                fillWithRock(result, from, to)
                from = to
            }
        }
        fillWithRock(result, Pos(minX, maxY), Pos(maxX, maxY))

        return Pair(result, Pos(start.x - minX, start.y - minY))
    }

    private fun drawGrid(grid: List<List<Cell>>) {
        for (line in grid) {
            println(line.map {
                when (it) {
                    Cell.Empty -> '.'
                    Cell.Rock -> '#'
                    Cell.Sand -> 'o'
                }
            }.joinToString(""))
        }
    }

    enum class Cell {
        Empty, Rock, Sand,
    }

    data class Pos(val x: Int, val y: Int) : Comparable<Pos> {
        override fun compareTo(other: Pos): Int {
            val cmpX = x.compareTo(other.x)
            if (cmpX != 0) {
                return cmpX
            }
            val cmpY = y.compareTo(other.y)
            if (cmpY != 0) {
                return cmpY
            }
            return 0
        }
    }
}

Compiled from "Sand.kt"
public final class Sand$Pos implements java.lang.Comparable<Sand$Pos> {
  private final int x;

  private final int y;

  public Sand$Pos(int, int);
    Code:
       0: aload_0
       1: invokespecial #12                 // Method java/lang/Object."<init>":()V
       4: aload_0
       5: iload_1
       6: putfield      #16                 // Field x:I
       9: aload_0
      10: iload_2
      11: putfield      #19                 // Field y:I
      14: return

  public final int getX();
    Code:
       0: aload_0
       1: getfield      #16                 // Field x:I
       4: ireturn

  public final int getY();
    Code:
       0: aload_0
       1: getfield      #19                 // Field y:I
       4: ireturn

  public int compareTo(Sand$Pos);
    Code:
       0: aload_1
       1: ldc           #29                 // String other
       3: invokestatic  #35                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: getfield      #16                 // Field x:I
      10: aload_1
      11: getfield      #16                 // Field x:I
      14: invokestatic  #39                 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I
      17: istore_2
      18: iload_2
      19: ifeq          24
      22: iload_2
      23: ireturn
      24: aload_0
      25: getfield      #19                 // Field y:I
      28: aload_1
      29: getfield      #19                 // Field y:I
      32: invokestatic  #39                 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I
      35: istore_3
      36: iload_3
      37: ifeq          42
      40: iload_3
      41: ireturn
      42: iconst_0
      43: ireturn

  public final int component1();
    Code:
       0: aload_0
       1: getfield      #16                 // Field x:I
       4: ireturn

  public final int component2();
    Code:
       0: aload_0
       1: getfield      #19                 // Field y:I
       4: ireturn

  public final Sand$Pos copy(int, int);
    Code:
       0: new           #2                  // class Sand$Pos
       3: dup
       4: iload_1
       5: iload_2
       6: invokespecial #47                 // Method "<init>":(II)V
       9: areturn

  public static Sand$Pos copy$default(Sand$Pos, int, int, int, java.lang.Object);
    Code:
       0: iload_3
       1: iconst_1
       2: iand
       3: ifeq          11
       6: aload_0
       7: getfield      #16                 // Field x:I
      10: istore_1
      11: iload_3
      12: iconst_2
      13: iand
      14: ifeq          22
      17: aload_0
      18: getfield      #19                 // Field y:I
      21: istore_2
      22: aload_0
      23: iload_1
      24: iload_2
      25: invokevirtual #51                 // Method copy:(II)LSand$Pos;
      28: areturn

  public java.lang.String toString();
    Code:
       0: new           #55                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #56                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #58                 // String Pos(x=
       9: invokevirtual #62                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #16                 // Field x:I
      16: invokevirtual #65                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: ldc           #67                 // String , y=
      21: invokevirtual #62                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #19                 // Field y:I
      28: invokevirtual #65                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      31: bipush        41
      33: invokevirtual #70                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      36: invokevirtual #72                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      39: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #16                 // Field x:I
       4: invokestatic  #78                 // Method java/lang/Integer.hashCode:(I)I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #19                 // Field y:I
      16: invokestatic  #78                 // Method java/lang/Integer.hashCode:(I)I
      19: iadd
      20: istore_1
      21: iload_1
      22: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class Sand$Pos
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class Sand$Pos
      20: astore_2
      21: aload_0
      22: getfield      #16                 // Field x:I
      25: aload_2
      26: getfield      #16                 // Field x:I
      29: if_icmpeq     34
      32: iconst_0
      33: ireturn
      34: aload_0
      35: getfield      #19                 // Field y:I
      38: aload_2
      39: getfield      #19                 // Field y:I
      42: if_icmpeq     47
      45: iconst_0
      46: ireturn
      47: iconst_1
      48: ireturn

  public int compareTo(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #2                  // class Sand$Pos
       5: invokevirtual #86                 // Method compareTo:(LSand$Pos;)I
       8: ireturn
}

Compiled from "Sand.kt"
public final class Sand$Cell extends java.lang.Enum<Sand$Cell> {
  public static final Sand$Cell Empty;

  public static final Sand$Cell Rock;

  public static final Sand$Cell Sand;

  private static final Sand$Cell[] $VALUES;

  private static final kotlin.enums.EnumEntries $ENTRIES;

  private Sand$Cell();
    Code:
       0: aload_0
       1: aload_1
       2: iload_2
       3: invokespecial #10                 // Method java/lang/Enum."<init>":(Ljava/lang/String;I)V
       6: return

  public static Sand$Cell[] values();
    Code:
       0: getstatic     #22                 // Field $VALUES:[LSand$Cell;
       3: invokevirtual #28                 // Method java/lang/Object.clone:()Ljava/lang/Object;
       6: checkcast     #29                 // class "[LSand$Cell;"
       9: areturn

  public static Sand$Cell valueOf(java.lang.String);
    Code:
       0: ldc           #2                  // class Sand$Cell
       2: aload_0
       3: invokestatic  #34                 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;
       6: checkcast     #2                  // class Sand$Cell
       9: areturn

  public static kotlin.enums.EnumEntries<Sand$Cell> getEntries();
    Code:
       0: getstatic     #43                 // Field $ENTRIES:Lkotlin/enums/EnumEntries;
       3: areturn

  private static final Sand$Cell[] $values();
    Code:
       0: iconst_3
       1: anewarray     #2                  // class Sand$Cell
       4: astore_0
       5: aload_0
       6: iconst_0
       7: getstatic     #47                 // Field Empty:LSand$Cell;
      10: aastore
      11: aload_0
      12: iconst_1
      13: getstatic     #50                 // Field Rock:LSand$Cell;
      16: aastore
      17: aload_0
      18: iconst_2
      19: getstatic     #53                 // Field Sand:LSand$Cell;
      22: aastore
      23: aload_0
      24: areturn

  static {};
    Code:
       0: new           #2                  // class Sand$Cell
       3: dup
       4: ldc           #55                 // String Empty
       6: iconst_0
       7: invokespecial #56                 // Method "<init>":(Ljava/lang/String;I)V
      10: putstatic     #47                 // Field Empty:LSand$Cell;
      13: new           #2                  // class Sand$Cell
      16: dup
      17: ldc           #57                 // String Rock
      19: iconst_1
      20: invokespecial #56                 // Method "<init>":(Ljava/lang/String;I)V
      23: putstatic     #50                 // Field Rock:LSand$Cell;
      26: new           #2                  // class Sand$Cell
      29: dup
      30: ldc           #58                 // String Sand
      32: iconst_2
      33: invokespecial #56                 // Method "<init>":(Ljava/lang/String;I)V
      36: putstatic     #53                 // Field Sand:LSand$Cell;
      39: invokestatic  #60                 // Method $values:()[LSand$Cell;
      42: putstatic     #22                 // Field $VALUES:[LSand$Cell;
      45: getstatic     #22                 // Field $VALUES:[LSand$Cell;
      48: checkcast     #62                 // class "[Ljava/lang/Enum;"
      51: invokestatic  #68                 // Method kotlin/enums/EnumEntriesKt.enumEntries:([Ljava/lang/Enum;)Lkotlin/enums/EnumEntries;
      54: putstatic     #43                 // Field $ENTRIES:Lkotlin/enums/EnumEntries;
      57: return
}

Compiled from "Sand.kt"
final class Sand$readInput$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function0<java.lang.String> {
  public static final Sand$readInput$1 INSTANCE;

  Sand$readInput$1();
    Code:
       0: aload_0
       1: iconst_0
       2: ldc           #11                 // class kotlin/io/ConsoleKt
       4: ldc           #13                 // String readLine
       6: ldc           #15                 // String readLine()Ljava/lang/String;
       8: iconst_1
       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.String invoke();
    Code:
       0: invokestatic  #24                 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;
       3: areturn

  public java.lang.Object invoke();
    Code:
       0: aload_0
       1: invokevirtual #27                 // Method invoke:()Ljava/lang/String;
       4: areturn

  static {};
    Code:
       0: new           #2                  // class Sand$readInput$1
       3: dup
       4: invokespecial #30                 // Method "<init>":()V
       7: putstatic     #33                 // Field INSTANCE:LSand$readInput$1;
      10: return
}

Compiled from "Sand.kt"
public final class SandKt {
  public static final void main();
    Code:
       0: getstatic     #12                 // Field Sand.INSTANCE:LSand;
       3: invokevirtual #15                 // Method Sand.solve:()V
       6: return

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

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

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

  public final void solve();
    Code:
       0: aload_0
       1: invokespecial #15                 // Method readInput:()Ljava/util/List;
       4: astore_1
       5: aload_0
       6: aload_1
       7: invokespecial #19                 // Method inputToGrid:(Ljava/util/List;)Lkotlin/Pair;
      10: astore_2
      11: aload_2
      12: invokevirtual #25                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
      15: checkcast     #27                 // class java/util/List
      18: astore_3
      19: aload_2
      20: invokevirtual #30                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
      23: checkcast     #32                 // class Sand$Pos
      26: astore        4
      28: aload_0
      29: aload_3
      30: invokespecial #36                 // Method drawGrid:(Ljava/util/List;)V
      33: new           #38                 // class java/lang/StringBuilder
      36: dup
      37: invokespecial #39                 // Method java/lang/StringBuilder."<init>":()V
      40: ldc           #41                 // String Start:
      42: invokevirtual #45                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      45: aload         4
      47: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      50: invokevirtual #52                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      53: getstatic     #58                 // Field java/lang/System.out:Ljava/io/PrintStream;
      56: swap
      57: invokevirtual #64                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      60: aload_0
      61: aload_0
      62: aload_3
      63: aload         4
      65: invokespecial #68                 // Method addSand:(Ljava/util/List;LSand$Pos;)Ljava/util/List;
      68: invokespecial #36                 // Method drawGrid:(Ljava/util/List;)V
      71: return

  private final java.util.List<java.util.List<Sand$Cell>> addSand(java.util.List<? extends java.util.List<Sand$Cell>>, Sand$Pos);
    Code:
       0: aload_1
       1: checkcast     #76                 // class java/lang/Iterable
       4: astore        4
       6: iconst_0
       7: istore        5
       9: aload         4
      11: astore        6
      13: new           #78                 // class java/util/ArrayList
      16: dup
      17: aload         4
      19: bipush        10
      21: invokestatic  #84                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      24: invokespecial #87                 // Method java/util/ArrayList."<init>":(I)V
      27: checkcast     #89                 // class java/util/Collection
      30: astore        7
      32: iconst_0
      33: istore        8
      35: aload         6
      37: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        9
      44: aload         9
      46: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          97
      54: aload         9
      56: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        10
      63: aload         7
      65: aload         10
      67: checkcast     #27                 // class java/util/List
      70: astore        11
      72: astore        13
      74: iconst_0
      75: istore        12
      77: aload         11
      79: checkcast     #89                 // class java/util/Collection
      82: invokestatic  #106                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
      85: aload         13
      87: swap
      88: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      93: pop
      94: goto          44
      97: aload         7
      99: checkcast     #27                 // class java/util/List
     102: nop
     103: astore_3
     104: iconst_1
     105: istore        4
     107: aload_2
     108: aload_3
     109: invokestatic  #114                // Method addSand$percolate:(LSand$Pos;Ljava/util/List;)Z
     112: ifeq          121
     115: iinc          4, 1
     118: goto          107
     121: new           #38                 // class java/lang/StringBuilder
     124: dup
     125: invokespecial #39                 // Method java/lang/StringBuilder."<init>":()V
     128: ldc           #116                // String Iterations:
     130: invokevirtual #45                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     133: iload         4
     135: invokevirtual #119                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     138: invokevirtual #52                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     141: getstatic     #58                 // Field java/lang/System.out:Ljava/io/PrintStream;
     144: swap
     145: invokevirtual #64                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     148: aload_3
     149: areturn

  private final java.util.List<java.util.List<Sand$Pos>> readInput();
    Code:
       0: getstatic     #140                // Field Sand$readInput$1.INSTANCE:LSand$readInput$1;
       3: checkcast     #142                // class kotlin/jvm/functions/Function0
       6: invokestatic  #148                // Method kotlin/sequences/SequencesKt.generateSequence:(Lkotlin/jvm/functions/Function0;)Lkotlin/sequences/Sequence;
       9: invokedynamic #167,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
      14: invokestatic  #171                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      17: invokestatic  #175                // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;
      20: areturn

  private final kotlin.Pair<java.util.List<java.util.List<Sand$Cell>>, Sand$Pos> inputToGrid(java.util.List<? extends java.util.List<Sand$Pos>>);
    Code:
       0: new           #32                 // class Sand$Pos
       3: dup
       4: sipush        500
       7: iconst_0
       8: invokespecial #179                // Method Sand$Pos."<init>":(II)V
      11: astore_2
      12: aload_1
      13: checkcast     #76                 // class java/lang/Iterable
      16: invokestatic  #183                // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;
      19: astore_3
      20: aload_2
      21: invokevirtual #187                // Method Sand$Pos.getX:()I
      24: istore        5
      26: aload_3
      27: checkcast     #76                 // class java/lang/Iterable
      30: astore        6
      32: iconst_0
      33: istore        7
      35: aload         6
      37: astore        8
      39: new           #78                 // class java/util/ArrayList
      42: dup
      43: aload         6
      45: bipush        10
      47: invokestatic  #84                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      50: invokespecial #87                 // Method java/util/ArrayList."<init>":(I)V
      53: checkcast     #89                 // class java/util/Collection
      56: astore        9
      58: iconst_0
      59: istore        10
      61: aload         8
      63: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      68: astore        11
      70: aload         11
      72: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      77: ifeq          123
      80: aload         11
      82: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      87: astore        12
      89: aload         9
      91: aload         12
      93: checkcast     #32                 // class Sand$Pos
      96: astore        13
      98: astore        18
     100: iconst_0
     101: istore        14
     103: aload         13
     105: invokevirtual #187                // Method Sand$Pos.getX:()I
     108: invokestatic  #193                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     111: aload         18
     113: swap
     114: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     119: pop
     120: goto          70
     123: aload         9
     125: checkcast     #27                 // class java/util/List
     128: nop
     129: checkcast     #76                 // class java/lang/Iterable
     132: invokestatic  #197                // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     135: checkcast     #199                // class java/lang/Number
     138: invokevirtual #202                // Method java/lang/Number.intValue:()I
     141: istore        6
     143: iload         5
     145: iload         6
     147: invokestatic  #208                // Method java/lang/Math.min:(II)I
     150: sipush        200
     153: isub
     154: istore        4
     156: aload_2
     157: invokevirtual #187                // Method Sand$Pos.getX:()I
     160: istore        6
     162: aload_3
     163: checkcast     #76                 // class java/lang/Iterable
     166: astore        7
     168: iconst_0
     169: istore        8
     171: aload         7
     173: astore        9
     175: new           #78                 // class java/util/ArrayList
     178: dup
     179: aload         7
     181: bipush        10
     183: invokestatic  #84                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     186: invokespecial #87                 // Method java/util/ArrayList."<init>":(I)V
     189: checkcast     #89                 // class java/util/Collection
     192: astore        10
     194: iconst_0
     195: istore        11
     197: aload         9
     199: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     204: astore        12
     206: aload         12
     208: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     213: ifeq          259
     216: aload         12
     218: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     223: astore        13
     225: aload         10
     227: aload         13
     229: checkcast     #32                 // class Sand$Pos
     232: astore        14
     234: astore        18
     236: iconst_0
     237: istore        15
     239: aload         14
     241: invokevirtual #187                // Method Sand$Pos.getX:()I
     244: invokestatic  #193                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     247: aload         18
     249: swap
     250: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     255: pop
     256: goto          206
     259: aload         10
     261: checkcast     #27                 // class java/util/List
     264: nop
     265: checkcast     #76                 // class java/lang/Iterable
     268: invokestatic  #211                // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     271: checkcast     #199                // class java/lang/Number
     274: invokevirtual #202                // Method java/lang/Number.intValue:()I
     277: istore        7
     279: iload         6
     281: iload         7
     283: invokestatic  #214                // Method java/lang/Math.max:(II)I
     286: sipush        200
     289: iadd
     290: istore        5
     292: aload_2
     293: invokevirtual #217                // Method Sand$Pos.getY:()I
     296: istore        7
     298: aload_3
     299: checkcast     #76                 // class java/lang/Iterable
     302: astore        8
     304: iconst_0
     305: istore        9
     307: aload         8
     309: astore        10
     311: new           #78                 // class java/util/ArrayList
     314: dup
     315: aload         8
     317: bipush        10
     319: invokestatic  #84                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     322: invokespecial #87                 // Method java/util/ArrayList."<init>":(I)V
     325: checkcast     #89                 // class java/util/Collection
     328: astore        11
     330: iconst_0
     331: istore        12
     333: aload         10
     335: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     340: astore        13
     342: aload         13
     344: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     349: ifeq          395
     352: aload         13
     354: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     359: astore        14
     361: aload         11
     363: aload         14
     365: checkcast     #32                 // class Sand$Pos
     368: astore        15
     370: astore        18
     372: iconst_0
     373: istore        16
     375: aload         15
     377: invokevirtual #217                // Method Sand$Pos.getY:()I
     380: invokestatic  #193                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     383: aload         18
     385: swap
     386: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     391: pop
     392: goto          342
     395: aload         11
     397: checkcast     #27                 // class java/util/List
     400: nop
     401: checkcast     #76                 // class java/lang/Iterable
     404: invokestatic  #197                // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     407: checkcast     #199                // class java/lang/Number
     410: invokevirtual #202                // Method java/lang/Number.intValue:()I
     413: istore        8
     415: iload         7
     417: iload         8
     419: invokestatic  #208                // Method java/lang/Math.min:(II)I
     422: istore        6
     424: aload_2
     425: invokevirtual #217                // Method Sand$Pos.getY:()I
     428: istore        8
     430: aload_3
     431: checkcast     #76                 // class java/lang/Iterable
     434: astore        9
     436: iconst_0
     437: istore        10
     439: aload         9
     441: astore        11
     443: new           #78                 // class java/util/ArrayList
     446: dup
     447: aload         9
     449: bipush        10
     451: invokestatic  #84                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     454: invokespecial #87                 // Method java/util/ArrayList."<init>":(I)V
     457: checkcast     #89                 // class java/util/Collection
     460: astore        12
     462: iconst_0
     463: istore        13
     465: aload         11
     467: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     472: astore        14
     474: aload         14
     476: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     481: ifeq          527
     484: aload         14
     486: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     491: astore        15
     493: aload         12
     495: aload         15
     497: checkcast     #32                 // class Sand$Pos
     500: astore        16
     502: astore        18
     504: iconst_0
     505: istore        17
     507: aload         16
     509: invokevirtual #217                // Method Sand$Pos.getY:()I
     512: invokestatic  #193                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     515: aload         18
     517: swap
     518: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     523: pop
     524: goto          474
     527: aload         12
     529: checkcast     #27                 // class java/util/List
     532: nop
     533: checkcast     #76                 // class java/lang/Iterable
     536: invokestatic  #211                // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;
     539: checkcast     #199                // class java/lang/Number
     542: invokevirtual #202                // Method java/lang/Number.intValue:()I
     545: istore        9
     547: iload         8
     549: iload         9
     551: invokestatic  #214                // Method java/lang/Math.max:(II)I
     554: iconst_2
     555: iadd
     556: istore        7
     558: new           #38                 // class java/lang/StringBuilder
     561: dup
     562: invokespecial #39                 // Method java/lang/StringBuilder."<init>":()V
     565: iload         4
     567: invokevirtual #119                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     570: bipush        32
     572: invokevirtual #220                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     575: iload         5
     577: invokevirtual #119                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     580: bipush        32
     582: invokevirtual #220                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     585: iload         6
     587: invokevirtual #119                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     590: bipush        32
     592: invokevirtual #220                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     595: iload         7
     597: invokevirtual #119                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     600: invokevirtual #52                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     603: getstatic     #58                 // Field java/lang/System.out:Ljava/io/PrintStream;
     606: swap
     607: invokevirtual #64                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     610: new           #78                 // class java/util/ArrayList
     613: dup
     614: invokespecial #221                // Method java/util/ArrayList."<init>":()V
     617: checkcast     #27                 // class java/util/List
     620: astore        8
     622: iload         6
     624: istore        9
     626: iload         9
     628: iload         7
     630: if_icmpgt     703
     633: new           #78                 // class java/util/ArrayList
     636: dup
     637: invokespecial #221                // Method java/util/ArrayList."<init>":()V
     640: checkcast     #27                 // class java/util/List
     643: astore        10
     645: iload         4
     647: istore        11
     649: iload         11
     651: iload         5
     653: if_icmpgt     680
     656: aload         10
     658: getstatic     #227                // Field Sand$Cell.Empty:LSand$Cell;
     661: invokeinterface #228,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     666: pop
     667: iload         11
     669: iload         5
     671: if_icmpeq     680
     674: iinc          11, 1
     677: goto          656
     680: aload         8
     682: aload         10
     684: invokeinterface #228,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     689: pop
     690: iload         9
     692: iload         7
     694: if_icmpeq     703
     697: iinc          9, 1
     700: goto          633
     703: aload_1
     704: invokeinterface #229,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     709: astore        9
     711: aload         9
     713: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     718: ifeq          809
     721: aload         9
     723: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     728: checkcast     #27                 // class java/util/List
     731: astore        10
     733: aload         10
     735: checkcast     #89                 // class java/util/Collection
     738: invokestatic  #106                // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;
     741: astore        11
     743: aload         11
     745: invokeinterface #232,  1          // InterfaceMethod java/util/List.removeFirst:()Ljava/lang/Object;
     750: dup
     751: ldc           #234                // String removeFirst(...)
     753: invokestatic  #240                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     756: checkcast     #32                 // class Sand$Pos
     759: astore        12
     761: aload         11
     763: invokeinterface #243,  1          // InterfaceMethod java/util/List.isEmpty:()Z
     768: ifne          711
     771: aload         11
     773: invokeinterface #232,  1          // InterfaceMethod java/util/List.removeFirst:()Ljava/lang/Object;
     778: dup
     779: ldc           #234                // String removeFirst(...)
     781: invokestatic  #240                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     784: checkcast     #32                 // class Sand$Pos
     787: astore        13
     789: iload         6
     791: iload         4
     793: aload         8
     795: aload         12
     797: aload         13
     799: invokestatic  #247                // Method inputToGrid$fillWithRock:(IILjava/util/List;LSand$Pos;LSand$Pos;)V
     802: aload         13
     804: astore        12
     806: goto          761
     809: iload         6
     811: iload         4
     813: aload         8
     815: new           #32                 // class Sand$Pos
     818: dup
     819: iload         4
     821: iload         7
     823: invokespecial #179                // Method Sand$Pos."<init>":(II)V
     826: new           #32                 // class Sand$Pos
     829: dup
     830: iload         5
     832: iload         7
     834: invokespecial #179                // Method Sand$Pos."<init>":(II)V
     837: invokestatic  #247                // Method inputToGrid$fillWithRock:(IILjava/util/List;LSand$Pos;LSand$Pos;)V
     840: new           #21                 // class kotlin/Pair
     843: dup
     844: aload         8
     846: new           #32                 // class Sand$Pos
     849: dup
     850: aload_2
     851: invokevirtual #187                // Method Sand$Pos.getX:()I
     854: iload         4
     856: isub
     857: aload_2
     858: invokevirtual #217                // Method Sand$Pos.getY:()I
     861: iload         6
     863: isub
     864: invokespecial #179                // Method Sand$Pos."<init>":(II)V
     867: invokespecial #250                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     870: areturn

  private final void drawGrid(java.util.List<? extends java.util.List<? extends Sand$Cell>>);
    Code:
       0: aload_1
       1: invokeinterface #229,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
       6: astore_2
       7: aload_2
       8: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      13: ifeq          218
      16: aload_2
      17: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      22: checkcast     #27                 // class java/util/List
      25: astore_3
      26: aload_3
      27: checkcast     #76                 // class java/lang/Iterable
      30: astore        4
      32: iconst_0
      33: istore        5
      35: aload         4
      37: astore        6
      39: new           #78                 // class java/util/ArrayList
      42: dup
      43: aload         4
      45: bipush        10
      47: invokestatic  #84                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      50: invokespecial #87                 // Method java/util/ArrayList."<init>":(I)V
      53: checkcast     #89                 // class java/util/Collection
      56: astore        7
      58: iconst_0
      59: istore        8
      61: aload         6
      63: invokeinterface #93,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      68: astore        9
      70: aload         9
      72: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      77: ifeq          179
      80: aload         9
      82: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      87: astore        10
      89: aload         7
      91: aload         10
      93: checkcast     #223                // class Sand$Cell
      96: astore        11
      98: astore        13
     100: iconst_0
     101: istore        12
     103: aload         11
     105: getstatic     #273                // Field Sand$WhenMappings.$EnumSwitchMapping$0:[I
     108: swap
     109: invokevirtual #276                // Method Sand$Cell.ordinal:()I
     112: iaload
     113: tableswitch   { // 1 to 3
                     1: 140
                     2: 145
                     3: 150
               default: 155
          }
     140: bipush        46
     142: goto          163
     145: bipush        35
     147: goto          163
     150: bipush        111
     152: goto          163
     155: new           #278                // class kotlin/NoWhenBranchMatchedException
     158: dup
     159: invokespecial #279                // Method kotlin/NoWhenBranchMatchedException."<init>":()V
     162: athrow
     163: nop
     164: invokestatic  #284                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     167: aload         13
     169: swap
     170: invokeinterface #110,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     175: pop
     176: goto          70
     179: aload         7
     181: checkcast     #27                 // class java/util/List
     184: nop
     185: checkcast     #76                 // class java/lang/Iterable
     188: ldc_w         #286                // String
     191: checkcast     #288                // class java/lang/CharSequence
     194: aconst_null
     195: aconst_null
     196: iconst_0
     197: aconst_null
     198: aconst_null
     199: bipush        62
     201: aconst_null
     202: invokestatic  #292                // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
     205: astore        4
     207: getstatic     #58                 // Field java/lang/System.out:Ljava/io/PrintStream;
     210: aload         4
     212: invokevirtual #64                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     215: goto          7
     218: return

  private static final Sand$Pos addSand$nextPos(java.util.List<? extends java.util.List<Sand$Cell>>, Sand$Pos);
    Code:
       0: iconst_3
       1: anewarray     #32                 // class Sand$Pos
       4: astore_3
       5: aload_3
       6: iconst_0
       7: new           #32                 // class Sand$Pos
      10: dup
      11: aload_1
      12: invokevirtual #187                // Method Sand$Pos.getX:()I
      15: aload_1
      16: invokevirtual #217                // Method Sand$Pos.getY:()I
      19: iconst_1
      20: iadd
      21: invokespecial #179                // Method Sand$Pos."<init>":(II)V
      24: aastore
      25: aload_3
      26: iconst_1
      27: new           #32                 // class Sand$Pos
      30: dup
      31: aload_1
      32: invokevirtual #187                // Method Sand$Pos.getX:()I
      35: iconst_1
      36: isub
      37: aload_1
      38: invokevirtual #217                // Method Sand$Pos.getY:()I
      41: iconst_1
      42: iadd
      43: invokespecial #179                // Method Sand$Pos."<init>":(II)V
      46: aastore
      47: aload_3
      48: iconst_2
      49: new           #32                 // class Sand$Pos
      52: dup
      53: aload_1
      54: invokevirtual #187                // Method Sand$Pos.getX:()I
      57: iconst_1
      58: iadd
      59: aload_1
      60: invokevirtual #217                // Method Sand$Pos.getY:()I
      63: iconst_1
      64: iadd
      65: invokespecial #179                // Method Sand$Pos."<init>":(II)V
      68: aastore
      69: aload_3
      70: invokestatic  #300                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      73: astore_2
      74: aload_2
      75: invokeinterface #229,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      80: astore_3
      81: aload_3
      82: invokeinterface #99,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      87: ifeq          180
      90: aload_3
      91: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      96: checkcast     #32                 // class Sand$Pos
      99: astore        4
     101: aload         4
     103: invokevirtual #217                // Method Sand$Pos.getY:()I
     106: aload_0
     107: invokeinterface #303,  1          // InterfaceMethod java/util/List.size:()I
     112: if_icmplt     117
     115: aconst_null
     116: areturn
     117: aload         4
     119: invokevirtual #187                // Method Sand$Pos.getX:()I
     122: iflt          145
     125: aload         4
     127: invokevirtual #187                // Method Sand$Pos.getX:()I
     130: aload_0
     131: invokestatic  #307                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     134: checkcast     #27                 // class java/util/List
     137: invokeinterface #303,  1          // InterfaceMethod java/util/List.size:()I
     142: if_icmplt     147
     145: aconst_null
     146: areturn
     147: aload_0
     148: aload         4
     150: invokevirtual #217                // Method Sand$Pos.getY:()I
     153: invokeinterface #311,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     158: checkcast     #27                 // class java/util/List
     161: aload         4
     163: invokevirtual #187                // Method Sand$Pos.getX:()I
     166: invokeinterface #311,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     171: getstatic     #227                // Field Sand$Cell.Empty:LSand$Cell;
     174: if_acmpne     81
     177: aload         4
     179: areturn
     180: aload_1
     181: areturn

  private static final boolean addSand$percolate(Sand$Pos, java.util.List<? extends java.util.List<Sand$Cell>>);
    Code:
       0: aload_0
       1: astore_2
       2: nop
       3: aload_1
       4: aload_2
       5: invokestatic  #317                // Method addSand$nextPos:(Ljava/util/List;LSand$Pos;)LSand$Pos;
       8: dup
       9: ifnonnull     15
      12: pop
      13: iconst_0
      14: ireturn
      15: astore_3
      16: aload_3
      17: aload_2
      18: invokestatic  #321                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      21: ifeq          64
      24: aload_1
      25: aload_2
      26: invokevirtual #217                // Method Sand$Pos.getY:()I
      29: invokeinterface #311,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      34: checkcast     #27                 // class java/util/List
      37: aload_2
      38: invokevirtual #187                // Method Sand$Pos.getX:()I
      41: getstatic     #323                // Field Sand$Cell.Sand:LSand$Cell;
      44: invokeinterface #327,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
      49: pop
      50: aload_2
      51: aload_0
      52: invokestatic  #321                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      55: ifne          62
      58: iconst_1
      59: goto          63
      62: iconst_0
      63: ireturn
      64: aload_3
      65: astore_2
      66: goto          2

  private static final Sand$Pos readInput$lambda$2$lambda$1(java.lang.String);
    Code:
       0: aload_0
       1: ldc_w         #331                // String it
       4: invokestatic  #334                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: checkcast     #288                // class java/lang/CharSequence
      11: iconst_1
      12: anewarray     #336                // class java/lang/String
      15: astore_2
      16: aload_2
      17: iconst_0
      18: ldc_w         #338                // String ,
      21: aastore
      22: aload_2
      23: iconst_0
      24: iconst_0
      25: bipush        6
      27: aconst_null
      28: invokestatic  #344                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      31: astore_1
      32: new           #32                 // class Sand$Pos
      35: dup
      36: aload_1
      37: iconst_0
      38: invokeinterface #311,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      43: checkcast     #336                // class java/lang/String
      46: bipush        10
      48: invokestatic  #350                // Method kotlin/text/CharsKt.checkRadix:(I)I
      51: invokestatic  #354                // Method java/lang/Integer.parseInt:(Ljava/lang/String;I)I
      54: aload_1
      55: iconst_1
      56: invokeinterface #311,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      61: checkcast     #336                // class java/lang/String
      64: bipush        10
      66: invokestatic  #350                // Method kotlin/text/CharsKt.checkRadix:(I)I
      69: invokestatic  #354                // Method java/lang/Integer.parseInt:(Ljava/lang/String;I)I
      72: invokespecial #179                // Method Sand$Pos."<init>":(II)V
      75: areturn

  private static final java.util.List readInput$lambda$2(java.lang.String);
    Code:
       0: aload_0
       1: ldc_w         #331                // String it
       4: invokestatic  #334                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: checkcast     #288                // class java/lang/CharSequence
      11: iconst_1
      12: anewarray     #336                // class java/lang/String
      15: astore_1
      16: aload_1
      17: iconst_0
      18: ldc_w         #358                // String  ->
      21: aastore
      22: aload_1
      23: iconst_0
      24: iconst_0
      25: bipush        6
      27: aconst_null
      28: invokestatic  #362                // Method kotlin/text/StringsKt.splitToSequence$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Lkotlin/sequences/Sequence;
      31: invokedynamic #367,  0            // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;
      36: invokestatic  #171                // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      39: invokestatic  #175                // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;
      42: areturn

  private static final void inputToGrid$fillWithRock(int, int, java.util.List<? extends java.util.List<Sand$Cell>>, Sand$Pos, Sand$Pos);
    Code:
       0: aload_3
       1: invokevirtual #187                // Method Sand$Pos.getX:()I
       4: aload         4
       6: invokevirtual #187                // Method Sand$Pos.getX:()I
       9: if_icmpeq     125
      12: new           #32                 // class Sand$Pos
      15: dup
      16: aload_3
      17: invokevirtual #187                // Method Sand$Pos.getX:()I
      20: aload         4
      22: invokevirtual #187                // Method Sand$Pos.getX:()I
      25: invokestatic  #208                // Method java/lang/Math.min:(II)I
      28: aload_3
      29: invokevirtual #217                // Method Sand$Pos.getY:()I
      32: invokespecial #179                // Method Sand$Pos."<init>":(II)V
      35: astore        5
      37: new           #32                 // class Sand$Pos
      40: dup
      41: aload_3
      42: invokevirtual #187                // Method Sand$Pos.getX:()I
      45: aload         4
      47: invokevirtual #187                // Method Sand$Pos.getX:()I
      50: invokestatic  #214                // Method java/lang/Math.max:(II)I
      53: aload_3
      54: invokevirtual #217                // Method Sand$Pos.getY:()I
      57: invokespecial #179                // Method Sand$Pos."<init>":(II)V
      60: astore        6
      62: aload         5
      64: invokevirtual #187                // Method Sand$Pos.getX:()I
      67: istore        7
      69: aload         6
      71: invokevirtual #187                // Method Sand$Pos.getX:()I
      74: istore        8
      76: iload         7
      78: iload         8
      80: if_icmpgt     238
      83: aload_2
      84: aload         5
      86: invokevirtual #217                // Method Sand$Pos.getY:()I
      89: iload_0
      90: isub
      91: invokeinterface #311,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      96: checkcast     #27                 // class java/util/List
      99: iload         7
     101: iload_1
     102: isub
     103: getstatic     #371                // Field Sand$Cell.Rock:LSand$Cell;
     106: invokeinterface #327,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     111: pop
     112: iload         7
     114: iload         8
     116: if_icmpeq     238
     119: iinc          7, 1
     122: goto          83
     125: new           #32                 // class Sand$Pos
     128: dup
     129: aload_3
     130: invokevirtual #187                // Method Sand$Pos.getX:()I
     133: aload_3
     134: invokevirtual #217                // Method Sand$Pos.getY:()I
     137: aload         4
     139: invokevirtual #217                // Method Sand$Pos.getY:()I
     142: invokestatic  #208                // Method java/lang/Math.min:(II)I
     145: invokespecial #179                // Method Sand$Pos."<init>":(II)V
     148: astore        5
     150: new           #32                 // class Sand$Pos
     153: dup
     154: aload_3
     155: invokevirtual #187                // Method Sand$Pos.getX:()I
     158: aload_3
     159: invokevirtual #217                // Method Sand$Pos.getY:()I
     162: aload         4
     164: invokevirtual #217                // Method Sand$Pos.getY:()I
     167: invokestatic  #214                // Method java/lang/Math.max:(II)I
     170: invokespecial #179                // Method Sand$Pos."<init>":(II)V
     173: astore        6
     175: aload         5
     177: invokevirtual #217                // Method Sand$Pos.getY:()I
     180: istore        7
     182: aload         6
     184: invokevirtual #217                // Method Sand$Pos.getY:()I
     187: istore        8
     189: iload         7
     191: iload         8
     193: if_icmpgt     238
     196: aload_2
     197: iload         7
     199: iload_0
     200: isub
     201: invokeinterface #311,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     206: checkcast     #27                 // class java/util/List
     209: aload         5
     211: invokevirtual #187                // Method Sand$Pos.getX:()I
     214: iload_1
     215: isub
     216: getstatic     #371                // Field Sand$Cell.Rock:LSand$Cell;
     219: invokeinterface #327,  3          // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;
     224: pop
     225: iload         7
     227: iload         8
     229: if_icmpeq     238
     232: iinc          7, 1
     235: goto          196
     238: return

  static {};
    Code:
       0: new           #2                  // class Sand
       3: dup
       4: invokespecial #375                // Method "<init>":()V
       7: putstatic     #377                // Field INSTANCE:LSand;
      10: return
}

Compiled from "Sand.kt"
public final class Sand$WhenMappings {
  public static final int[] $EnumSwitchMapping$0;

  static {};
    Code:
       0: invokestatic  #14                 // Method Sand$Cell.values:()[LSand$Cell;
       3: arraylength
       4: newarray       int
       6: astore_0
       7: nop
       8: aload_0
       9: getstatic     #18                 // Field Sand$Cell.Empty:LSand$Cell;
      12: invokevirtual #22                 // Method Sand$Cell.ordinal:()I
      15: iconst_1
      16: iastore
      17: goto          21
      20: astore_1
      21: nop
      22: aload_0
      23: getstatic     #25                 // Field Sand$Cell.Rock:LSand$Cell;
      26: invokevirtual #22                 // Method Sand$Cell.ordinal:()I
      29: iconst_2
      30: iastore
      31: goto          35
      34: astore_1
      35: nop
      36: aload_0
      37: getstatic     #28                 // Field Sand$Cell.Sand:LSand$Cell;
      40: invokevirtual #22                 // Method Sand$Cell.ordinal:()I
      43: iconst_3
      44: iastore
      45: goto          49
      48: astore_1
      49: aload_0
      50: putstatic     #32                 // Field $EnumSwitchMapping$0:[I
      53: return
    Exception table:
       from    to  target type
           7    17    20   Class java/lang/NoSuchFieldError
          21    31    34   Class java/lang/NoSuchFieldError
          35    45    48   Class java/lang/NoSuchFieldError
}