import java.io.File

fun main() {
    fun stringToPair(data: String) : IntRange {
        val nums = data.split("-")
        return IntRange(nums[0].toInt(), nums[1].toInt())
    }

    fun processInput(pair: String): Pair<IntRange, IntRange> {
        val areas = pair.split(",")
            .map { stringToPair(it) }
        return Pair(areas.first(), areas.last())
    }

    fun part1(input: List<String>): Int {
        return input.map { processInput(it) }
            .count { pair ->
                pair.first.subsumes(pair.second) || pair.second.subsumes(pair.first) }
    }

    fun part2(input: List<String>): Int {
        return input.map { processInput(it) }
            .count { pair ->
                pair.first.intersect(pair.second).any() }
    }

    val testInput = listOf(
        "2-4,6-8",
        "2-3,4-5",
        "5-7,7-9",
        "2-8,3-7",
        "6-6,4-6",
        "2-6,4-8"
    )

    // test if implementation meets criteria from the description, like:
    check(part1(testInput) == 2)
    check(part2(testInput) == 4)

    val input = File("./src/resources/Day04.txt").readLines()
    println(part1(input))
    println(part2(input))
}

fun IntRange.subsumes(other: IntRange): Boolean =
    contains(other.first) && contains(other.last)

Compiled from "Day04.kt"
public final class Day04Kt {
  public static final void main();
    Code:
       0: bipush        6
       2: anewarray     #8                  // class java/lang/String
       5: astore_1
       6: aload_1
       7: iconst_0
       8: ldc           #10                 // String 2-4,6-8
      10: aastore
      11: aload_1
      12: iconst_1
      13: ldc           #12                 // String 2-3,4-5
      15: aastore
      16: aload_1
      17: iconst_2
      18: ldc           #14                 // String 5-7,7-9
      20: aastore
      21: aload_1
      22: iconst_3
      23: ldc           #16                 // String 2-8,3-7
      25: aastore
      26: aload_1
      27: iconst_4
      28: ldc           #18                 // String 6-6,4-6
      30: aastore
      31: aload_1
      32: iconst_5
      33: ldc           #20                 // String 2-6,4-8
      35: aastore
      36: aload_1
      37: invokestatic  #26                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      40: astore_0
      41: aload_0
      42: invokestatic  #30                 // Method main$part1:(Ljava/util/List;)I
      45: iconst_2
      46: if_icmpne     53
      49: iconst_1
      50: goto          54
      53: iconst_0
      54: ifne          67
      57: new           #32                 // class java/lang/IllegalStateException
      60: dup
      61: ldc           #34                 // String Check failed.
      63: invokespecial #38                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      66: athrow
      67: aload_0
      68: invokestatic  #41                 // Method main$part2:(Ljava/util/List;)I
      71: iconst_4
      72: if_icmpne     79
      75: iconst_1
      76: goto          80
      79: iconst_0
      80: ifne          93
      83: new           #32                 // class java/lang/IllegalStateException
      86: dup
      87: ldc           #34                 // String Check failed.
      89: invokespecial #38                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      92: athrow
      93: new           #43                 // class java/io/File
      96: dup
      97: ldc           #45                 // String ./src/resources/Day04.txt
      99: invokespecial #46                 // Method java/io/File."<init>":(Ljava/lang/String;)V
     102: aconst_null
     103: iconst_1
     104: aconst_null
     105: invokestatic  #52                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
     108: astore_1
     109: aload_1
     110: invokestatic  #30                 // Method main$part1:(Ljava/util/List;)I
     113: istore_2
     114: getstatic     #58                 // Field java/lang/System.out:Ljava/io/PrintStream;
     117: iload_2
     118: invokevirtual #64                 // Method java/io/PrintStream.println:(I)V
     121: aload_1
     122: invokestatic  #41                 // Method main$part2:(Ljava/util/List;)I
     125: istore_2
     126: getstatic     #58                 // Field java/lang/System.out:Ljava/io/PrintStream;
     129: iload_2
     130: invokevirtual #64                 // Method java/io/PrintStream.println:(I)V
     133: return

  public static final boolean subsumes(kotlin.ranges.IntRange, kotlin.ranges.IntRange);
    Code:
       0: aload_0
       1: ldc           #76                 // String <this>
       3: invokestatic  #82                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #84                 // String other
       9: invokestatic  #82                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: aload_1
      14: invokevirtual #90                 // Method kotlin/ranges/IntRange.getFirst:()I
      17: invokevirtual #94                 // Method kotlin/ranges/IntRange.contains:(I)Z
      20: ifeq          38
      23: aload_0
      24: aload_1
      25: invokevirtual #97                 // Method kotlin/ranges/IntRange.getLast:()I
      28: invokevirtual #94                 // Method kotlin/ranges/IntRange.contains:(I)Z
      31: ifeq          38
      34: iconst_1
      35: goto          39
      38: iconst_0
      39: ireturn

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

  private static final kotlin.ranges.IntRange main$stringToPair(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #107                // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #8                  // class java/lang/String
       8: astore_2
       9: aload_2
      10: iconst_0
      11: ldc           #109                // String -
      13: aastore
      14: aload_2
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #115                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: astore_1
      24: new           #86                 // class kotlin/ranges/IntRange
      27: dup
      28: aload_1
      29: iconst_0
      30: invokeinterface #119,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      35: checkcast     #8                  // class java/lang/String
      38: invokestatic  #125                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      41: aload_1
      42: iconst_1
      43: invokeinterface #119,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      48: checkcast     #8                  // class java/lang/String
      51: invokestatic  #125                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
      54: invokespecial #128                // Method kotlin/ranges/IntRange."<init>":(II)V
      57: areturn

  private static final kotlin.Pair<kotlin.ranges.IntRange, kotlin.ranges.IntRange> main$processInput(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #107                // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #8                  // class java/lang/String
       8: astore_2
       9: aload_2
      10: iconst_0
      11: ldc           #136                // String ,
      13: aastore
      14: aload_2
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #115                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: checkcast     #138                // class java/lang/Iterable
      26: astore_2
      27: nop
      28: iconst_0
      29: istore_3
      30: aload_2
      31: astore        4
      33: new           #140                // class java/util/ArrayList
      36: dup
      37: aload_2
      38: bipush        10
      40: invokestatic  #144                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      43: invokespecial #146                // Method java/util/ArrayList."<init>":(I)V
      46: checkcast     #148                // class java/util/Collection
      49: astore        5
      51: iconst_0
      52: istore        6
      54: aload         4
      56: invokeinterface #152,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      61: astore        7
      63: aload         7
      65: invokeinterface #158,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      70: ifeq          113
      73: aload         7
      75: invokeinterface #162,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      80: astore        8
      82: aload         5
      84: aload         8
      86: checkcast     #8                  // class java/lang/String
      89: astore        9
      91: astore        11
      93: iconst_0
      94: istore        10
      96: aload         9
      98: invokestatic  #164                // Method main$stringToPair:(Ljava/lang/String;)Lkotlin/ranges/IntRange;
     101: aload         11
     103: swap
     104: invokeinterface #168,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     109: pop
     110: goto          63
     113: aload         5
     115: checkcast     #69                 // class java/util/List
     118: nop
     119: astore_1
     120: new           #170                // class kotlin/Pair
     123: dup
     124: aload_1
     125: invokestatic  #174                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     128: aload_1
     129: invokestatic  #177                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     132: invokespecial #180                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     135: areturn

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #138                // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: astore_3
       9: new           #140                // class java/util/ArrayList
      12: dup
      13: aload_1
      14: bipush        10
      16: invokestatic  #144                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      19: invokespecial #146                // Method java/util/ArrayList."<init>":(I)V
      22: checkcast     #148                // class java/util/Collection
      25: astore        4
      27: iconst_0
      28: istore        5
      30: aload_3
      31: invokeinterface #152,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      36: astore        6
      38: aload         6
      40: invokeinterface #158,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      45: ifeq          88
      48: aload         6
      50: invokeinterface #162,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      55: astore        7
      57: aload         4
      59: aload         7
      61: checkcast     #8                  // class java/lang/String
      64: astore        8
      66: astore        10
      68: iconst_0
      69: istore        9
      71: aload         8
      73: invokestatic  #197                // Method main$processInput:(Ljava/lang/String;)Lkotlin/Pair;
      76: aload         10
      78: swap
      79: invokeinterface #168,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      84: pop
      85: goto          38
      88: aload         4
      90: checkcast     #69                 // class java/util/List
      93: nop
      94: checkcast     #138                // class java/lang/Iterable
      97: astore_1
      98: nop
      99: iconst_0
     100: istore_2
     101: aload_1
     102: instanceof    #148                // class java/util/Collection
     105: ifeq          124
     108: aload_1
     109: checkcast     #148                // class java/util/Collection
     112: invokeinterface #200,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     117: ifeq          124
     120: iconst_0
     121: goto          229
     124: iconst_0
     125: istore_3
     126: aload_1
     127: invokeinterface #152,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     132: astore        4
     134: aload         4
     136: invokeinterface #158,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     141: ifeq          228
     144: aload         4
     146: invokeinterface #162,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     151: astore        5
     153: aload         5
     155: checkcast     #170                // class kotlin/Pair
     158: astore        6
     160: iconst_0
     161: istore        7
     163: aload         6
     165: invokevirtual #202                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     168: checkcast     #86                 // class kotlin/ranges/IntRange
     171: aload         6
     173: invokevirtual #205                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     176: checkcast     #86                 // class kotlin/ranges/IntRange
     179: invokestatic  #207                // Method subsumes:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z
     182: ifne          207
     185: aload         6
     187: invokevirtual #205                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     190: checkcast     #86                 // class kotlin/ranges/IntRange
     193: aload         6
     195: invokevirtual #202                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     198: checkcast     #86                 // class kotlin/ranges/IntRange
     201: invokestatic  #207                // Method subsumes:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z
     204: ifeq          211
     207: iconst_1
     208: goto          212
     211: iconst_0
     212: ifeq          134
     215: iinc          3, 1
     218: iload_3
     219: ifge          134
     222: invokestatic  #210                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     225: goto          134
     228: iload_3
     229: ireturn

  private static final int main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: checkcast     #138                // class java/lang/Iterable
       4: astore_1
       5: iconst_0
       6: istore_2
       7: aload_1
       8: astore_3
       9: new           #140                // class java/util/ArrayList
      12: dup
      13: aload_1
      14: bipush        10
      16: invokestatic  #144                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      19: invokespecial #146                // Method java/util/ArrayList."<init>":(I)V
      22: checkcast     #148                // class java/util/Collection
      25: astore        4
      27: iconst_0
      28: istore        5
      30: aload_3
      31: invokeinterface #152,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      36: astore        6
      38: aload         6
      40: invokeinterface #158,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      45: ifeq          88
      48: aload         6
      50: invokeinterface #162,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      55: astore        7
      57: aload         4
      59: aload         7
      61: checkcast     #8                  // class java/lang/String
      64: astore        8
      66: astore        10
      68: iconst_0
      69: istore        9
      71: aload         8
      73: invokestatic  #197                // Method main$processInput:(Ljava/lang/String;)Lkotlin/Pair;
      76: aload         10
      78: swap
      79: invokeinterface #168,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      84: pop
      85: goto          38
      88: aload         4
      90: checkcast     #69                 // class java/util/List
      93: nop
      94: checkcast     #138                // class java/lang/Iterable
      97: astore_1
      98: nop
      99: iconst_0
     100: istore_2
     101: aload_1
     102: instanceof    #148                // class java/util/Collection
     105: ifeq          124
     108: aload_1
     109: checkcast     #148                // class java/util/Collection
     112: invokeinterface #200,  1          // InterfaceMethod java/util/Collection.isEmpty:()Z
     117: ifeq          124
     120: iconst_0
     121: goto          205
     124: iconst_0
     125: istore_3
     126: aload_1
     127: invokeinterface #152,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     132: astore        4
     134: aload         4
     136: invokeinterface #158,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     141: ifeq          204
     144: aload         4
     146: invokeinterface #162,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     151: astore        5
     153: aload         5
     155: checkcast     #170                // class kotlin/Pair
     158: astore        6
     160: iconst_0
     161: istore        7
     163: aload         6
     165: invokevirtual #202                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     168: checkcast     #138                // class java/lang/Iterable
     171: aload         6
     173: invokevirtual #205                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     176: checkcast     #138                // class java/lang/Iterable
     179: invokestatic  #221                // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;
     182: checkcast     #138                // class java/lang/Iterable
     185: invokestatic  #225                // Method kotlin/collections/CollectionsKt.any:(Ljava/lang/Iterable;)Z
     188: ifeq          134
     191: iinc          3, 1
     194: iload_3
     195: ifge          134
     198: invokestatic  #210                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
     201: goto          134
     204: iload_3
     205: ireturn
}


import java.io.File

fun main() {
    fun dataToParts(input: String): Pair<String, String> {
        val parts = input.split("\n\n")
        return parts[0] to parts[1]
    }

    fun initStacks(input: String): Map<Int, MutableList<Char>>{
        val lines = input.split("\n").reversed()
        val stacks = lines[0].filter { it != ' ' }.map { c -> c.digitToInt() to mutableListOf<Char>() }.toMap()
        lines.drop(1).forEach { line -> line.chunked(4).forEachIndexed { i, s ->
            if (s[1] != ' ') stacks[i+1]?.add(s[1])
        } }
        return stacks
    }

    fun readMoves(input: String): List<Triple<Int, Int, Int>> {
        return input.lines().map { line -> line.split(" ")}
            .map { Triple(it[1].toInt(), it[3].toInt(), it[5].toInt())}
    }

    fun part1(input: String): String {
        val (stackData, moveData) = dataToParts(input)
        val stacks = initStacks(stackData)
        val moves = readMoves(moveData)

        moves.forEach { move ->
            repeat (move.first) {
                stacks[move.third]?.add(stacks[move.second]?.removeLast() ?: ' ')
            }
        }
        return stacks.map {
            it.value.last() }.joinToString("")
    }

    fun part2(input: String): String {
        val (stackData, moveData) = dataToParts(input)
        val stacks = initStacks(stackData)
        val moves = readMoves(moveData)
        moves.forEach { move ->
            val crates = stacks[move.second]?.takeLast(move.first) ?: listOf()
            repeat(move.first) { stacks[move.second]?.removeLast() }
            stacks[move.third]?.addAll(crates)
        }
        return stacks.map {
            it.value.last() }.joinToString("")
    }

    val testInput = listOf<String>(
        "    [D]",
        "[N] [C]",
        "[Z] [M] [P]",
        " 1   2   3",
        "",
        "move 1 from 2 to 1",
        "move 3 from 1 to 3",
        "move 2 from 2 to 1",
        "move 1 from 1 to 2"
    ).joinToString("\n")

    // test if implementation meets criteria from the description, like:
    val test = part1(testInput)
    println(test)
    check(test == "CMZ")
//    check(part2(testInput) == 42)

    val input = File("./src/resources/Day05.txt").readText()
    println(part1(input))
    println(part2(input))
}

Compiled from "Day05.kt"
public final class Day05Kt {
  public static final void main();
    Code:
       0: bipush        9
       2: anewarray     #8                  // class java/lang/String
       5: astore_1
       6: aload_1
       7: iconst_0
       8: ldc           #10                 // String     [D]
      10: aastore
      11: aload_1
      12: iconst_1
      13: ldc           #12                 // String [N] [C]
      15: aastore
      16: aload_1
      17: iconst_2
      18: ldc           #14                 // String [Z] [M] [P]
      20: aastore
      21: aload_1
      22: iconst_3
      23: ldc           #16                 // String  1   2   3
      25: aastore
      26: aload_1
      27: iconst_4
      28: ldc           #18                 // String
      30: aastore
      31: aload_1
      32: iconst_5
      33: ldc           #20                 // String move 1 from 2 to 1
      35: aastore
      36: aload_1
      37: bipush        6
      39: ldc           #22                 // String move 3 from 1 to 3
      41: aastore
      42: aload_1
      43: bipush        7
      45: ldc           #24                 // String move 2 from 2 to 1
      47: aastore
      48: aload_1
      49: bipush        8
      51: ldc           #26                 // String move 1 from 1 to 2
      53: aastore
      54: aload_1
      55: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      58: checkcast     #34                 // class java/lang/Iterable
      61: ldc           #36                 // String \n
      63: checkcast     #38                 // class java/lang/CharSequence
      66: aconst_null
      67: aconst_null
      68: iconst_0
      69: aconst_null
      70: aconst_null
      71: bipush        62
      73: aconst_null
      74: invokestatic  #42                 // 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;
      77: astore_0
      78: aload_0
      79: invokestatic  #46                 // Method main$part1:(Ljava/lang/String;)Ljava/lang/String;
      82: astore_1
      83: getstatic     #52                 // Field java/lang/System.out:Ljava/io/PrintStream;
      86: aload_1
      87: invokevirtual #58                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      90: aload_1
      91: ldc           #60                 // String CMZ
      93: invokestatic  #66                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      96: ifne          109
      99: new           #68                 // class java/lang/IllegalStateException
     102: dup
     103: ldc           #70                 // String Check failed.
     105: invokespecial #74                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     108: athrow
     109: new           #76                 // class java/io/File
     112: dup
     113: ldc           #78                 // String ./src/resources/Day05.txt
     115: invokespecial #79                 // Method java/io/File."<init>":(Ljava/lang/String;)V
     118: aconst_null
     119: iconst_1
     120: aconst_null
     121: invokestatic  #85                 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;
     124: astore_2
     125: aload_2
     126: invokestatic  #46                 // Method main$part1:(Ljava/lang/String;)Ljava/lang/String;
     129: getstatic     #52                 // Field java/lang/System.out:Ljava/io/PrintStream;
     132: swap
     133: invokevirtual #58                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     136: aload_2
     137: invokestatic  #88                 // Method main$part2:(Ljava/lang/String;)Ljava/lang/String;
     140: getstatic     #52                 // Field java/lang/System.out:Ljava/io/PrintStream;
     143: swap
     144: invokevirtual #58                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     147: return

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

  private static final kotlin.Pair<java.lang.String, java.lang.String> main$dataToParts(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #38                 // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #8                  // class java/lang/String
       8: astore_2
       9: aload_2
      10: iconst_0
      11: ldc           #102                // String \n\n
      13: aastore
      14: aload_2
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #108                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: astore_1
      24: aload_1
      25: iconst_0
      26: invokeinterface #114,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      31: aload_1
      32: iconst_1
      33: invokeinterface #114,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      38: invokestatic  #120                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      41: areturn

  private static final java.util.Map<java.lang.Integer, java.util.List<java.lang.Character>> main$initStacks(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #38                 // class java/lang/CharSequence
       4: iconst_1
       5: anewarray     #8                  // class java/lang/String
       8: astore_2
       9: aload_2
      10: iconst_0
      11: ldc           #36                 // String \n
      13: aastore
      14: aload_2
      15: iconst_0
      16: iconst_0
      17: bipush        6
      19: aconst_null
      20: invokestatic  #108                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      23: checkcast     #34                 // class java/lang/Iterable
      26: invokestatic  #129                // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
      29: astore_1
      30: aload_1
      31: iconst_0
      32: invokeinterface #114,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      37: checkcast     #8                  // class java/lang/String
      40: astore_3
      41: iconst_0
      42: istore        4
      44: aload_3
      45: checkcast     #38                 // class java/lang/CharSequence
      48: astore        5
      50: new           #131                // class java/lang/StringBuilder
      53: dup
      54: invokespecial #133                // Method java/lang/StringBuilder."<init>":()V
      57: checkcast     #135                // class java/lang/Appendable
      60: astore        6
      62: iconst_0
      63: istore        7
      65: iconst_0
      66: istore        8
      68: aload         5
      70: invokeinterface #139,  1          // InterfaceMethod java/lang/CharSequence.length:()I
      75: istore        9
      77: iload         8
      79: iload         9
      81: if_icmpge     133
      84: aload         5
      86: iload         8
      88: invokeinterface #143,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
      93: istore        10
      95: iload         10
      97: istore        11
      99: iconst_0
     100: istore        12
     102: iload         11
     104: bipush        32
     106: if_icmpeq     113
     109: iconst_1
     110: goto          114
     113: iconst_0
     114: ifeq          127
     117: aload         6
     119: iload         10
     121: invokeinterface #147,  2          // InterfaceMethod java/lang/Appendable.append:(C)Ljava/lang/Appendable;
     126: pop
     127: iinc          8, 1
     130: goto          77
     133: aload         6
     135: checkcast     #131                // class java/lang/StringBuilder
     138: invokevirtual #151                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     141: checkcast     #38                 // class java/lang/CharSequence
     144: astore_3
     145: nop
     146: iconst_0
     147: istore        4
     149: aload_3
     150: astore        5
     152: new           #153                // class java/util/ArrayList
     155: dup
     156: aload_3
     157: invokeinterface #139,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     162: invokespecial #156                // Method java/util/ArrayList."<init>":(I)V
     165: checkcast     #158                // class java/util/Collection
     168: astore        6
     170: iconst_0
     171: istore        7
     173: iconst_0
     174: istore        8
     176: iload         8
     178: aload         5
     180: invokeinterface #139,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     185: if_icmpge     246
     188: aload         5
     190: iload         8
     192: invokeinterface #143,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     197: istore        9
     199: aload         6
     201: iload         9
     203: istore        10
     205: astore        18
     207: iconst_0
     208: istore        11
     210: iload         10
     212: invokestatic  #164                // Method kotlin/text/CharsKt.digitToInt:(C)I
     215: invokestatic  #170                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     218: new           #153                // class java/util/ArrayList
     221: dup
     222: invokespecial #171                // Method java/util/ArrayList."<init>":()V
     225: checkcast     #110                // class java/util/List
     228: invokestatic  #120                // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     231: aload         18
     233: swap
     234: invokeinterface #175,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     239: pop
     240: iinc          8, 1
     243: goto          176
     246: aload         6
     248: checkcast     #110                // class java/util/List
     251: nop
     252: checkcast     #34                 // class java/lang/Iterable
     255: invokestatic  #181                // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;
     258: astore_2
     259: aload_1
     260: checkcast     #34                 // class java/lang/Iterable
     263: iconst_1
     264: invokestatic  #185                // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;
     267: checkcast     #34                 // class java/lang/Iterable
     270: astore_3
     271: iconst_0
     272: istore        4
     274: aload_3
     275: invokeinterface #189,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     280: astore        5
     282: aload         5
     284: invokeinterface #195,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     289: ifeq          449
     292: aload         5
     294: invokeinterface #199,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     299: astore        6
     301: aload         6
     303: checkcast     #8                  // class java/lang/String
     306: astore        7
     308: iconst_0
     309: istore        8
     311: aload         7
     313: checkcast     #38                 // class java/lang/CharSequence
     316: iconst_4
     317: invokestatic  #203                // Method kotlin/text/StringsKt.chunked:(Ljava/lang/CharSequence;I)Ljava/util/List;
     320: checkcast     #34                 // class java/lang/Iterable
     323: astore        9
     325: iconst_0
     326: istore        10
     328: iconst_0
     329: istore        11
     331: aload         9
     333: invokeinterface #189,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     338: astore        12
     340: aload         12
     342: invokeinterface #195,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     347: ifeq          443
     350: aload         12
     352: invokeinterface #199,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     357: astore        13
     359: iload         11
     361: iinc          11, 1
     364: istore        14
     366: iload         14
     368: ifge          374
     371: invokestatic  #206                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     374: iload         14
     376: aload         13
     378: checkcast     #8                  // class java/lang/String
     381: astore        15
     383: istore        16
     385: iconst_0
     386: istore        17
     388: aload         15
     390: iconst_1
     391: invokevirtual #207                // Method java/lang/String.charAt:(I)C
     394: bipush        32
     396: if_icmpeq     438
     399: aload_2
     400: iload         16
     402: iconst_1
     403: iadd
     404: invokestatic  #170                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     407: invokeinterface #212,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     412: checkcast     #110                // class java/util/List
     415: dup
     416: ifnull        437
     419: aload         15
     421: iconst_1
     422: invokevirtual #207                // Method java/lang/String.charAt:(I)C
     425: invokestatic  #217                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     428: invokeinterface #218,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     433: pop
     434: goto          438
     437: pop
     438: nop
     439: nop
     440: goto          340
     443: nop
     444: nop
     445: nop
     446: goto          282
     449: nop
     450: aload_2
     451: areturn

  private static final java.util.List<kotlin.Triple<java.lang.Integer, java.lang.Integer, java.lang.Integer>> main$readMoves(java.lang.String);
    Code:
       0: aload_0
       1: checkcast     #38                 // class java/lang/CharSequence
       4: invokestatic  #263                // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;
       7: checkcast     #34                 // class java/lang/Iterable
      10: astore_1
      11: iconst_0
      12: istore_2
      13: aload_1
      14: astore_3
      15: new           #153                // class java/util/ArrayList
      18: dup
      19: aload_1
      20: bipush        10
      22: invokestatic  #267                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      25: invokespecial #156                // Method java/util/ArrayList."<init>":(I)V
      28: checkcast     #158                // class java/util/Collection
      31: astore        4
      33: iconst_0
      34: istore        5
      36: aload_3
      37: invokeinterface #189,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      42: astore        6
      44: aload         6
      46: invokeinterface #195,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      51: ifeq          117
      54: aload         6
      56: invokeinterface #199,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      61: astore        7
      63: aload         4
      65: aload         7
      67: checkcast     #8                  // class java/lang/String
      70: astore        8
      72: astore        11
      74: iconst_0
      75: istore        9
      77: aload         8
      79: checkcast     #38                 // class java/lang/CharSequence
      82: iconst_1
      83: anewarray     #8                  // class java/lang/String
      86: astore        10
      88: aload         10
      90: iconst_0
      91: ldc_w         #269                // String
      94: aastore
      95: aload         10
      97: iconst_0
      98: iconst_0
      99: bipush        6
     101: aconst_null
     102: invokestatic  #108                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     105: aload         11
     107: swap
     108: invokeinterface #175,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     113: pop
     114: goto          44
     117: aload         4
     119: checkcast     #110                // class java/util/List
     122: nop
     123: checkcast     #34                 // class java/lang/Iterable
     126: astore_1
     127: nop
     128: iconst_0
     129: istore_2
     130: aload_1
     131: astore_3
     132: new           #153                // class java/util/ArrayList
     135: dup
     136: aload_1
     137: bipush        10
     139: invokestatic  #267                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     142: invokespecial #156                // Method java/util/ArrayList."<init>":(I)V
     145: checkcast     #158                // class java/util/Collection
     148: astore        4
     150: iconst_0
     151: istore        5
     153: aload_3
     154: invokeinterface #189,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     159: astore        6
     161: aload         6
     163: invokeinterface #195,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     168: ifeq          264
     171: aload         6
     173: invokeinterface #199,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     178: astore        7
     180: aload         4
     182: aload         7
     184: checkcast     #110                // class java/util/List
     187: astore        8
     189: astore        11
     191: iconst_0
     192: istore        9
     194: new           #271                // class kotlin/Triple
     197: dup
     198: aload         8
     200: iconst_1
     201: invokeinterface #114,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     206: checkcast     #8                  // class java/lang/String
     209: invokestatic  #275                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     212: invokestatic  #170                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     215: aload         8
     217: iconst_3
     218: invokeinterface #114,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     223: checkcast     #8                  // class java/lang/String
     226: invokestatic  #275                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     229: invokestatic  #170                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     232: aload         8
     234: iconst_5
     235: invokeinterface #114,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     240: checkcast     #8                  // class java/lang/String
     243: invokestatic  #275                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     246: invokestatic  #170                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     249: invokespecial #278                // Method kotlin/Triple."<init>":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
     252: aload         11
     254: swap
     255: invokeinterface #175,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     260: pop
     261: goto          161
     264: aload         4
     266: checkcast     #110                // class java/util/List
     269: nop
     270: areturn

  private static final java.lang.String main$part1(java.lang.String);
    Code:
       0: aload_0
       1: invokestatic  #282                // Method main$dataToParts:(Ljava/lang/String;)Lkotlin/Pair;
       4: astore_1
       5: aload_1
       6: invokevirtual #287                // Method kotlin/Pair.component1:()Ljava/lang/Object;
       9: checkcast     #8                  // class java/lang/String
      12: astore_2
      13: aload_1
      14: invokevirtual #290                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      17: checkcast     #8                  // class java/lang/String
      20: astore_3
      21: aload_2
      22: invokestatic  #292                // Method main$initStacks:(Ljava/lang/String;)Ljava/util/Map;
      25: astore        4
      27: aload_3
      28: invokestatic  #294                // Method main$readMoves:(Ljava/lang/String;)Ljava/util/List;
      31: astore        5
      33: aload         5
      35: checkcast     #34                 // class java/lang/Iterable
      38: astore        6
      40: iconst_0
      41: istore        7
      43: aload         6
      45: invokeinterface #189,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      50: astore        8
      52: aload         8
      54: invokeinterface #195,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      59: ifeq          195
      62: aload         8
      64: invokeinterface #199,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      69: astore        9
      71: aload         9
      73: checkcast     #271                // class kotlin/Triple
      76: astore        10
      78: iconst_0
      79: istore        11
      81: aload         10
      83: invokevirtual #297                // Method kotlin/Triple.getFirst:()Ljava/lang/Object;
      86: checkcast     #299                // class java/lang/Number
      89: invokevirtual #302                // Method java/lang/Number.intValue:()I
      92: istore        12
      94: iconst_0
      95: istore        13
      97: iload         13
      99: iload         12
     101: if_icmpge     190
     104: iload         13
     106: istore        14
     108: iconst_0
     109: istore        15
     111: aload         4
     113: aload         10
     115: invokevirtual #305                // Method kotlin/Triple.getThird:()Ljava/lang/Object;
     118: invokeinterface #212,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     123: checkcast     #110                // class java/util/List
     126: dup
     127: ifnull        182
     130: aload         4
     132: aload         10
     134: invokevirtual #308                // Method kotlin/Triple.getSecond:()Ljava/lang/Object;
     137: invokeinterface #212,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     142: checkcast     #110                // class java/util/List
     145: dup
     146: ifnull        167
     149: invokeinterface #311,  1          // InterfaceMethod java/util/List.removeLast:()Ljava/lang/Object;
     154: checkcast     #214                // class java/lang/Character
     157: dup
     158: ifnull        167
     161: invokevirtual #315                // Method java/lang/Character.charValue:()C
     164: goto          170
     167: pop
     168: bipush        32
     170: invokestatic  #217                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     173: invokeinterface #218,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     178: pop
     179: goto          183
     182: pop
     183: nop
     184: iinc          13, 1
     187: goto          97
     190: nop
     191: nop
     192: goto          52
     195: nop
     196: aload         4
     198: astore        6
     200: iconst_0
     201: istore        7
     203: aload         6
     205: astore        8
     207: new           #153                // class java/util/ArrayList
     210: dup
     211: aload         6
     213: invokeinterface #318,  1          // InterfaceMethod java/util/Map.size:()I
     218: invokespecial #156                // Method java/util/ArrayList."<init>":(I)V
     221: checkcast     #158                // class java/util/Collection
     224: astore        9
     226: iconst_0
     227: istore        10
     229: aload         8
     231: invokeinterface #322,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     236: invokeinterface #325,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     241: astore        11
     243: aload         11
     245: invokeinterface #195,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     250: ifeq          310
     253: aload         11
     255: invokeinterface #199,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     260: checkcast     #327                // class java/util/Map$Entry
     263: astore        12
     265: aload         9
     267: aload         12
     269: astore        13
     271: astore        16
     273: iconst_0
     274: istore        14
     276: aload         13
     278: invokeinterface #330,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     283: checkcast     #110                // class java/util/List
     286: invokestatic  #334                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     289: checkcast     #214                // class java/lang/Character
     292: invokevirtual #315                // Method java/lang/Character.charValue:()C
     295: invokestatic  #217                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     298: aload         16
     300: swap
     301: invokeinterface #175,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     306: pop
     307: goto          243
     310: aload         9
     312: checkcast     #110                // class java/util/List
     315: nop
     316: checkcast     #34                 // class java/lang/Iterable
     319: ldc           #18                 // String
     321: checkcast     #38                 // class java/lang/CharSequence
     324: aconst_null
     325: aconst_null
     326: iconst_0
     327: aconst_null
     328: aconst_null
     329: bipush        62
     331: aconst_null
     332: invokestatic  #42                 // 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;
     335: areturn

  private static final java.lang.String main$part2(java.lang.String);
    Code:
       0: aload_0
       1: invokestatic  #282                // Method main$dataToParts:(Ljava/lang/String;)Lkotlin/Pair;
       4: astore_1
       5: aload_1
       6: invokevirtual #287                // Method kotlin/Pair.component1:()Ljava/lang/Object;
       9: checkcast     #8                  // class java/lang/String
      12: astore_2
      13: aload_1
      14: invokevirtual #290                // Method kotlin/Pair.component2:()Ljava/lang/Object;
      17: checkcast     #8                  // class java/lang/String
      20: astore_3
      21: aload_2
      22: invokestatic  #292                // Method main$initStacks:(Ljava/lang/String;)Ljava/util/Map;
      25: astore        4
      27: aload_3
      28: invokestatic  #294                // Method main$readMoves:(Ljava/lang/String;)Ljava/util/List;
      31: astore        5
      33: aload         5
      35: checkcast     #34                 // class java/lang/Iterable
      38: astore        6
      40: iconst_0
      41: istore        7
      43: aload         6
      45: invokeinterface #189,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      50: astore        8
      52: aload         8
      54: invokeinterface #195,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      59: ifeq          231
      62: aload         8
      64: invokeinterface #199,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      69: astore        9
      71: aload         9
      73: checkcast     #271                // class kotlin/Triple
      76: astore        10
      78: iconst_0
      79: istore        11
      81: aload         4
      83: aload         10
      85: invokevirtual #308                // Method kotlin/Triple.getSecond:()Ljava/lang/Object;
      88: invokeinterface #212,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
      93: checkcast     #110                // class java/util/List
      96: dup
      97: ifnull        118
     100: aload         10
     102: invokevirtual #297                // Method kotlin/Triple.getFirst:()Ljava/lang/Object;
     105: checkcast     #299                // class java/lang/Number
     108: invokevirtual #302                // Method java/lang/Number.intValue:()I
     111: invokestatic  #347                // Method kotlin/collections/CollectionsKt.takeLast:(Ljava/util/List;I)Ljava/util/List;
     114: dup
     115: ifnonnull     122
     118: pop
     119: invokestatic  #351                // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     122: astore        12
     124: aload         10
     126: invokevirtual #297                // Method kotlin/Triple.getFirst:()Ljava/lang/Object;
     129: checkcast     #299                // class java/lang/Number
     132: invokevirtual #302                // Method java/lang/Number.intValue:()I
     135: istore        13
     137: iconst_0
     138: istore        14
     140: iload         14
     142: iload         13
     144: if_icmpge     192
     147: iload         14
     149: istore        15
     151: iconst_0
     152: istore        16
     154: aload         4
     156: aload         10
     158: invokevirtual #308                // Method kotlin/Triple.getSecond:()Ljava/lang/Object;
     161: invokeinterface #212,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     166: checkcast     #110                // class java/util/List
     169: dup
     170: ifnull        185
     173: invokeinterface #311,  1          // InterfaceMethod java/util/List.removeLast:()Ljava/lang/Object;
     178: checkcast     #214                // class java/lang/Character
     181: pop
     182: goto          186
     185: pop
     186: iinc          14, 1
     189: goto          140
     192: aload         4
     194: aload         10
     196: invokevirtual #305                // Method kotlin/Triple.getThird:()Ljava/lang/Object;
     199: invokeinterface #212,  2          // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;
     204: checkcast     #110                // class java/util/List
     207: dup
     208: ifnull        225
     211: aload         12
     213: checkcast     #158                // class java/util/Collection
     216: invokeinterface #355,  2          // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z
     221: pop
     222: goto          226
     225: pop
     226: nop
     227: nop
     228: goto          52
     231: nop
     232: aload         4
     234: astore        6
     236: iconst_0
     237: istore        7
     239: aload         6
     241: astore        8
     243: new           #153                // class java/util/ArrayList
     246: dup
     247: aload         6
     249: invokeinterface #318,  1          // InterfaceMethod java/util/Map.size:()I
     254: invokespecial #156                // Method java/util/ArrayList."<init>":(I)V
     257: checkcast     #158                // class java/util/Collection
     260: astore        9
     262: iconst_0
     263: istore        10
     265: aload         8
     267: invokeinterface #322,  1          // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;
     272: invokeinterface #325,  1          // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;
     277: astore        11
     279: aload         11
     281: invokeinterface #195,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     286: ifeq          346
     289: aload         11
     291: invokeinterface #199,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     296: checkcast     #327                // class java/util/Map$Entry
     299: astore        12
     301: aload         9
     303: aload         12
     305: astore        13
     307: astore        17
     309: iconst_0
     310: istore        14
     312: aload         13
     314: invokeinterface #330,  1          // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;
     319: checkcast     #110                // class java/util/List
     322: invokestatic  #334                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     325: checkcast     #214                // class java/lang/Character
     328: invokevirtual #315                // Method java/lang/Character.charValue:()C
     331: invokestatic  #217                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     334: aload         17
     336: swap
     337: invokeinterface #175,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     342: pop
     343: goto          279
     346: aload         9
     348: checkcast     #110                // class java/util/List
     351: nop
     352: checkcast     #34                 // class java/lang/Iterable
     355: ldc           #18                 // String
     357: checkcast     #38                 // class java/lang/CharSequence
     360: aconst_null
     361: aconst_null
     362: iconst_0
     363: aconst_null
     364: aconst_null
     365: bipush        62
     367: aconst_null
     368: invokestatic  #42                 // 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;
     371: areturn
}


import java.io.File
import java.util.Dictionary

fun main() {
    fun buildFilesystem(data: List<String>): Directory {
        val root = Directory("/", null)
        var cwd = root

        data.forEachIndexed { i, line ->
            val curr = line.split(" ")
            when {
                curr[1] == "cd" -> cwd = if (curr[2] == "/") root
                                        else if (curr[2] == "..") cwd.parent ?: cwd
                                        else cwd.contents.firstOrNull { it.name == curr[2] } as? Directory ?: Directory(curr[2], cwd).also { cwd.contents.add(it) }
                curr[0] == "dir" -> cwd.contents.firstOrNull { it.name == curr[1] } ?: cwd.contents.add(Directory(curr[1], cwd))
                curr[1] == "ls" -> {}
                curr[0].matches(Regex("\\d+")) -> cwd.contents.firstOrNull { it.name == curr[1] } ?: cwd.contents.add(Data(curr[1], curr[0].toInt(), cwd))
            }
        }
        return root
    }

    fun part1(input: List<String>): Int {
        val fs = buildFilesystem(input)
//        fs.filetree().forEach { println(it) }

        val bigdirs = fs.listAll().filter { it is Directory && it.size <= 100000 }
        return bigdirs.sumOf { it.size }
    }

    fun part2(input: List<String>): Int {
        val fs = buildFilesystem(input)

        val dirs = fs.listAll().filterIsInstance<Directory>()
        val target = fs.size - 4e7
        return dirs.filter { it.size >= target }.minBy { it.size }.size
    }

    val testInput = listOf<String>(
        "$ cd /",
        "$ ls",
        "dir a",
        "14848514 b.txt",
        "8504156 c.dat",
        "dir d",
        "$ cd a",
        "$ ls",
        "dir e",
        "29116 f",
        "2557 g",
        "62596 h.lst",
        "$ cd e",
        "$ ls",
        "584 i",
        "$ cd ..",
        "$ cd ..",
        "$ cd d",
        "$ ls",
        "4060174 j",
        "8033020 d.log",
        "5626152 d.ext",
        "7214296 k",
    )

    // test if implementation meets criteria from the description, like:
    check(part1(testInput) == 95437)
//    check(part2(testInput) == 42)

    val input = File("./src/resources/Day07.txt").readLines()
    println(part1(input))
    println(part2(input))
}

sealed class FsNode(val name: String, val parent: Directory?) {
    abstract val size: Int
    abstract fun listAll() : List<FsNode>
}

class Directory(
    name: String,
    parent: Directory?,
    val contents: MutableList<FsNode> = mutableListOf()
) : FsNode(name, parent) {
    override val size
        get() = contents.sumOf { it.size }
    override fun toString(): String {
        return "- $name (dir, size = $size)" //\n  " + contents.sortedBy { it.name }.joinToString("\n  ")
    }

    fun filetree() : List<String> {
        return listOf("$this") + contents.flatMap { (it as? Directory)?.filetree() ?: listOf("$it") }.map { "  $it" }
    }

    override fun listAll() : List<FsNode> = listOf(this) + contents.flatMap { it.listAll() }
}

class Data(name: String, override val size: Int, parent: Directory) : FsNode(name, parent) {
    override fun toString(): String {
        return "- $name (file, size = $size)"
    }

    override fun listAll() : List<FsNode> = listOf(this)
}

Compiled from "Day07.kt"
public final class Day07Kt {
  public static final void main();
    Code:
       0: bipush        23
       2: anewarray     #8                  // class java/lang/String
       5: astore_1
       6: aload_1
       7: iconst_0
       8: ldc           #10                 // String $ cd /
      10: aastore
      11: aload_1
      12: iconst_1
      13: ldc           #12                 // String $ ls
      15: aastore
      16: aload_1
      17: iconst_2
      18: ldc           #14                 // String dir a
      20: aastore
      21: aload_1
      22: iconst_3
      23: ldc           #16                 // String 14848514 b.txt
      25: aastore
      26: aload_1
      27: iconst_4
      28: ldc           #18                 // String 8504156 c.dat
      30: aastore
      31: aload_1
      32: iconst_5
      33: ldc           #20                 // String dir d
      35: aastore
      36: aload_1
      37: bipush        6
      39: ldc           #22                 // String $ cd a
      41: aastore
      42: aload_1
      43: bipush        7
      45: ldc           #12                 // String $ ls
      47: aastore
      48: aload_1
      49: bipush        8
      51: ldc           #24                 // String dir e
      53: aastore
      54: aload_1
      55: bipush        9
      57: ldc           #26                 // String 29116 f
      59: aastore
      60: aload_1
      61: bipush        10
      63: ldc           #28                 // String 2557 g
      65: aastore
      66: aload_1
      67: bipush        11
      69: ldc           #30                 // String 62596 h.lst
      71: aastore
      72: aload_1
      73: bipush        12
      75: ldc           #32                 // String $ cd e
      77: aastore
      78: aload_1
      79: bipush        13
      81: ldc           #12                 // String $ ls
      83: aastore
      84: aload_1
      85: bipush        14
      87: ldc           #34                 // String 584 i
      89: aastore
      90: aload_1
      91: bipush        15
      93: ldc           #36                 // String $ cd ..
      95: aastore
      96: aload_1
      97: bipush        16
      99: ldc           #36                 // String $ cd ..
     101: aastore
     102: aload_1
     103: bipush        17
     105: ldc           #38                 // String $ cd d
     107: aastore
     108: aload_1
     109: bipush        18
     111: ldc           #12                 // String $ ls
     113: aastore
     114: aload_1
     115: bipush        19
     117: ldc           #40                 // String 4060174 j
     119: aastore
     120: aload_1
     121: bipush        20
     123: ldc           #42                 // String 8033020 d.log
     125: aastore
     126: aload_1
     127: bipush        21
     129: ldc           #44                 // String 5626152 d.ext
     131: aastore
     132: aload_1
     133: bipush        22
     135: ldc           #46                 // String 7214296 k
     137: aastore
     138: aload_1
     139: invokestatic  #52                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     142: astore_0
     143: aload_0
     144: invokestatic  #56                 // Method main$part1:(Ljava/util/List;)I
     147: ldc           #57                 // int 95437
     149: if_icmpne     156
     152: iconst_1
     153: goto          157
     156: iconst_0
     157: ifne          170
     160: new           #59                 // class java/lang/IllegalStateException
     163: dup
     164: ldc           #61                 // String Check failed.
     166: invokespecial #65                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     169: athrow
     170: new           #67                 // class java/io/File
     173: dup
     174: ldc           #69                 // String ./src/resources/Day07.txt
     176: invokespecial #70                 // Method java/io/File."<init>":(Ljava/lang/String;)V
     179: aconst_null
     180: iconst_1
     181: aconst_null
     182: invokestatic  #76                 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;
     185: astore_1
     186: aload_1
     187: invokestatic  #56                 // Method main$part1:(Ljava/util/List;)I
     190: istore_2
     191: getstatic     #82                 // Field java/lang/System.out:Ljava/io/PrintStream;
     194: iload_2
     195: invokevirtual #88                 // Method java/io/PrintStream.println:(I)V
     198: aload_1
     199: invokestatic  #91                 // Method main$part2:(Ljava/util/List;)I
     202: istore_2
     203: getstatic     #82                 // Field java/lang/System.out:Ljava/io/PrintStream;
     206: iload_2
     207: invokevirtual #88                 // Method java/io/PrintStream.println:(I)V
     210: return

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

  private static final Directory main$buildFilesystem(java.util.List<java.lang.String>);
    Code:
       0: new           #107                // class Directory
       3: dup
       4: ldc           #109                // String /
       6: aconst_null
       7: aconst_null
       8: iconst_4
       9: aconst_null
      10: invokespecial #112                // Method Directory."<init>":(Ljava/lang/String;LDirectory;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
      13: astore_1
      14: new           #114                // class kotlin/jvm/internal/Ref$ObjectRef
      17: dup
      18: invokespecial #116                // Method kotlin/jvm/internal/Ref$ObjectRef."<init>":()V
      21: astore_2
      22: aload_2
      23: aload_1
      24: putfield      #120                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
      27: aload_0
      28: checkcast     #122                // class java/lang/Iterable
      31: astore_3
      32: iconst_0
      33: istore        4
      35: iconst_0
      36: istore        5
      38: aload_3
      39: invokeinterface #126,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      44: astore        6
      46: aload         6
      48: invokeinterface #132,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      53: ifeq          732
      56: aload         6
      58: invokeinterface #136,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: astore        7
      65: iload         5
      67: iinc          5, 1
      70: istore        8
      72: iload         8
      74: ifge          80
      77: invokestatic  #139                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
      80: iload         8
      82: aload         7
      84: checkcast     #8                  // class java/lang/String
      87: astore        9
      89: istore        10
      91: iconst_0
      92: istore        11
      94: aload         9
      96: checkcast     #141                // class java/lang/CharSequence
      99: iconst_1
     100: anewarray     #8                  // class java/lang/String
     103: astore        12
     105: aload         12
     107: iconst_0
     108: ldc           #143                // String
     110: aastore
     111: aload         12
     113: iconst_0
     114: iconst_0
     115: bipush        6
     117: aconst_null
     118: invokestatic  #149                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     121: astore        13
     123: nop
     124: aload         13
     126: iconst_1
     127: invokeinterface #153,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     132: ldc           #155                // String cd
     134: invokestatic  #161                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     137: ifeq          379
     140: aload_2
     141: aload         13
     143: iconst_2
     144: invokeinterface #153,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     149: ldc           #109                // String /
     151: invokestatic  #161                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     154: ifeq          161
     157: aload_1
     158: goto          373
     161: aload         13
     163: iconst_2
     164: invokeinterface #153,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     169: ldc           #163                // String ..
     171: invokestatic  #161                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     174: ifeq          202
     177: aload_2
     178: getfield      #120                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     181: checkcast     #107                // class Directory
     184: invokevirtual #167                // Method Directory.getParent:()LDirectory;
     187: dup
     188: ifnonnull     373
     191: pop
     192: aload_2
     193: getfield      #120                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     196: checkcast     #107                // class Directory
     199: goto          373
     202: aload_2
     203: getfield      #120                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     206: checkcast     #107                // class Directory
     209: invokevirtual #171                // Method Directory.getContents:()Ljava/util/List;
     212: checkcast     #122                // class java/lang/Iterable
     215: astore        14
     217: astore        15
     219: iconst_0
     220: istore        16
     222: aload         14
     224: invokeinterface #126,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     229: astore        17
     231: aload         17
     233: invokeinterface #132,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     238: ifeq          284
     241: aload         17
     243: invokeinterface #136,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     248: astore        18
     250: aload         18
     252: checkcast     #173                // class FsNode
     255: astore        19
     257: iconst_0
     258: istore        20
     260: aload         19
     262: invokevirtual #177                // Method FsNode.getName:()Ljava/lang/String;
     265: aload         13
     267: iconst_2
     268: invokeinterface #153,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     273: invokestatic  #161                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     276: ifeq          231
     279: aload         18
     281: goto          285
     284: aconst_null
     285: aload         15
     287: swap
     288: astore        21
     290: aload         21
     292: instanceof    #107                // class Directory
     295: ifeq          306
     298: aload         21
     300: checkcast     #107                // class Directory
     303: goto          307
     306: aconst_null
     307: dup
     308: ifnonnull     373
     311: pop
     312: new           #107                // class Directory
     315: dup
     316: aload         13
     318: iconst_2
     319: invokeinterface #153,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     324: checkcast     #8                  // class java/lang/String
     327: aload_2
     328: getfield      #120                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     331: checkcast     #107                // class Directory
     334: aconst_null
     335: iconst_4
     336: aconst_null
     337: invokespecial #112                // Method Directory."<init>":(Ljava/lang/String;LDirectory;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
     340: astore        21
     342: aload         21
     344: astore        14
     346: astore        15
     348: iconst_0
     349: istore        16
     351: aload_2
     352: getfield      #120                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     355: checkcast     #107                // class Directory
     358: invokevirtual #171                // Method Directory.getContents:()Ljava/util/List;
     361: aload         14
     363: invokeinterface #181,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     368: pop
     369: aload         15
     371: aload         21
     373: putfield      #120                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     376: goto          727
     379: aload         13
     381: iconst_0
     382: invokeinterface #153,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     387: ldc           #183                // String dir
     389: invokestatic  #161                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     392: ifeq          534
     395: aload_2
     396: getfield      #120                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     399: checkcast     #107                // class Directory
     402: invokevirtual #171                // Method Directory.getContents:()Ljava/util/List;
     405: checkcast     #122                // class java/lang/Iterable
     408: astore        21
     410: iconst_0
     411: istore        14
     413: aload         21
     415: invokeinterface #126,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     420: astore        16
     422: aload         16
     424: invokeinterface #132,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     429: ifeq          475
     432: aload         16
     434: invokeinterface #136,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     439: astore        17
     441: aload         17
     443: checkcast     #173                // class FsNode
     446: astore        18
     448: iconst_0
     449: istore        19
     451: aload         18
     453: invokevirtual #177                // Method FsNode.getName:()Ljava/lang/String;
     456: aload         13
     458: iconst_1
     459: invokeinterface #153,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     464: invokestatic  #161                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     467: ifeq          422
     470: aload         17
     472: goto          476
     475: aconst_null
     476: checkcast     #173                // class FsNode
     479: dup
     480: ifnonnull     530
     483: pop
     484: aload_2
     485: getfield      #120                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     488: checkcast     #107                // class Directory
     491: invokevirtual #171                // Method Directory.getContents:()Ljava/util/List;
     494: new           #107                // class Directory
     497: dup
     498: aload         13
     500: iconst_1
     501: invokeinterface #153,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     506: checkcast     #8                  // class java/lang/String
     509: aload_2
     510: getfield      #120                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     513: checkcast     #107                // class Directory
     516: aconst_null
     517: iconst_4
     518: aconst_null
     519: invokespecial #112                // Method Directory."<init>":(Ljava/lang/String;LDirectory;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
     522: invokeinterface #181,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     527: invokestatic  #189                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     530: pop
     531: goto          727
     534: aload         13
     536: iconst_1
     537: invokeinterface #153,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     542: ldc           #191                // String ls
     544: invokestatic  #161                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     547: ifne          727
     550: aload         13
     552: iconst_0
     553: invokeinterface #153,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     558: checkcast     #141                // class java/lang/CharSequence
     561: astore        12
     563: new           #193                // class kotlin/text/Regex
     566: dup
     567: ldc           #195                // String \\d+
     569: invokespecial #196                // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
     572: aload         12
     574: invokevirtual #200                // Method kotlin/text/Regex.matches:(Ljava/lang/CharSequence;)Z
     577: ifeq          727
     580: aload_2
     581: getfield      #120                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     584: checkcast     #107                // class Directory
     587: invokevirtual #171                // Method Directory.getContents:()Ljava/util/List;
     590: checkcast     #122                // class java/lang/Iterable
     593: astore        21
     595: iconst_0
     596: istore        14
     598: aload         21
     600: invokeinterface #126,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     605: astore        16
     607: aload         16
     609: invokeinterface #132,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     614: ifeq          660
     617: aload         16
     619: invokeinterface #136,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     624: astore        17
     626: aload         17
     628: checkcast     #173                // class FsNode
     631: astore        18
     633: iconst_0
     634: istore        19
     636: aload         18
     638: invokevirtual #177                // Method FsNode.getName:()Ljava/lang/String;
     641: aload         13
     643: iconst_1
     644: invokeinterface #153,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     649: invokestatic  #161                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     652: ifeq          607
     655: aload         17
     657: goto          661
     660: aconst_null
     661: checkcast     #173                // class FsNode
     664: dup
     665: ifnonnull     726
     668: pop
     669: aload_2
     670: getfield      #120                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     673: checkcast     #107                // class Directory
     676: invokevirtual #171                // Method Directory.getContents:()Ljava/util/List;
     679: new           #202                // class Data
     682: dup
     683: aload         13
     685: iconst_1
     686: invokeinterface #153,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     691: checkcast     #8                  // class java/lang/String
     694: aload         13
     696: iconst_0
     697: invokeinterface #153,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     702: checkcast     #8                  // class java/lang/String
     705: invokestatic  #208                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     708: aload_2
     709: getfield      #120                // Field kotlin/jvm/internal/Ref$ObjectRef.element:Ljava/lang/Object;
     712: checkcast     #107                // class Directory
     715: invokespecial #211                // Method Data."<init>":(Ljava/lang/String;ILDirectory;)V
     718: invokeinterface #181,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     723: invokestatic  #189                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     726: pop
     727: nop
     728: nop
     729: goto          46
     732: nop
     733: aload_1
     734: areturn

  private static final int main$part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #239                // Method main$buildFilesystem:(Ljava/util/List;)LDirectory;
       4: astore_1
       5: aload_1
       6: invokevirtual #242                // Method Directory.listAll:()Ljava/util/List;
       9: checkcast     #122                // class java/lang/Iterable
      12: astore_3
      13: iconst_0
      14: istore        4
      16: aload_3
      17: astore        5
      19: new           #244                // class java/util/ArrayList
      22: dup
      23: invokespecial #245                // Method java/util/ArrayList."<init>":()V
      26: checkcast     #247                // class java/util/Collection
      29: astore        6
      31: iconst_0
      32: istore        7
      34: aload         5
      36: invokeinterface #126,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      41: astore        8
      43: aload         8
      45: invokeinterface #132,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      50: ifeq          114
      53: aload         8
      55: invokeinterface #136,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      60: astore        9
      62: aload         9
      64: checkcast     #173                // class FsNode
      67: astore        10
      69: iconst_0
      70: istore        11
      72: aload         10
      74: instanceof    #107                // class Directory
      77: ifeq          97
      80: aload         10
      82: checkcast     #107                // class Directory
      85: invokevirtual #251                // Method Directory.getSize:()I
      88: ldc           #252                // int 100000
      90: if_icmpgt     97
      93: iconst_1
      94: goto          98
      97: iconst_0
      98: ifeq          43
     101: aload         6
     103: aload         9
     105: invokeinterface #253,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     110: pop
     111: goto          43
     114: aload         6
     116: checkcast     #96                 // class java/util/List
     119: nop
     120: astore_2
     121: aload_2
     122: checkcast     #122                // class java/lang/Iterable
     125: astore_3
     126: iconst_0
     127: istore        4
     129: aload_3
     130: invokeinterface #126,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     135: astore        5
     137: aload         5
     139: invokeinterface #132,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     144: ifeq          187
     147: aload         5
     149: invokeinterface #136,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     154: astore        6
     156: iload         4
     158: aload         6
     160: checkcast     #173                // class FsNode
     163: astore        7
     165: istore        12
     167: iconst_0
     168: istore        8
     170: aload         7
     172: invokevirtual #254                // Method FsNode.getSize:()I
     175: istore        13
     177: iload         12
     179: iload         13
     181: iadd
     182: istore        4
     184: goto          137
     187: iload         4
     189: ireturn

  private static final int main$part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: invokestatic  #239                // Method main$buildFilesystem:(Ljava/util/List;)LDirectory;
       4: astore_1
       5: aload_1
       6: invokevirtual #242                // Method Directory.listAll:()Ljava/util/List;
       9: checkcast     #122                // class java/lang/Iterable
      12: astore_3
      13: iconst_0
      14: istore        4
      16: aload_3
      17: astore        5
      19: new           #244                // class java/util/ArrayList
      22: dup
      23: invokespecial #245                // Method java/util/ArrayList."<init>":()V
      26: checkcast     #247                // class java/util/Collection
      29: astore        6
      31: iconst_0
      32: istore        7
      34: aload         5
      36: invokeinterface #126,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      41: astore        8
      43: aload         8
      45: invokeinterface #132,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      50: ifeq          83
      53: aload         8
      55: invokeinterface #136,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      60: astore        9
      62: aload         9
      64: instanceof    #107                // class Directory
      67: ifeq          43
      70: aload         6
      72: aload         9
      74: invokeinterface #253,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      79: pop
      80: goto          43
      83: aload         6
      85: checkcast     #96                 // class java/util/List
      88: nop
      89: astore_2
      90: aload_1
      91: invokevirtual #251                // Method Directory.getSize:()I
      94: i2d
      95: ldc2_w        #266                // double 4.0E7d
      98: dsub
      99: dstore_3
     100: aload_2
     101: checkcast     #122                // class java/lang/Iterable
     104: astore        5
     106: iconst_0
     107: istore        6
     109: aload         5
     111: astore        7
     113: new           #244                // class java/util/ArrayList
     116: dup
     117: invokespecial #245                // Method java/util/ArrayList."<init>":()V
     120: checkcast     #247                // class java/util/Collection
     123: astore        8
     125: iconst_0
     126: istore        9
     128: aload         7
     130: invokeinterface #126,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     135: astore        10
     137: aload         10
     139: invokeinterface #132,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     144: ifeq          198
     147: aload         10
     149: invokeinterface #136,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     154: astore        11
     156: aload         11
     158: checkcast     #107                // class Directory
     161: astore        12
     163: iconst_0
     164: istore        13
     166: aload         12
     168: invokevirtual #251                // Method Directory.getSize:()I
     171: i2d
     172: dload_3
     173: dcmpl
     174: iflt          181
     177: iconst_1
     178: goto          182
     181: iconst_0
     182: ifeq          137
     185: aload         8
     187: aload         11
     189: invokeinterface #253,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     194: pop
     195: goto          137
     198: aload         8
     200: checkcast     #96                 // class java/util/List
     203: nop
     204: checkcast     #122                // class java/lang/Iterable
     207: astore        5
     209: nop
     210: iconst_0
     211: istore        6
     213: aload         5
     215: invokeinterface #126,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     220: astore        7
     222: aload         7
     224: invokeinterface #132,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     229: ifne          240
     232: new           #269                // class java/util/NoSuchElementException
     235: dup
     236: invokespecial #270                // Method java/util/NoSuchElementException."<init>":()V
     239: athrow
     240: aload         7
     242: invokeinterface #136,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     247: astore        8
     249: aload         7
     251: invokeinterface #132,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     256: ifne          264
     259: aload         8
     261: goto          334
     264: aload         8
     266: checkcast     #107                // class Directory
     269: astore        9
     271: iconst_0
     272: istore        10
     274: aload         9
     276: invokevirtual #251                // Method Directory.getSize:()I
     279: istore        9
     281: aload         7
     283: invokeinterface #136,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     288: astore        10
     290: aload         10
     292: checkcast     #107                // class Directory
     295: astore        11
     297: iconst_0
     298: istore        12
     300: aload         11
     302: invokevirtual #251                // Method Directory.getSize:()I
     305: istore        11
     307: iload         9
     309: iload         11
     311: if_icmple     322
     314: aload         10
     316: astore        8
     318: iload         11
     320: istore        9
     322: aload         7
     324: invokeinterface #132,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     329: ifne          281
     332: aload         8
     334: checkcast     #107                // class Directory
     337: invokevirtual #251                // Method Directory.getSize:()I
     340: ireturn
}