import kotlin.math.abs
import java.util.Random

// https://en.wikipedia.org/wiki/Gauss–Jordan_elimination
// returns x such that A * x = b. requires |A| > 0
fun gauss(A: Array<DoubleArray>, b: DoubleArray): DoubleArray {
    val a = A.mapIndexed { i, Ai -> Ai + b[i] }.toTypedArray()
    val n = a.size
    for (i in 0 until n) {
        val pivot = (i until n).maxByOrNull { abs(a[it][i]) }!!
        a[i] = a[pivot].also { a[pivot] = a[i] }
        for (j in i + 1..n)
            a[i][j] /= a[i][i]
        for (j in 0 until n)
            if (j != i && a[j][i] != 0.0)
                for (k in i + 1..n)
                    a[j][k] -= a[i][k] * a[j][i]
    }
    return a.map { it[n] }.toDoubleArray()
}

// random test
fun main() {
    val rnd = Random(1)
    for (step in 0..9999) {
        val n = rnd.nextInt(5) + 1
        val a = (0 until n).map { (0 until n).map { (rnd.nextInt(10) - 5).toDouble() }.toDoubleArray() }.toTypedArray()
        if (abs(det(a)) > 1e-6) {
            val b = (0 until n).map { (rnd.nextInt(10) - 5).toDouble() }.toDoubleArray()
            val x = gauss(a, b)
            for (i in a.indices) {
                val y = a[i].zip(x).sumOf { it.first * it.second }
                if (abs(b[i] - y) > 1e-9)
                    throw RuntimeException()
            }
        }
    }
}

Compiled from "Gauss.kt"
public final class GaussKt {
  public static final double[] gauss(double[][], double[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String A
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #17                 // String b
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: checkcast     #19                 // class "[Ljava/lang/Object;"
      16: astore_3
      17: iconst_0
      18: istore        4
      20: aload_3
      21: astore        5
      23: new           #21                 // class java/util/ArrayList
      26: dup
      27: aload_3
      28: arraylength
      29: invokespecial #25                 // Method java/util/ArrayList."<init>":(I)V
      32: checkcast     #27                 // class java/util/Collection
      35: astore        6
      37: iconst_0
      38: istore        7
      40: iconst_0
      41: istore        8
      43: iconst_0
      44: istore        9
      46: aload         5
      48: arraylength
      49: istore        10
      51: iload         9
      53: iload         10
      55: if_icmpge     110
      58: aload         5
      60: iload         9
      62: aaload
      63: astore        12
      65: aload         6
      67: iload         8
      69: iinc          8, 1
      72: aload         12
      74: checkcast     #29                 // class "[D"
      77: astore        13
      79: istore        15
      81: astore        17
      83: iconst_0
      84: istore        16
      86: aload         13
      88: aload_1
      89: iload         15
      91: daload
      92: invokestatic  #35                 // Method kotlin/collections/ArraysKt.plus:([DD)[D
      95: aload         17
      97: swap
      98: invokeinterface #39,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     103: pop
     104: iinc          9, 1
     107: goto          51
     110: aload         6
     112: checkcast     #41                 // class java/util/List
     115: nop
     116: checkcast     #27                 // class java/util/Collection
     119: astore_3
     120: nop
     121: iconst_0
     122: istore        4
     124: aload_3
     125: astore        5
     127: aload         5
     129: iconst_0
     130: anewarray     #29                 // class "[D"
     133: invokeinterface #45,  2           // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;
     138: checkcast     #47                 // class "[[D"
     141: astore_2
     142: aload_2
     143: checkcast     #19                 // class "[Ljava/lang/Object;"
     146: arraylength
     147: istore_3
     148: iconst_0
     149: istore        4
     151: iload         4
     153: iload_3
     154: if_icmpge     521
     157: iload         4
     159: iload_3
     160: invokestatic  #53                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     163: checkcast     #55                 // class java/lang/Iterable
     166: astore        6
     168: iconst_0
     169: istore        7
     171: aload         6
     173: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     178: astore        8
     180: aload         8
     182: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     187: ifne          194
     190: aconst_null
     191: goto          309
     194: aload         8
     196: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     201: astore        9
     203: aload         8
     205: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     210: ifne          218
     213: aload         9
     215: goto          309
     218: aload         9
     220: checkcast     #71                 // class java/lang/Number
     223: invokevirtual #75                 // Method java/lang/Number.intValue:()I
     226: istore        10
     228: iconst_0
     229: istore        12
     231: aload_2
     232: iload         10
     234: aaload
     235: iload         4
     237: daload
     238: invokestatic  #81                 // Method java/lang/Math.abs:(D)D
     241: nop
     242: dstore        10
     244: aload         8
     246: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     251: astore        12
     253: aload         12
     255: checkcast     #71                 // class java/lang/Number
     258: invokevirtual #75                 // Method java/lang/Number.intValue:()I
     261: istore        13
     263: iconst_0
     264: istore        15
     266: aload_2
     267: iload         13
     269: aaload
     270: iload         4
     272: daload
     273: invokestatic  #81                 // Method java/lang/Math.abs:(D)D
     276: nop
     277: dstore        13
     279: dload         10
     281: dload         13
     283: invokestatic  #87                 // Method java/lang/Double.compare:(DD)I
     286: ifge          297
     289: aload         12
     291: astore        9
     293: dload         13
     295: dstore        10
     297: aload         8
     299: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     304: ifne          244
     307: aload         9
     309: dup
     310: invokestatic  #91                 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     313: checkcast     #71                 // class java/lang/Number
     316: invokevirtual #75                 // Method java/lang/Number.intValue:()I
     319: istore        5
     321: aload_2
     322: iload         4
     324: aload_2
     325: iload         5
     327: aaload
     328: astore        6
     330: aload         6
     332: astore        7
     334: istore        18
     336: astore        17
     338: iconst_0
     339: istore        8
     341: aload_2
     342: iload         5
     344: aload_2
     345: iload         4
     347: aaload
     348: aastore
     349: getstatic     #97                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     352: astore        19
     354: aload         17
     356: iload         18
     358: aload         6
     360: aastore
     361: iload         4
     363: iconst_1
     364: iadd
     365: istore        6
     367: iload         6
     369: iload_3
     370: if_icmpgt     413
     373: aload_2
     374: iload         4
     376: aaload
     377: astore        7
     379: iload         6
     381: istore        8
     383: aload         7
     385: iload         8
     387: aload         7
     389: iload         8
     391: daload
     392: aload_2
     393: iload         4
     395: aaload
     396: iload         4
     398: daload
     399: ddiv
     400: dastore
     401: iload         6
     403: iload_3
     404: if_icmpeq     413
     407: iinc          6, 1
     410: goto          373
     413: iconst_0
     414: istore        6
     416: iload         6
     418: iload_3
     419: if_icmpge     515
     422: iload         6
     424: iload         4
     426: if_icmpeq     509
     429: aload_2
     430: iload         6
     432: aaload
     433: iload         4
     435: daload
     436: dconst_0
     437: dcmpg
     438: ifne          445
     441: iconst_1
     442: goto          446
     445: iconst_0
     446: ifne          509
     449: iload         4
     451: iconst_1
     452: iadd
     453: istore        7
     455: iload         7
     457: iload_3
     458: if_icmpgt     509
     461: aload_2
     462: iload         6
     464: aaload
     465: astore        8
     467: iload         7
     469: istore        9
     471: aload         8
     473: iload         9
     475: aload         8
     477: iload         9
     479: daload
     480: aload_2
     481: iload         4
     483: aaload
     484: iload         7
     486: daload
     487: aload_2
     488: iload         6
     490: aaload
     491: iload         4
     493: daload
     494: dmul
     495: dsub
     496: dastore
     497: iload         7
     499: iload_3
     500: if_icmpeq     509
     503: iinc          7, 1
     506: goto          461
     509: iinc          6, 1
     512: goto          416
     515: iinc          4, 1
     518: goto          151
     521: aload_2
     522: checkcast     #19                 // class "[Ljava/lang/Object;"
     525: astore        4
     527: iconst_0
     528: istore        5
     530: aload         4
     532: astore        6
     534: new           #21                 // class java/util/ArrayList
     537: dup
     538: aload         4
     540: arraylength
     541: invokespecial #25                 // Method java/util/ArrayList."<init>":(I)V
     544: checkcast     #27                 // class java/util/Collection
     547: astore        7
     549: iconst_0
     550: istore        8
     552: iconst_0
     553: istore        9
     555: aload         6
     557: arraylength
     558: istore        10
     560: iload         9
     562: iload         10
     564: if_icmpge     610
     567: aload         6
     569: iload         9
     571: aaload
     572: astore        12
     574: aload         7
     576: aload         12
     578: checkcast     #29                 // class "[D"
     581: astore        13
     583: astore        17
     585: iconst_0
     586: istore        15
     588: aload         13
     590: iload_3
     591: daload
     592: invokestatic  #101                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     595: aload         17
     597: swap
     598: invokeinterface #39,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     603: pop
     604: iinc          9, 1
     607: goto          560
     610: aload         7
     612: checkcast     #41                 // class java/util/List
     615: nop
     616: checkcast     #27                 // class java/util/Collection
     619: invokestatic  #107                // Method kotlin/collections/CollectionsKt.toDoubleArray:(Ljava/util/Collection;)[D
     622: areturn

  public static final void main();
    Code:
       0: new           #150                // class java/util/Random
       3: dup
       4: lconst_1
       5: invokespecial #153                // Method java/util/Random."<init>":(J)V
       8: astore_0
       9: iconst_0
      10: istore_1
      11: iload_1
      12: sipush        10000
      15: if_icmpge     558
      18: aload_0
      19: iconst_5
      20: invokevirtual #157                // Method java/util/Random.nextInt:(I)I
      23: iconst_1
      24: iadd
      25: istore_2
      26: iconst_0
      27: iload_2
      28: invokestatic  #53                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      31: checkcast     #55                 // class java/lang/Iterable
      34: astore        4
      36: iconst_0
      37: istore        5
      39: aload         4
      41: astore        6
      43: new           #21                 // class java/util/ArrayList
      46: dup
      47: aload         4
      49: bipush        10
      51: invokestatic  #161                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      54: invokespecial #25                 // Method java/util/ArrayList."<init>":(I)V
      57: checkcast     #27                 // class java/util/Collection
      60: astore        7
      62: iconst_0
      63: istore        8
      65: aload         6
      67: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      72: astore        9
      74: aload         9
      76: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      81: ifeq          232
      84: aload         9
      86: checkcast     #163                // class kotlin/collections/IntIterator
      89: invokevirtual #165                // Method kotlin/collections/IntIterator.nextInt:()I
      92: istore        10
      94: aload         7
      96: iload         10
      98: istore        11
     100: astore        23
     102: iconst_0
     103: istore        12
     105: iconst_0
     106: iload_2
     107: invokestatic  #53                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     110: checkcast     #55                 // class java/lang/Iterable
     113: astore        13
     115: iconst_0
     116: istore        14
     118: aload         13
     120: astore        15
     122: new           #21                 // class java/util/ArrayList
     125: dup
     126: aload         13
     128: bipush        10
     130: invokestatic  #161                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     133: invokespecial #25                 // Method java/util/ArrayList."<init>":(I)V
     136: checkcast     #27                 // class java/util/Collection
     139: astore        16
     141: iconst_0
     142: istore        17
     144: aload         15
     146: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     151: astore        18
     153: aload         18
     155: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     160: ifeq          208
     163: aload         18
     165: checkcast     #163                // class kotlin/collections/IntIterator
     168: invokevirtual #165                // Method kotlin/collections/IntIterator.nextInt:()I
     171: istore        19
     173: aload         16
     175: iload         19
     177: istore        20
     179: astore        21
     181: iconst_0
     182: istore        22
     184: aload_0
     185: bipush        10
     187: invokevirtual #157                // Method java/util/Random.nextInt:(I)I
     190: iconst_5
     191: isub
     192: i2d
     193: invokestatic  #101                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     196: aload         21
     198: swap
     199: invokeinterface #39,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     204: pop
     205: goto          153
     208: aload         16
     210: checkcast     #41                 // class java/util/List
     213: nop
     214: checkcast     #27                 // class java/util/Collection
     217: invokestatic  #107                // Method kotlin/collections/CollectionsKt.toDoubleArray:(Ljava/util/Collection;)[D
     220: aload         23
     222: swap
     223: invokeinterface #39,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     228: pop
     229: goto          74
     232: aload         7
     234: checkcast     #41                 // class java/util/List
     237: nop
     238: checkcast     #27                 // class java/util/Collection
     241: astore        4
     243: nop
     244: iconst_0
     245: istore        5
     247: aload         4
     249: astore        6
     251: aload         6
     253: iconst_0
     254: anewarray     #29                 // class "[D"
     257: invokeinterface #45,  2           // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;
     262: checkcast     #47                 // class "[[D"
     265: astore_3
     266: aload_3
     267: invokestatic  #171                // Method DeterminantKt.det:([[D)D
     270: invokestatic  #81                 // Method java/lang/Math.abs:(D)D
     273: ldc2_w        #172                // double 1.0E-6d
     276: dcmpl
     277: ifle          552
     280: iconst_0
     281: iload_2
     282: invokestatic  #53                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     285: checkcast     #55                 // class java/lang/Iterable
     288: astore        5
     290: iconst_0
     291: istore        6
     293: aload         5
     295: astore        7
     297: new           #21                 // class java/util/ArrayList
     300: dup
     301: aload         5
     303: bipush        10
     305: invokestatic  #161                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     308: invokespecial #25                 // Method java/util/ArrayList."<init>":(I)V
     311: checkcast     #27                 // class java/util/Collection
     314: astore        8
     316: iconst_0
     317: istore        9
     319: aload         7
     321: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     326: astore        10
     328: aload         10
     330: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     335: ifeq          383
     338: aload         10
     340: checkcast     #163                // class kotlin/collections/IntIterator
     343: invokevirtual #165                // Method kotlin/collections/IntIterator.nextInt:()I
     346: istore        11
     348: aload         8
     350: iload         11
     352: istore        12
     354: astore        23
     356: iconst_0
     357: istore        13
     359: aload_0
     360: bipush        10
     362: invokevirtual #157                // Method java/util/Random.nextInt:(I)I
     365: iconst_5
     366: isub
     367: i2d
     368: invokestatic  #101                // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;
     371: aload         23
     373: swap
     374: invokeinterface #39,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     379: pop
     380: goto          328
     383: aload         8
     385: checkcast     #41                 // class java/util/List
     388: nop
     389: checkcast     #27                 // class java/util/Collection
     392: invokestatic  #107                // Method kotlin/collections/CollectionsKt.toDoubleArray:(Ljava/util/Collection;)[D
     395: astore        4
     397: aload_3
     398: aload         4
     400: invokestatic  #175                // Method gauss:([[D[D)[D
     403: astore        5
     405: iconst_0
     406: istore        6
     408: aload_3
     409: checkcast     #19                 // class "[Ljava/lang/Object;"
     412: arraylength
     413: istore        7
     415: iload         6
     417: iload         7
     419: if_icmpge     552
     422: aload_3
     423: iload         6
     425: aaload
     426: aload         5
     428: invokestatic  #179                // Method kotlin/collections/ArraysKt.zip:([D[D)Ljava/util/List;
     431: checkcast     #55                 // class java/lang/Iterable
     434: astore        10
     436: dconst_0
     437: dstore        11
     439: aload         10
     441: invokeinterface #59,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     446: astore        13
     448: aload         13
     450: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     455: ifeq          516
     458: aload         13
     460: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     465: astore        14
     467: dload         11
     469: aload         14
     471: checkcast     #181                // class kotlin/Pair
     474: astore        15
     476: dstore        23
     478: iconst_0
     479: istore        16
     481: aload         15
     483: invokevirtual #184                // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     486: checkcast     #71                 // class java/lang/Number
     489: invokevirtual #188                // Method java/lang/Number.doubleValue:()D
     492: aload         15
     494: invokevirtual #191                // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     497: checkcast     #71                 // class java/lang/Number
     500: invokevirtual #188                // Method java/lang/Number.doubleValue:()D
     503: dmul
     504: dstore        25
     506: dload         23
     508: dload         25
     510: dadd
     511: dstore        11
     513: goto          448
     516: dload         11
     518: dstore        8
     520: aload         4
     522: iload         6
     524: daload
     525: dload         8
     527: dsub
     528: invokestatic  #81                 // Method java/lang/Math.abs:(D)D
     531: ldc2_w        #192                // double 1.0E-9d
     534: dcmpl
     535: ifle          546
     538: new           #195                // class java/lang/RuntimeException
     541: dup
     542: invokespecial #197                // Method java/lang/RuntimeException."<init>":()V
     545: athrow
     546: iinc          6, 1
     549: goto          415
     552: iinc          1, 1
     555: goto          11
     558: return

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


import kotlin.math.max
import kotlin.math.min

fun findMedianSortedArrays(nums1: IntArray, nums2: IntArray): Double {
    val size = nums1.size + nums2.size
    return if (size % 2 == 0) {
        (findK(nums1, nums2, size / 2) + findK(nums1, nums2, size / 2 + 1)) / 2.0
    } else {
        findK(nums1, nums2, size / 2 + 1).toDouble()
    }
}

fun findK(nums1: IntArray, nums2: IntArray, k: Int): Int {
    var i = max(0, k - nums2.size)
    var j = min(k, nums1.size)
    while (i < j) {
        val m = (i + j) / 2
        if (nums1[m] < nums2[k - m - 1]) {
            i = m + 1
        } else {
            j = m
        }
    }
    return when (i) {
        0 -> nums2[k - i - 1]
        k -> nums1[i - 1]
        else -> max(nums1[i - 1], nums2[k - i - 1])
    }
}

Compiled from "solution.kt"
public final class SolutionKt {
  public static final double findMedianSortedArrays(int[], int[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String nums1
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #17                 // String nums2
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_0
      13: arraylength
      14: aload_1
      15: arraylength
      16: iadd
      17: istore_2
      18: iload_2
      19: iconst_2
      20: irem
      21: ifne          51
      24: aload_0
      25: aload_1
      26: iload_2
      27: iconst_2
      28: idiv
      29: invokestatic  #21                 // Method findK:([I[II)I
      32: aload_0
      33: aload_1
      34: iload_2
      35: iconst_2
      36: idiv
      37: iconst_1
      38: iadd
      39: invokestatic  #21                 // Method findK:([I[II)I
      42: iadd
      43: i2d
      44: ldc2_w        #22                 // double 2.0d
      47: ddiv
      48: goto          62
      51: aload_0
      52: aload_1
      53: iload_2
      54: iconst_2
      55: idiv
      56: iconst_1
      57: iadd
      58: invokestatic  #21                 // Method findK:([I[II)I
      61: i2d
      62: dreturn

  public static final int findK(int[], int[], int);
    Code:
       0: aload_0
       1: ldc           #9                  // String nums1
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #17                 // String nums2
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: iconst_0
      13: iload_2
      14: aload_1
      15: arraylength
      16: isub
      17: invokestatic  #32                 // Method java/lang/Math.max:(II)I
      20: istore_3
      21: iload_2
      22: aload_0
      23: arraylength
      24: invokestatic  #35                 // Method java/lang/Math.min:(II)I
      27: istore        4
      29: iload_3
      30: iload         4
      32: if_icmpge     73
      35: iload_3
      36: iload         4
      38: iadd
      39: iconst_2
      40: idiv
      41: istore        5
      43: aload_0
      44: iload         5
      46: iaload
      47: aload_1
      48: iload_2
      49: iload         5
      51: isub
      52: iconst_1
      53: isub
      54: iaload
      55: if_icmpge     66
      58: iload         5
      60: iconst_1
      61: iadd
      62: istore_3
      63: goto          29
      66: iload         5
      68: istore        4
      70: goto          29
      73: iload_3
      74: istore        5
      76: iload         5
      78: ifne          91
      81: aload_1
      82: iload_2
      83: iload_3
      84: isub
      85: iconst_1
      86: isub
      87: iaload
      88: goto          120
      91: iload         5
      93: iload_2
      94: if_icmpne     105
      97: aload_0
      98: iload_3
      99: iconst_1
     100: isub
     101: iaload
     102: goto          120
     105: aload_0
     106: iload_3
     107: iconst_1
     108: isub
     109: iaload
     110: aload_1
     111: iload_2
     112: iload_3
     113: isub
     114: iconst_1
     115: isub
     116: iaload
     117: invokestatic  #32                 // Method java/lang/Math.max:(II)I
     120: ireturn
}


//顶层变量：
val Pi = 3.14159265358979
var temp = 0
fun main(){
    //定义只读局部变量使⽤关键字 val 定义。只能为其赋值⼀次
    val a: Int = 1 // ⽴即赋值
    val b = 2 // ⾃动推断出 `Int` 类型
    val c: Int // 如果没有初始值类型不能省略
    c = 3 // 明确赋值
    var edge = a*b*c
    println("S-P-D-B")
    println(sum(a,b))
    edge*=2
    println(sum1(b,c))
    println(sum2(a,c))
    println(sum3(b,c))
    println("sum:${sum(edge,edge)}")

    println(incrementX())
    println(maxOf(a,b))
}

//带有两个 Int 参数、返回 Int 的函数
fun sum(a:Int,b:Int):Int{
    return a+b
}
//将表达式作为函数体、返回值类型⾃动推断的函数
fun sum1(a:Int,b:Int)= a+b

//函数返回⽆意义的值：
fun sum2(a:Int,b:Int):Unit{
    println("sum of $a and $b is ${a+b}")
}

//Unit 返回类型可以省略：
fun sum3(a:Int,b:Int){
    println("sum of $a and $b is ${a+b}")
}

fun incrementX():Int{
    temp +=9
    temp *=temp
    println(Pi)

    val sz = "temp is $temp"
    temp = 10086
    println(sz)
    val so = "${sz.replace("is","was")},but new is $temp"
    println(so)
    return temp
}

fun maxOf(a: Int, b: Int): Int {
    if (a > b) {
        return a
    } else {
        return b
    }
}

Compiled from "Main.kt"
public final class MainKt {
  private static final double Pi;

  private static int temp;

  public static final double getPi();
    Code:
       0: getstatic     #10                 // Field Pi:D
       3: dreturn

  public static final int getTemp();
    Code:
       0: getstatic     #16                 // Field temp:I
       3: ireturn

  public static final void setTemp(int);
    Code:
       0: iload_0
       1: putstatic     #16                 // Field temp:I
       4: return

  public static final void main();
    Code:
       0: iconst_1
       1: istore_0
       2: iconst_2
       3: istore_1
       4: iconst_0
       5: istore_2
       6: iconst_3
       7: istore_2
       8: iload_0
       9: iload_1
      10: imul
      11: iload_2
      12: imul
      13: istore_3
      14: ldc           #23                 // String S-P-D-B
      16: getstatic     #29                 // Field java/lang/System.out:Ljava/io/PrintStream;
      19: swap
      20: invokevirtual #35                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      23: iload_0
      24: iload_1
      25: invokestatic  #39                 // Method sum:(II)I
      28: istore        4
      30: getstatic     #29                 // Field java/lang/System.out:Ljava/io/PrintStream;
      33: iload         4
      35: invokevirtual #41                 // Method java/io/PrintStream.println:(I)V
      38: iload_3
      39: iconst_2
      40: imul
      41: istore_3
      42: iload_1
      43: iload_2
      44: invokestatic  #44                 // Method sum1:(II)I
      47: istore        4
      49: getstatic     #29                 // Field java/lang/System.out:Ljava/io/PrintStream;
      52: iload         4
      54: invokevirtual #41                 // Method java/io/PrintStream.println:(I)V
      57: iload_0
      58: iload_2
      59: invokestatic  #48                 // Method sum2:(II)V
      62: getstatic     #54                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      65: getstatic     #29                 // Field java/lang/System.out:Ljava/io/PrintStream;
      68: swap
      69: invokevirtual #35                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      72: iload_1
      73: iload_2
      74: invokestatic  #57                 // Method sum3:(II)V
      77: getstatic     #54                 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      80: getstatic     #29                 // Field java/lang/System.out:Ljava/io/PrintStream;
      83: swap
      84: invokevirtual #35                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      87: new           #59                 // class java/lang/StringBuilder
      90: dup
      91: invokespecial #62                 // Method java/lang/StringBuilder."<init>":()V
      94: ldc           #64                 // String sum:
      96: invokevirtual #68                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      99: iload_3
     100: iload_3
     101: invokestatic  #39                 // Method sum:(II)I
     104: invokevirtual #71                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     107: invokevirtual #75                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     110: getstatic     #29                 // Field java/lang/System.out:Ljava/io/PrintStream;
     113: swap
     114: invokevirtual #35                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     117: invokestatic  #78                 // Method incrementX:()I
     120: istore        4
     122: getstatic     #29                 // Field java/lang/System.out:Ljava/io/PrintStream;
     125: iload         4
     127: invokevirtual #41                 // Method java/io/PrintStream.println:(I)V
     130: iload_0
     131: iload_1
     132: invokestatic  #81                 // Method maxOf:(II)I
     135: istore        4
     137: getstatic     #29                 // Field java/lang/System.out:Ljava/io/PrintStream;
     140: iload         4
     142: invokevirtual #41                 // Method java/io/PrintStream.println:(I)V
     145: return

  public static final int sum(int, int);
    Code:
       0: iload_0
       1: iload_1
       2: iadd
       3: ireturn

  public static final int sum1(int, int);
    Code:
       0: iload_0
       1: iload_1
       2: iadd
       3: ireturn

  public static final void sum2(int, int);
    Code:
       0: new           #59                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #62                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #87                 // String sum of
       9: invokevirtual #68                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: iload_0
      13: invokevirtual #71                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      16: ldc           #89                 // String  and
      18: invokevirtual #68                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      21: iload_1
      22: invokevirtual #71                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      25: ldc           #91                 // String  is
      27: invokevirtual #68                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      30: iload_0
      31: iload_1
      32: iadd
      33: invokevirtual #71                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      36: invokevirtual #75                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      39: getstatic     #29                 // Field java/lang/System.out:Ljava/io/PrintStream;
      42: swap
      43: invokevirtual #35                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      46: return

  public static final void sum3(int, int);
    Code:
       0: new           #59                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #62                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #87                 // String sum of
       9: invokevirtual #68                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: iload_0
      13: invokevirtual #71                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      16: ldc           #89                 // String  and
      18: invokevirtual #68                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      21: iload_1
      22: invokevirtual #71                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      25: ldc           #91                 // String  is
      27: invokevirtual #68                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      30: iload_0
      31: iload_1
      32: iadd
      33: invokevirtual #71                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      36: invokevirtual #75                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      39: getstatic     #29                 // Field java/lang/System.out:Ljava/io/PrintStream;
      42: swap
      43: invokevirtual #35                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      46: return

  public static final int incrementX();
    Code:
       0: getstatic     #16                 // Field temp:I
       3: bipush        9
       5: iadd
       6: putstatic     #16                 // Field temp:I
       9: getstatic     #16                 // Field temp:I
      12: getstatic     #16                 // Field temp:I
      15: imul
      16: putstatic     #16                 // Field temp:I
      19: getstatic     #10                 // Field Pi:D
      22: dstore_0
      23: getstatic     #29                 // Field java/lang/System.out:Ljava/io/PrintStream;
      26: dload_0
      27: invokevirtual #94                 // Method java/io/PrintStream.println:(D)V
      30: new           #59                 // class java/lang/StringBuilder
      33: dup
      34: invokespecial #62                 // Method java/lang/StringBuilder."<init>":()V
      37: ldc           #96                 // String temp is
      39: invokevirtual #68                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      42: getstatic     #16                 // Field temp:I
      45: invokevirtual #71                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      48: invokevirtual #75                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      51: astore_0
      52: sipush        10086
      55: putstatic     #16                 // Field temp:I
      58: getstatic     #29                 // Field java/lang/System.out:Ljava/io/PrintStream;
      61: aload_0
      62: invokevirtual #35                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      65: new           #59                 // class java/lang/StringBuilder
      68: dup
      69: invokespecial #62                 // Method java/lang/StringBuilder."<init>":()V
      72: aload_0
      73: ldc           #98                 // String is
      75: ldc           #100                // String was
      77: iconst_0
      78: iconst_4
      79: aconst_null
      80: invokestatic  #106                // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;
      83: invokevirtual #68                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      86: ldc           #108                // String ,but new is
      88: invokevirtual #68                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      91: getstatic     #16                 // Field temp:I
      94: invokevirtual #71                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      97: invokevirtual #75                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     100: astore_1
     101: getstatic     #29                 // Field java/lang/System.out:Ljava/io/PrintStream;
     104: aload_1
     105: invokevirtual #35                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     108: getstatic     #16                 // Field temp:I
     111: ireturn

  public static final int maxOf(int, int);
    Code:
       0: iload_0
       1: iload_1
       2: if_icmple     7
       5: iload_0
       6: ireturn
       7: iload_1
       8: ireturn

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

  static {};
    Code:
       0: ldc2_w        #118                // double 3.14159265358979d
       3: putstatic     #10                 // Field Pi:D
       6: return
}


class Day03(raw: List<String>) {

    private val forest: Forest = Forest.parse(raw)

    fun part1(): Long = forest.trees(Slope(right = 3, down = 1))

    fun part2(): Long = listOf(
        Slope(right = 1, down = 1),
        Slope(right = 3, down = 1),
        Slope(right = 5, down = 1),
        Slope(right = 7, down = 1),
        Slope(right = 1, down = 2),
    ).map(forest::trees).reduce { acc, i -> acc * i }

    data class Forest(val raw: List<BooleanArray>) {

        companion object {

            fun parse(lines: List<String>): Forest = lines.map { line ->
                line.map { it.toTree() }.toBooleanArray()
            }.let(::Forest)

            private fun Char.toTree() = when (this) {
                '#' -> true
                '.' -> false
                else -> throw Exception()
            }

        }

        private operator fun get(position: Position): Boolean = raw[position.y].let { it[position.x % it.size] }

        private fun horizontal(slope: Slope): Sequence<Int> = generateSequence(0) { x -> x + slope.right }

        private fun vertical(slope: Slope): Sequence<Int> = generateSequence(0) { y -> (y + slope.down).takeUnless { it >= raw.size } }

        private fun positions(slope: Slope): Sequence<Position> = horizontal(slope).zip(vertical(slope), ::Position)

        fun trees(slope: Slope): Long = positions(slope).count { this[it] }.toLong()

    }

    data class Slope(val right: Int, val down: Int)

    data class Position(val x: Int, val y: Int)

}

Compiled from "Day03.kt"
final class Day03$Forest$positions$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<java.lang.Integer, java.lang.Integer, Day03$Position> {
  public static final Day03$Forest$positions$1 INSTANCE;

  Day03$Forest$positions$1();
    Code:
       0: aload_0
       1: iconst_2
       2: ldc           #11                 // class Day03$Position
       4: ldc           #12                 // String <init>
       6: ldc           #14                 // String <init>(II)V
       8: iconst_0
       9: invokespecial #17                 // Method kotlin/jvm/internal/FunctionReferenceImpl."<init>":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
      12: return

  public final Day03$Position invoke(int, int);
    Code:
       0: new           #11                 // class Day03$Position
       3: dup
       4: iload_1
       5: iload_2
       6: invokespecial #24                 // Method Day03$Position."<init>":(II)V
       9: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #30                 // class java/lang/Number
       5: invokevirtual #34                 // Method java/lang/Number.intValue:()I
       8: aload_2
       9: checkcast     #30                 // class java/lang/Number
      12: invokevirtual #34                 // Method java/lang/Number.intValue:()I
      15: invokevirtual #36                 // Method invoke:(II)LDay03$Position;
      18: areturn

  static {};
    Code:
       0: new           #2                  // class Day03$Forest$positions$1
       3: dup
       4: invokespecial #41                 // Method "<init>":()V
       7: putstatic     #44                 // Field INSTANCE:LDay03$Forest$positions$1;
      10: return
}

Compiled from "Day03.kt"
public final class Day03$Position {
  private final int x;

  private final int y;

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

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

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

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

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

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

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

  public java.lang.String toString();
    Code:
       0: new           #36                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #37                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #39                 // String Position(x=
       9: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #13                 // Field x:I
      16: invokevirtual #46                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: ldc           #48                 // String , y=
      21: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #16                 // Field y:I
      28: invokevirtual #46                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      31: bipush        41
      33: invokevirtual #51                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      36: invokevirtual #53                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      39: areturn

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

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

Compiled from "Day03.kt"
public final class Day03$Forest$Companion {
  private Day03$Forest$Companion();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final Day03$Forest parse(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #16                 // String lines
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #24                 // class java/lang/Iterable
      10: astore_2
      11: iconst_0
      12: istore_3
      13: aload_2
      14: astore        4
      16: new           #26                 // class java/util/ArrayList
      19: dup
      20: aload_2
      21: bipush        10
      23: invokestatic  #32                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      26: invokespecial #35                 // Method java/util/ArrayList."<init>":(I)V
      29: checkcast     #37                 // class java/util/Collection
      32: astore        5
      34: iconst_0
      35: istore        6
      37: aload         4
      39: invokeinterface #41,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      44: astore        7
      46: aload         7
      48: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      53: ifeq          202
      56: aload         7
      58: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      63: astore        8
      65: aload         5
      67: aload         8
      69: checkcast     #53                 // class java/lang/String
      72: astore        9
      74: astore        21
      76: iconst_0
      77: istore        10
      79: aload         9
      81: checkcast     #55                 // class java/lang/CharSequence
      84: astore        11
      86: iconst_0
      87: istore        12
      89: aload         11
      91: astore        13
      93: new           #26                 // class java/util/ArrayList
      96: dup
      97: aload         11
      99: invokeinterface #59,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     104: invokespecial #35                 // Method java/util/ArrayList."<init>":(I)V
     107: checkcast     #37                 // class java/util/Collection
     110: astore        14
     112: iconst_0
     113: istore        15
     115: iconst_0
     116: istore        16
     118: iload         16
     120: aload         13
     122: invokeinterface #59,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     127: if_icmpge     178
     130: aload         13
     132: iload         16
     134: invokeinterface #63,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     139: istore        17
     141: aload         14
     143: iload         17
     145: istore        18
     147: astore        19
     149: iconst_0
     150: istore        20
     152: getstatic     #68                 // Field Day03$Forest.Companion:LDay03$Forest$Companion;
     155: iload         18
     157: invokespecial #72                 // Method toTree:(C)Z
     160: invokestatic  #78                 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;
     163: aload         19
     165: swap
     166: invokeinterface #82,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     171: pop
     172: iinc          16, 1
     175: goto          118
     178: aload         14
     180: checkcast     #84                 // class java/util/List
     183: nop
     184: checkcast     #37                 // class java/util/Collection
     187: invokestatic  #88                 // Method kotlin/collections/CollectionsKt.toBooleanArray:(Ljava/util/Collection;)[Z
     190: aload         21
     192: swap
     193: invokeinterface #82,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     198: pop
     199: goto          46
     202: aload         5
     204: checkcast     #84                 // class java/util/List
     207: nop
     208: astore_3
     209: iconst_0
     210: istore        4
     212: new           #65                 // class Day03$Forest
     215: dup
     216: aload_3
     217: invokespecial #91                 // Method Day03$Forest."<init>":(Ljava/util/List;)V
     220: nop
     221: areturn

  private final boolean toTree(char);
    Code:
       0: iload_1
       1: lookupswitch  { // 2
                    35: 28
                    46: 32
               default: 36
          }
      28: iconst_1
      29: goto          44
      32: iconst_0
      33: goto          44
      36: new           #113                // class java/lang/Exception
      39: dup
      40: invokespecial #114                // Method java/lang/Exception."<init>":()V
      43: athrow
      44: ireturn

  public Day03$Forest$Companion(kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: aload_0
       1: invokespecial #117                // Method "<init>":()V
       4: return
}

Compiled from "Day03.kt"
public final class Day03$Forest {
  public static final Day03$Forest$Companion Companion;

  private final java.util.List<boolean[]> raw;

  public Day03$Forest(java.util.List<boolean[]>);
    Code:
       0: aload_1
       1: ldc           #10                 // String raw
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #19                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: aload_1
      12: putfield      #22                 // Field raw:Ljava/util/List;
      15: return

  public final java.util.List<boolean[]> getRaw();
    Code:
       0: aload_0
       1: getfield      #22                 // Field raw:Ljava/util/List;
       4: areturn

  private final boolean get(Day03$Position);
    Code:
       0: aload_0
       1: getfield      #22                 // Field raw:Ljava/util/List;
       4: aload_1
       5: invokevirtual #35                 // Method Day03$Position.getY:()I
       8: invokeinterface #40,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      13: checkcast     #42                 // class "[Z"
      16: astore_2
      17: iconst_0
      18: istore_3
      19: aload_2
      20: aload_1
      21: invokevirtual #45                 // Method Day03$Position.getX:()I
      24: aload_2
      25: arraylength
      26: irem
      27: baload
      28: nop
      29: ireturn

  private final kotlin.sequences.Sequence<java.lang.Integer> horizontal(Day03$Slope);
    Code:
       0: iconst_0
       1: invokestatic  #59                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
       4: aload_1
       5: invokedynamic #79,  0             // InvokeDynamic #0:invoke:(LDay03$Slope;)Lkotlin/jvm/functions/Function1;
      10: invokestatic  #85                 // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      13: areturn

  private final kotlin.sequences.Sequence<java.lang.Integer> vertical(Day03$Slope);
    Code:
       0: iconst_0
       1: invokestatic  #59                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
       4: aload_1
       5: aload_0
       6: invokedynamic #96,  0             // InvokeDynamic #1:invoke:(LDay03$Slope;LDay03$Forest;)Lkotlin/jvm/functions/Function1;
      11: invokestatic  #85                 // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;
      14: areturn

  private final kotlin.sequences.Sequence<Day03$Position> positions(Day03$Slope);
    Code:
       0: aload_0
       1: aload_1
       2: invokespecial #100                // Method horizontal:(LDay03$Slope;)Lkotlin/sequences/Sequence;
       5: aload_0
       6: aload_1
       7: invokespecial #102                // Method vertical:(LDay03$Slope;)Lkotlin/sequences/Sequence;
      10: getstatic     #108                // Field Day03$Forest$positions$1.INSTANCE:LDay03$Forest$positions$1;
      13: checkcast     #110                // class kotlin/jvm/functions/Function2
      16: invokestatic  #114                // Method kotlin/sequences/SequencesKt.zip:(Lkotlin/sequences/Sequence;Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function2;)Lkotlin/sequences/Sequence;
      19: areturn

  public final long trees(Day03$Slope);
    Code:
       0: aload_1
       1: ldc           #117                // String slope
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: aload_1
       8: invokespecial #119                // Method positions:(LDay03$Slope;)Lkotlin/sequences/Sequence;
      11: astore_2
      12: iconst_0
      13: istore_3
      14: iconst_0
      15: istore        4
      17: aload_2
      18: invokeinterface #125,  1          // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
      23: astore        5
      25: aload         5
      27: invokeinterface #131,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      32: ifeq          77
      35: aload         5
      37: invokeinterface #135,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      42: astore        6
      44: aload         6
      46: checkcast     #31                 // class Day03$Position
      49: astore        7
      51: iconst_0
      52: istore        8
      54: aload_0
      55: aload         7
      57: invokespecial #137                // Method get:(LDay03$Position;)Z
      60: ifeq          25
      63: iinc          4, 1
      66: iload         4
      68: ifge          25
      71: invokestatic  #142                // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V
      74: goto          25
      77: iload         4
      79: i2l
      80: lreturn

  public final java.util.List<boolean[]> component1();
    Code:
       0: aload_0
       1: getfield      #22                 // Field raw:Ljava/util/List;
       4: areturn

  public final Day03$Forest copy(java.util.List<boolean[]>);
    Code:
       0: aload_1
       1: ldc           #10                 // String raw
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #2                  // class Day03$Forest
       9: dup
      10: aload_1
      11: invokespecial #157                // Method "<init>":(Ljava/util/List;)V
      14: areturn

  public static Day03$Forest copy$default(Day03$Forest, java.util.List, int, java.lang.Object);
    Code:
       0: iload_2
       1: iconst_1
       2: iand
       3: ifeq          11
       6: aload_0
       7: getfield      #22                 // Field raw:Ljava/util/List;
      10: astore_1
      11: aload_0
      12: aload_1
      13: invokevirtual #161                // Method copy:(Ljava/util/List;)LDay03$Forest;
      16: areturn

  public java.lang.String toString();
    Code:
       0: new           #165                // class java/lang/StringBuilder
       3: dup
       4: invokespecial #166                // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #168                // String Forest(raw=
       9: invokevirtual #172                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #22                 // Field raw:Ljava/util/List;
      16: invokevirtual #175                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      19: bipush        41
      21: invokevirtual #178                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      24: invokevirtual #180                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      27: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #22                 // Field raw:Ljava/util/List;
       4: invokevirtual #183                // Method java/lang/Object.hashCode:()I
       7: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class Day03$Forest
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class Day03$Forest
      20: astore_2
      21: aload_0
      22: getfield      #22                 // Field raw:Ljava/util/List;
      25: aload_2
      26: getfield      #22                 // Field raw:Ljava/util/List;
      29: invokestatic  #190                // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      32: ifne          37
      35: iconst_0
      36: ireturn
      37: iconst_1
      38: ireturn

  private static final java.lang.Integer horizontal$lambda$1(Day03$Slope, int);
    Code:
       0: iload_1
       1: aload_0
       2: invokevirtual #194                // Method Day03$Slope.getRight:()I
       5: iadd
       6: invokestatic  #59                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
       9: areturn

  private static final java.lang.Integer vertical$lambda$3(Day03$Slope, Day03$Forest, int);
    Code:
       0: iload_2
       1: aload_0
       2: invokevirtual #199                // Method Day03$Slope.getDown:()I
       5: iadd
       6: invokestatic  #59                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
       9: astore_3
      10: aload_3
      11: checkcast     #201                // class java/lang/Number
      14: invokevirtual #204                // Method java/lang/Number.intValue:()I
      17: istore        4
      19: iconst_0
      20: istore        5
      22: iload         4
      24: aload_1
      25: getfield      #22                 // Field raw:Ljava/util/List;
      28: invokeinterface #207,  1          // InterfaceMethod java/util/List.size:()I
      33: if_icmplt     40
      36: iconst_1
      37: goto          41
      40: iconst_0
      41: ifne          48
      44: aload_3
      45: goto          49
      48: aconst_null
      49: areturn

  static {};
    Code:
       0: new           #213                // class Day03$Forest$Companion
       3: dup
       4: aconst_null
       5: invokespecial #216                // Method Day03$Forest$Companion."<init>":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V
       8: putstatic     #220                // Field Companion:LDay03$Forest$Companion;
      11: return
}

Compiled from "Day03.kt"
public final class Day03$Slope {
  private final int right;

  private final int down;

  public Day03$Slope(int, int);
    Code:
       0: aload_0
       1: invokespecial #9                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: iload_1
       6: putfield      #13                 // Field right:I
       9: aload_0
      10: iload_2
      11: putfield      #16                 // Field down:I
      14: return

  public final int getRight();
    Code:
       0: aload_0
       1: getfield      #13                 // Field right:I
       4: ireturn

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

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

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

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

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

  public java.lang.String toString();
    Code:
       0: new           #36                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #37                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #39                 // String Slope(right=
       9: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #13                 // Field right:I
      16: invokevirtual #46                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: ldc           #48                 // String , down=
      21: invokevirtual #43                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #16                 // Field down:I
      28: invokevirtual #46                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      31: bipush        41
      33: invokevirtual #51                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      36: invokevirtual #53                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      39: areturn

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

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

Compiled from "Day03.kt"
public final class Day03 {
  private final Day03$Forest forest;

  public Day03(java.util.List<java.lang.String>);
    Code:
       0: aload_1
       1: ldc           #10                 // String raw
       3: invokestatic  #16                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokespecial #19                 // Method java/lang/Object."<init>":()V
      10: aload_0
      11: getstatic     #25                 // Field Day03$Forest.Companion:LDay03$Forest$Companion;
      14: aload_1
      15: invokevirtual #31                 // Method Day03$Forest$Companion.parse:(Ljava/util/List;)LDay03$Forest;
      18: putfield      #35                 // Field forest:LDay03$Forest;
      21: return

  public final long part1();
    Code:
       0: aload_0
       1: getfield      #35                 // Field forest:LDay03$Forest;
       4: new           #42                 // class Day03$Slope
       7: dup
       8: iconst_3
       9: iconst_1
      10: invokespecial #45                 // Method Day03$Slope."<init>":(II)V
      13: invokevirtual #49                 // Method Day03$Forest.trees:(LDay03$Slope;)J
      16: lreturn

  public final long part2();
    Code:
       0: iconst_5
       1: anewarray     #42                 // class Day03$Slope
       4: astore_1
       5: aload_1
       6: iconst_0
       7: new           #42                 // class Day03$Slope
      10: dup
      11: iconst_1
      12: iconst_1
      13: invokespecial #45                 // Method Day03$Slope."<init>":(II)V
      16: aastore
      17: aload_1
      18: iconst_1
      19: new           #42                 // class Day03$Slope
      22: dup
      23: iconst_3
      24: iconst_1
      25: invokespecial #45                 // Method Day03$Slope."<init>":(II)V
      28: aastore
      29: aload_1
      30: iconst_2
      31: new           #42                 // class Day03$Slope
      34: dup
      35: iconst_5
      36: iconst_1
      37: invokespecial #45                 // Method Day03$Slope."<init>":(II)V
      40: aastore
      41: aload_1
      42: iconst_3
      43: new           #42                 // class Day03$Slope
      46: dup
      47: bipush        7
      49: iconst_1
      50: invokespecial #45                 // Method Day03$Slope."<init>":(II)V
      53: aastore
      54: aload_1
      55: iconst_4
      56: new           #42                 // class Day03$Slope
      59: dup
      60: iconst_1
      61: iconst_2
      62: invokespecial #45                 // Method Day03$Slope."<init>":(II)V
      65: aastore
      66: aload_1
      67: invokestatic  #56                 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      70: checkcast     #58                 // class java/lang/Iterable
      73: astore_1
      74: aload_0
      75: getfield      #35                 // Field forest:LDay03$Forest;
      78: astore_2
      79: iconst_0
      80: istore_3
      81: aload_1
      82: astore        4
      84: new           #60                 // class java/util/ArrayList
      87: dup
      88: aload_1
      89: bipush        10
      91: invokestatic  #64                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      94: invokespecial #67                 // Method java/util/ArrayList."<init>":(I)V
      97: checkcast     #69                 // class java/util/Collection
     100: astore        5
     102: iconst_0
     103: istore        6
     105: aload         4
     107: invokeinterface #73,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     112: astore        7
     114: aload         7
     116: invokeinterface #79,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     121: ifeq          168
     124: aload         7
     126: invokeinterface #83,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     131: astore        8
     133: aload         5
     135: aload         8
     137: checkcast     #42                 // class Day03$Slope
     140: astore        9
     142: astore        11
     144: iconst_0
     145: istore        10
     147: aload_2
     148: aload         9
     150: invokevirtual #49                 // Method Day03$Forest.trees:(LDay03$Slope;)J
     153: invokestatic  #89                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     156: aload         11
     158: swap
     159: invokeinterface #93,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     164: pop
     165: goto          114
     168: aload         5
     170: checkcast     #95                 // class java/util/List
     173: nop
     174: checkcast     #58                 // class java/lang/Iterable
     177: astore_1
     178: nop
     179: iconst_0
     180: istore_2
     181: aload_1
     182: invokeinterface #73,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     187: astore_3
     188: aload_3
     189: invokeinterface #79,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     194: ifne          207
     197: new           #97                 // class java/lang/UnsupportedOperationException
     200: dup
     201: ldc           #99                 // String Empty collection can\'t be reduced.
     203: invokespecial #102                // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
     206: athrow
     207: aload_3
     208: invokeinterface #83,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     213: astore        4
     215: aload_3
     216: invokeinterface #79,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     221: ifeq          264
     224: aload         4
     226: aload_3
     227: invokeinterface #83,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     232: checkcast     #104                // class java/lang/Number
     235: invokevirtual #107                // Method java/lang/Number.longValue:()J
     238: lstore        5
     240: checkcast     #104                // class java/lang/Number
     243: invokevirtual #107                // Method java/lang/Number.longValue:()J
     246: lstore        7
     248: iconst_0
     249: istore        9
     251: lload         7
     253: lload         5
     255: lmul
     256: invokestatic  #89                 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     259: astore        4
     261: goto          215
     264: aload         4
     266: checkcast     #104                // class java/lang/Number
     269: invokevirtual #107                // Method java/lang/Number.longValue:()J
     272: lreturn
}