package day17

import java.nio.file.Files
import java.nio.file.Paths
import kotlin.math.absoluteValue
import kotlin.math.sign

fun main() {
  fun part1(input: Input): Int {
    val (xRange, yRange) = input.toList().map { it.first..it.second }
    require(xRange.first > 0 && xRange.last >= xRange.first)
    require(yRange.last < 0 && yRange.last >= yRange.first)
    // assume we can find X such that X * (X + 1) / 2 in xRange and X <= Y * 2 + 1
    // works for my test case, YMMW
    val y = yRange.first.absoluteValue - 1
    return y * (y + 1) / 2
  }

  fun part2(input: Input): Int {
    val (xRange, yRange) = input.toList().map { it.first..it.second }
    require(xRange.first > 0 && xRange.last >= xRange.first)
    require(yRange.last < 0 && yRange.last >= yRange.first)
    var answer = 0
    for (xv in 1..xRange.last) {
      for (yv in yRange.first..yRange.first.absoluteValue) {
        var (cx, cy) = 0 to 0
        var (cxv, cyv) = xv to yv
        while (true) {
          cx += cxv.also { cxv -= cxv.sign }
          cy += cyv--
          if (cx in xRange && cy in yRange) {
            answer++
            break
          }
          if (cx > xRange.last || cy < yRange.first) break
        }
      }
    }
    return answer
  }

//  illustrate(7, 2, readInput("test-input.txt"))
//  illustrate(6, 3, readInput("test-input.txt"))
//  illustrate(9, 0, readInput("test-input.txt"))
//  illustrate(17, -4, readInput("test-input.txt"))
//  illustrate(6, 9, readInput("test-input.txt"))
//  illustrate(6, 10, readInput("test-input.txt"))

  check(part1(readInput("test-input.txt")) == 45)
  check(part2(readInput("test-input.txt")) == 112)

  println(part1(readInput("input.txt")))
  println(part2(readInput("input.txt")))
}

private fun illustrate(xv: Int, yv: Int, target: Input) {
  val (txRange, tyRange) = target
  val tx = txRange.first..txRange.second
  val ty = tyRange.first..tyRange.second
  var (cx, cy) = 0 to 0
  var (cxv, cyv) = xv to yv
  val visited = mutableListOf<Pair<Int, Int>>()
  while (cx <= tx.last && cy >= ty.last) {
    cx += cxv.also { cxv -= cxv.sign }
    cy += cyv--
    visited.add(cx to cy)
  }
  val minX = minOf(minOf(0, tx.first), visited.minOf { it.first })
  val maxX = maxOf(maxOf(0, tx.last), visited.maxOf { it.first })
  val minY = minOf(minOf(0, ty.first), visited.minOf { it.second })
  val maxY = maxOf(maxOf(0, ty.last), visited.maxOf { it.second })
  val output = Array(maxY - minY + 1) {
    CharArray(maxX - minX + 1) { '.' }
  }
  for (x in tx) {
    for (y in ty) {
      output[maxY - y][x - minX] = 'T'
    }
  }
  output[maxY - 0][0 - minX] = 'S'
  for ((x, y) in visited) {
    output[maxY - y][x - minX] = '#'
  }
  println("($xv, $yv) -> $target")
  println(output.joinToString("\n") { String(it) })
}

private fun readInput(s: String): Input {
  return Files.newBufferedReader(Paths.get("src/day17/$s")).readLine()!!.let { line ->
    val (xRange, yRange) = line.substring("target area: ".length).split(", ")
    val (xMin, xMax) = xRange.substring("x=".length).split("..").map { it.toInt() }
    val (yMin, yMax) = yRange.substring("y=".length).split("..").map { it.toInt() }
    Pair(xMin to xMax, yMin to yMax)
  }
}

private typealias Input = Pair<Pair<Int, Int>, Pair<Int, Int>>

Compiled from "Solution.kt"
public final class day17.SolutionKt {
  public static final void main();
    Code:
       0: ldc           #8                  // String test-input.txt
       2: invokestatic  #12                 // Method readInput:(Ljava/lang/String;)Lkotlin/Pair;
       5: invokestatic  #16                 // Method main$part1:(Lkotlin/Pair;)I
       8: bipush        45
      10: if_icmpne     17
      13: iconst_1
      14: goto          18
      17: iconst_0
      18: ifne          31
      21: new           #18                 // class java/lang/IllegalStateException
      24: dup
      25: ldc           #20                 // String Check failed.
      27: invokespecial #24                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      30: athrow
      31: ldc           #8                  // String test-input.txt
      33: invokestatic  #12                 // Method readInput:(Ljava/lang/String;)Lkotlin/Pair;
      36: invokestatic  #27                 // Method main$part2:(Lkotlin/Pair;)I
      39: bipush        112
      41: if_icmpne     48
      44: iconst_1
      45: goto          49
      48: iconst_0
      49: ifne          62
      52: new           #18                 // class java/lang/IllegalStateException
      55: dup
      56: ldc           #20                 // String Check failed.
      58: invokespecial #24                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      61: athrow
      62: ldc           #29                 // String input.txt
      64: invokestatic  #12                 // Method readInput:(Ljava/lang/String;)Lkotlin/Pair;
      67: invokestatic  #16                 // Method main$part1:(Lkotlin/Pair;)I
      70: istore_0
      71: getstatic     #35                 // Field java/lang/System.out:Ljava/io/PrintStream;
      74: iload_0
      75: invokevirtual #41                 // Method java/io/PrintStream.println:(I)V
      78: ldc           #29                 // String input.txt
      80: invokestatic  #12                 // Method readInput:(Ljava/lang/String;)Lkotlin/Pair;
      83: invokestatic  #27                 // Method main$part2:(Lkotlin/Pair;)I
      86: istore_0
      87: getstatic     #35                 // Field java/lang/System.out:Ljava/io/PrintStream;
      90: iload_0
      91: invokevirtual #41                 // Method java/io/PrintStream.println:(I)V
      94: return

  private static final void illustrate(int, int, kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>>);
    Code:
       0: aload_2
       1: invokevirtual #50                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
       4: checkcast     #46                 // class kotlin/Pair
       7: astore_3
       8: aload_2
       9: invokevirtual #53                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
      12: checkcast     #46                 // class kotlin/Pair
      15: astore        4
      17: new           #55                 // class kotlin/ranges/IntRange
      20: dup
      21: aload_3
      22: invokevirtual #58                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      25: checkcast     #60                 // class java/lang/Number
      28: invokevirtual #64                 // Method java/lang/Number.intValue:()I
      31: aload_3
      32: invokevirtual #67                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      35: checkcast     #60                 // class java/lang/Number
      38: invokevirtual #64                 // Method java/lang/Number.intValue:()I
      41: invokespecial #70                 // Method kotlin/ranges/IntRange."<init>":(II)V
      44: astore        5
      46: new           #55                 // class kotlin/ranges/IntRange
      49: dup
      50: aload         4
      52: invokevirtual #58                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      55: checkcast     #60                 // class java/lang/Number
      58: invokevirtual #64                 // Method java/lang/Number.intValue:()I
      61: aload         4
      63: invokevirtual #67                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      66: checkcast     #60                 // class java/lang/Number
      69: invokevirtual #64                 // Method java/lang/Number.intValue:()I
      72: invokespecial #70                 // Method kotlin/ranges/IntRange."<init>":(II)V
      75: astore        6
      77: iconst_0
      78: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      81: iconst_0
      82: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      85: invokestatic  #82                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
      88: astore        7
      90: aload         7
      92: invokevirtual #50                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
      95: checkcast     #60                 // class java/lang/Number
      98: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     101: istore        8
     103: aload         7
     105: invokevirtual #53                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     108: checkcast     #60                 // class java/lang/Number
     111: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     114: istore        9
     116: iload_0
     117: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     120: iload_1
     121: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     124: invokestatic  #82                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     127: astore        10
     129: iconst_0
     130: istore        11
     132: aload         10
     134: invokevirtual #50                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     137: checkcast     #60                 // class java/lang/Number
     140: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     143: istore        11
     145: aload         10
     147: invokevirtual #53                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     150: checkcast     #60                 // class java/lang/Number
     153: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     156: istore        12
     158: new           #84                 // class java/util/ArrayList
     161: dup
     162: invokespecial #86                 // Method java/util/ArrayList."<init>":()V
     165: checkcast     #88                 // class java/util/List
     168: astore        13
     170: iload         8
     172: aload         5
     174: invokevirtual #91                 // Method kotlin/ranges/IntRange.getLast:()I
     177: if_icmpgt     261
     180: iload         9
     182: aload         6
     184: invokevirtual #91                 // Method kotlin/ranges/IntRange.getLast:()I
     187: if_icmplt     261
     190: iload         8
     192: iload         11
     194: istore        14
     196: iload         14
     198: istore        15
     200: istore        27
     202: iconst_0
     203: istore        16
     205: iload         11
     207: iload         11
     209: invokestatic  #97                 // Method kotlin/math/MathKt.getSign:(I)I
     212: isub
     213: istore        11
     215: getstatic     #103                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     218: astore        28
     220: iload         27
     222: iload         14
     224: iadd
     225: istore        8
     227: iload         9
     229: iload         12
     231: iinc          12, -1
     234: iadd
     235: istore        9
     237: aload         13
     239: iload         8
     241: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     244: iload         9
     246: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     249: invokestatic  #82                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     252: invokeinterface #107,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     257: pop
     258: goto          170
     261: iconst_0
     262: aload         5
     264: invokevirtual #109                // Method kotlin/ranges/IntRange.getFirst:()I
     267: invokestatic  #115                // Method java/lang/Math.min:(II)I
     270: istore        15
     272: aload         13
     274: checkcast     #117                // class java/lang/Iterable
     277: invokeinterface #121,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     282: astore        17
     284: aload         17
     286: invokeinterface #127,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     291: ifne          302
     294: new           #129                // class java/util/NoSuchElementException
     297: dup
     298: invokespecial #130                // Method java/util/NoSuchElementException."<init>":()V
     301: athrow
     302: aload         17
     304: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     309: checkcast     #46                 // class kotlin/Pair
     312: astore        18
     314: iconst_0
     315: istore        19
     317: aload         18
     319: invokevirtual #58                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     322: checkcast     #60                 // class java/lang/Number
     325: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     328: istore        18
     330: aload         17
     332: invokeinterface #127,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     337: ifeq          382
     340: aload         17
     342: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     347: checkcast     #46                 // class kotlin/Pair
     350: astore        19
     352: iconst_0
     353: istore        20
     355: aload         19
     357: invokevirtual #58                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     360: checkcast     #60                 // class java/lang/Number
     363: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     366: istore        19
     368: iload         18
     370: iload         19
     372: if_icmple     330
     375: iload         19
     377: istore        18
     379: goto          330
     382: iload         18
     384: istore        16
     386: iload         15
     388: iload         16
     390: invokestatic  #115                // Method java/lang/Math.min:(II)I
     393: istore        14
     395: iconst_0
     396: aload         5
     398: invokevirtual #91                 // Method kotlin/ranges/IntRange.getLast:()I
     401: invokestatic  #136                // Method java/lang/Math.max:(II)I
     404: istore        16
     406: aload         13
     408: checkcast     #117                // class java/lang/Iterable
     411: invokeinterface #121,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     416: astore        18
     418: aload         18
     420: invokeinterface #127,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     425: ifne          436
     428: new           #129                // class java/util/NoSuchElementException
     431: dup
     432: invokespecial #130                // Method java/util/NoSuchElementException."<init>":()V
     435: athrow
     436: aload         18
     438: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     443: checkcast     #46                 // class kotlin/Pair
     446: astore        19
     448: iconst_0
     449: istore        20
     451: aload         19
     453: invokevirtual #58                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     456: checkcast     #60                 // class java/lang/Number
     459: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     462: istore        19
     464: aload         18
     466: invokeinterface #127,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     471: ifeq          516
     474: aload         18
     476: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     481: checkcast     #46                 // class kotlin/Pair
     484: astore        20
     486: iconst_0
     487: istore        21
     489: aload         20
     491: invokevirtual #58                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
     494: checkcast     #60                 // class java/lang/Number
     497: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     500: istore        20
     502: iload         19
     504: iload         20
     506: if_icmpge     464
     509: iload         20
     511: istore        19
     513: goto          464
     516: iload         19
     518: istore        17
     520: iload         16
     522: iload         17
     524: invokestatic  #136                // Method java/lang/Math.max:(II)I
     527: istore        15
     529: iconst_0
     530: aload         6
     532: invokevirtual #109                // Method kotlin/ranges/IntRange.getFirst:()I
     535: invokestatic  #115                // Method java/lang/Math.min:(II)I
     538: istore        17
     540: aload         13
     542: checkcast     #117                // class java/lang/Iterable
     545: invokeinterface #121,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     550: astore        19
     552: aload         19
     554: invokeinterface #127,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     559: ifne          570
     562: new           #129                // class java/util/NoSuchElementException
     565: dup
     566: invokespecial #130                // Method java/util/NoSuchElementException."<init>":()V
     569: athrow
     570: aload         19
     572: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     577: checkcast     #46                 // class kotlin/Pair
     580: astore        20
     582: iconst_0
     583: istore        21
     585: aload         20
     587: invokevirtual #67                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     590: checkcast     #60                 // class java/lang/Number
     593: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     596: istore        20
     598: aload         19
     600: invokeinterface #127,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     605: ifeq          650
     608: aload         19
     610: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     615: checkcast     #46                 // class kotlin/Pair
     618: astore        21
     620: iconst_0
     621: istore        22
     623: aload         21
     625: invokevirtual #67                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     628: checkcast     #60                 // class java/lang/Number
     631: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     634: istore        21
     636: iload         20
     638: iload         21
     640: if_icmple     598
     643: iload         21
     645: istore        20
     647: goto          598
     650: iload         20
     652: istore        18
     654: iload         17
     656: iload         18
     658: invokestatic  #115                // Method java/lang/Math.min:(II)I
     661: istore        16
     663: iconst_0
     664: aload         6
     666: invokevirtual #91                 // Method kotlin/ranges/IntRange.getLast:()I
     669: invokestatic  #136                // Method java/lang/Math.max:(II)I
     672: istore        18
     674: aload         13
     676: checkcast     #117                // class java/lang/Iterable
     679: invokeinterface #121,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     684: astore        20
     686: aload         20
     688: invokeinterface #127,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     693: ifne          704
     696: new           #129                // class java/util/NoSuchElementException
     699: dup
     700: invokespecial #130                // Method java/util/NoSuchElementException."<init>":()V
     703: athrow
     704: aload         20
     706: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     711: checkcast     #46                 // class kotlin/Pair
     714: astore        21
     716: iconst_0
     717: istore        22
     719: aload         21
     721: invokevirtual #67                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     724: checkcast     #60                 // class java/lang/Number
     727: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     730: istore        21
     732: aload         20
     734: invokeinterface #127,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     739: ifeq          784
     742: aload         20
     744: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     749: checkcast     #46                 // class kotlin/Pair
     752: astore        22
     754: iconst_0
     755: istore        23
     757: aload         22
     759: invokevirtual #67                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
     762: checkcast     #60                 // class java/lang/Number
     765: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     768: istore        22
     770: iload         21
     772: iload         22
     774: if_icmpge     732
     777: iload         22
     779: istore        21
     781: goto          732
     784: iload         21
     786: istore        19
     788: iload         18
     790: iload         19
     792: invokestatic  #136                // Method java/lang/Math.max:(II)I
     795: istore        17
     797: iconst_0
     798: istore        19
     800: iload         17
     802: iload         16
     804: isub
     805: iconst_1
     806: iadd
     807: istore        20
     809: iload         20
     811: anewarray     #138                // class "[C"
     814: astore        21
     816: iload         19
     818: iload         20
     820: if_icmpge     890
     823: iload         19
     825: istore        22
     827: aload         21
     829: iload         22
     831: iconst_0
     832: istore        23
     834: iload         15
     836: iload         14
     838: isub
     839: iconst_1
     840: iadd
     841: istore        24
     843: iload         24
     845: newarray       char
     847: astore        25
     849: istore        28
     851: astore        27
     853: iload         23
     855: iload         24
     857: if_icmpge     877
     860: iload         23
     862: istore        26
     864: aload         25
     866: iload         26
     868: bipush        46
     870: castore
     871: iinc          23, 1
     874: goto          853
     877: aload         27
     879: iload         28
     881: aload         25
     883: aastore
     884: iinc          19, 1
     887: goto          816
     890: aload         21
     892: astore        18
     894: aload         5
     896: invokevirtual #109                // Method kotlin/ranges/IntRange.getFirst:()I
     899: istore        19
     901: aload         5
     903: invokevirtual #91                 // Method kotlin/ranges/IntRange.getLast:()I
     906: istore        20
     908: iload         19
     910: iload         20
     912: if_icmpgt     978
     915: aload         6
     917: invokevirtual #109                // Method kotlin/ranges/IntRange.getFirst:()I
     920: istore        21
     922: aload         6
     924: invokevirtual #91                 // Method kotlin/ranges/IntRange.getLast:()I
     927: istore        22
     929: iload         21
     931: iload         22
     933: if_icmpgt     965
     936: aload         18
     938: iload         17
     940: iload         21
     942: isub
     943: aaload
     944: iload         19
     946: iload         14
     948: isub
     949: bipush        84
     951: castore
     952: iload         21
     954: iload         22
     956: if_icmpeq     965
     959: iinc          21, 1
     962: goto          936
     965: iload         19
     967: iload         20
     969: if_icmpeq     978
     972: iinc          19, 1
     975: goto          915
     978: aload         18
     980: iload         17
     982: iconst_0
     983: isub
     984: aaload
     985: iconst_0
     986: iload         14
     988: isub
     989: bipush        83
     991: castore
     992: aload         13
     994: invokeinterface #139,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     999: astore        19
    1001: aload         19
    1003: invokeinterface #127,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
    1008: ifeq          1068
    1011: aload         19
    1013: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
    1018: checkcast     #46                 // class kotlin/Pair
    1021: astore        20
    1023: aload         20
    1025: invokevirtual #50                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
    1028: checkcast     #60                 // class java/lang/Number
    1031: invokevirtual #64                 // Method java/lang/Number.intValue:()I
    1034: istore        21
    1036: aload         20
    1038: invokevirtual #53                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
    1041: checkcast     #60                 // class java/lang/Number
    1044: invokevirtual #64                 // Method java/lang/Number.intValue:()I
    1047: istore        22
    1049: aload         18
    1051: iload         17
    1053: iload         22
    1055: isub
    1056: aaload
    1057: iload         21
    1059: iload         14
    1061: isub
    1062: bipush        35
    1064: castore
    1065: goto          1001
    1068: new           #141                // class java/lang/StringBuilder
    1071: dup
    1072: invokespecial #142                // Method java/lang/StringBuilder."<init>":()V
    1075: bipush        40
    1077: invokevirtual #146                // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
    1080: iload_0
    1081: invokevirtual #149                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
    1084: ldc           #151                // String ,
    1086: invokevirtual #154                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
    1089: iload_1
    1090: invokevirtual #149                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
    1093: ldc           #156                // String ) ->
    1095: invokevirtual #154                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
    1098: aload_2
    1099: invokevirtual #159                // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
    1102: invokevirtual #163                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
    1105: getstatic     #35                 // Field java/lang/System.out:Ljava/io/PrintStream;
    1108: swap
    1109: invokevirtual #166                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
    1112: aload         18
    1114: checkcast     #168                // class "[Ljava/lang/Object;"
    1117: ldc           #170                // String \n
    1119: checkcast     #172                // class java/lang/CharSequence
    1122: aconst_null
    1123: aconst_null
    1124: iconst_0
    1125: aconst_null
    1126: invokedynamic #191,  0            // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;
    1131: bipush        30
    1133: aconst_null
    1134: invokestatic  #197                // Method kotlin/collections/ArraysKt.joinToString$default:([Ljava/lang/Object;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;
    1137: getstatic     #35                 // Field java/lang/System.out:Ljava/io/PrintStream;
    1140: swap
    1141: invokevirtual #166                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
    1144: return

  private static final kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>> readInput(java.lang.String);
    Code:
       0: new           #141                // class java/lang/StringBuilder
       3: dup
       4: invokespecial #142                // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #231                // String src/day17/
       9: invokevirtual #154                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: invokevirtual #154                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      16: invokevirtual #163                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      19: iconst_0
      20: anewarray     #233                // class java/lang/String
      23: invokestatic  #239                // Method java/nio/file/Paths.get:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;
      26: invokestatic  #245                // Method java/nio/file/Files.newBufferedReader:(Ljava/nio/file/Path;)Ljava/io/BufferedReader;
      29: invokevirtual #250                // Method java/io/BufferedReader.readLine:()Ljava/lang/String;
      32: dup
      33: invokestatic  #255                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      36: astore_1
      37: iconst_0
      38: istore_2
      39: aload_1
      40: bipush        13
      42: invokevirtual #259                // Method java/lang/String.substring:(I)Ljava/lang/String;
      45: dup
      46: ldc_w         #261                // String substring(...)
      49: invokestatic  #265                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      52: checkcast     #172                // class java/lang/CharSequence
      55: iconst_1
      56: anewarray     #233                // class java/lang/String
      59: astore_3
      60: aload_3
      61: iconst_0
      62: ldc           #151                // String ,
      64: aastore
      65: aload_3
      66: iconst_0
      67: iconst_0
      68: bipush        6
      70: aconst_null
      71: invokestatic  #271                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
      74: astore        4
      76: aload         4
      78: iconst_0
      79: invokeinterface #274,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      84: checkcast     #233                // class java/lang/String
      87: astore_3
      88: aload         4
      90: iconst_1
      91: invokeinterface #274,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      96: checkcast     #233                // class java/lang/String
      99: astore        5
     101: aload_3
     102: iconst_2
     103: invokevirtual #259                // Method java/lang/String.substring:(I)Ljava/lang/String;
     106: dup
     107: ldc_w         #261                // String substring(...)
     110: invokestatic  #265                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     113: checkcast     #172                // class java/lang/CharSequence
     116: iconst_1
     117: anewarray     #233                // class java/lang/String
     120: astore        6
     122: aload         6
     124: iconst_0
     125: ldc_w         #276                // String ..
     128: aastore
     129: aload         6
     131: iconst_0
     132: iconst_0
     133: bipush        6
     135: aconst_null
     136: invokestatic  #271                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     139: checkcast     #117                // class java/lang/Iterable
     142: astore        6
     144: iconst_0
     145: istore        7
     147: aload         6
     149: astore        8
     151: new           #84                 // class java/util/ArrayList
     154: dup
     155: aload         6
     157: bipush        10
     159: invokestatic  #282                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     162: invokespecial #284                // Method java/util/ArrayList."<init>":(I)V
     165: checkcast     #286                // class java/util/Collection
     168: astore        9
     170: iconst_0
     171: istore        10
     173: aload         8
     175: invokeinterface #121,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     180: astore        11
     182: aload         11
     184: invokeinterface #127,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     189: ifeq          236
     192: aload         11
     194: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     199: astore        12
     201: aload         9
     203: aload         12
     205: checkcast     #233                // class java/lang/String
     208: astore        13
     210: astore        14
     212: iconst_0
     213: istore        15
     215: aload         13
     217: invokestatic  #290                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     220: nop
     221: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     224: aload         14
     226: swap
     227: invokeinterface #291,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     232: pop
     233: goto          182
     236: aload         9
     238: checkcast     #88                 // class java/util/List
     241: nop
     242: astore        16
     244: aload         16
     246: iconst_0
     247: invokeinterface #274,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     252: checkcast     #60                 // class java/lang/Number
     255: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     258: istore        6
     260: aload         16
     262: iconst_1
     263: invokeinterface #274,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     268: checkcast     #60                 // class java/lang/Number
     271: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     274: istore        7
     276: aload         5
     278: iconst_2
     279: invokevirtual #259                // Method java/lang/String.substring:(I)Ljava/lang/String;
     282: dup
     283: ldc_w         #261                // String substring(...)
     286: invokestatic  #265                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     289: checkcast     #172                // class java/lang/CharSequence
     292: iconst_1
     293: anewarray     #233                // class java/lang/String
     296: astore        9
     298: aload         9
     300: iconst_0
     301: ldc_w         #276                // String ..
     304: aastore
     305: aload         9
     307: iconst_0
     308: iconst_0
     309: bipush        6
     311: aconst_null
     312: invokestatic  #271                // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;
     315: checkcast     #117                // class java/lang/Iterable
     318: astore        9
     320: iconst_0
     321: istore        10
     323: aload         9
     325: astore        11
     327: new           #84                 // class java/util/ArrayList
     330: dup
     331: aload         9
     333: bipush        10
     335: invokestatic  #282                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     338: invokespecial #284                // Method java/util/ArrayList."<init>":(I)V
     341: checkcast     #286                // class java/util/Collection
     344: astore        12
     346: iconst_0
     347: istore        13
     349: aload         11
     351: invokeinterface #121,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     356: astore        15
     358: aload         15
     360: invokeinterface #127,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     365: ifeq          412
     368: aload         15
     370: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     375: astore        17
     377: aload         12
     379: aload         17
     381: checkcast     #233                // class java/lang/String
     384: astore        18
     386: astore        14
     388: iconst_0
     389: istore        19
     391: aload         18
     393: invokestatic  #290                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     396: nop
     397: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     400: aload         14
     402: swap
     403: invokeinterface #291,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     408: pop
     409: goto          358
     412: aload         12
     414: checkcast     #88                 // class java/util/List
     417: nop
     418: astore        8
     420: aload         8
     422: iconst_0
     423: invokeinterface #274,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     428: checkcast     #60                 // class java/lang/Number
     431: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     434: istore        9
     436: aload         8
     438: iconst_1
     439: invokeinterface #274,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     444: checkcast     #60                 // class java/lang/Number
     447: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     450: istore        10
     452: new           #46                 // class kotlin/Pair
     455: dup
     456: iload         6
     458: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     461: iload         7
     463: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     466: invokestatic  #82                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     469: iload         9
     471: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     474: iload         10
     476: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     479: invokestatic  #82                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     482: invokespecial #294                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     485: nop
     486: areturn

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

  private static final int main$part1(kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>>);
    Code:
       0: aload_0
       1: invokestatic  #325                // Method kotlin/TuplesKt.toList:(Lkotlin/Pair;)Ljava/util/List;
       4: checkcast     #117                // class java/lang/Iterable
       7: astore_2
       8: iconst_0
       9: istore_3
      10: aload_2
      11: astore        4
      13: new           #84                 // class java/util/ArrayList
      16: dup
      17: aload_2
      18: bipush        10
      20: invokestatic  #282                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      23: invokespecial #284                // Method java/util/ArrayList."<init>":(I)V
      26: checkcast     #286                // class java/util/Collection
      29: astore        5
      31: iconst_0
      32: istore        6
      34: aload         4
      36: invokeinterface #121,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      41: astore        7
      43: aload         7
      45: invokeinterface #127,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      50: ifeq          117
      53: aload         7
      55: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      60: astore        8
      62: aload         5
      64: aload         8
      66: checkcast     #46                 // class kotlin/Pair
      69: astore        9
      71: astore        11
      73: iconst_0
      74: istore        10
      76: new           #55                 // class kotlin/ranges/IntRange
      79: dup
      80: aload         9
      82: invokevirtual #58                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      85: checkcast     #60                 // class java/lang/Number
      88: invokevirtual #64                 // Method java/lang/Number.intValue:()I
      91: aload         9
      93: invokevirtual #67                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      96: checkcast     #60                 // class java/lang/Number
      99: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     102: invokespecial #70                 // Method kotlin/ranges/IntRange."<init>":(II)V
     105: aload         11
     107: swap
     108: invokeinterface #291,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     113: pop
     114: goto          43
     117: aload         5
     119: checkcast     #88                 // class java/util/List
     122: nop
     123: astore_1
     124: aload_1
     125: iconst_0
     126: invokeinterface #274,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     131: checkcast     #55                 // class kotlin/ranges/IntRange
     134: astore_2
     135: aload_1
     136: iconst_1
     137: invokeinterface #274,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     142: checkcast     #55                 // class kotlin/ranges/IntRange
     145: astore_3
     146: aload_2
     147: invokevirtual #109                // Method kotlin/ranges/IntRange.getFirst:()I
     150: ifle          168
     153: aload_2
     154: invokevirtual #91                 // Method kotlin/ranges/IntRange.getLast:()I
     157: aload_2
     158: invokevirtual #109                // Method kotlin/ranges/IntRange.getFirst:()I
     161: if_icmplt     168
     164: iconst_1
     165: goto          169
     168: iconst_0
     169: ifne          190
     172: ldc_w         #327                // String Failed requirement.
     175: astore        5
     177: new           #329                // class java/lang/IllegalArgumentException
     180: dup
     181: aload         5
     183: invokevirtual #330                // Method java/lang/Object.toString:()Ljava/lang/String;
     186: invokespecial #331                // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     189: athrow
     190: aload_3
     191: invokevirtual #91                 // Method kotlin/ranges/IntRange.getLast:()I
     194: ifge          212
     197: aload_3
     198: invokevirtual #91                 // Method kotlin/ranges/IntRange.getLast:()I
     201: aload_3
     202: invokevirtual #109                // Method kotlin/ranges/IntRange.getFirst:()I
     205: if_icmplt     212
     208: iconst_1
     209: goto          213
     212: iconst_0
     213: ifne          234
     216: ldc_w         #327                // String Failed requirement.
     219: astore        5
     221: new           #329                // class java/lang/IllegalArgumentException
     224: dup
     225: aload         5
     227: invokevirtual #330                // Method java/lang/Object.toString:()Ljava/lang/String;
     230: invokespecial #331                // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     233: athrow
     234: aload_3
     235: invokevirtual #109                // Method kotlin/ranges/IntRange.getFirst:()I
     238: invokestatic  #334                // Method java/lang/Math.abs:(I)I
     241: iconst_1
     242: isub
     243: istore        4
     245: iload         4
     247: iload         4
     249: iconst_1
     250: iadd
     251: imul
     252: iconst_2
     253: idiv
     254: ireturn

  private static final int main$part2(kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>>);
    Code:
       0: aload_0
       1: invokestatic  #325                // Method kotlin/TuplesKt.toList:(Lkotlin/Pair;)Ljava/util/List;
       4: checkcast     #117                // class java/lang/Iterable
       7: astore_2
       8: iconst_0
       9: istore_3
      10: aload_2
      11: astore        4
      13: new           #84                 // class java/util/ArrayList
      16: dup
      17: aload_2
      18: bipush        10
      20: invokestatic  #282                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      23: invokespecial #284                // Method java/util/ArrayList."<init>":(I)V
      26: checkcast     #286                // class java/util/Collection
      29: astore        5
      31: iconst_0
      32: istore        6
      34: aload         4
      36: invokeinterface #121,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      41: astore        7
      43: aload         7
      45: invokeinterface #127,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      50: ifeq          117
      53: aload         7
      55: invokeinterface #133,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      60: astore        8
      62: aload         5
      64: aload         8
      66: checkcast     #46                 // class kotlin/Pair
      69: astore        9
      71: astore        18
      73: iconst_0
      74: istore        10
      76: new           #55                 // class kotlin/ranges/IntRange
      79: dup
      80: aload         9
      82: invokevirtual #58                 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;
      85: checkcast     #60                 // class java/lang/Number
      88: invokevirtual #64                 // Method java/lang/Number.intValue:()I
      91: aload         9
      93: invokevirtual #67                 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;
      96: checkcast     #60                 // class java/lang/Number
      99: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     102: invokespecial #70                 // Method kotlin/ranges/IntRange."<init>":(II)V
     105: aload         18
     107: swap
     108: invokeinterface #291,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     113: pop
     114: goto          43
     117: aload         5
     119: checkcast     #88                 // class java/util/List
     122: nop
     123: astore_1
     124: aload_1
     125: iconst_0
     126: invokeinterface #274,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     131: checkcast     #55                 // class kotlin/ranges/IntRange
     134: astore_2
     135: aload_1
     136: iconst_1
     137: invokeinterface #274,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     142: checkcast     #55                 // class kotlin/ranges/IntRange
     145: astore_3
     146: aload_2
     147: invokevirtual #109                // Method kotlin/ranges/IntRange.getFirst:()I
     150: ifle          168
     153: aload_2
     154: invokevirtual #91                 // Method kotlin/ranges/IntRange.getLast:()I
     157: aload_2
     158: invokevirtual #109                // Method kotlin/ranges/IntRange.getFirst:()I
     161: if_icmplt     168
     164: iconst_1
     165: goto          169
     168: iconst_0
     169: ifne          190
     172: ldc_w         #327                // String Failed requirement.
     175: astore        5
     177: new           #329                // class java/lang/IllegalArgumentException
     180: dup
     181: aload         5
     183: invokevirtual #330                // Method java/lang/Object.toString:()Ljava/lang/String;
     186: invokespecial #331                // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     189: athrow
     190: aload_3
     191: invokevirtual #91                 // Method kotlin/ranges/IntRange.getLast:()I
     194: ifge          212
     197: aload_3
     198: invokevirtual #91                 // Method kotlin/ranges/IntRange.getLast:()I
     201: aload_3
     202: invokevirtual #109                // Method kotlin/ranges/IntRange.getFirst:()I
     205: if_icmplt     212
     208: iconst_1
     209: goto          213
     212: iconst_0
     213: ifne          234
     216: ldc_w         #327                // String Failed requirement.
     219: astore        5
     221: new           #329                // class java/lang/IllegalArgumentException
     224: dup
     225: aload         5
     227: invokevirtual #330                // Method java/lang/Object.toString:()Ljava/lang/String;
     230: invokespecial #331                // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     233: athrow
     234: iconst_0
     235: istore        4
     237: iconst_1
     238: istore        5
     240: aload_2
     241: invokevirtual #91                 // Method kotlin/ranges/IntRange.getLast:()I
     244: istore        6
     246: iload         5
     248: iload         6
     250: if_icmpgt     527
     253: aload_3
     254: invokevirtual #109                // Method kotlin/ranges/IntRange.getFirst:()I
     257: istore        7
     259: aload_3
     260: invokevirtual #109                // Method kotlin/ranges/IntRange.getFirst:()I
     263: invokestatic  #334                // Method java/lang/Math.abs:(I)I
     266: istore        8
     268: iload         7
     270: iload         8
     272: if_icmpgt     514
     275: iconst_0
     276: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     279: iconst_0
     280: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     283: invokestatic  #82                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     286: astore        9
     288: aload         9
     290: invokevirtual #50                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     293: checkcast     #60                 // class java/lang/Number
     296: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     299: istore        10
     301: aload         9
     303: invokevirtual #53                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     306: checkcast     #60                 // class java/lang/Number
     309: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     312: istore        11
     314: iload         5
     316: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     319: iload         7
     321: invokestatic  #76                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     324: invokestatic  #82                 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;
     327: astore        12
     329: iconst_0
     330: istore        13
     332: aload         12
     334: invokevirtual #50                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
     337: checkcast     #60                 // class java/lang/Number
     340: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     343: istore        13
     345: aload         12
     347: invokevirtual #53                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
     350: checkcast     #60                 // class java/lang/Number
     353: invokevirtual #64                 // Method java/lang/Number.intValue:()I
     356: istore        14
     358: nop
     359: iload         10
     361: iload         13
     363: istore        15
     365: iload         15
     367: istore        16
     369: istore        18
     371: iconst_0
     372: istore        17
     374: iload         13
     376: iload         13
     378: invokestatic  #97                 // Method kotlin/math/MathKt.getSign:(I)I
     381: isub
     382: istore        13
     384: getstatic     #103                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     387: astore        19
     389: iload         18
     391: iload         15
     393: iadd
     394: istore        10
     396: iload         11
     398: iload         14
     400: iinc          14, -1
     403: iadd
     404: istore        11
     406: aload_2
     407: invokevirtual #109                // Method kotlin/ranges/IntRange.getFirst:()I
     410: istore        15
     412: iload         10
     414: aload_2
     415: invokevirtual #91                 // Method kotlin/ranges/IntRange.getLast:()I
     418: if_icmpgt     436
     421: iload         15
     423: iload         10
     425: if_icmpgt     432
     428: iconst_1
     429: goto          437
     432: iconst_0
     433: goto          437
     436: iconst_0
     437: ifeq          480
     440: aload_3
     441: invokevirtual #109                // Method kotlin/ranges/IntRange.getFirst:()I
     444: istore        15
     446: iload         11
     448: aload_3
     449: invokevirtual #91                 // Method kotlin/ranges/IntRange.getLast:()I
     452: if_icmpgt     470
     455: iload         15
     457: iload         11
     459: if_icmpgt     466
     462: iconst_1
     463: goto          471
     466: iconst_0
     467: goto          471
     470: iconst_0
     471: ifeq          480
     474: iinc          4, 1
     477: goto          501
     480: iload         10
     482: aload_2
     483: invokevirtual #91                 // Method kotlin/ranges/IntRange.getLast:()I
     486: if_icmpgt     501
     489: iload         11
     491: aload_3
     492: invokevirtual #109                // Method kotlin/ranges/IntRange.getFirst:()I
     495: if_icmpge     358
     498: goto          501
     501: iload         7
     503: iload         8
     505: if_icmpeq     514
     508: iinc          7, 1
     511: goto          275
     514: iload         5
     516: iload         6
     518: if_icmpeq     527
     521: iinc          5, 1
     524: goto          253
     527: iload         4
     529: ireturn

  private static final java.lang.CharSequence illustrate$lambda$8(char[]);
    Code:
       0: aload_0
       1: ldc_w         #340                // String it
       4: invokestatic  #343                // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: new           #233                // class java/lang/String
      10: dup
      11: aload_0
      12: invokespecial #346                // Method java/lang/String."<init>":([C)V
      15: checkcast     #172                // class java/lang/CharSequence
      18: areturn
}


package day21

import java.nio.file.Files
import java.nio.file.Paths

fun main() {
  fun part1(input: Input): Int {
    var rolled = 0
    val score = intArrayOf(0, 0)
    val position = input.map { it - 1 }.toIntArray()
    var current = 0
    while (score.all { it < 1000 }) {
      var move = 0
      repeat(3) {
        move += (rolled++) % 100 + 1
      }
      position[current] = (position[current] + move) % 10
      score[current] += position[current] + 1
      current = 1 - current
    }
    return rolled * score.find { it < 1000 }!!
  }

  fun part2(input: Input): Long {
    val mem = Array(10) {
      Array(10) {
        Array(21) {
          arrayOfNulls<Pair<Long, Long>?>(21)
        }
      }
    }

    fun rec(
      firstPosition: Int,
      secondPosition: Int,
      firstScore: Int,
      secondScore: Int,
    ): Pair<Long, Long> {
      check(firstScore < 21)
      if (secondScore >= 21) return Pair(0L, 1L)
      mem[firstPosition][secondPosition][firstScore][secondScore]?.let { return it }

      var firstWins = 0L
      var secondWins = 0L
      for (i in 1..3) {
        for (j in 1..3) {
          for (k in 1..3) {
            val newPosition = (firstPosition + (i + j + k)) % 10
            val (second, first) = rec(
              firstPosition = secondPosition,
              secondPosition = newPosition,
              firstScore = secondScore,
              secondScore = firstScore + newPosition + 1
            )
            firstWins += first
            secondWins += second
          }
        }
      }
      return Pair(firstWins, secondWins).also {
        mem[firstPosition][secondPosition][firstScore][secondScore] = it
      }
    }

    val (first, second) = rec(
      firstPosition = input[0] - 1,
      secondPosition = input[1] - 1,
      firstScore = 0,
      secondScore = 0
    )
    return maxOf(first, second)
  }

  check(part1(readInput("test-input.txt")) == 739785)
  check(part2(readInput("test-input.txt")) == 444356092776315L)

  println(part1(readInput("input.txt")))
  println(part2(readInput("input.txt")))
}

private fun readInput(s: String): Input {
  return Files.newBufferedReader(Paths.get("src/day21/$s")).readLines().mapIndexed { index, line ->
    check(line.startsWith("Player ${index + 1} starting position: "))
    line.substring("Player ${index + 1} starting position: ".length).toInt()
  }
}

private typealias Input = List<Int>

Compiled from "Solution.kt"
public final class day21.SolutionKt {
  public static final void main();
    Code:
       0: ldc           #8                  // String test-input.txt
       2: invokestatic  #12                 // Method readInput:(Ljava/lang/String;)Ljava/util/List;
       5: invokestatic  #16                 // Method main$part1:(Ljava/util/List;)I
       8: ldc           #17                 // int 739785
      10: if_icmpne     17
      13: iconst_1
      14: goto          18
      17: iconst_0
      18: ifne          31
      21: new           #19                 // class java/lang/IllegalStateException
      24: dup
      25: ldc           #21                 // String Check failed.
      27: invokespecial #25                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      30: athrow
      31: ldc           #8                  // String test-input.txt
      33: invokestatic  #12                 // Method readInput:(Ljava/lang/String;)Ljava/util/List;
      36: invokestatic  #29                 // Method main$part2:(Ljava/util/List;)J
      39: ldc2_w        #30                 // long 444356092776315l
      42: lcmp
      43: ifne          50
      46: iconst_1
      47: goto          51
      50: iconst_0
      51: ifne          64
      54: new           #19                 // class java/lang/IllegalStateException
      57: dup
      58: ldc           #21                 // String Check failed.
      60: invokespecial #25                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      63: athrow
      64: ldc           #33                 // String input.txt
      66: invokestatic  #12                 // Method readInput:(Ljava/lang/String;)Ljava/util/List;
      69: invokestatic  #16                 // Method main$part1:(Ljava/util/List;)I
      72: istore_0
      73: getstatic     #39                 // Field java/lang/System.out:Ljava/io/PrintStream;
      76: iload_0
      77: invokevirtual #45                 // Method java/io/PrintStream.println:(I)V
      80: ldc           #33                 // String input.txt
      82: invokestatic  #12                 // Method readInput:(Ljava/lang/String;)Ljava/util/List;
      85: invokestatic  #29                 // Method main$part2:(Ljava/util/List;)J
      88: lstore_0
      89: getstatic     #39                 // Field java/lang/System.out:Ljava/io/PrintStream;
      92: lload_0
      93: invokevirtual #48                 // Method java/io/PrintStream.println:(J)V
      96: return

  private static final java.util.List<java.lang.Integer> readInput(java.lang.String);
    Code:
       0: new           #51                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #53                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #55                 // String src/day21/
       9: invokevirtual #59                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: invokevirtual #59                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      16: invokevirtual #63                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      19: iconst_0
      20: anewarray     #65                 // class java/lang/String
      23: invokestatic  #71                 // Method java/nio/file/Paths.get:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;
      26: invokestatic  #77                 // Method java/nio/file/Files.newBufferedReader:(Ljava/nio/file/Path;)Ljava/io/BufferedReader;
      29: dup
      30: ldc           #79                 // String newBufferedReader(...)
      32: invokestatic  #85                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      35: checkcast     #87                 // class java/io/Reader
      38: invokestatic  #93                 // Method kotlin/io/TextStreamsKt.readLines:(Ljava/io/Reader;)Ljava/util/List;
      41: checkcast     #95                 // class java/lang/Iterable
      44: astore_1
      45: iconst_0
      46: istore_2
      47: aload_1
      48: astore_3
      49: new           #97                 // class java/util/ArrayList
      52: dup
      53: aload_1
      54: bipush        10
      56: invokestatic  #103                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      59: invokespecial #105                // Method java/util/ArrayList."<init>":(I)V
      62: checkcast     #107                // class java/util/Collection
      65: astore        4
      67: iconst_0
      68: istore        5
      70: iconst_0
      71: istore        6
      73: aload_3
      74: invokeinterface #111,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      79: astore        7
      81: aload         7
      83: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      88: ifeq          242
      91: aload         7
      93: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      98: astore        8
     100: aload         4
     102: iload         6
     104: iinc          6, 1
     107: istore        9
     109: iload         9
     111: ifge          117
     114: invokestatic  #124                // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V
     117: iload         9
     119: aload         8
     121: checkcast     #65                 // class java/lang/String
     124: astore        10
     126: istore        11
     128: astore        13
     130: iconst_0
     131: istore        12
     133: aload         10
     135: new           #51                 // class java/lang/StringBuilder
     138: dup
     139: invokespecial #53                 // Method java/lang/StringBuilder."<init>":()V
     142: ldc           #126                // String Player
     144: invokevirtual #59                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     147: iload         11
     149: iconst_1
     150: iadd
     151: invokevirtual #129                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     154: ldc           #131                // String  starting position:
     156: invokevirtual #59                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     159: invokevirtual #63                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     162: iconst_0
     163: iconst_2
     164: aconst_null
     165: invokestatic  #137                // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z
     168: ifne          181
     171: new           #19                 // class java/lang/IllegalStateException
     174: dup
     175: ldc           #21                 // String Check failed.
     177: invokespecial #25                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     180: athrow
     181: nop
     182: aload         10
     184: new           #51                 // class java/lang/StringBuilder
     187: dup
     188: invokespecial #53                 // Method java/lang/StringBuilder."<init>":()V
     191: ldc           #126                // String Player
     193: invokevirtual #59                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     196: iload         11
     198: iconst_1
     199: iadd
     200: invokevirtual #129                // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     203: ldc           #131                // String  starting position:
     205: invokevirtual #59                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     208: invokevirtual #63                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     211: invokevirtual #141                // Method java/lang/String.length:()I
     214: invokevirtual #145                // Method java/lang/String.substring:(I)Ljava/lang/String;
     217: dup
     218: ldc           #147                // String substring(...)
     220: invokestatic  #85                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     223: invokestatic  #153                // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     226: nop
     227: invokestatic  #157                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     230: aload         13
     232: swap
     233: invokeinterface #161,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     238: pop
     239: goto          81
     242: aload         4
     244: checkcast     #163                // class java/util/List
     247: nop
     248: areturn

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

  private static final int main$part1(java.util.List<java.lang.Integer>);
    Code:
       0: iconst_0
       1: istore_1
       2: iconst_2
       3: newarray       int
       5: astore_3
       6: aload_3
       7: iconst_0
       8: iconst_0
       9: iastore
      10: aload_3
      11: iconst_1
      12: iconst_0
      13: iastore
      14: aload_3
      15: astore_2
      16: aload_0
      17: checkcast     #95                 // class java/lang/Iterable
      20: astore        4
      22: iconst_0
      23: istore        5
      25: aload         4
      27: astore        6
      29: new           #97                 // class java/util/ArrayList
      32: dup
      33: aload         4
      35: bipush        10
      37: invokestatic  #103                // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
      40: invokespecial #105                // Method java/util/ArrayList."<init>":(I)V
      43: checkcast     #107                // class java/util/Collection
      46: astore        7
      48: iconst_0
      49: istore        8
      51: aload         6
      53: invokeinterface #111,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      58: astore        9
      60: aload         9
      62: invokeinterface #117,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      67: ifeq          115
      70: aload         9
      72: invokeinterface #121,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      77: astore        10
      79: aload         7
      81: aload         10
      83: checkcast     #187                // class java/lang/Number
      86: invokevirtual #190                // Method java/lang/Number.intValue:()I
      89: istore        11
      91: astore        13
      93: iconst_0
      94: istore        12
      96: iload         11
      98: iconst_1
      99: isub
     100: invokestatic  #157                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     103: aload         13
     105: swap
     106: invokeinterface #161,  2          // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     111: pop
     112: goto          60
     115: aload         7
     117: checkcast     #163                // class java/util/List
     120: nop
     121: checkcast     #107                // class java/util/Collection
     124: invokestatic  #194                // Method kotlin/collections/CollectionsKt.toIntArray:(Ljava/util/Collection;)[I
     127: astore_3
     128: iconst_0
     129: istore        4
     131: aload_2
     132: astore        5
     134: iconst_0
     135: istore        6
     137: iconst_0
     138: istore        7
     140: aload         5
     142: arraylength
     143: istore        8
     145: iload         7
     147: iload         8
     149: if_icmpge     192
     152: aload         5
     154: iload         7
     156: iaload
     157: istore        9
     159: iload         9
     161: istore        10
     163: iconst_0
     164: istore        11
     166: iload         10
     168: sipush        1000
     171: if_icmpge     178
     174: iconst_1
     175: goto          179
     178: iconst_0
     179: ifne          186
     182: iconst_0
     183: goto          193
     186: iinc          7, 1
     189: goto          145
     192: iconst_1
     193: ifeq          288
     196: iconst_0
     197: istore        5
     199: iconst_3
     200: istore        6
     202: iconst_0
     203: istore        7
     205: iload         7
     207: iload         6
     209: if_icmpge     246
     212: iload         7
     214: istore        8
     216: iconst_0
     217: istore        9
     219: iload         5
     221: iload_1
     222: istore        10
     224: iload         10
     226: iconst_1
     227: iadd
     228: istore_1
     229: iload         10
     231: bipush        100
     233: irem
     234: iconst_1
     235: iadd
     236: iadd
     237: istore        5
     239: nop
     240: iinc          7, 1
     243: goto          205
     246: aload_3
     247: iload         4
     249: aload_3
     250: iload         4
     252: iaload
     253: iload         5
     255: iadd
     256: bipush        10
     258: irem
     259: iastore
     260: iload         4
     262: istore        6
     264: aload_2
     265: iload         6
     267: aload_2
     268: iload         6
     270: iaload
     271: aload_3
     272: iload         4
     274: iaload
     275: iconst_1
     276: iadd
     277: iadd
     278: iastore
     279: iconst_1
     280: iload         4
     282: isub
     283: istore        4
     285: goto          131
     288: iload_1
     289: aload_2
     290: astore        5
     292: istore        13
     294: aload         5
     296: astore        6
     298: iconst_0
     299: istore        7
     301: aload         6
     303: arraylength
     304: istore        8
     306: iload         7
     308: iload         8
     310: if_icmpge     357
     313: aload         6
     315: iload         7
     317: iaload
     318: istore        9
     320: iload         9
     322: istore        10
     324: iconst_0
     325: istore        11
     327: iload         10
     329: sipush        1000
     332: if_icmpge     339
     335: iconst_1
     336: goto          340
     339: iconst_0
     340: ifeq          351
     343: iload         9
     345: invokestatic  #157                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     348: goto          358
     351: iinc          7, 1
     354: goto          306
     357: aconst_null
     358: astore        14
     360: iload         13
     362: aload         14
     364: dup
     365: invokestatic  #198                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
     368: invokevirtual #199                // Method java/lang/Integer.intValue:()I
     371: imul
     372: ireturn

  private static final kotlin.Pair<java.lang.Long, java.lang.Long> main$part2$rec(kotlin.Pair<java.lang.Long, java.lang.Long>[][][][], int, int, int, int);
    Code:
       0: iload_3
       1: bipush        21
       3: if_icmpge     10
       6: iconst_1
       7: goto          11
      10: iconst_0
      11: ifne          24
      14: new           #19                 // class java/lang/IllegalStateException
      17: dup
      18: ldc           #21                 // String Check failed.
      20: invokespecial #25                 // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
      23: athrow
      24: iload         4
      26: bipush        21
      28: if_icmplt     47
      31: new           #225                // class kotlin/Pair
      34: dup
      35: lconst_0
      36: invokestatic  #230                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      39: lconst_1
      40: invokestatic  #230                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
      43: invokespecial #233                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      46: areturn
      47: aload_0
      48: iload_1
      49: aaload
      50: iload_2
      51: aaload
      52: iload_3
      53: aaload
      54: iload         4
      56: aaload
      57: astore        5
      59: aload         5
      61: ifnull        74
      64: aload         5
      66: astore        7
      68: iconst_0
      69: istore        8
      71: aload         7
      73: areturn
      74: lconst_0
      75: lstore        5
      77: lconst_0
      78: lstore        7
      80: iconst_1
      81: istore        9
      83: iload         9
      85: iconst_4
      86: if_icmpge     197
      89: iconst_1
      90: istore        10
      92: iload         10
      94: iconst_4
      95: if_icmpge     191
      98: iconst_1
      99: istore        11
     101: iload         11
     103: iconst_4
     104: if_icmpge     185
     107: iload_1
     108: iload         9
     110: iload         10
     112: iadd
     113: iload         11
     115: iadd
     116: iadd
     117: bipush        10
     119: irem
     120: istore        12
     122: aload_0
     123: iload_2
     124: iload         12
     126: iload         4
     128: iload_3
     129: iload         12
     131: iadd
     132: iconst_1
     133: iadd
     134: invokestatic  #235                // Method main$part2$rec:([[[[Lkotlin/Pair;IIII)Lkotlin/Pair;
     137: astore        13
     139: aload         13
     141: invokevirtual #238                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     144: checkcast     #187                // class java/lang/Number
     147: invokevirtual #242                // Method java/lang/Number.longValue:()J
     150: lstore        14
     152: aload         13
     154: invokevirtual #245                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     157: checkcast     #187                // class java/lang/Number
     160: invokevirtual #242                // Method java/lang/Number.longValue:()J
     163: lstore        16
     165: lload         5
     167: lload         16
     169: ladd
     170: lstore        5
     172: lload         7
     174: lload         14
     176: ladd
     177: lstore        7
     179: iinc          11, 1
     182: goto          101
     185: iinc          10, 1
     188: goto          92
     191: iinc          9, 1
     194: goto          83
     197: new           #225                // class kotlin/Pair
     200: dup
     201: lload         5
     203: invokestatic  #230                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     206: lload         7
     208: invokestatic  #230                // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;
     211: invokespecial #233                // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
     214: astore        9
     216: aload         9
     218: astore        10
     220: iconst_0
     221: istore        11
     223: aload_0
     224: iload_1
     225: aaload
     226: iload_2
     227: aaload
     228: iload_3
     229: aaload
     230: iload         4
     232: aload         10
     234: aastore
     235: nop
     236: aload         9
     238: areturn

  private static final long main$part2(java.util.List<java.lang.Integer>);
    Code:
       0: iconst_0
       1: istore_2
       2: bipush        10
       4: anewarray     #267                // class "[[[Lkotlin/Pair;"
       7: astore_3
       8: iload_2
       9: bipush        10
      11: if_icmpge     116
      14: iload_2
      15: istore        4
      17: aload_3
      18: iload         4
      20: iconst_0
      21: istore        5
      23: bipush        10
      25: anewarray     #269                // class "[[Lkotlin/Pair;"
      28: astore        6
      30: istore        12
      32: astore        11
      34: iload         5
      36: bipush        10
      38: if_icmpge     103
      41: iload         5
      43: istore        7
      45: aload         6
      47: iload         7
      49: iconst_0
      50: istore        8
      52: bipush        21
      54: anewarray     #271                // class "[Lkotlin/Pair;"
      57: astore        9
      59: istore        14
      61: astore        13
      63: iload         8
      65: bipush        21
      67: if_icmpge     90
      70: iload         8
      72: istore        10
      74: aload         9
      76: iload         10
      78: bipush        21
      80: anewarray     #225                // class kotlin/Pair
      83: aastore
      84: iinc          8, 1
      87: goto          63
      90: aload         13
      92: iload         14
      94: aload         9
      96: aastore
      97: iinc          5, 1
     100: goto          34
     103: aload         11
     105: iload         12
     107: aload         6
     109: aastore
     110: iinc          2, 1
     113: goto          8
     116: aload_3
     117: astore_1
     118: aload_1
     119: aload_0
     120: iconst_0
     121: invokeinterface #274,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     126: checkcast     #187                // class java/lang/Number
     129: invokevirtual #190                // Method java/lang/Number.intValue:()I
     132: iconst_1
     133: isub
     134: aload_0
     135: iconst_1
     136: invokeinterface #274,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     141: checkcast     #187                // class java/lang/Number
     144: invokevirtual #190                // Method java/lang/Number.intValue:()I
     147: iconst_1
     148: isub
     149: iconst_0
     150: iconst_0
     151: invokestatic  #235                // Method main$part2$rec:([[[[Lkotlin/Pair;IIII)Lkotlin/Pair;
     154: astore_2
     155: aload_2
     156: invokevirtual #238                // Method kotlin/Pair.component1:()Ljava/lang/Object;
     159: checkcast     #187                // class java/lang/Number
     162: invokevirtual #242                // Method java/lang/Number.longValue:()J
     165: lstore_3
     166: aload_2
     167: invokevirtual #245                // Method kotlin/Pair.component2:()Ljava/lang/Object;
     170: checkcast     #187                // class java/lang/Number
     173: invokevirtual #242                // Method java/lang/Number.longValue:()J
     176: lstore        5
     178: lload_3
     179: lload         5
     181: invokestatic  #280                // Method java/lang/Math.max:(JJ)J
     184: lreturn
}