import java.io.File
import java.util.Stack

fun main() {
    val inputPair = getInputPair("src/day05_input.txt")
    part1(inputPair)
}

fun part1(inputPair: Pair<List<Stack<Char>>, List<Triple<Int, Int, Int>>>) {
    val stacks = inputPair.first
    val inputs = inputPair.second
    inputs.forEach {
        for (i in 0 until it.first) {
            if (stacks.size >= it.second) {
                val selected = stacks[it.second - 1]
                if (stacks.size >= it.third && selected.isNotEmpty()) {
                    stacks[it.third - 1].push(selected.peek())
                    selected.pop()
                }
            }
        }
    }
    val ans = stacks.joinToString(separator = "") {
        it.peek().toString()
    }
    println(ans)
}

fun getInputPair(fileName: String): Pair<List<Stack<Char>>, List<Triple<Int, Int, Int>>> {
    val fileInput = File(fileName).readText().split("\n\n")
    val other = fileInput[1].split("\n")
    val inputs = other.map {
        val words = it.split(" ")
        Triple(words[1].toInt(), words[3].toInt(), words[5].toInt())
    }
    val matrix = fileInput.first()
    var str = ""
    matrix.forEachIndexed { i, c ->
        if (i % 4 == 0) {
            str += "["
        } else if (i % 2 == 0) {
            str += "]"
        } else {
            str += c
        }
    }
    val lets = str.replace("[ ]", "-").replace("[", "").replace("]", "").replace(" ", "").split("\n").map {
        it.split("").filter { it.isNotBlank() }
    }
    val length = lets.last().size
    val letters = lets.dropLast(1)
    val stacks = mutableListOf<Stack<Char>>()
    for (i in 0 until length) {
        stacks.add(Stack())
        for (j in 0 until length) {
            if (letters.size > j && letters[j].size > i) letters[j][i].let {
                if (it != "-") stacks[i].add(it.first())
            }
        }
        stacks[i].reverse()
    }
    return Pair(stacks.toList(), inputs)
}

Compiled from "Day05.kt"
public final class Day05Kt {
  public static final void main();
    Code:
       0: ldc           #8                  // String src/day05_input.txt
       2: invokestatic  #12                 // Method getInputPair:(Ljava/lang/String;)Lkotlin/Pair;
       5: astore_0
       6: aload_0
       7: invokestatic  #16                 // Method part1:(Lkotlin/Pair;)V
      10: return

  public static final void part1(kotlin.Pair<? extends java.util.List<? extends java.util.Stack<java.lang.Character>>, ? extends java.util.List<kotlin.Triple<java.lang.Integer, java.lang.Integer, java.lang.Integer>>>);
    Code:
       0: aload_0
       1: ldc           #21                 // String inputPair
       3: invokestatic  #27                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #33                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      10: checkcast     #35                 // class java/util/List
      13: astore_1
      14: aload_0
      15: invokevirtual #38                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      18: checkcast     #35                 // class java/util/List
      21: astore_2
      22: aload_2
      23: checkcast     #40                 // class java/lang/Iterable
      26: astore_3
      27: iconst_0
      28: istore        4
      30: aload_3
      31: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      36: astore        5
      38: aload         5
      40: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      45: ifeq          223
      48: aload         5
      50: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      55: astore        6
      57: aload         6
      59: checkcast     #55                 // class kotlin/Triple
      62: astore        7
      64: iconst_0
      65: istore        8
      67: iconst_0
      68: istore        9
      70: aload         7
      72: invokevirtual #56                 // Method kotlin/Triple.getFirst:()Ljava/lang/Object;
      75: checkcast     #58                 // class java/lang/Number
      78: invokevirtual #62                 // Method java/lang/Number.intValue:()I
      81: istore        10
      83: iload         9
      85: iload         10
      87: if_icmpge     218
      90: aload_1
      91: invokeinterface #65,  1           // InterfaceMethod java/util/List.size:()I
      96: aload         7
      98: invokevirtual #66                 // Method kotlin/Triple.getSecond:()Ljava/lang/Object;
     101: checkcast     #58                 // class java/lang/Number
     104: invokevirtual #62                 // Method java/lang/Number.intValue:()I
     107: if_icmplt     212
     110: aload_1
     111: aload         7
     113: invokevirtual #66                 // Method kotlin/Triple.getSecond:()Ljava/lang/Object;
     116: checkcast     #58                 // class java/lang/Number
     119: invokevirtual #62                 // Method java/lang/Number.intValue:()I
     122: iconst_1
     123: isub
     124: invokeinterface #70,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     129: checkcast     #72                 // class java/util/Stack
     132: astore        11
     134: aload_1
     135: invokeinterface #65,  1           // InterfaceMethod java/util/List.size:()I
     140: aload         7
     142: invokevirtual #75                 // Method kotlin/Triple.getThird:()Ljava/lang/Object;
     145: checkcast     #58                 // class java/lang/Number
     148: invokevirtual #62                 // Method java/lang/Number.intValue:()I
     151: if_icmplt     212
     154: aload         11
     156: checkcast     #77                 // class java/util/Collection
     159: invokeinterface #80,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
     164: ifne          171
     167: iconst_1
     168: goto          172
     171: iconst_0
     172: ifeq          212
     175: aload_1
     176: aload         7
     178: invokevirtual #75                 // Method kotlin/Triple.getThird:()Ljava/lang/Object;
     181: checkcast     #58                 // class java/lang/Number
     184: invokevirtual #62                 // Method java/lang/Number.intValue:()I
     187: iconst_1
     188: isub
     189: invokeinterface #70,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     194: checkcast     #72                 // class java/util/Stack
     197: aload         11
     199: invokevirtual #83                 // Method java/util/Stack.peek:()Ljava/lang/Object;
     202: invokevirtual #87                 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;
     205: pop
     206: aload         11
     208: invokevirtual #90                 // Method java/util/Stack.pop:()Ljava/lang/Object;
     211: pop
     212: iinc          9, 1
     215: goto          83
     218: nop
     219: nop
     220: goto          38
     223: nop
     224: aload_1
     225: checkcast     #40                 // class java/lang/Iterable
     228: ldc           #92                 // String
     230: checkcast     #94                 // class java/lang/CharSequence
     233: aconst_null
     234: aconst_null
     235: iconst_0
     236: aconst_null
     237: invokedynamic #112,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
     242: bipush        30
     244: aconst_null
     245: invokestatic  #118                // 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;
     248: astore_3
     249: getstatic     #124                // Field java/lang/System.out:Ljava/io/PrintStream;
     252: aload_3
     253: invokevirtual #130                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     256: return

  public static final kotlin.Pair<java.util.List<java.util.Stack<java.lang.Character>>, java.util.List<kotlin.Triple<java.lang.Integer, java.lang.Integer, java.lang.Integer>>> getInputPair(java.lang.String);
    Code:
       0: aload_0
       1: ldc           #150                // String fileName
       3: invokestatic  #27                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #152                // class java/io/File
       9: dup
      10: aload_0
      11: invokespecial #156                // Method java/io/File."<init>":(Ljava/lang/String;)V
      14: aconst_null
      15: iconst_1
      16: aconst_null
      17: invokestatic  #162                // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;
      20: checkcast     #94                 // class java/lang/CharSequence
      23: iconst_1
      24: anewarray     #164                // class java/lang/String
      27: astore_2
      28: aload_2
      29: iconst_0
      30: ldc           #166                // String \n\n
      32: aastore
      33: aload_2
      34: iconst_0
      35: iconst_0
      36: bipush        6
      38: aconst_null
      39: invokestatic  #172                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      42: astore_1
      43: aload_1
      44: iconst_1
      45: invokeinterface #70,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      50: checkcast     #94                 // class java/lang/CharSequence
      53: iconst_1
      54: anewarray     #164                // class java/lang/String
      57: astore_3
      58: aload_3
      59: iconst_0
      60: ldc           #174                // String \n
      62: aastore
      63: aload_3
      64: iconst_0
      65: iconst_0
      66: bipush        6
      68: aconst_null
      69: invokestatic  #172                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      72: astore_2
      73: aload_2
      74: checkcast     #40                 // class java/lang/Iterable
      77: astore        4
      79: iconst_0
      80: istore        5
      82: aload         4
      84: astore        6
      86: new           #176                // class java/util/ArrayList
      89: dup
      90: aload         4
      92: bipush        10
      94: invokestatic  #180                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      97: invokespecial #183                // Method java/util/ArrayList."<init>":(I)V
     100: checkcast     #77                 // class java/util/Collection
     103: astore        7
     105: iconst_0
     106: istore        8
     108: aload         6
     110: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     115: astore        9
     117: aload         9
     119: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     124: ifeq          249
     127: aload         9
     129: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     134: astore        10
     136: aload         7
     138: aload         10
     140: checkcast     #164                // class java/lang/String
     143: astore        11
     145: astore        25
     147: iconst_0
     148: istore        12
     150: aload         11
     152: checkcast     #94                 // class java/lang/CharSequence
     155: iconst_1
     156: anewarray     #164                // class java/lang/String
     159: astore        13
     161: aload         13
     163: iconst_0
     164: ldc           #185                // String
     166: aastore
     167: aload         13
     169: iconst_0
     170: iconst_0
     171: bipush        6
     173: aconst_null
     174: invokestatic  #172                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     177: astore        14
     179: new           #55                 // class kotlin/Triple
     182: dup
     183: aload         14
     185: iconst_1
     186: invokeinterface #70,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     191: checkcast     #164                // class java/lang/String
     194: invokestatic  #191                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     197: invokestatic  #195                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     200: aload         14
     202: iconst_3
     203: invokeinterface #70,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     208: checkcast     #164                // class java/lang/String
     211: invokestatic  #191                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     214: invokestatic  #195                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     217: aload         14
     219: iconst_5
     220: invokeinterface #70,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     225: checkcast     #164                // class java/lang/String
     228: invokestatic  #191                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     231: invokestatic  #195                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     234: invokespecial #198                // Method kotlin/Triple."<init>":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
     237: aload         25
     239: swap
     240: invokeinterface #202,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     245: pop
     246: goto          117
     249: aload         7
     251: checkcast     #35                 // class java/util/List
     254: nop
     255: astore_3
     256: aload_1
     257: invokestatic  #206                // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;
     260: checkcast     #164                // class java/lang/String
     263: astore        4
     265: aconst_null
     266: astore        5
     268: ldc           #92                 // String
     270: astore        5
     272: aload         4
     274: checkcast     #94                 // class java/lang/CharSequence
     277: astore        6
     279: iconst_0
     280: istore        7
     282: iconst_0
     283: istore        8
     285: iconst_0
     286: istore        9
     288: iload         9
     290: aload         6
     292: invokeinterface #209,  1          // InterfaceMethod java/lang/CharSequence.length:()I
     297: if_icmpge     419
     300: aload         6
     302: iload         9
     304: invokeinterface #213,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     309: istore        10
     311: iload         8
     313: iinc          8, 1
     316: iload         10
     318: istore        11
     320: istore        12
     322: iconst_0
     323: istore        13
     325: iload         12
     327: iconst_4
     328: irem
     329: ifne          357
     332: new           #215                // class java/lang/StringBuilder
     335: dup
     336: invokespecial #217                // Method java/lang/StringBuilder."<init>":()V
     339: aload         5
     341: invokevirtual #221                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     344: bipush        91
     346: invokevirtual #224                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     349: invokevirtual #228                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     352: astore        5
     354: goto          411
     357: iload         12
     359: iconst_2
     360: irem
     361: ifne          389
     364: new           #215                // class java/lang/StringBuilder
     367: dup
     368: invokespecial #217                // Method java/lang/StringBuilder."<init>":()V
     371: aload         5
     373: invokevirtual #221                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     376: bipush        93
     378: invokevirtual #224                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     381: invokevirtual #228                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     384: astore        5
     386: goto          411
     389: new           #215                // class java/lang/StringBuilder
     392: dup
     393: invokespecial #217                // Method java/lang/StringBuilder."<init>":()V
     396: aload         5
     398: invokevirtual #221                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     401: iload         11
     403: invokevirtual #224                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     406: invokevirtual #228                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     409: astore        5
     411: nop
     412: nop
     413: iinc          9, 1
     416: goto          288
     419: nop
     420: aload         5
     422: ldc           #230                // String [ ]
     424: ldc           #232                // String -
     426: iconst_0
     427: iconst_4
     428: aconst_null
     429: invokestatic  #236                // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
     432: ldc           #238                // String [
     434: ldc           #92                 // String
     436: iconst_0
     437: iconst_4
     438: aconst_null
     439: invokestatic  #236                // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
     442: ldc           #240                // String ]
     444: ldc           #92                 // String
     446: iconst_0
     447: iconst_4
     448: aconst_null
     449: invokestatic  #236                // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
     452: ldc           #185                // String
     454: ldc           #92                 // String
     456: iconst_0
     457: iconst_4
     458: aconst_null
     459: invokestatic  #236                // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
     462: checkcast     #94                 // class java/lang/CharSequence
     465: iconst_1
     466: anewarray     #164                // class java/lang/String
     469: astore        7
     471: aload         7
     473: iconst_0
     474: ldc           #174                // String \n
     476: aastore
     477: aload         7
     479: iconst_0
     480: iconst_0
     481: bipush        6
     483: aconst_null
     484: invokestatic  #172                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     487: checkcast     #40                 // class java/lang/Iterable
     490: astore        7
     492: iconst_0
     493: istore        8
     495: aload         7
     497: astore        9
     499: new           #176                // class java/util/ArrayList
     502: dup
     503: aload         7
     505: bipush        10
     507: invokestatic  #180                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     510: invokespecial #183                // Method java/util/ArrayList."<init>":(I)V
     513: checkcast     #77                 // class java/util/Collection
     516: astore        10
     518: iconst_0
     519: istore        11
     521: aload         9
     523: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     528: astore        12
     530: aload         12
     532: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     537: ifeq          707
     540: aload         12
     542: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     547: astore        13
     549: aload         10
     551: aload         13
     553: checkcast     #164                // class java/lang/String
     556: astore        14
     558: astore        25
     560: iconst_0
     561: istore        15
     563: aload         14
     565: checkcast     #94                 // class java/lang/CharSequence
     568: iconst_1
     569: anewarray     #164                // class java/lang/String
     572: astore        16
     574: aload         16
     576: iconst_0
     577: ldc           #92                 // String
     579: aastore
     580: aload         16
     582: iconst_0
     583: iconst_0
     584: bipush        6
     586: aconst_null
     587: invokestatic  #172                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     590: checkcast     #40                 // class java/lang/Iterable
     593: astore        16
     595: iconst_0
     596: istore        17
     598: aload         16
     600: astore        18
     602: new           #176                // class java/util/ArrayList
     605: dup
     606: invokespecial #241                // Method java/util/ArrayList."<init>":()V
     609: checkcast     #77                 // class java/util/Collection
     612: astore        19
     614: iconst_0
     615: istore        20
     617: aload         18
     619: invokeinterface #44,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     624: astore        21
     626: aload         21
     628: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     633: ifeq          688
     636: aload         21
     638: invokeinterface #53,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     643: astore        22
     645: aload         22
     647: checkcast     #164                // class java/lang/String
     650: astore        23
     652: iconst_0
     653: istore        24
     655: aload         23
     657: checkcast     #94                 // class java/lang/CharSequence
     660: invokestatic  #245                // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z
     663: ifne          670
     666: iconst_1
     667: goto          671
     670: iconst_0
     671: nop
     672: ifeq          626
     675: aload         19
     677: aload         22
     679: invokeinterface #202,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     684: pop
     685: goto          626
     688: aload         19
     690: checkcast     #35                 // class java/util/List
     693: nop
     694: nop
     695: aload         25
     697: swap
     698: invokeinterface #202,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     703: pop
     704: goto          530
     707: aload         10
     709: checkcast     #35                 // class java/util/List
     712: nop
     713: astore        6
     715: aload         6
     717: invokestatic  #248                // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;
     720: checkcast     #35                 // class java/util/List
     723: invokeinterface #65,  1           // InterfaceMethod java/util/List.size:()I
     728: istore        7
     730: aload         6
     732: iconst_1
     733: invokestatic  #252                // Method kotlin/collections/CollectionsKt.dropLast:(Ljava/util/List;I)Ljava/util/List;
     736: astore        8
     738: new           #176                // class java/util/ArrayList
     741: dup
     742: invokespecial #241                // Method java/util/ArrayList."<init>":()V
     745: checkcast     #35                 // class java/util/List
     748: astore        9
     750: iconst_0
     751: istore        10
     753: iload         10
     755: iload         7
     757: if_icmpge     912
     760: aload         9
     762: new           #72                 // class java/util/Stack
     765: dup
     766: invokespecial #253                // Method java/util/Stack."<init>":()V
     769: invokeinterface #254,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     774: pop
     775: iconst_0
     776: istore        11
     778: iload         11
     780: iload         7
     782: if_icmpge     891
     785: aload         8
     787: invokeinterface #65,  1           // InterfaceMethod java/util/List.size:()I
     792: iload         11
     794: if_icmple     885
     797: aload         8
     799: iload         11
     801: invokeinterface #70,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     806: checkcast     #35                 // class java/util/List
     809: invokeinterface #65,  1           // InterfaceMethod java/util/List.size:()I
     814: iload         10
     816: if_icmple     885
     819: aload         8
     821: iload         11
     823: invokeinterface #70,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     828: checkcast     #35                 // class java/util/List
     831: iload         10
     833: invokeinterface #70,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     838: checkcast     #164                // class java/lang/String
     841: astore        13
     843: iconst_0
     844: istore        14
     846: aload         13
     848: ldc           #232                // String -
     850: invokestatic  #258                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     853: ifne          883
     856: aload         9
     858: iload         10
     860: invokeinterface #70,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     865: checkcast     #72                 // class java/util/Stack
     868: aload         13
     870: checkcast     #94                 // class java/lang/CharSequence
     873: invokestatic  #261                // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C
     876: invokestatic  #266                // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;
     879: invokevirtual #267                // Method java/util/Stack.add:(Ljava/lang/Object;)Z
     882: pop
     883: nop
     884: nop
     885: iinc          11, 1
     888: goto          778
     891: aload         9
     893: iload         10
     895: invokeinterface #70,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     900: checkcast     #35                 // class java/util/List
     903: invokestatic  #271                // Method kotlin/collections/CollectionsKt.reverse:(Ljava/util/List;)V
     906: iinc          10, 1
     909: goto          753
     912: new           #29                 // class kotlin/Pair
     915: dup
     916: aload         9
     918: checkcast     #40                 // class java/lang/Iterable
     921: invokestatic  #275                // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;
     924: aload_3
     925: invokespecial #278                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     928: areturn

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

  private static final java.lang.CharSequence part1$lambda$1(java.util.Stack);
    Code:
       0: aload_0
       1: ldc_w         #317                // String it
       4: invokestatic  #27                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_0
       8: invokevirtual #83                 // Method java/util/Stack.peek:()Ljava/lang/Object;
      11: checkcast     #263                // class java/lang/Character
      14: invokevirtual #318                // Method java/lang/Character.toString:()Ljava/lang/String;
      17: checkcast     #94                 // class java/lang/CharSequence
      20: areturn
}


import java.io.File

fun main() {
    val input = File("src/day02_input.txt").readText().split("\n")
    println(part1(input))
    println(part2(input))
}

fun part1(input: List<String>): Int {
    var score = 0
    input.forEach {
        val oppMove = Move.getMoveObj(it[0]) ?: return@part1 (score)
        val myMove = Move.getMoveObj(it[2]) ?: return@part1 (score)
        score += myMove.score
        when {
            myMove.winsTo == oppMove.score -> score += 6
            myMove.score == oppMove.score -> score += 3
            myMove.losesTo == oppMove.score -> score += 0
        }
    }
    return score
}

fun part2(input: List<String>): Int {
    var score = 0
    input.forEach {
        val oppMove = Move.getMoveObj(it[0]) ?: return@part2 (score)
        val myMove = Move.getMoveObj(it[2]) ?: return@part2 (score)
        when (myMove) {
            is Move.Rock -> {
                score += oppMove.winsTo
                score += 0
            }

            is Move.Paper -> {
                score += oppMove.score
                score += 3
            }

            is Move.Scissors -> {
                score += oppMove.losesTo
                score += 6
            }
        }
    }
    return score
}

sealed class Move(
    val score: Int,
    val winsTo: Int,
    val losesTo: Int,
) {
    object Rock : Move(1, 3, 2)

    object Paper : Move(2, 1, 3)

    object Scissors : Move(3, 2, 1)
    companion object {
        fun getMoveObj(moveChar: Char): Move? {
            return when (moveChar) {
                'A' -> Rock
                'X' -> Rock
                'B' -> Paper
                'Y' -> Paper
                'C' -> Scissors
                'Z' -> Scissors
                else -> null
            }
        }
    }
}

Compiled from "Day02.kt"
public final class Day02Kt {
  public static final void main();
    Code:
       0: new           #8                  // class java/io/File
       3: dup
       4: ldc           #10                 // String src/day02_input.txt
       6: invokespecial #14                 // Method java/io/File."<init>":(Ljava/lang/String;)V
       9: aconst_null
      10: iconst_1
      11: aconst_null
      12: invokestatic  #20                 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;
      15: checkcast     #22                 // class java/lang/CharSequence
      18: iconst_1
      19: anewarray     #24                 // class java/lang/String
      22: astore_1
      23: aload_1
      24: iconst_0
      25: ldc           #26                 // String \n
      27: aastore
      28: aload_1
      29: iconst_0
      30: iconst_0
      31: bipush        6
      33: aconst_null
      34: invokestatic  #32                 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      37: astore_0
      38: aload_0
      39: invokestatic  #36                 // Method part1:(Ljava/util/List;)I
      42: istore_1
      43: getstatic     #42                 // Field java/lang/System.out:Ljava/io/PrintStream;
      46: iload_1
      47: invokevirtual #48                 // Method java/io/PrintStream.println:(I)V
      50: aload_0
      51: invokestatic  #51                 // Method part2:(Ljava/util/List;)I
      54: istore_1
      55: getstatic     #42                 // Field java/lang/System.out:Ljava/io/PrintStream;
      58: iload_1
      59: invokevirtual #48                 // Method java/io/PrintStream.println:(I)V
      62: return

  public static final int part1(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #56                 // String input
       3: invokestatic  #62                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_1
       8: aload_0
       9: checkcast     #64                 // class java/lang/Iterable
      12: astore_2
      13: iconst_0
      14: istore_3
      15: aload_2
      16: invokeinterface #68,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      21: astore        4
      23: aload         4
      25: invokeinterface #74,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      30: ifeq          166
      33: aload         4
      35: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      40: astore        5
      42: aload         5
      44: checkcast     #24                 // class java/lang/String
      47: astore        6
      49: iconst_0
      50: istore        7
      52: getstatic     #84                 // Field Move.Companion:LMove$Companion;
      55: aload         6
      57: iconst_0
      58: invokevirtual #88                 // Method java/lang/String.charAt:(I)C
      61: invokevirtual #94                 // Method Move$Companion.getMoveObj:(C)LMove;
      64: dup
      65: ifnonnull     71
      68: pop
      69: iload_1
      70: ireturn
      71: astore        8
      73: getstatic     #84                 // Field Move.Companion:LMove$Companion;
      76: aload         6
      78: iconst_2
      79: invokevirtual #88                 // Method java/lang/String.charAt:(I)C
      82: invokevirtual #94                 // Method Move$Companion.getMoveObj:(C)LMove;
      85: dup
      86: ifnonnull     92
      89: pop
      90: iload_1
      91: ireturn
      92: astore        9
      94: iload_1
      95: aload         9
      97: invokevirtual #98                 // Method Move.getScore:()I
     100: iadd
     101: istore_1
     102: nop
     103: aload         9
     105: invokevirtual #101                // Method Move.getWinsTo:()I
     108: aload         8
     110: invokevirtual #98                 // Method Move.getScore:()I
     113: if_icmpne     124
     116: iload_1
     117: bipush        6
     119: iadd
     120: istore_1
     121: goto          161
     124: aload         9
     126: invokevirtual #98                 // Method Move.getScore:()I
     129: aload         8
     131: invokevirtual #98                 // Method Move.getScore:()I
     134: if_icmpne     144
     137: iload_1
     138: iconst_3
     139: iadd
     140: istore_1
     141: goto          161
     144: aload         9
     146: invokevirtual #104                // Method Move.getLosesTo:()I
     149: aload         8
     151: invokevirtual #98                 // Method Move.getScore:()I
     154: if_icmpne     161
     157: iload_1
     158: iconst_0
     159: iadd
     160: istore_1
     161: nop
     162: nop
     163: goto          23
     166: nop
     167: iload_1
     168: ireturn

  public static final int part2(java.util.List<java.lang.String>);
    Code:
       0: aload_0
       1: ldc           #56                 // String input
       3: invokestatic  #62                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: iconst_0
       7: istore_1
       8: aload_0
       9: checkcast     #64                 // class java/lang/Iterable
      12: astore_2
      13: iconst_0
      14: istore_3
      15: aload_2
      16: invokeinterface #68,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      21: astore        4
      23: aload         4
      25: invokeinterface #74,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      30: ifeq          181
      33: aload         4
      35: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      40: astore        5
      42: aload         5
      44: checkcast     #24                 // class java/lang/String
      47: astore        6
      49: iconst_0
      50: istore        7
      52: getstatic     #84                 // Field Move.Companion:LMove$Companion;
      55: aload         6
      57: iconst_0
      58: invokevirtual #88                 // Method java/lang/String.charAt:(I)C
      61: invokevirtual #94                 // Method Move$Companion.getMoveObj:(C)LMove;
      64: dup
      65: ifnonnull     71
      68: pop
      69: iload_1
      70: ireturn
      71: astore        8
      73: getstatic     #84                 // Field Move.Companion:LMove$Companion;
      76: aload         6
      78: iconst_2
      79: invokevirtual #88                 // Method java/lang/String.charAt:(I)C
      82: invokevirtual #94                 // Method Move$Companion.getMoveObj:(C)LMove;
      85: dup
      86: ifnonnull     92
      89: pop
      90: iload_1
      91: ireturn
      92: astore        9
      94: aload         9
      96: astore        10
      98: aload         10
     100: instanceof    #121                // class Move$Rock
     103: ifeq          121
     106: iload_1
     107: aload         8
     109: invokevirtual #101                // Method Move.getWinsTo:()I
     112: iadd
     113: istore_1
     114: iload_1
     115: iconst_0
     116: iadd
     117: istore_1
     118: goto          176
     121: aload         10
     123: instanceof    #123                // class Move$Paper
     126: ifeq          144
     129: iload_1
     130: aload         8
     132: invokevirtual #98                 // Method Move.getScore:()I
     135: iadd
     136: istore_1
     137: iload_1
     138: iconst_3
     139: iadd
     140: istore_1
     141: goto          176
     144: aload         10
     146: instanceof    #125                // class Move$Scissors
     149: ifeq          168
     152: iload_1
     153: aload         8
     155: invokevirtual #104                // Method Move.getLosesTo:()I
     158: iadd
     159: istore_1
     160: iload_1
     161: bipush        6
     163: iadd
     164: istore_1
     165: goto          176
     168: new           #127                // class kotlin/NoWhenBranchMatchedException
     171: dup
     172: invokespecial #129                // Method kotlin/NoWhenBranchMatchedException."<init>":()V
     175: athrow
     176: nop
     177: nop
     178: goto          23
     181: nop
     182: iload_1
     183: ireturn

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


import java.math.BigInteger

/**
 * Square root with its coefficient.
 *
 * Definitions: a square root is of form 'coefficient * sqrt(radicand)'.
 * In other words, the coefficient is outside the square root
 * and the radicand in inside the square root.
 *
 * @property coefficient number in front of the radical ('root') sign.
 * @property radicand number inside the radical ('root') sign.
 */
data class SquareRootBI(val coefficient: BigInteger, val radicand: BigInteger)

/**
 * Simplifies the square root and makes radicand as small as possible.
 *
 *
 * @param squareRoot the square root to simplify.
 * @return the simplified square root.
 */
fun simplifySquareRoot(squareRoot: SquareRootBI): SquareRootBI =
    if (squareRoot.radicand < BigInteger.ZERO) throw IllegalArgumentException("Radicand cannot be negative")
    else if (squareRoot.radicand == BigInteger.ZERO) SquareRootBI(BigInteger.ZERO, BigInteger.ZERO)
    else if (squareRoot.radicand == BigInteger.ONE) SquareRootBI(squareRoot.coefficient, BigInteger.ONE)
    else {
        val decreasingSequence = sequence {
            // We can start at sqrt(radicand) because radicand is
            // never divisible without remainder by anything greater than i = sqrt(radicand)
            // This optimization is applied because tests are otherwise very very slow.
            var bi = squareRoot.radicand.sqrt()
            while (bi > BigInteger.ONE) {
                yield(bi)
                bi = bi.subtract(BigInteger.ONE)
            }
        }

        decreasingSequence
            .fold(squareRoot) { simplifiedSquareRoot, i ->
                run {
                    if (simplifiedSquareRoot.radicand.mod(i.pow(2)) == BigInteger.ZERO) {
                        SquareRootBI(
                            simplifiedSquareRoot.coefficient.times(i),
                            simplifiedSquareRoot.radicand.div(i.pow(2))
                        )
                    } else {
                        simplifiedSquareRoot
                    }
                }
            }
    }

Compiled from "SimplifySquareRootBigDecimal.kt"
final class SimplifySquareRootBigDecimalKt$simplifySquareRoot$decreasingSequence$1 extends kotlin.coroutines.jvm.internal.RestrictedSuspendLambda implements kotlin.jvm.functions.Function2<kotlin.sequences.SequenceScope<? super java.math.BigInteger>, kotlin.coroutines.Continuation<? super kotlin.Unit>, java.lang.Object> {
  java.lang.Object L$1;

  int label;

  private java.lang.Object L$0;

  final SquareRootBI $squareRoot;

  SimplifySquareRootBigDecimalKt$simplifySquareRoot$decreasingSequence$1(SquareRootBI, kotlin.coroutines.Continuation<? super SimplifySquareRootBigDecimalKt$simplifySquareRoot$decreasingSequence$1>);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #14                 // Field $squareRoot:LSquareRootBI;
       5: aload_0
       6: iconst_2
       7: aload_2
       8: invokespecial #17                 // Method kotlin/coroutines/jvm/internal/RestrictedSuspendLambda."<init>":(ILkotlin/coroutines/Continuation;)V
      11: return

  public final java.lang.Object invokeSuspend(java.lang.Object);
    Code:
       0: invokestatic  #45                 // Method kotlin/coroutines/intrinsics/IntrinsicsKt.getCOROUTINE_SUSPENDED:()Ljava/lang/Object;
       3: astore        4
       5: aload_0
       6: getfield      #49                 // Field label:I
       9: tableswitch   { // 0 to 1
                     0: 32
                     1: 98
               default: 135
          }
      32: aload_1
      33: invokestatic  #55                 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V
      36: aload_0
      37: getfield      #57                 // Field L$0:Ljava/lang/Object;
      40: checkcast     #59                 // class kotlin/sequences/SequenceScope
      43: astore_2
      44: aload_0
      45: getfield      #14                 // Field $squareRoot:LSquareRootBI;
      48: invokevirtual #65                 // Method SquareRootBI.getRadicand:()Ljava/math/BigInteger;
      51: invokevirtual #70                 // Method java/math/BigInteger.sqrt:()Ljava/math/BigInteger;
      54: astore_3
      55: aload_3
      56: getstatic     #74                 // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;
      59: invokevirtual #78                 // Method java/math/BigInteger.compareTo:(Ljava/math/BigInteger;)I
      62: ifle          131
      65: aload_2
      66: aload_3
      67: aload_0
      68: checkcast     #80                 // class kotlin/coroutines/Continuation
      71: aload_0
      72: aload_2
      73: putfield      #57                 // Field L$0:Ljava/lang/Object;
      76: aload_0
      77: aload_3
      78: putfield      #82                 // Field L$1:Ljava/lang/Object;
      81: aload_0
      82: iconst_1
      83: putfield      #49                 // Field label:I
      86: invokevirtual #86                 // Method kotlin/sequences/SequenceScope.yield:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
      89: dup
      90: aload         4
      92: if_acmpne     119
      95: aload         4
      97: areturn
      98: aload_0
      99: getfield      #82                 // Field L$1:Ljava/lang/Object;
     102: checkcast     #67                 // class java/math/BigInteger
     105: astore_3
     106: aload_0
     107: getfield      #57                 // Field L$0:Ljava/lang/Object;
     110: checkcast     #59                 // class kotlin/sequences/SequenceScope
     113: astore_2
     114: aload_1
     115: invokestatic  #55                 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V
     118: aload_1
     119: pop
     120: aload_3
     121: getstatic     #74                 // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;
     124: invokevirtual #90                 // Method java/math/BigInteger.subtract:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     127: astore_3
     128: goto          55
     131: getstatic     #96                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     134: areturn
     135: new           #98                 // class java/lang/IllegalStateException
     138: dup
     139: ldc           #100                // String call to \'resume\' before \'invoke\' with coroutine
     141: invokespecial #103                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     144: athrow

  public final kotlin.coroutines.Continuation<kotlin.Unit> create(java.lang.Object, kotlin.coroutines.Continuation<?>);
    Code:
       0: new           #2                  // class SimplifySquareRootBigDecimalKt$simplifySquareRoot$decreasingSequence$1
       3: dup
       4: aload_0
       5: getfield      #14                 // Field $squareRoot:LSquareRootBI;
       8: aload_2
       9: invokespecial #112                // Method "<init>":(LSquareRootBI;Lkotlin/coroutines/Continuation;)V
      12: astore_3
      13: aload_3
      14: aload_1
      15: putfield      #57                 // Field L$0:Ljava/lang/Object;
      18: aload_3
      19: checkcast     #80                 // class kotlin/coroutines/Continuation
      22: areturn

  public final java.lang.Object invoke(kotlin.sequences.SequenceScope<? super java.math.BigInteger>, kotlin.coroutines.Continuation<? super kotlin.Unit>);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: invokevirtual #118                // Method create:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Lkotlin/coroutines/Continuation;
       6: checkcast     #2                  // class SimplifySquareRootBigDecimalKt$simplifySquareRoot$decreasingSequence$1
       9: getstatic     #96                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      12: invokevirtual #120                // Method invokeSuspend:(Ljava/lang/Object;)Ljava/lang/Object;
      15: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #59                 // class kotlin/sequences/SequenceScope
       5: aload_2
       6: checkcast     #80                 // class kotlin/coroutines/Continuation
       9: invokevirtual #125                // Method invoke:(Lkotlin/sequences/SequenceScope;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
      12: areturn
}

Compiled from "SimplifySquareRootBigDecimal.kt"
public final class SimplifySquareRootBigDecimalKt {
  public static final SquareRootBI simplifySquareRoot(SquareRootBI);
    Code:
       0: aload_0
       1: ldc           #9                  // String squareRoot
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokevirtual #21                 // Method SquareRootBI.getRadicand:()Ljava/math/BigInteger;
      10: getstatic     #27                 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;
      13: invokevirtual #31                 // Method java/math/BigInteger.compareTo:(Ljava/math/BigInteger;)I
      16: ifge          29
      19: new           #33                 // class java/lang/IllegalArgumentException
      22: dup
      23: ldc           #35                 // String Radicand cannot be negative
      25: invokespecial #39                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
      28: athrow
      29: aload_0
      30: invokevirtual #21                 // Method SquareRootBI.getRadicand:()Ljava/math/BigInteger;
      33: getstatic     #27                 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;
      36: invokestatic  #43                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      39: ifeq          70
      42: new           #17                 // class SquareRootBI
      45: dup
      46: getstatic     #27                 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;
      49: dup
      50: ldc           #44                 // String ZERO
      52: invokestatic  #47                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      55: getstatic     #27                 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;
      58: dup
      59: ldc           #44                 // String ZERO
      61: invokestatic  #47                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      64: invokespecial #50                 // Method SquareRootBI."<init>":(Ljava/math/BigInteger;Ljava/math/BigInteger;)V
      67: goto          271
      70: aload_0
      71: invokevirtual #21                 // Method SquareRootBI.getRadicand:()Ljava/math/BigInteger;
      74: getstatic     #53                 // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;
      77: invokestatic  #43                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      80: ifeq          106
      83: new           #17                 // class SquareRootBI
      86: dup
      87: aload_0
      88: invokevirtual #56                 // Method SquareRootBI.getCoefficient:()Ljava/math/BigInteger;
      91: getstatic     #53                 // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;
      94: dup
      95: ldc           #57                 // String ONE
      97: invokestatic  #47                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     100: invokespecial #50                 // Method SquareRootBI."<init>":(Ljava/math/BigInteger;Ljava/math/BigInteger;)V
     103: goto          271
     106: new           #59                 // class SimplifySquareRootBigDecimalKt$simplifySquareRoot$decreasingSequence$1
     109: dup
     110: aload_0
     111: aconst_null
     112: invokespecial #62                 // Method SimplifySquareRootBigDecimalKt$simplifySquareRoot$decreasingSequence$1."<init>":(LSquareRootBI;Lkotlin/coroutines/Continuation;)V
     115: checkcast     #64                 // class kotlin/jvm/functions/Function2
     118: invokestatic  #70                 // Method kotlin/sequences/SequencesKt.sequence:(Lkotlin/jvm/functions/Function2;)Lkotlin/sequences/Sequence;
     121: astore_1
     122: aload_1
     123: astore_2
     124: nop
     125: iconst_0
     126: istore_3
     127: aload_0
     128: astore        4
     130: aload_2
     131: invokeinterface #76,  1           // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
     136: astore        5
     138: aload         5
     140: invokeinterface #82,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     145: ifeq          269
     148: aload         5
     150: invokeinterface #86,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     155: astore        6
     157: aload         4
     159: aload         6
     161: checkcast     #23                 // class java/math/BigInteger
     164: astore        7
     166: astore        8
     168: iconst_0
     169: istore        9
     171: iconst_0
     172: istore        10
     174: aload         8
     176: invokevirtual #21                 // Method SquareRootBI.getRadicand:()Ljava/math/BigInteger;
     179: aload         7
     181: iconst_2
     182: invokevirtual #90                 // Method java/math/BigInteger.pow:(I)Ljava/math/BigInteger;
     185: invokevirtual #94                 // Method java/math/BigInteger.mod:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     188: getstatic     #27                 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;
     191: invokestatic  #43                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
     194: ifeq          259
     197: new           #17                 // class SquareRootBI
     200: dup
     201: aload         8
     203: invokevirtual #56                 // Method SquareRootBI.getCoefficient:()Ljava/math/BigInteger;
     206: aload         7
     208: invokestatic  #98                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     211: aload         7
     213: invokevirtual #101                // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     216: dup
     217: ldc           #103                // String multiply(...)
     219: invokestatic  #47                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     222: aload         8
     224: invokevirtual #21                 // Method SquareRootBI.getRadicand:()Ljava/math/BigInteger;
     227: astore        11
     229: aload         7
     231: iconst_2
     232: invokevirtual #90                 // Method java/math/BigInteger.pow:(I)Ljava/math/BigInteger;
     235: dup
     236: ldc           #105                // String pow(...)
     238: invokestatic  #47                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     241: aload         11
     243: swap
     244: invokevirtual #108                // Method java/math/BigInteger.divide:(Ljava/math/BigInteger;)Ljava/math/BigInteger;
     247: dup
     248: ldc           #110                // String divide(...)
     250: invokestatic  #47                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     253: invokespecial #50                 // Method SquareRootBI."<init>":(Ljava/math/BigInteger;Ljava/math/BigInteger;)V
     256: goto          261
     259: aload         8
     261: nop
     262: nop
     263: nop
     264: astore        4
     266: goto          138
     269: aload         4
     271: areturn
}


import kotlin.math.floor
import kotlin.math.sqrt
import kotlin.system.measureNanoTime

/**
 * 10001st prime
 *
 * By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
 *
 * What is the 10001st prime number?
 *
 * https://projecteuler.net/problem=7
 */

fun main() {
    println(findPrime1(6))
    println(findPrime(6))
    val time1 = measureNanoTime {
        println(findPrime1(10_001))
    }
    val time2 = measureNanoTime {
        println(findPrime(10_001))
    }
    println(time1)
    println(time2)
}

private fun findPrime1(n: Int): Long {
    var prime = 2L
    val primes = mutableListOf(prime)
    while (primes.size != n) {
        prime++
        if (!primes.any { prime % it == 0L }) {
            primes.add(prime)
        }
    }
    return prime
}

fun findPrime(n: Int): Long {
    if (n == 1) return 2
    var count = 1
    var candidate = 1L
    do {
        candidate += 2
        if (isPrime(candidate)) count++
    } while (count != n)
    return candidate
}

fun isPrime(n: Long): Boolean {
    return when {
        n < 2 -> false // 1 is not prime
        n < 4 -> true // 2 and 3 are prime
        n % 2 == 0L -> false // all primes except 2 are odd
        n < 9 -> true // we have already excluded 4. 6 and 8
        n % 3 == 0L -> false
        else -> { // All primes greater than 3 can be written in the form 6k+/-1.
            val r = floor(sqrt(n.toDouble())).toLong()
            for (f in 5L .. r step 6) {
                if (n % f == 0L) return false
                if (n % (f + 2) == 0L) return false
            }
            true
        }
    }
}

Compiled from "Problem7.kt"
public final class Problem7Kt {
  public static final void main();
    Code:
       0: bipush        6
       2: invokestatic  #10                 // Method findPrime1:(I)J
       5: lstore_0
       6: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
       9: lload_0
      10: invokevirtual #22                 // Method java/io/PrintStream.println:(J)V
      13: bipush        6
      15: invokestatic  #25                 // Method findPrime:(I)J
      18: lstore_0
      19: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
      22: lload_0
      23: invokevirtual #22                 // Method java/io/PrintStream.println:(J)V
      26: iconst_0
      27: istore_2
      28: invokestatic  #29                 // Method java/lang/System.nanoTime:()J
      31: lstore_3
      32: iconst_0
      33: istore        5
      35: sipush        10001
      38: invokestatic  #10                 // Method findPrime1:(I)J
      41: lstore        6
      43: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
      46: lload         6
      48: invokevirtual #22                 // Method java/io/PrintStream.println:(J)V
      51: nop
      52: nop
      53: invokestatic  #29                 // Method java/lang/System.nanoTime:()J
      56: lload_3
      57: lsub
      58: lstore_0
      59: iconst_0
      60: istore        4
      62: invokestatic  #29                 // Method java/lang/System.nanoTime:()J
      65: lstore        5
      67: iconst_0
      68: istore        7
      70: sipush        10001
      73: invokestatic  #25                 // Method findPrime:(I)J
      76: lstore        8
      78: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
      81: lload         8
      83: invokevirtual #22                 // Method java/io/PrintStream.println:(J)V
      86: nop
      87: nop
      88: invokestatic  #29                 // Method java/lang/System.nanoTime:()J
      91: lload         5
      93: lsub
      94: lstore_2
      95: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
      98: lload_0
      99: invokevirtual #22                 // Method java/io/PrintStream.println:(J)V
     102: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
     105: lload_2
     106: invokevirtual #22                 // Method java/io/PrintStream.println:(J)V
     109: return

  private static final long findPrime1(int);
    Code:
       0: lconst_0
       1: lstore        9
       3: ldc2_w        #38                 // long 2l
       6: lstore        9
       8: iconst_1
       9: anewarray     #41                 // class java/lang/Long
      12: astore_2
      13: aload_2
      14: iconst_0
      15: lload         9
      17: invokestatic  #45                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      20: aastore
      21: aload_2
      22: invokestatic  #51                 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
      25: astore_1
      26: aload_1
      27: invokeinterface #57,  1           // InterfaceMethod java/util/List.size:()I
      32: iload_0
      33: if_icmpeq     155
      36: lload         9
      38: lstore_2
      39: lload_2
      40: lconst_1
      41: ladd
      42: lstore        9
      44: aload_1
      45: checkcast     #59                 // class java/lang/Iterable
      48: astore_2
      49: iconst_0
      50: istore_3
      51: aload_2
      52: instanceof    #61                 // class java/util/Collection
      55: ifeq          74
      58: aload_2
      59: checkcast     #61                 // class java/util/Collection
      62: invokeinterface #65,  1           // InterfaceMethod java/util/Collection.isEmpty:()Z
      67: ifeq          74
      70: iconst_0
      71: goto          137
      74: aload_2
      75: invokeinterface #69,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      80: astore        4
      82: aload         4
      84: invokeinterface #74,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      89: ifeq          136
      92: aload         4
      94: invokeinterface #78,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      99: astore        5
     101: aload         5
     103: checkcast     #80                 // class java/lang/Number
     106: invokevirtual #83                 // Method java/lang/Number.longValue:()J
     109: lstore        6
     111: iconst_0
     112: istore        8
     114: lload         9
     116: lload         6
     118: lrem
     119: lconst_0
     120: lcmp
     121: ifne          128
     124: iconst_1
     125: goto          129
     128: iconst_0
     129: ifeq          82
     132: iconst_1
     133: goto          137
     136: iconst_0
     137: ifne          26
     140: aload_1
     141: lload         9
     143: invokestatic  #45                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     146: invokeinterface #87,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     151: pop
     152: goto          26
     155: lload         9
     157: lreturn

  public static final long findPrime(int);
    Code:
       0: iload_0
       1: iconst_1
       2: if_icmpne     9
       5: ldc2_w        #38                 // long 2l
       8: lreturn
       9: iconst_1
      10: istore_1
      11: lconst_1
      12: lstore_2
      13: lload_2
      14: iconst_2
      15: i2l
      16: ladd
      17: lstore_2
      18: lload_2
      19: invokestatic  #102                // Method isPrime:(J)Z
      22: ifeq          28
      25: iinc          1, 1
      28: iload_1
      29: iload_0
      30: if_icmpne     13
      33: lload_2
      34: lreturn

  public static final boolean isPrime(long);
    Code:
       0: nop
       1: lload_0
       2: ldc2_w        #38                 // long 2l
       5: lcmp
       6: ifge          13
       9: iconst_0
      10: goto          143
      13: lload_0
      14: ldc2_w        #105                // long 4l
      17: lcmp
      18: ifge          25
      21: iconst_1
      22: goto          143
      25: lload_0
      26: iconst_2
      27: i2l
      28: lrem
      29: lconst_0
      30: lcmp
      31: ifne          38
      34: iconst_0
      35: goto          143
      38: lload_0
      39: ldc2_w        #107                // long 9l
      42: lcmp
      43: ifge          50
      46: iconst_1
      47: goto          143
      50: lload_0
      51: iconst_3
      52: i2l
      53: lrem
      54: lconst_0
      55: lcmp
      56: ifne          63
      59: iconst_0
      60: goto          143
      63: lload_0
      64: l2d
      65: invokestatic  #114                // Method java/lang/Math.sqrt:(D)D
      68: invokestatic  #117                // Method java/lang/Math.floor:(D)D
      71: d2l
      72: lstore_2
      73: ldc2_w        #118                // long 5l
      76: lstore        4
      78: ldc2_w        #118                // long 5l
      81: lload_2
      82: ldc2_w        #120                // long 6l
      85: invokestatic  #127                // Method kotlin/internal/ProgressionUtilKt.getProgressionLastElement:(JJJ)J
      88: lstore        6
      90: lload         4
      92: lload         6
      94: lcmp
      95: ifgt          142
      98: lload_0
      99: lload         4
     101: lrem
     102: lconst_0
     103: lcmp
     104: ifne          109
     107: iconst_0
     108: ireturn
     109: lload_0
     110: lload         4
     112: iconst_2
     113: i2l
     114: ladd
     115: lrem
     116: lconst_0
     117: lcmp
     118: ifne          123
     121: iconst_0
     122: ireturn
     123: lload         4
     125: lload         6
     127: lcmp
     128: ifeq          142
     131: lload         4
     133: ldc2_w        #120                // long 6l
     136: ladd
     137: lstore        4
     139: goto          98
     142: iconst_1
     143: ireturn

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


import kotlin.math.floor
import kotlin.math.sqrt

/**
 * Amicable numbers
 *
 * Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).
 * If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable
 * numbers.
 *
 * For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefore d(220) = 284. The
 * proper divisors of 284 are 1, 2, 4, 71 and 142; so d(284) = 220.
 *
 * Evaluate the sum of all the amicable numbers under 10000.
 *
 * https://projecteuler.net/problem=21
 */

fun main() {
    println(220.sumOfProperDivisors())
    println(284.sumOfProperDivisors())
    println(sumOfAmicables(10_000))
}

private fun sumOfAmicables(n: Int): Int {
    var sum = 0
    val amicables = mutableSetOf<Int>()
    for (a in 2 until n) {
        if (a in amicables) continue
        val b = a.sumOfProperDivisors()
        if (b > a && a == b.sumOfProperDivisors()) {
            sum += a + b
            amicables.add(b)
        }
    }
    return sum
}

fun Int.sumOfProperDivisors(): Int {
    var sum = 1
    var start = 2
    var step = 1

    var r = floor(sqrt(toDouble())).toInt()
    if (r * r == this) {
        sum += r
        r--
    }

    if (this % 2 != 0) {
        start = 3
        step = 2
    }

    for (i in start..r step step) {
        if (this % i == 0) {
            sum += i + (this / i)
        }
    }
    return sum
}

Compiled from "Problem21.kt"
public final class Problem21Kt {
  public static final void main();
    Code:
       0: sipush        220
       3: invokestatic  #10                 // Method sumOfProperDivisors:(I)I
       6: istore_0
       7: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
      10: iload_0
      11: invokevirtual #22                 // Method java/io/PrintStream.println:(I)V
      14: sipush        284
      17: invokestatic  #10                 // Method sumOfProperDivisors:(I)I
      20: istore_0
      21: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
      24: iload_0
      25: invokevirtual #22                 // Method java/io/PrintStream.println:(I)V
      28: sipush        10000
      31: invokestatic  #25                 // Method sumOfAmicables:(I)I
      34: istore_0
      35: getstatic     #16                 // Field java/lang/System.out:Ljava/io/PrintStream;
      38: iload_0
      39: invokevirtual #22                 // Method java/io/PrintStream.println:(I)V
      42: return

  private static final int sumOfAmicables(int);
    Code:
       0: iconst_0
       1: istore_1
       2: new           #27                 // class java/util/LinkedHashSet
       5: dup
       6: invokespecial #30                 // Method java/util/LinkedHashSet."<init>":()V
       9: checkcast     #32                 // class java/util/Set
      12: astore_2
      13: iconst_2
      14: istore_3
      15: iload_3
      16: iload_0
      17: if_icmpge     79
      20: aload_2
      21: iload_3
      22: invokestatic  #38                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      25: invokeinterface #42,  2           // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z
      30: ifne          73
      33: iload_3
      34: invokestatic  #10                 // Method sumOfProperDivisors:(I)I
      37: istore        4
      39: iload         4
      41: iload_3
      42: if_icmple     73
      45: iload_3
      46: iload         4
      48: invokestatic  #10                 // Method sumOfProperDivisors:(I)I
      51: if_icmpne     73
      54: iload_1
      55: iload_3
      56: iload         4
      58: iadd
      59: iadd
      60: istore_1
      61: aload_2
      62: iload         4
      64: invokestatic  #38                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      67: invokeinterface #45,  2           // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
      72: pop
      73: iinc          3, 1
      76: goto          15
      79: iload_1
      80: ireturn

  public static final int sumOfProperDivisors(int);
    Code:
       0: iconst_1
       1: istore_1
       2: iconst_2
       3: istore_2
       4: iconst_1
       5: istore_3
       6: iload_0
       7: i2d
       8: invokestatic  #58                 // Method java/lang/Math.sqrt:(D)D
      11: invokestatic  #61                 // Method java/lang/Math.floor:(D)D
      14: d2i
      15: istore        4
      17: iload         4
      19: iload         4
      21: imul
      22: iload_0
      23: if_icmpne     34
      26: iload_1
      27: iload         4
      29: iadd
      30: istore_1
      31: iinc          4, -1
      34: iload_0
      35: iconst_2
      36: irem
      37: ifeq          44
      40: iconst_3
      41: istore_2
      42: iconst_2
      43: istore_3
      44: iload_2
      45: istore        5
      47: iload         4
      49: istore        6
      51: iload_3
      52: istore        7
      54: iload         7
      56: ifgt          92
      59: new           #63                 // class java/lang/IllegalArgumentException
      62: dup
      63: new           #65                 // class java/lang/StringBuilder
      66: dup
      67: invokespecial #66                 // Method java/lang/StringBuilder."<init>":()V
      70: ldc           #68                 // String Step must be positive, was:
      72: invokevirtual #72                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      75: iload         7
      77: invokevirtual #75                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      80: bipush        46
      82: invokevirtual #78                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      85: invokevirtual #82                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      88: invokespecial #85                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
      91: athrow
      92: iload         5
      94: istore        8
      96: iload         5
      98: iload         6
     100: iload         7
     102: invokestatic  #91                 // Method kotlin/internal/ProgressionUtilKt.getProgressionLastElement:(III)I
     105: istore        9
     107: iload         7
     109: istore        10
     111: iload         8
     113: iload         9
     115: if_icmpgt     152
     118: iload_0
     119: iload         8
     121: irem
     122: ifne          135
     125: iload_1
     126: iload         8
     128: iload_0
     129: iload         8
     131: idiv
     132: iadd
     133: iadd
     134: istore_1
     135: iload         8
     137: iload         9
     139: if_icmpeq     152
     142: iload         8
     144: iload         10
     146: iadd
     147: istore        8
     149: goto          118
     152: iload_1
     153: ireturn

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


import kotlin.math.floor
import kotlin.math.sqrt
import kotlin.system.measureNanoTime

/**
 * Summation of primes
 *
 * The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
 * Find the sum of all the primes below two million.
 *
 * https://projecteuler.net/problem=10
 */

fun main() {
    println(sumOfPrimes(10))
    println(sumOfPrimesSieve(10))
    val time1 = measureNanoTime { println(sumOfPrimes(2_000_000)) }
    val time2 = measureNanoTime { println(sumOfPrimesSieve(2_000_000)) }

    println(time1)
    println(time2)
}

private fun sumOfPrimes(n: Long): Long {
    if (n < 2) return 0
    return (3..n step 2).asSequence()
        .filter(::isPrime)
        .sum() + 2
}

private fun sumOfPrimesSieve(n: Long): Long {
    return primes(n).sumOf(Int::toLong)
}

// The sieve of Eratosthenes optimized
fun primes(n: Long): List<Int> {
    val sieveBound = ((n - 1) / 2).toInt()
    val sieve = Array(sieveBound) { true }
    val crosslimit = (floor(sqrt(n.toDouble())).toInt() - 1) / 2

    for (i in 1..crosslimit) {
        if (!sieve[i-1]) continue
        for (j in (2 * i * (i + 1)) .. sieveBound step 2 * i + 1) {
            sieve[j-1] = false
        }
    }

    return listOf(2) + sieve.mapIndexedNotNull { i, isPrime -> if (isPrime) 2 * (i + 1) + 1 else null }
}

Compiled from "Problem10.kt"
final class Problem10Kt$sumOfPrimes$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.Long, java.lang.Boolean> {
  public static final Problem10Kt$sumOfPrimes$1 INSTANCE;

  Problem10Kt$sumOfPrimes$1();
    Code:
       0: aload_0
       1: iconst_1
       2: ldc           #11                 // class Problem7Kt
       4: ldc           #13                 // String isPrime
       6: ldc           #15                 // String isPrime(J)Z
       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.Boolean invoke(long);
    Code:
       0: lload_1
       1: invokestatic  #25                 // Method Problem7Kt.isPrime:(J)Z
       4: invokestatic  #31                 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
       7: areturn

  public java.lang.Object invoke(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #36                 // class java/lang/Number
       5: invokevirtual #40                 // Method java/lang/Number.longValue:()J
       8: invokevirtual #42                 // Method invoke:(J)Ljava/lang/Boolean;
      11: areturn

  static {};
    Code:
       0: new           #2                  // class Problem10Kt$sumOfPrimes$1
       3: dup
       4: invokespecial #47                 // Method "<init>":()V
       7: putstatic     #50                 // Field INSTANCE:LProblem10Kt$sumOfPrimes$1;
      10: return
}

Compiled from "Problem10.kt"
public final class Problem10Kt {
  public static final void main();
    Code:
       0: ldc2_w        #7                  // long 10l
       3: invokestatic  #12                 // Method sumOfPrimes:(J)J
       6: lstore_0
       7: getstatic     #18                 // Field java/lang/System.out:Ljava/io/PrintStream;
      10: lload_0
      11: invokevirtual #24                 // Method java/io/PrintStream.println:(J)V
      14: ldc2_w        #7                  // long 10l
      17: invokestatic  #27                 // Method sumOfPrimesSieve:(J)J
      20: lstore_0
      21: getstatic     #18                 // Field java/lang/System.out:Ljava/io/PrintStream;
      24: lload_0
      25: invokevirtual #24                 // Method java/io/PrintStream.println:(J)V
      28: iconst_0
      29: istore_2
      30: invokestatic  #31                 // Method java/lang/System.nanoTime:()J
      33: lstore_3
      34: iconst_0
      35: istore        5
      37: ldc2_w        #32                 // long 2000000l
      40: invokestatic  #12                 // Method sumOfPrimes:(J)J
      43: lstore        6
      45: getstatic     #18                 // Field java/lang/System.out:Ljava/io/PrintStream;
      48: lload         6
      50: invokevirtual #24                 // Method java/io/PrintStream.println:(J)V
      53: nop
      54: nop
      55: invokestatic  #31                 // Method java/lang/System.nanoTime:()J
      58: lload_3
      59: lsub
      60: lstore_0
      61: iconst_0
      62: istore        4
      64: invokestatic  #31                 // Method java/lang/System.nanoTime:()J
      67: lstore        5
      69: iconst_0
      70: istore        7
      72: ldc2_w        #32                 // long 2000000l
      75: invokestatic  #27                 // Method sumOfPrimesSieve:(J)J
      78: lstore        8
      80: getstatic     #18                 // Field java/lang/System.out:Ljava/io/PrintStream;
      83: lload         8
      85: invokevirtual #24                 // Method java/io/PrintStream.println:(J)V
      88: nop
      89: nop
      90: invokestatic  #31                 // Method java/lang/System.nanoTime:()J
      93: lload         5
      95: lsub
      96: lstore_2
      97: getstatic     #18                 // Field java/lang/System.out:Ljava/io/PrintStream;
     100: lload_0
     101: invokevirtual #24                 // Method java/io/PrintStream.println:(J)V
     104: getstatic     #18                 // Field java/lang/System.out:Ljava/io/PrintStream;
     107: lload_2
     108: invokevirtual #24                 // Method java/io/PrintStream.println:(J)V
     111: return

  private static final long sumOfPrimes(long);
    Code:
       0: lload_0
       1: ldc2_w        #42                 // long 2l
       4: lcmp
       5: ifge          10
       8: lconst_0
       9: lreturn
      10: new           #45                 // class kotlin/ranges/LongRange
      13: dup
      14: iconst_3
      15: i2l
      16: lload_0
      17: invokespecial #49                 // Method kotlin/ranges/LongRange."<init>":(JJ)V
      20: checkcast     #51                 // class kotlin/ranges/LongProgression
      23: ldc2_w        #42                 // long 2l
      26: invokestatic  #57                 // Method kotlin/ranges/RangesKt.step:(Lkotlin/ranges/LongProgression;J)Lkotlin/ranges/LongProgression;
      29: checkcast     #59                 // class java/lang/Iterable
      32: invokestatic  #65                 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;
      35: getstatic     #71                 // Field Problem10Kt$sumOfPrimes$1.INSTANCE:LProblem10Kt$sumOfPrimes$1;
      38: checkcast     #73                 // class kotlin/jvm/functions/Function1
      41: invokestatic  #79                 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      44: invokestatic  #83                 // Method kotlin/sequences/SequencesKt.sumOfLong:(Lkotlin/sequences/Sequence;)J
      47: iconst_2
      48: i2l
      49: ladd
      50: lreturn

  private static final long sumOfPrimesSieve(long);
    Code:
       0: lload_0
       1: invokestatic  #88                 // Method primes:(J)Ljava/util/List;
       4: checkcast     #59                 // class java/lang/Iterable
       7: astore_2
       8: lconst_0
       9: lstore_3
      10: aload_2
      11: invokeinterface #92,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      16: astore        5
      18: aload         5
      20: invokeinterface #98,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      25: ifeq          67
      28: aload         5
      30: invokeinterface #102,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      35: astore        6
      37: lload_3
      38: aload         6
      40: checkcast     #104                // class java/lang/Number
      43: invokevirtual #108                // Method java/lang/Number.intValue:()I
      46: istore        7
      48: lstore        9
      50: iconst_0
      51: istore        8
      53: iload         7
      55: i2l
      56: lstore        11
      58: lload         9
      60: lload         11
      62: ladd
      63: lstore_3
      64: goto          18
      67: lload_3
      68: lreturn

  public static final java.util.List<java.lang.Integer> primes(long);
    Code:
       0: lload_0
       1: lconst_1
       2: lsub
       3: iconst_2
       4: i2l
       5: ldiv
       6: l2i
       7: istore_2
       8: iconst_0
       9: istore        4
      11: iload_2
      12: anewarray     #114                // class java/lang/Boolean
      15: astore        5
      17: iload         4
      19: iload_2
      20: if_icmpge     42
      23: iload         4
      25: istore        6
      27: aload         5
      29: iload         6
      31: iconst_1
      32: invokestatic  #118                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
      35: aastore
      36: iinc          4, 1
      39: goto          17
      42: aload         5
      44: astore_3
      45: lload_0
      46: l2d
      47: invokestatic  #124                // Method java/lang/Math.sqrt:(D)D
      50: invokestatic  #127                // Method java/lang/Math.floor:(D)D
      53: d2i
      54: iconst_1
      55: isub
      56: iconst_2
      57: idiv
      58: istore        4
      60: iconst_1
      61: istore        5
      63: iload         5
      65: iload         4
      67: if_icmpgt     204
      70: aload_3
      71: iload         5
      73: iconst_1
      74: isub
      75: aaload
      76: invokevirtual #130                // Method java/lang/Boolean.booleanValue:()Z
      79: ifeq          191
      82: iconst_2
      83: iload         5
      85: imul
      86: iload         5
      88: iconst_1
      89: iadd
      90: imul
      91: istore        6
      93: iconst_2
      94: iload         5
      96: imul
      97: iconst_1
      98: iadd
      99: istore        7
     101: iload         7
     103: ifgt          139
     106: new           #132                // class java/lang/IllegalArgumentException
     109: dup
     110: new           #134                // class java/lang/StringBuilder
     113: dup
     114: invokespecial #136                // Method java/lang/StringBuilder."<init>":()V
     117: ldc           #138                // String Step must be positive, was:
     119: invokevirtual #142                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     122: iload         7
     124: invokevirtual #145                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     127: bipush        46
     129: invokevirtual #148                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
     132: invokevirtual #152                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     135: invokespecial #155                // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     138: athrow
     139: iload         6
     141: istore        8
     143: iload         6
     145: iload_2
     146: iload         7
     148: invokestatic  #161                // Method kotlin/internal/ProgressionUtilKt.getProgressionLastElement:(III)I
     151: istore        9
     153: iload         7
     155: istore        10
     157: iload         8
     159: iload         9
     161: if_icmpgt     191
     164: aload_3
     165: iload         8
     167: iconst_1
     168: isub
     169: iconst_0
     170: invokestatic  #118                // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     173: aastore
     174: iload         8
     176: iload         9
     178: if_icmpeq     191
     181: iload         8
     183: iload         10
     185: iadd
     186: istore        8
     188: goto          164
     191: iload         5
     193: iload         4
     195: if_icmpeq     204
     198: iinc          5, 1
     201: goto          70
     204: iconst_2
     205: invokestatic  #166                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     208: invokestatic  #170                // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
     211: checkcast     #172                // class java/util/Collection
     214: aload_3
     215: astore        5
     217: astore        24
     219: iconst_0
     220: istore        6
     222: aload         5
     224: astore        7
     226: new           #174                // class java/util/ArrayList
     229: dup
     230: invokespecial #175                // Method java/util/ArrayList."<init>":()V
     233: checkcast     #172                // class java/util/Collection
     236: astore        8
     238: iconst_0
     239: istore        9
     241: aload         7
     243: astore        10
     245: iconst_0
     246: istore        11
     248: iconst_0
     249: istore        12
     251: iconst_0
     252: istore        13
     254: aload         10
     256: arraylength
     257: istore        14
     259: iload         13
     261: iload         14
     263: if_icmpge     351
     266: aload         10
     268: iload         13
     270: aaload
     271: astore        15
     273: iload         12
     275: iinc          12, 1
     278: aload         15
     280: astore        16
     282: istore        17
     284: iconst_0
     285: istore        18
     287: iload         17
     289: aload         16
     291: invokevirtual #130                // Method java/lang/Boolean.booleanValue:()Z
     294: istore        19
     296: istore        20
     298: iconst_0
     299: istore        21
     301: iload         19
     303: ifeq          320
     306: iconst_2
     307: iload         20
     309: iconst_1
     310: iadd
     311: imul
     312: iconst_1
     313: iadd
     314: invokestatic  #166                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     317: goto          321
     320: aconst_null
     321: dup
     322: ifnull        343
     325: astore        22
     327: iconst_0
     328: istore        23
     330: aload         8
     332: aload         22
     334: invokeinterface #179,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     339: pop
     340: goto          344
     343: pop
     344: nop
     345: iinc          13, 1
     348: goto          259
     351: nop
     352: aload         8
     354: checkcast     #181                // class java/util/List
     357: nop
     358: aload         24
     360: swap
     361: checkcast     #59                 // class java/lang/Iterable
     364: invokestatic  #185                // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;
     367: areturn

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